[PATCH] D156300: [clangd] Avoid unexpected desugaring in isSugaredTemplateParameter

2023-07-31 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!




Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:1432
 
 TEST(TypeHints, SubstTemplateParameterAliases) {
+  llvm::StringRef Header = R"cpp(

zyounan wrote:
> I feel like this test is becoming clunky: The validations here require an 
> invented class template `vector` which I think should be better placed in a 
> header; however, in the remaining snippet, it seems that I'm testing too many 
> hints in one `assertHint` call. Should I split these cases into different 
> snippets, or we just leave them as-is at the moment?
I think this is fine as-is for now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156300

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


[PATCH] D154588: [CSKY] Optimize implementation of intrinsic 'llvm.cttz.i32'

2023-07-31 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added inline comments.



Comment at: llvm/test/CodeGen/CSKY/intrinsic.ll:21
+entry:
+  %ntz = call i32 @llvm.cttz.i32(i32 %x, i1 1)
+  ret i32 %ntz

I think we can also test the condition that the second argument is zero.


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

https://reviews.llvm.org/D154588

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


[PATCH] D156027: [clang][Interp] Rework how initializers work

2023-07-31 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 545929.
tbaeder added a comment.

merge `visitConditional()` into its only caller, 
`VisitAbstractConditionalOperator()`. This works now sine the initializer and 
non-initializer code paths are the same.


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

https://reviews.llvm.org/D156027

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Context.cpp
  clang/test/AST/Interp/lambda.cpp
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -856,3 +856,44 @@
 
 };
 #endif
+
+namespace CompositeDefaultArgs {
+  struct Foo {
+int a;
+int b;
+constexpr Foo() : a(12), b(13) {}
+  };
+
+  class Bar {
+  public:
+bool B = false;
+
+constexpr int someFunc(Foo F = Foo()) {
+  this->B = true;
+  return 5;
+}
+  };
+
+  constexpr bool testMe() {
+Bar B;
+B.someFunc();
+return B.B;
+  }
+  static_assert(testMe(), "");
+}
+
+constexpr bool BPand(BoolPair bp) {
+  return bp.first && bp.second;
+}
+static_assert(BPand(BoolPair{true, false}) == false, "");
+
+namespace TemporaryObjectExpr {
+  struct F {
+int a;
+constexpr F() : a(12) {}
+  };
+  constexpr int foo(F f) {
+return 0;
+  }
+  static_assert(foo(F()) == 0, "");
+}
Index: clang/test/AST/Interp/lambda.cpp
===
--- clang/test/AST/Interp/lambda.cpp
+++ clang/test/AST/Interp/lambda.cpp
@@ -135,10 +135,6 @@
   }
   static_assert(sv4(12) == 12);
 
-
-
-  /// FIXME: This is broken for lambda-unrelated reasons.
-#if 0
   constexpr int sv5(int i) {
 struct F { int a; float f; };
 auto l = [](int m, F f) { return m; };
@@ -146,7 +142,6 @@
 return fp(i, F{12, 14.0});
   }
   static_assert(sv5(12) == 12);
-#endif
 
   constexpr int sv6(int i) {
 struct F { int a;
@@ -182,3 +177,27 @@
   static_assert(F.a == 33, "");
   static_assert(F.Aplus2() == (33 + 2), "");
 }
+
+namespace LambdasAsParams {
+  template
+  constexpr auto call(F f) {
+return f();
+  }
+  static_assert(call([](){ return 1;}) == 1);
+  static_assert(call([](){ return 2;}) == 2);
+
+
+  constexpr unsigned L = call([](){ return 12;});
+  static_assert(L == 12);
+
+
+  constexpr float heh() {
+auto a = []() {
+  return 1.0;
+};
+
+return static_cast(a());
+  }
+  static_assert(heh() == 1.0);
+}
+
Index: clang/lib/AST/Interp/Context.cpp
===
--- clang/lib/AST/Interp/Context.cpp
+++ clang/lib/AST/Interp/Context.cpp
@@ -128,7 +128,7 @@
 return PT_Float;
 
   if (T->isFunctionPointerType() || T->isFunctionReferenceType() ||
-  T->isFunctionType())
+  T->isFunctionType() || T->isSpecificBuiltinType(BuiltinType::BoundMember))
 return PT_FnPtr;
 
   if (T->isReferenceType() || T->isPointerType())
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -83,6 +83,7 @@
   bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E);
   bool VisitMemberExpr(const MemberExpr *E);
   bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E);
+  bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E);
   bool VisitOpaqueValueExpr(const OpaqueValueExpr *E);
   bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E);
   bool VisitStringLiteral(const StringLiteral *E);
@@ -93,7 +94,6 @@
   bool VisitExprWithCleanups(const ExprWithCleanups *E);
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
   bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E);
-  bool VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *E);
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
   bool VisitTypeTraitExpr(const TypeTraitExpr *E);
   bool VisitLambdaExpr(const LambdaExpr *E);
@@ -101,6 +101,7 @@
   bool VisitCXXThrowExpr(const CXXThrowExpr *E);
   bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E);
   bool VisitCXXNoexceptExpr(const CXXNoexceptExpr *E);
+  bool VisitCXXConstructExpr(const CXXConstructExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
@@ -136,17 +137,21 @@
 }
 llvm_unreachable("not a primitive type");
   }
-
-  /// Evaluates an expression for side effects and discards the result.
-  bool discard(const Expr *E);
-  /// Evaluates an expression and places result on stack.
+  /// Evaluates an expression and places the result on the stack. If the
+  /// expression is of composite type, a local variable will be created
+  /// and a pointer to said variable will be placed on the stack.
   bool visit(const Expr *E);
-  /// Compiles an initializer.
+  /// Compiles 

cfe-commits@lists.llvm.org

2023-07-31 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155863

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


[PATCH] D156027: [clang][Interp] Rework how initializers work

2023-07-31 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 545928.

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

https://reviews.llvm.org/D156027

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Context.cpp
  clang/test/AST/Interp/lambda.cpp
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -856,3 +856,44 @@
 
 };
 #endif
+
+namespace CompositeDefaultArgs {
+  struct Foo {
+int a;
+int b;
+constexpr Foo() : a(12), b(13) {}
+  };
+
+  class Bar {
+  public:
+bool B = false;
+
+constexpr int someFunc(Foo F = Foo()) {
+  this->B = true;
+  return 5;
+}
+  };
+
+  constexpr bool testMe() {
+Bar B;
+B.someFunc();
+return B.B;
+  }
+  static_assert(testMe(), "");
+}
+
+constexpr bool BPand(BoolPair bp) {
+  return bp.first && bp.second;
+}
+static_assert(BPand(BoolPair{true, false}) == false, "");
+
+namespace TemporaryObjectExpr {
+  struct F {
+int a;
+constexpr F() : a(12) {}
+  };
+  constexpr int foo(F f) {
+return 0;
+  }
+  static_assert(foo(F()) == 0, "");
+}
Index: clang/test/AST/Interp/lambda.cpp
===
--- clang/test/AST/Interp/lambda.cpp
+++ clang/test/AST/Interp/lambda.cpp
@@ -135,10 +135,6 @@
   }
   static_assert(sv4(12) == 12);
 
-
-
-  /// FIXME: This is broken for lambda-unrelated reasons.
-#if 0
   constexpr int sv5(int i) {
 struct F { int a; float f; };
 auto l = [](int m, F f) { return m; };
@@ -146,7 +142,6 @@
 return fp(i, F{12, 14.0});
   }
   static_assert(sv5(12) == 12);
-#endif
 
   constexpr int sv6(int i) {
 struct F { int a;
@@ -182,3 +177,27 @@
   static_assert(F.a == 33, "");
   static_assert(F.Aplus2() == (33 + 2), "");
 }
+
+namespace LambdasAsParams {
+  template
+  constexpr auto call(F f) {
+return f();
+  }
+  static_assert(call([](){ return 1;}) == 1);
+  static_assert(call([](){ return 2;}) == 2);
+
+
+  constexpr unsigned L = call([](){ return 12;});
+  static_assert(L == 12);
+
+
+  constexpr float heh() {
+auto a = []() {
+  return 1.0;
+};
+
+return static_cast(a());
+  }
+  static_assert(heh() == 1.0);
+}
+
Index: clang/lib/AST/Interp/Context.cpp
===
--- clang/lib/AST/Interp/Context.cpp
+++ clang/lib/AST/Interp/Context.cpp
@@ -128,7 +128,7 @@
 return PT_Float;
 
   if (T->isFunctionPointerType() || T->isFunctionReferenceType() ||
-  T->isFunctionType())
+  T->isFunctionType() || T->isSpecificBuiltinType(BuiltinType::BoundMember))
 return PT_FnPtr;
 
   if (T->isReferenceType() || T->isPointerType())
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -83,6 +83,7 @@
   bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E);
   bool VisitMemberExpr(const MemberExpr *E);
   bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E);
+  bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E);
   bool VisitOpaqueValueExpr(const OpaqueValueExpr *E);
   bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E);
   bool VisitStringLiteral(const StringLiteral *E);
@@ -93,7 +94,6 @@
   bool VisitExprWithCleanups(const ExprWithCleanups *E);
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
   bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E);
-  bool VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *E);
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
   bool VisitTypeTraitExpr(const TypeTraitExpr *E);
   bool VisitLambdaExpr(const LambdaExpr *E);
@@ -101,6 +101,7 @@
   bool VisitCXXThrowExpr(const CXXThrowExpr *E);
   bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E);
   bool VisitCXXNoexceptExpr(const CXXNoexceptExpr *E);
+  bool VisitCXXConstructExpr(const CXXConstructExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
@@ -136,17 +137,21 @@
 }
 llvm_unreachable("not a primitive type");
   }
-
-  /// Evaluates an expression for side effects and discards the result.
-  bool discard(const Expr *E);
-  /// Evaluates an expression and places result on stack.
+  /// Evaluates an expression and places the result on the stack. If the
+  /// expression is of composite type, a local variable will be created
+  /// and a pointer to said variable will be placed on the stack.
   bool visit(const Expr *E);
-  /// Compiles an initializer.
+  /// Compiles an initializer. This is like visit() but it will never
+  /// create a variable and instead rely on a variable already having
+  /// been created. visitInitializer() then relies on a pointer to thi

cfe-commits@lists.llvm.org

2023-07-31 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 545927.
yubing added a comment.

update testcase due to w=>x


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155863

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/check-regcall4-moduleflag.c
  clang/test/CodeGen/regcall4.c
  clang/test/CodeGenCXX/regcall4.cpp
  clang/test/Driver/cl-cc-flags.c
  llvm/lib/Target/X86/X86CallingConv.td
  llvm/test/CodeGen/X86/sse-regcall4.ll

Index: llvm/test/CodeGen/X86/sse-regcall4.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/sse-regcall4.ll
@@ -0,0 +1,467 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i386-pc-win32 -mattr=+sse | FileCheck --check-prefix=WIN32 %s
+; RUN: llc < %s -mtriple=x86_64-win32 -mattr=+sse | FileCheck --check-prefix=WIN64 %s
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -mattr=+sse | FileCheck --check-prefix=LINUXOSX %s
+
+; Test regcall when receiving/returning i1
+define x86_regcallcc i1 @test_argReti1(i1 %a)  {
+; WIN32-LABEL: test_argReti1:
+; WIN32:   # %bb.0:
+; WIN32-NEXT:incb %cl
+; WIN32-NEXT:# kill: def $cl killed $cl killed $ecx
+; WIN32-NEXT:retl
+;
+; WIN64-LABEL: test_argReti1:
+; WIN64:   # %bb.0:
+; WIN64-NEXT:incb %al
+; WIN64-NEXT:# kill: def $al killed $al killed $eax
+; WIN64-NEXT:retq
+;
+; LINUXOSX-LABEL: test_argReti1:
+; LINUXOSX:   # %bb.0:
+; LINUXOSX-NEXT:incb %al
+; LINUXOSX-NEXT:# kill: def $al killed $al killed $eax
+; LINUXOSX-NEXT:retq
+  %add = add i1 %a, 1
+  ret i1 %add
+}
+
+; Test regcall when passing/retrieving i1
+define x86_regcallcc i1 @test_CallargReti1(i1 %a)  {
+; WIN32-LABEL: test_CallargReti1:
+; WIN32:   # %bb.0:
+; WIN32-NEXT:incb %cl
+; WIN32-NEXT:movzbl %cl, %ecx
+; WIN32-NEXT:calll _test_argReti1
+; WIN32-NEXT:incb %cl
+; WIN32-NEXT:retl
+;
+; WIN64-LABEL: test_CallargReti1:
+; WIN64:   # %bb.0:
+; WIN64-NEXT:pushq %rax
+; WIN64-NEXT:.seh_stackalloc 8
+; WIN64-NEXT:.seh_endprologue
+; WIN64-NEXT:incb %al
+; WIN64-NEXT:movzbl %al, %eax
+; WIN64-NEXT:callq test_argReti1
+; WIN64-NEXT:incb %al
+; WIN64-NEXT:popq %rcx
+; WIN64-NEXT:retq
+; WIN64-NEXT:.seh_endproc
+;
+; LINUXOSX-LABEL: test_CallargReti1:
+; LINUXOSX:   # %bb.0:
+; LINUXOSX-NEXT:pushq %rax
+; LINUXOSX-NEXT:.cfi_def_cfa_offset 16
+; LINUXOSX-NEXT:incb %al
+; LINUXOSX-NEXT:movzbl %al, %eax
+; LINUXOSX-NEXT:callq *test_argReti1@GOTPCREL(%rip)
+; LINUXOSX-NEXT:incb %al
+; LINUXOSX-NEXT:popq %rcx
+; LINUXOSX-NEXT:.cfi_def_cfa_offset 8
+; LINUXOSX-NEXT:retq
+  %b = add i1 %a, 1
+  %c = call x86_regcallcc i1 @test_argReti1(i1 %b)
+  %d = add i1 %c, 1
+  ret i1 %d
+}
+
+;test calling conventions - input parameters, callee saved xmms
+define x86_regcallcc <16 x float> @testf32_inp(<16 x float> %a, <16 x float> %b, <16 x float> %c) nounwind {
+; WIN32-LABEL: testf32_inp:
+; WIN32:   # %bb.0:
+; WIN32-NEXT:pushl %ebp
+; WIN32-NEXT:movl %esp, %ebp
+; WIN32-NEXT:andl $-16, %esp
+; WIN32-NEXT:subl $32, %esp
+; WIN32-NEXT:movaps %xmm7, (%esp) # 16-byte Spill
+; WIN32-NEXT:movaps %xmm6, %xmm7
+; WIN32-NEXT:movaps %xmm5, %xmm6
+; WIN32-NEXT:movaps %xmm3, %xmm5
+; WIN32-NEXT:movaps %xmm2, %xmm3
+; WIN32-NEXT:movaps %xmm1, %xmm2
+; WIN32-NEXT:movaps %xmm0, %xmm1
+; WIN32-NEXT:addps %xmm4, %xmm0
+; WIN32-NEXT:mulps %xmm4, %xmm1
+; WIN32-NEXT:subps %xmm1, %xmm0
+; WIN32-NEXT:movups 8(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm0
+; WIN32-NEXT:movaps %xmm2, %xmm4
+; WIN32-NEXT:addps %xmm6, %xmm4
+; WIN32-NEXT:mulps %xmm6, %xmm2
+; WIN32-NEXT:subps %xmm2, %xmm4
+; WIN32-NEXT:movups 24(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm4
+; WIN32-NEXT:movaps %xmm3, %xmm2
+; WIN32-NEXT:addps %xmm7, %xmm2
+; WIN32-NEXT:mulps %xmm7, %xmm3
+; WIN32-NEXT:subps %xmm3, %xmm2
+; WIN32-NEXT:movups 40(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm2
+; WIN32-NEXT:movaps %xmm5, %xmm3
+; WIN32-NEXT:movaps (%esp), %xmm1 # 16-byte Reload
+; WIN32-NEXT:addps %xmm1, %xmm3
+; WIN32-NEXT:mulps %xmm1, %xmm5
+; WIN32-NEXT:subps %xmm5, %xmm3
+; WIN32-NEXT:movups 56(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm3
+; WIN32-NEXT:movaps %xmm4, %xmm1
+; WIN32-NEXT:movl %ebp, %esp
+; WIN32-NEXT:popl %ebp
+; WIN32-NEXT:retl
+;
+; WIN64-LABEL: testf32_inp:
+; WIN64:   # %bb.0:
+; WIN64-NEXT:subq $72, %rsp
+; WIN64-NEXT:movaps %xmm15, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
+; WIN64-NEXT:movaps %xmm1

[PATCH] D156027: [clang][Interp] Rework how initializers work

2023-07-31 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 545926.
tbaeder added a comment.

Add `::delegate(const Expr *E)` and squash previous commits into this one.


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

https://reviews.llvm.org/D156027

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Context.cpp
  clang/test/AST/Interp/lambda.cpp
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -856,3 +856,51 @@
 
 };
 #endif
+
+namespace CompositeDefaultArgs {
+  struct Foo {
+int a;
+int b;
+constexpr Foo() : a(12), b(13) {}
+  };
+
+  class Bar {
+  public:
+bool B = false;
+
+constexpr int someFunc(Foo F = Foo()) {
+  this->B = true;
+  return 5;
+}
+  };
+
+  constexpr bool testMe() {
+Bar B;
+B.someFunc();
+return B.B;
+  }
+  static_assert(testMe(), "");
+}
+
+constexpr bool BPand(BoolPair bp) {
+  return bp.first && bp.second;
+}
+static_assert(BPand(BoolPair{true, false}) == false, "");
+
+namespace TemporaryObjectExpr {
+  struct F {
+int a;
+constexpr F() : a(12) {}
+  };
+  constexpr int foo(F f) {
+return 0;
+  }
+  static_assert(foo(F()) == 0, "");
+}
+
+#if 0
+constexpr bool BPand(BoolPair bp) {
+  return bp.first && bp.second;
+}
+static_assert(BPand(BoolPair{true, false}) == false, "");
+#endif
Index: clang/test/AST/Interp/lambda.cpp
===
--- clang/test/AST/Interp/lambda.cpp
+++ clang/test/AST/Interp/lambda.cpp
@@ -135,10 +135,6 @@
   }
   static_assert(sv4(12) == 12);
 
-
-
-  /// FIXME: This is broken for lambda-unrelated reasons.
-#if 0
   constexpr int sv5(int i) {
 struct F { int a; float f; };
 auto l = [](int m, F f) { return m; };
@@ -146,7 +142,6 @@
 return fp(i, F{12, 14.0});
   }
   static_assert(sv5(12) == 12);
-#endif
 
   constexpr int sv6(int i) {
 struct F { int a;
@@ -182,3 +177,27 @@
   static_assert(F.a == 33, "");
   static_assert(F.Aplus2() == (33 + 2), "");
 }
+
+namespace LambdasAsParams {
+  template
+  constexpr auto call(F f) {
+return f();
+  }
+  static_assert(call([](){ return 1;}) == 1);
+  static_assert(call([](){ return 2;}) == 2);
+
+
+  constexpr unsigned L = call([](){ return 12;});
+  static_assert(L == 12);
+
+
+  constexpr float heh() {
+auto a = []() {
+  return 1.0;
+};
+
+return static_cast(a());
+  }
+  static_assert(heh() == 1.0);
+}
+
Index: clang/lib/AST/Interp/Context.cpp
===
--- clang/lib/AST/Interp/Context.cpp
+++ clang/lib/AST/Interp/Context.cpp
@@ -128,7 +128,7 @@
 return PT_Float;
 
   if (T->isFunctionPointerType() || T->isFunctionReferenceType() ||
-  T->isFunctionType())
+  T->isFunctionType() || T->isSpecificBuiltinType(BuiltinType::BoundMember))
 return PT_FnPtr;
 
   if (T->isReferenceType() || T->isPointerType())
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -83,6 +83,7 @@
   bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E);
   bool VisitMemberExpr(const MemberExpr *E);
   bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E);
+  bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E);
   bool VisitOpaqueValueExpr(const OpaqueValueExpr *E);
   bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E);
   bool VisitStringLiteral(const StringLiteral *E);
@@ -93,7 +94,6 @@
   bool VisitExprWithCleanups(const ExprWithCleanups *E);
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
   bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E);
-  bool VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *E);
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
   bool VisitTypeTraitExpr(const TypeTraitExpr *E);
   bool VisitLambdaExpr(const LambdaExpr *E);
@@ -101,6 +101,7 @@
   bool VisitCXXThrowExpr(const CXXThrowExpr *E);
   bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E);
   bool VisitCXXNoexceptExpr(const CXXNoexceptExpr *E);
+  bool VisitCXXConstructExpr(const CXXConstructExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
@@ -136,17 +137,21 @@
 }
 llvm_unreachable("not a primitive type");
   }
-
-  /// Evaluates an expression for side effects and discards the result.
-  bool discard(const Expr *E);
-  /// Evaluates an expression and places result on stack.
+  /// Evaluates an expression and places the result on the stack. If the
+  /// expression is of composite type, a local variable will be created
+  /// and a pointer to said variable will be placed on the stack.
   bool visit(const Expr

[PATCH] D154038: [clang][ExtractAPI] Add semicolons to vars and fields and to test reference JSON

2023-07-31 Thread Erick Velez 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 rG422bcd10c48b: [clang][ExtractAPI] Add semicolons to vars and 
fields and to test reference JSON (authored by evelez7).

Changed prior to commit:
  https://reviews.llvm.org/D154038?vs=536245&id=545925#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154038

Files:
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/test/ExtractAPI/anonymous_record_no_typedef.c
  clang/test/ExtractAPI/global_record.c
  clang/test/ExtractAPI/global_record_multifile.c
  clang/test/ExtractAPI/known_files_only.c
  clang/test/ExtractAPI/language.c
  clang/test/ExtractAPI/objc_interface.m
  clang/test/ExtractAPI/relative_include.m
  clang/test/ExtractAPI/struct.c
  clang/test/ExtractAPI/typedef_struct_enum.c
  clang/test/ExtractAPI/underscored.c

Index: clang/test/ExtractAPI/underscored.c
===
--- clang/test/ExtractAPI/underscored.c
+++ clang/test/ExtractAPI/underscored.c
@@ -85,6 +85,10 @@
 {
   "kind": "identifier",
   "spelling": "exposed_global"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -190,6 +194,10 @@
 {
   "kind": "identifier",
   "spelling": "a"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/typedef_struct_enum.c
===
--- clang/test/ExtractAPI/typedef_struct_enum.c
+++ clang/test/ExtractAPI/typedef_struct_enum.c
@@ -328,6 +328,10 @@
 {
   "kind": "identifier",
   "spelling": "bar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/struct.c
===
--- clang/test/ExtractAPI/struct.c
+++ clang/test/ExtractAPI/struct.c
@@ -161,6 +161,10 @@
 {
   "kind": "identifier",
   "spelling": "Red"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -213,6 +217,10 @@
 {
   "kind": "identifier",
   "spelling": "Green"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -265,6 +273,10 @@
 {
   "kind": "identifier",
   "spelling": "Blue"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -317,6 +329,10 @@
 {
   "kind": "identifier",
   "spelling": "Alpha"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "docComment": {
Index: clang/test/ExtractAPI/relative_include.m
===
--- clang/test/ExtractAPI/relative_include.m
+++ clang/test/ExtractAPI/relative_include.m
@@ -102,6 +102,10 @@
 {
   "kind": "identifier",
   "spelling": "MyInt"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -153,6 +157,10 @@
 {
   "kind": "identifier",
   "spelling": "MyChar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -579,6 +579,10 @@
 {
   "kind": "identifier",
   "spelling": "Ivar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/language.c
===
--- clang/test/ExtractAPI/language.c
+++ clang/test/ExtractAPI/language.c
@@ -70,6 +70,10 @@
 {
   "kind": "identifier",
   "spelling": "c"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -150,6 +154,10 @@
 {
   "kind": "identifier",
   "spelling": "objc"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/known_files_only.c
===
--- clang/test/ExtractAPI/known_files_only.c
+++ clang/test/ExtractAPI/known_files_only.c
@@ -66,6 +66,10 @@
 {
   "kind": "ident

[clang] 422bcd1 - [clang][ExtractAPI] Add semicolons to vars and fields and to test reference JSON

2023-07-31 Thread Erick Velez via cfe-commits

Author: Erick Velez
Date: 2023-07-31T23:29:04-07:00
New Revision: 422bcd10c48bac9042ed9f33f3d17eb81ebfd21a

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

LOG: [clang][ExtractAPI] Add semicolons to vars and fields and to test 
reference JSON

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

Added: 


Modified: 
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/test/ExtractAPI/anonymous_record_no_typedef.c
clang/test/ExtractAPI/global_record.c
clang/test/ExtractAPI/global_record_multifile.c
clang/test/ExtractAPI/known_files_only.c
clang/test/ExtractAPI/language.c
clang/test/ExtractAPI/objc_interface.m
clang/test/ExtractAPI/relative_include.m
clang/test/ExtractAPI/struct.c
clang/test/ExtractAPI/typedef_struct_enum.c
clang/test/ExtractAPI/underscored.c

Removed: 




diff  --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp 
b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index 1e52f221c7982d..20335768ac30b0 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -389,7 +389,8 @@ DeclarationFragmentsBuilder::getFragmentsForVar(const 
VarDecl *Var) {
   return Fragments.append(getFragmentsForType(T, Var->getASTContext(), After))
   .appendSpace()
   .append(Var->getName(), DeclarationFragments::FragmentKind::Identifier)
-  .append(std::move(After));
+  .append(std::move(After))
+  .append(";", DeclarationFragments::FragmentKind::Text);
 }
 
 DeclarationFragments
@@ -495,7 +496,8 @@ DeclarationFragmentsBuilder::getFragmentsForField(const 
FieldDecl *Field) {
   return getFragmentsForType(Field->getType(), Field->getASTContext(), After)
   .appendSpace()
   .append(Field->getName(), DeclarationFragments::FragmentKind::Identifier)
-  .append(std::move(After));
+  .append(std::move(After))
+  .append(";", DeclarationFragments::FragmentKind::Text);
 }
 
 DeclarationFragments

diff  --git a/clang/test/ExtractAPI/anonymous_record_no_typedef.c 
b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
index 880a42c30ceb8d..0890e3cbdb6d08 100644
--- a/clang/test/ExtractAPI/anonymous_record_no_typedef.c
+++ b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
@@ -316,6 +316,10 @@ struct Vehicle {
 {
   "kind": "identifier",
   "spelling": "type"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -367,6 +371,10 @@ struct Vehicle {
 {
   "kind": "identifier",
   "spelling": "information"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {

diff  --git a/clang/test/ExtractAPI/global_record.c 
b/clang/test/ExtractAPI/global_record.c
index 7ca89875d66ae5..c287c791d947e6 100644
--- a/clang/test/ExtractAPI/global_record.c
+++ b/clang/test/ExtractAPI/global_record.c
@@ -68,6 +68,10 @@ char unavailable __attribute__((unavailable));
 {
   "kind": "identifier",
   "spelling": "num"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {

diff  --git a/clang/test/ExtractAPI/global_record_multifile.c 
b/clang/test/ExtractAPI/global_record_multifile.c
index b1e9f9ed21d425..fd4022fada6a04 100644
--- a/clang/test/ExtractAPI/global_record_multifile.c
+++ b/clang/test/ExtractAPI/global_record_multifile.c
@@ -70,6 +70,10 @@ char unavailable __attribute__((unavailable));
 {
   "kind": "identifier",
   "spelling": "num"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {

diff  --git a/clang/test/ExtractAPI/known_files_only.c 
b/clang/test/ExtractAPI/known_files_only.c
index ddb6e577823a85..1e51139c0cae4b 100644
--- a/clang/test/ExtractAPI/known_files_only.c
+++ b/clang/test/ExtractAPI/known_files_only.c
@@ -66,6 +66,10 @@ struct Foo { int a; };
 {
   "kind": "identifier",
   "spelling": "num"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {

diff  --git a/clang/test/ExtractAPI/language.c 
b/clang/test/ExtractAPI/language.c
index b9f69b272a44c3..3a434d475134f8 100644
--- a/clang/test/ExtractAPI/language.c
+++ b/clang/test/ExtractAPI/language.c
@@ -70,6 +70,10 @@ char objc;
 {
   "kind": "identifier",
   "spelling": "c"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -150,6 +154,10 @@ char objc;
 {
   "kind": "identifier",
   "spelling": "objc"
+},
+{
+  "kind": 

cfe-commits@lists.llvm.org

2023-07-31 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 545924.
yubing added a comment.

address c++ windows's mangling prefix w=>x


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155863

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/check-regcall4-moduleflag.c
  clang/test/CodeGen/regcall4.c
  clang/test/CodeGenCXX/regcall4.cpp
  clang/test/Driver/cl-cc-flags.c
  llvm/lib/Target/X86/X86CallingConv.td
  llvm/test/CodeGen/X86/sse-regcall4.ll

Index: llvm/test/CodeGen/X86/sse-regcall4.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/sse-regcall4.ll
@@ -0,0 +1,467 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i386-pc-win32 -mattr=+sse | FileCheck --check-prefix=WIN32 %s
+; RUN: llc < %s -mtriple=x86_64-win32 -mattr=+sse | FileCheck --check-prefix=WIN64 %s
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -mattr=+sse | FileCheck --check-prefix=LINUXOSX %s
+
+; Test regcall when receiving/returning i1
+define x86_regcallcc i1 @test_argReti1(i1 %a)  {
+; WIN32-LABEL: test_argReti1:
+; WIN32:   # %bb.0:
+; WIN32-NEXT:incb %cl
+; WIN32-NEXT:# kill: def $cl killed $cl killed $ecx
+; WIN32-NEXT:retl
+;
+; WIN64-LABEL: test_argReti1:
+; WIN64:   # %bb.0:
+; WIN64-NEXT:incb %al
+; WIN64-NEXT:# kill: def $al killed $al killed $eax
+; WIN64-NEXT:retq
+;
+; LINUXOSX-LABEL: test_argReti1:
+; LINUXOSX:   # %bb.0:
+; LINUXOSX-NEXT:incb %al
+; LINUXOSX-NEXT:# kill: def $al killed $al killed $eax
+; LINUXOSX-NEXT:retq
+  %add = add i1 %a, 1
+  ret i1 %add
+}
+
+; Test regcall when passing/retrieving i1
+define x86_regcallcc i1 @test_CallargReti1(i1 %a)  {
+; WIN32-LABEL: test_CallargReti1:
+; WIN32:   # %bb.0:
+; WIN32-NEXT:incb %cl
+; WIN32-NEXT:movzbl %cl, %ecx
+; WIN32-NEXT:calll _test_argReti1
+; WIN32-NEXT:incb %cl
+; WIN32-NEXT:retl
+;
+; WIN64-LABEL: test_CallargReti1:
+; WIN64:   # %bb.0:
+; WIN64-NEXT:pushq %rax
+; WIN64-NEXT:.seh_stackalloc 8
+; WIN64-NEXT:.seh_endprologue
+; WIN64-NEXT:incb %al
+; WIN64-NEXT:movzbl %al, %eax
+; WIN64-NEXT:callq test_argReti1
+; WIN64-NEXT:incb %al
+; WIN64-NEXT:popq %rcx
+; WIN64-NEXT:retq
+; WIN64-NEXT:.seh_endproc
+;
+; LINUXOSX-LABEL: test_CallargReti1:
+; LINUXOSX:   # %bb.0:
+; LINUXOSX-NEXT:pushq %rax
+; LINUXOSX-NEXT:.cfi_def_cfa_offset 16
+; LINUXOSX-NEXT:incb %al
+; LINUXOSX-NEXT:movzbl %al, %eax
+; LINUXOSX-NEXT:callq *test_argReti1@GOTPCREL(%rip)
+; LINUXOSX-NEXT:incb %al
+; LINUXOSX-NEXT:popq %rcx
+; LINUXOSX-NEXT:.cfi_def_cfa_offset 8
+; LINUXOSX-NEXT:retq
+  %b = add i1 %a, 1
+  %c = call x86_regcallcc i1 @test_argReti1(i1 %b)
+  %d = add i1 %c, 1
+  ret i1 %d
+}
+
+;test calling conventions - input parameters, callee saved xmms
+define x86_regcallcc <16 x float> @testf32_inp(<16 x float> %a, <16 x float> %b, <16 x float> %c) nounwind {
+; WIN32-LABEL: testf32_inp:
+; WIN32:   # %bb.0:
+; WIN32-NEXT:pushl %ebp
+; WIN32-NEXT:movl %esp, %ebp
+; WIN32-NEXT:andl $-16, %esp
+; WIN32-NEXT:subl $32, %esp
+; WIN32-NEXT:movaps %xmm7, (%esp) # 16-byte Spill
+; WIN32-NEXT:movaps %xmm6, %xmm7
+; WIN32-NEXT:movaps %xmm5, %xmm6
+; WIN32-NEXT:movaps %xmm3, %xmm5
+; WIN32-NEXT:movaps %xmm2, %xmm3
+; WIN32-NEXT:movaps %xmm1, %xmm2
+; WIN32-NEXT:movaps %xmm0, %xmm1
+; WIN32-NEXT:addps %xmm4, %xmm0
+; WIN32-NEXT:mulps %xmm4, %xmm1
+; WIN32-NEXT:subps %xmm1, %xmm0
+; WIN32-NEXT:movups 8(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm0
+; WIN32-NEXT:movaps %xmm2, %xmm4
+; WIN32-NEXT:addps %xmm6, %xmm4
+; WIN32-NEXT:mulps %xmm6, %xmm2
+; WIN32-NEXT:subps %xmm2, %xmm4
+; WIN32-NEXT:movups 24(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm4
+; WIN32-NEXT:movaps %xmm3, %xmm2
+; WIN32-NEXT:addps %xmm7, %xmm2
+; WIN32-NEXT:mulps %xmm7, %xmm3
+; WIN32-NEXT:subps %xmm3, %xmm2
+; WIN32-NEXT:movups 40(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm2
+; WIN32-NEXT:movaps %xmm5, %xmm3
+; WIN32-NEXT:movaps (%esp), %xmm1 # 16-byte Reload
+; WIN32-NEXT:addps %xmm1, %xmm3
+; WIN32-NEXT:mulps %xmm1, %xmm5
+; WIN32-NEXT:subps %xmm5, %xmm3
+; WIN32-NEXT:movups 56(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm3
+; WIN32-NEXT:movaps %xmm4, %xmm1
+; WIN32-NEXT:movl %ebp, %esp
+; WIN32-NEXT:popl %ebp
+; WIN32-NEXT:retl
+;
+; WIN64-LABEL: testf32_inp:
+; WIN64:   # %bb.0:
+; WIN64-NEXT:subq $72, %rsp
+; WIN64-NEXT:movaps %xmm15, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
+; WIN64-NEXT: 

[PATCH] D156300: [clangd] Avoid unexpected desugaring in isSugaredTemplateParameter

2023-07-31 Thread Younan Zhang via Phabricator via cfe-commits
zyounan added a comment.

Sorry, looks like I messed up with the commits before. Fixed it now.




Comment at: clang-tools-extra/clangd/InlayHints.cpp:207
+
+  // This is a bit tricky: we traverse the type structure and find whether or
+  // not a type in the desugaring process is of SubstTemplateTypeParmType.

nridge wrote:
> Nice find, this is indeed pretty tricky. I remember running into a similar 
> issue before in https://reviews.llvm.org/D124690#inline-1205484.
Cool. That looks far more intricate and I should take some time to understand 
the context. Thanks for the reference :)



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:1432
 
 TEST(TypeHints, SubstTemplateParameterAliases) {
+  llvm::StringRef Header = R"cpp(

I feel like this test is becoming clunky: The validations here require an 
invented class template `vector` which I think should be better placed in a 
header; however, in the remaining snippet, it seems that I'm testing too many 
hints in one `assertHint` call. Should I split these cases into different 
snippets, or we just leave them as-is at the moment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156300

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


[PATCH] D156300: [clangd] Avoid unexpected desugaring in isSugaredTemplateParameter

2023-07-31 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 545922.
zyounan added a comment.

Fix the chaos in the previous update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156300

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -81,11 +81,13 @@
 }
 
 template 
-void assertHints(InlayHintKind Kind, llvm::StringRef AnnotatedSource,
- ExpectedHints... Expected) {
+void assertHintsWithHeader(InlayHintKind Kind, llvm::StringRef AnnotatedSource,
+   llvm::StringRef HeaderContent,
+   ExpectedHints... Expected) {
   Annotations Source(AnnotatedSource);
   TestTU TU = TestTU::withCode(Source.code());
   TU.ExtraArgs.push_back("-std=c++20");
+  TU.HeaderCode = HeaderContent;
   auto AST = TU.build();
 
   EXPECT_THAT(hintsOfKind(AST, Kind),
@@ -96,6 +98,13 @@
   EXPECT_THAT(inlayHints(AST, std::nullopt), IsEmpty());
 }
 
+template 
+void assertHints(InlayHintKind Kind, llvm::StringRef AnnotatedSource,
+ ExpectedHints... Expected) {
+  return assertHintsWithHeader(Kind, AnnotatedSource, "",
+   std::move(Expected)...);
+}
+
 // Hack to allow expression-statements operating on parameter packs in C++14.
 template  void ignore(T &&...) {}
 
@@ -1421,8 +1430,7 @@
 }
 
 TEST(TypeHints, SubstTemplateParameterAliases) {
-  assertTypeHints(
-  R"cpp(
+  llvm::StringRef Header = R"cpp(
   template  struct allocator {};
 
   template 
@@ -1455,9 +1463,34 @@
 
 T elements[10];
   };
+  )cpp";
+
+  llvm::StringRef VectorIntPtr = R"cpp(
+vector array;
+auto $no_modifier[[x]] = array[3];
+auto* $ptr_modifier[[ptr]] = &array[3];
+auto& $ref_modifier[[ref]] = array[3];
+auto& $at[[immutable]] = array.at(3);
+
+auto $data[[data]] = array.data();
+auto $allocator[[alloc]] = array.get_allocator();
+auto $size[[size]] = array.size();
+auto $begin[[begin]] = array.begin();
+auto $end[[end]] = array.end();
+  )cpp";
+
+  assertHintsWithHeader(
+  InlayHintKind::Type, VectorIntPtr, Header,
+  ExpectedHint{": int *", "no_modifier"},
+  ExpectedHint{": int **", "ptr_modifier"},
+  ExpectedHint{": int *&", "ref_modifier"},
+  ExpectedHint{": int *const &", "at"}, ExpectedHint{": int **", "data"},
+  ExpectedHint{": allocator", "allocator"},
+  ExpectedHint{": size_type", "size"}, ExpectedHint{": iterator", "begin"},
+  ExpectedHint{": non_template_iterator", "end"});
 
+  llvm::StringRef VectorInt = R"cpp(
   vector array;
-
   auto $no_modifier[[by_value]] = array[3];
   auto* $ptr_modifier[[ptr]] = &array[3];
   auto& $ref_modifier[[ref]] = array[3];
@@ -1468,8 +1501,19 @@
   auto $size[[size]] = array.size();
   auto $begin[[begin]] = array.begin();
   auto $end[[end]] = array.end();
+  )cpp";
 
+  assertHintsWithHeader(
+  InlayHintKind::Type, VectorInt, Header,
+  ExpectedHint{": int", "no_modifier"},
+  ExpectedHint{": int *", "ptr_modifier"},
+  ExpectedHint{": int &", "ref_modifier"},
+  ExpectedHint{": const int &", "at"}, ExpectedHint{": int *", "data"},
+  ExpectedHint{": allocator", "allocator"},
+  ExpectedHint{": size_type", "size"}, ExpectedHint{": iterator", "begin"},
+  ExpectedHint{": non_template_iterator", "end"});
 
+  llvm::StringRef TypeAlias = R"cpp(
   // If the type alias is not of substituted template parameter type,
   // do not show desugared type.
   using VeryLongLongTypeName = my_iterator;
@@ -1484,16 +1528,11 @@
   using static_vector = basic_static_vector>;
 
   auto $vector_name[[vec]] = static_vector();
-  )cpp",
-  ExpectedHint{": int", "no_modifier"},
-  ExpectedHint{": int *", "ptr_modifier"},
-  ExpectedHint{": int &", "ref_modifier"},
-  ExpectedHint{": const int &", "at"}, ExpectedHint{": int *", "data"},
-  ExpectedHint{": allocator", "allocator"},
-  ExpectedHint{": size_type", "size"}, ExpectedHint{": iterator", "begin"},
-  ExpectedHint{": non_template_iterator", "end"},
-  ExpectedHint{": Short", "short_name"},
-  ExpectedHint{": static_vector", "vector_name"});
+  )cpp";
+
+  assertHintsWithHeader(InlayHintKind::Type, TypeAlias, Header,
+ExpectedHint{": Short", "short_name"},
+ExpectedHint{": static_vector", "vector_name"});
 }
 
 TEST(DesignatorHints, Basic) {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -195,22 +195,47 @@
 // Determines if any intermediate type in de

[PATCH] D156686: [AST] Simplify Type::isSizelessBuiltinType(). NFC.

2023-07-31 Thread Jim Lin via Phabricator via cfe-commits
Jim updated this revision to Diff 545921.
Jim added a comment.

Address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156686

Files:
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2353,14 +2353,11 @@
 }
 
 bool Type::isSizelessBuiltinType() const {
+  if (isSVESizelessBuiltinType() || isRVVSizelessBuiltinType())
+return true;
+
   if (const BuiltinType *BT = getAs()) {
 switch (BT->getKind()) {
-  // SVE Types
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/AArch64SVEACLETypes.def"
-#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/RISCVVTypes.def"
-  return true;
   // WebAssembly reference types
 #define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/WebAssemblyReferenceTypes.def"


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2353,14 +2353,11 @@
 }
 
 bool Type::isSizelessBuiltinType() const {
+  if (isSVESizelessBuiltinType() || isRVVSizelessBuiltinType())
+return true;
+
   if (const BuiltinType *BT = getAs()) {
 switch (BT->getKind()) {
-  // SVE Types
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/AArch64SVEACLETypes.def"
-#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/RISCVVTypes.def"
-  return true;
   // WebAssembly reference types
 #define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156300: [clangd] Avoid unexpected desugaring in isSugaredTemplateParameter

2023-07-31 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 545920.
zyounan marked 2 inline comments as done.
zyounan added a comment.
Herald added a project: clang.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156300

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -214,15 +214,25 @@
 struct OtherClass {
   OtherClass() {
 Foo f;
+Derived d;
 f.$canBeCall^
+; // Prevent parsing as 'f.f'
+f.Foo::$canBeCall^
 &Foo::$cannotBeCall^
+;
+d.Foo::$canBeCall^
   }
 };
 
 int main() {
   Foo f;
+  Derived d;
   f.$canBeCall^
+  ; // Prevent parsing as 'f.f'
+  f.Foo::$canBeCall^
   &Foo::$cannotBeCall^
+  ;
+  d.Foo::$canBeCall^
 }
 )cpp");
 
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -338,8 +338,11 @@
   ///
   /// \param InBaseClass whether the result was found in a base
   /// class of the searched context.
+  ///
+  /// \param BaseType the type of expression that precedes the "." or "->"
+  /// in a member access expression.
   void AddResult(Result R, DeclContext *CurContext, NamedDecl *Hiding,
- bool InBaseClass);
+ bool InBaseClass, QualType BaseType);
 
   /// Add a new non-declaration result to this result set.
   void AddResult(Result R);
@@ -1262,7 +1265,8 @@
 }
 
 void ResultBuilder::AddResult(Result R, DeclContext *CurContext,
-  NamedDecl *Hiding, bool InBaseClass = false) {
+  NamedDecl *Hiding, bool InBaseClass = false,
+  QualType BaseType = QualType()) {
   if (R.Kind != Result::RK_Declaration) {
 // For non-declaration results, just add the result.
 Results.push_back(R);
@@ -1380,9 +1384,7 @@
 OverloadSet.Add(Method, Results.size());
   }
 
-  // When completing a non-static member function (and not via
-  // dot/arrow member access) and we're not inside that class' scope,
-  // it can't be a call.
+  // Decide whether or not a non-static member function can be a call.
   if (CompletionContext.getKind() == clang::CodeCompletionContext::CCC_Symbol) {
 const NamedDecl *ND = R.getDeclaration();
 if (const auto *FuncTmpl = dyn_cast(ND)) {
@@ -1404,10 +1406,24 @@
 return nullptr;
   }();
 
+  // When completing a non-static member function (and not via
+  // dot/arrow member access) and we're not inside that class' scope,
+  // it can't be a call.
   R.FunctionCanBeCall =
   CurrentClassScope &&
   (CurrentClassScope == Method->getParent() ||
CurrentClassScope->isDerivedFrom(Method->getParent()));
+
+  // If the member access "." or "->" is followed by a qualified Id and the
+  // object type is derived from or the same as that of the Id, then
+  // the candidate functions should be perceived as calls.
+  if (const CXXRecordDecl *MaybeDerived = nullptr;
+  !BaseType.isNull() &&
+  (MaybeDerived = BaseType->getAsCXXRecordDecl())) {
+auto *MaybeBase = Method->getParent();
+R.FunctionCanBeCall =
+MaybeDerived == MaybeBase || MaybeDerived->isDerivedFrom(MaybeBase);
+  }
 }
   }
 
@@ -1683,7 +1699,7 @@
  bool InBaseClass) override {
 ResultBuilder::Result Result(ND, Results.getBasePriority(ND), nullptr,
  false, IsAccessible(ND, Ctx), FixIts);
-Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass);
+Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass, BaseType);
   }
 
   void EnteredContext(DeclContext *Ctx) override {
Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -81,11 +81,13 @@
 }
 
 template 
-void assertHints(InlayHintKind Kind, llvm::StringRef AnnotatedSource,
- ExpectedHints... Expected) {
+void assertHintsWithHeader(InlayHintKind Kind, llvm::StringRef AnnotatedSource,
+   llvm::StringRef HeaderContent,
+   ExpectedHints... Expected) {
   Annotations Source(AnnotatedSource);
   TestTU TU = TestTU::withCode(Source.code());
   TU.ExtraArgs.push_back

[PATCH] D150929: [RISCV][BF16] Enable __bf16 for riscv targets

2023-07-31 Thread Jun Sha via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa5791bfef4e4: [RISCV][BF16] Enable __bf16 for riscv targets 
(authored by joshua-arch1).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D150929?vs=528286&id=545919#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150929

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/RISCV/bfloat-abi.c
  clang/test/CodeGen/RISCV/bfloat-mangle.cpp
  clang/test/Sema/vector-decl-crash.c

Index: clang/test/Sema/vector-decl-crash.c
===
--- clang/test/Sema/vector-decl-crash.c
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -triple riscv64-unknown-unknown
-
-// GH50171
-// This would previously crash when __bf16 was not a supported type.
-__bf16 v64bf __attribute__((vector_size(128))); // expected-error {{__bf16 is not supported on this target}} \
-   expected-error {{vector size not an integral multiple of component size}}
-
Index: clang/test/CodeGen/RISCV/bfloat-mangle.cpp
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/bfloat-mangle.cpp
@@ -0,0 +1,19 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK-RV64
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK-RV32
+
+// CHECK-RV64-LABEL: define dso_local void @_Z3fooDF16b
+// CHECK-RV64-SAME: (bfloat noundef [[B:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[B_ADDR:%.*]] = alloca bfloat, align 2
+// CHECK-RV64-NEXT:store bfloat [[B]], ptr [[B_ADDR]], align 2
+// CHECK-RV64-NEXT:ret void
+//
+// CHECK-RV32-LABEL: define dso_local void @_Z3fooDF16b
+// CHECK-RV32-SAME: (bfloat noundef [[B:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[B_ADDR:%.*]] = alloca bfloat, align 2
+// CHECK-RV32-NEXT:store bfloat [[B]], ptr [[B_ADDR]], align 2
+// CHECK-RV32-NEXT:ret void
+//
+void foo(__bf16 b) {}
Index: clang/test/CodeGen/RISCV/bfloat-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/bfloat-abi.c
@@ -0,0 +1,587 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK-RV64
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK-RV32
+
+struct bfloat1 {
+  __bf16 a;
+};
+
+// CHECK-RV64-LABEL: define dso_local i64 @h1
+// CHECK-RV64-SAME: (bfloat noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[RETVAL:%.*]] = alloca [[STRUCT_BFLOAT1:%.*]], align 2
+// CHECK-RV64-NEXT:[[A_ADDR:%.*]] = alloca bfloat, align 2
+// CHECK-RV64-NEXT:[[COERCE_DIVE_COERCE:%.*]] = alloca i64, align 8
+// CHECK-RV64-NEXT:store bfloat [[A]], ptr [[A_ADDR]], align 2
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
+// CHECK-RV64-NEXT:[[A1:%.*]] = getelementptr inbounds [[STRUCT_BFLOAT1]], ptr [[RETVAL]], i32 0, i32 0
+// CHECK-RV64-NEXT:store bfloat [[TMP0]], ptr [[A1]], align 2
+// CHECK-RV64-NEXT:[[COERCE_DIVE:%.*]] = getelementptr inbounds [[STRUCT_BFLOAT1]], ptr [[RETVAL]], i32 0, i32 0
+// CHECK-RV64-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[COERCE_DIVE_COERCE]], ptr align 2 [[COERCE_DIVE]], i64 2, i1 false)
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = load i64, ptr [[COERCE_DIVE_COERCE]], align 8
+// CHECK-RV64-NEXT:ret i64 [[TMP1]]
+//
+// CHECK-RV32-LABEL: define dso_local i32 @h1
+// CHECK-RV32-SAME: (bfloat noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[RETVAL:%.*]] = alloca [[STRUCT_BFLOAT1:%.*]], align 2
+// CHECK-RV32-NEXT:[[A_ADDR:%.*]] = alloca bfloat, align 2
+// CHECK-RV32-NEXT:[[COERCE_DIVE_COERCE:%.*]] = alloca i32, align 4
+// CHECK-RV32-NEXT:store bfloat [[A]], ptr [[A_ADDR]], align 2
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
+// CHECK-RV32-NEXT:[[A1:%.*]] = getelementptr inbounds [[STRUCT_BFLOAT1]], ptr [[RETVAL]], i32 0, i32 0
+// CHECK-RV32-NEXT:store bfloat [[TMP0]], ptr [[A1]], align 2
+// CHECK-RV32-NEXT:[[COERCE_DIVE:%.*]] = getelementptr inbounds [[STRUCT_BFLOAT1]], ptr [[RETVAL]], i32 0, i32 0
+// CHECK-RV32-NEXT:call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[COERCE_DIVE_COERCE]], ptr align 2 [[COERCE_DIVE]], i32 2, i1 false)
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = load 

[clang] a5791bf - [RISCV][BF16] Enable __bf16 for riscv targets

2023-07-31 Thread Jun Sha via cfe-commits

Author: Jun Sha (Joshua)
Date: 2023-08-01T13:59:27+08:00
New Revision: a5791bfef4e4bcc159ef9bf40d88262e5f409766

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

LOG: [RISCV][BF16] Enable __bf16 for riscv targets

The RISC-V psABI recently added __bf16 in 
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/367.
Now we can enable this new type in clang.

Reviewed By: craig.topper

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

Added: 
clang/test/CodeGen/RISCV/bfloat-abi.c
clang/test/CodeGen/RISCV/bfloat-mangle.cpp

Modified: 
clang/docs/LanguageExtensions.rst
clang/lib/Basic/Targets/RISCV.h

Removed: 
clang/test/Sema/vector-decl-crash.c



diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index fbe240dd79b8484..be80751b40668a3 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -816,6 +816,7 @@ to ``float``; see below for more information on this 
emulation.
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM
   * 64-bit ARM (AArch64)
+  * RISC-V
   * X86 (when SSE2 is available)
 
 (For X86, SSE2 is available on 64-bit and all recent 32-bit processors.)

diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index e4e39506bccf5ca..6be0e49ca2f5525 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -32,6 +32,9 @@ class RISCVTargetInfo : public TargetInfo {
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple) {
+BFloat16Width = 16;
+BFloat16Align = 16;
+BFloat16Format = &llvm::APFloat::BFloat();
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
@@ -101,6 +104,8 @@ class RISCVTargetInfo : public TargetInfo {
 
   bool hasBitIntType() const override { return true; }
 
+  bool hasBFloat16Type() const override { return true; }
+
   bool useFP16ConversionIntrinsics() const override {
 return false;
   }

diff  --git a/clang/test/CodeGen/RISCV/bfloat-abi.c 
b/clang/test/CodeGen/RISCV/bfloat-abi.c
new file mode 100644
index 000..bfaf1043133b80b
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/bfloat-abi.c
@@ -0,0 +1,587 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK-RV64
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK-RV32
+
+struct bfloat1 {
+  __bf16 a;
+};
+
+// CHECK-RV64-LABEL: define dso_local i64 @h1
+// CHECK-RV64-SAME: (bfloat noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[RETVAL:%.*]] = alloca [[STRUCT_BFLOAT1:%.*]], align 2
+// CHECK-RV64-NEXT:[[A_ADDR:%.*]] = alloca bfloat, align 2
+// CHECK-RV64-NEXT:[[COERCE_DIVE_COERCE:%.*]] = alloca i64, align 8
+// CHECK-RV64-NEXT:store bfloat [[A]], ptr [[A_ADDR]], align 2
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
+// CHECK-RV64-NEXT:[[A1:%.*]] = getelementptr inbounds [[STRUCT_BFLOAT1]], 
ptr [[RETVAL]], i32 0, i32 0
+// CHECK-RV64-NEXT:store bfloat [[TMP0]], ptr [[A1]], align 2
+// CHECK-RV64-NEXT:[[COERCE_DIVE:%.*]] = getelementptr inbounds 
[[STRUCT_BFLOAT1]], ptr [[RETVAL]], i32 0, i32 0
+// CHECK-RV64-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 8 
[[COERCE_DIVE_COERCE]], ptr align 2 [[COERCE_DIVE]], i64 2, i1 false)
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = load i64, ptr [[COERCE_DIVE_COERCE]], 
align 8
+// CHECK-RV64-NEXT:ret i64 [[TMP1]]
+//
+// CHECK-RV32-LABEL: define dso_local i32 @h1
+// CHECK-RV32-SAME: (bfloat noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[RETVAL:%.*]] = alloca [[STRUCT_BFLOAT1:%.*]], align 2
+// CHECK-RV32-NEXT:[[A_ADDR:%.*]] = alloca bfloat, align 2
+// CHECK-RV32-NEXT:[[COERCE_DIVE_COERCE:%.*]] = alloca i32, align 4
+// CHECK-RV32-NEXT:store bfloat [[A]], ptr [[A_ADDR]], align 2
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
+// CHECK-RV32-NEXT:[[A1:%.*]] = getelementptr inbounds [[STRUCT_BFLOAT1]], 
ptr [[RETVAL]], i32 0, i32 0
+// CHECK-RV32-NEXT:store bfloat [[TMP0]], ptr [[A1]], align 2
+// CHECK-RV32-NEXT:[[COERCE_DIVE:%.*]] = getelementptr inbounds 
[[STRUCT_BFLOAT1]], ptr [[RETVAL]], i32 0, i32 0
+// CHECK-RV32-NEXT:call void @llvm.memcpy.p0.p0.i32(ptr align 4 
[[COERCE_DIVE_COERCE]], ptr align 2 [[COERCE_DIVE]], i32 2, i1 false)
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = load i32, ptr [[COERCE_DIVE_COERCE]], 
align 4
+// CHECK-RV32-NEXT:ret i32 [[TMP1]]
+/

[PATCH] D156749: [modules] Fix error about the same module being defined in different .pcm files when using VFS overlays.

2023-07-31 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the quick review!

In D156749#4549226 , @ChuanqiXu wrote:

> Although there is a FIXME in the definition of `getNameAsRequested()`, it 
> looks not sense to require you to fix that. It might not be an over burden 
> for someone who  will be intended to fix this later. So LGTM.

I've discussed with @jansvoboda11 the future of 
`FileEntryRef::getNameAsRequested` and it is supposed to replace 
`FileEntryRef::getName` (eventually, not immediately), if I understand 
correctly. Given that, it is the move in the right direction regardless of 
FIXMEs. If I've misunderstood something, Jan can chime in and correct me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156749

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


[PATCH] D155661: [clang][ASTImporter] Fix friend class template import within dependent context

2023-07-31 Thread Ding Fei via Phabricator via cfe-commits
danix800 updated this revision to Diff 545913.
danix800 added a comment.

Update ReleaseNotes.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155661

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3968,8 +3968,31 @@
   EXPECT_EQ(ToDef->getPreviousDecl(), ToProto);
 }
 
-
-struct ImportFriendClasses : ASTImporterOptionSpecificTestBase {};
+struct ImportFriendClasses : ASTImporterOptionSpecificTestBase {
+  void testRecursiveFriendClassTemplate(Decl *FromTu) {
+auto *FromD = FirstDeclMatcher().match(
+FromTu, classTemplateDecl());
+auto *ToD = Import(FromD, Lang_CXX03);
+
+auto Pattern = classTemplateDecl(
+has(cxxRecordDecl(has(friendDecl(has(classTemplateDecl()));
+ASSERT_TRUE(MatchVerifier{}.match(FromD, Pattern));
+EXPECT_TRUE(MatchVerifier{}.match(ToD, Pattern));
+
+auto *FromFriend =
+FirstDeclMatcher().match(FromD, friendDecl());
+auto *FromClass =
+FirstDeclMatcher().match(FromD, classTemplateDecl());
+EXPECT_NE(FromFriend->getFriendDecl(), FromClass);
+EXPECT_TRUE(FromFriend->getFriendDecl()->getPreviousDecl() == nullptr);
+
+auto *Class =
+FirstDeclMatcher().match(ToD, classTemplateDecl());
+auto *Friend = FirstDeclMatcher().match(ToD, friendDecl());
+EXPECT_NE(Friend->getFriendDecl(), Class);
+EXPECT_TRUE(Friend->getFriendDecl()->getPreviousDecl() == nullptr);
+  }
+};
 
 TEST_P(ImportFriendClasses, ImportOfFriendRecordDoesNotMergeDefinition) {
   Decl *FromTU = getTuDecl(
@@ -4074,20 +4097,19 @@
   )",
   Lang_CXX03, "input.cc");
 
-  auto *FromD =
-  FirstDeclMatcher().match(FromTu, classTemplateDecl());
-  auto *ToD = Import(FromD, Lang_CXX03);
-
-  auto Pattern = classTemplateDecl(
-  has(cxxRecordDecl(has(friendDecl(has(classTemplateDecl()));
-  ASSERT_TRUE(MatchVerifier{}.match(FromD, Pattern));
-  EXPECT_TRUE(MatchVerifier{}.match(ToD, Pattern));
+  testRecursiveFriendClassTemplate(FromTu);
+}
 
-  auto *Class =
-  FirstDeclMatcher().match(ToD, classTemplateDecl());
-  auto *Friend = FirstDeclMatcher().match(ToD, friendDecl());
-  EXPECT_NE(Friend->getFriendDecl(), Class);
-  EXPECT_EQ(Friend->getFriendDecl()->getPreviousDecl(), Class);
+TEST_P(ImportFriendClasses,
+   ImportOfRecursiveFriendClassTemplateWithNonTypeParm) {
+  Decl *FromTu = getTuDecl(
+  R"(
+  template class declToImport {
+template friend class declToImport;
+  };
+  )",
+  Lang_CXX03, "input.cc");
+  testRecursiveFriendClassTemplate(FromTu);
 }
 
 TEST_P(ImportFriendClasses, ProperPrevDeclForClassTemplateDecls) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -2857,9 +2857,13 @@
   } else if (Importer.getToContext().getLangOpts().CPlusPlus)
 IDNS |= Decl::IDNS_Ordinary | Decl::IDNS_TagFriend;
 
+  bool IsDependentContext = DC != LexicalDC ? LexicalDC->isDependentContext()
+: DC->isDependentContext();
+  bool DependentFriend = IsFriendTemplate && IsDependentContext;
+
   // We may already have a record of the same name; try to find and match it.
   RecordDecl *PrevDecl = nullptr;
-  if (!DC->isFunctionOrMethod() && !D->isLambda()) {
+  if (!DependentFriend && !DC->isFunctionOrMethod() && !D->isLambda()) {
 SmallVector ConflictingDecls;
 auto FoundDecls =
 Importer.findDeclsInToCtx(DC, SearchName);
@@ -5796,10 +5800,15 @@
   if (ToD)
 return ToD;
 
+  bool IsFriendTemplate = D->getFriendObjectKind() != Decl::FOK_None;
+  bool IsDependentContext = DC != LexicalDC ? LexicalDC->isDependentContext()
+: DC->isDependentContext();
+  bool DependentFriend = IsFriendTemplate && IsDependentContext;
+
   ClassTemplateDecl *FoundByLookup = nullptr;
 
   // We may already have a template of the same name; try to find and match it.
-  if (!DC->isFunctionOrMethod()) {
+  if (!DependentFriend && !DC->isFunctionOrMethod()) {
 SmallVector ConflictingDecls;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
 for (auto *FoundDecl : FoundDecls) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@
 
 Bug Fixes to AST Handling
 ^
+- Fixed an import failure of recursive friend class template.
+  `Issue 64169 `_
 
 Miscellaneous Bug Fixes
 ^^^

[PATCH] D155661: [clang][ASTImporter] Fix friend class template import within dependent context

2023-07-31 Thread Ding Fei via Phabricator via cfe-commits
danix800 added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:2862-2866
+  bool ShouldAddRedecl = !(IsFriendTemplate && IsDependentContext);
+
   // We may already have a record of the same name; try to find and match it.
   RecordDecl *PrevDecl = nullptr;
   if (!DC->isFunctionOrMethod() && !D->isLambda()) {

balazske wrote:
> The code seems to work but I was confused by the different conditions used 
> (is it possible that `IsFriendTemplate` and `ShouldAddRedecl` is true at the 
> same time?). I had the observation that if `ShouldAddRedecl` is false we do 
> not need the whole search for previous decl. At a friend template we shall 
> not find a definition, the loop would just find the last declaration (this 
> value is not used). So I have the idea of this code (could not find the 
> "suggest edit" command):
> 
> ```
>   bool DependentFriend = IsFriendTemplate && IsDependentContext;
> 
>   // We may already have a record of the same name; try to find and match it.
>   RecordDecl *PrevDecl = nullptr;
>   if (!DependentFriend && !DC->isFunctionOrMethod() && !D->isLambda()) {
> 
> ```
This is more clear. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155661

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


[PATCH] D155661: [clang][ASTImporter] Fix friend class template import within dependent context

2023-07-31 Thread Ding Fei via Phabricator via cfe-commits
danix800 updated this revision to Diff 545912.
danix800 added a comment.

Cleanup as @balazske suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155661

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3968,8 +3968,31 @@
   EXPECT_EQ(ToDef->getPreviousDecl(), ToProto);
 }
 
-
-struct ImportFriendClasses : ASTImporterOptionSpecificTestBase {};
+struct ImportFriendClasses : ASTImporterOptionSpecificTestBase {
+  void testRecursiveFriendClassTemplate(Decl *FromTu) {
+auto *FromD = FirstDeclMatcher().match(
+FromTu, classTemplateDecl());
+auto *ToD = Import(FromD, Lang_CXX03);
+
+auto Pattern = classTemplateDecl(
+has(cxxRecordDecl(has(friendDecl(has(classTemplateDecl()));
+ASSERT_TRUE(MatchVerifier{}.match(FromD, Pattern));
+EXPECT_TRUE(MatchVerifier{}.match(ToD, Pattern));
+
+auto *FromFriend =
+FirstDeclMatcher().match(FromD, friendDecl());
+auto *FromClass =
+FirstDeclMatcher().match(FromD, classTemplateDecl());
+EXPECT_NE(FromFriend->getFriendDecl(), FromClass);
+EXPECT_TRUE(FromFriend->getFriendDecl()->getPreviousDecl() == nullptr);
+
+auto *Class =
+FirstDeclMatcher().match(ToD, classTemplateDecl());
+auto *Friend = FirstDeclMatcher().match(ToD, friendDecl());
+EXPECT_NE(Friend->getFriendDecl(), Class);
+EXPECT_TRUE(Friend->getFriendDecl()->getPreviousDecl() == nullptr);
+  }
+};
 
 TEST_P(ImportFriendClasses, ImportOfFriendRecordDoesNotMergeDefinition) {
   Decl *FromTU = getTuDecl(
@@ -4074,20 +4097,19 @@
   )",
   Lang_CXX03, "input.cc");
 
-  auto *FromD =
-  FirstDeclMatcher().match(FromTu, classTemplateDecl());
-  auto *ToD = Import(FromD, Lang_CXX03);
-
-  auto Pattern = classTemplateDecl(
-  has(cxxRecordDecl(has(friendDecl(has(classTemplateDecl()));
-  ASSERT_TRUE(MatchVerifier{}.match(FromD, Pattern));
-  EXPECT_TRUE(MatchVerifier{}.match(ToD, Pattern));
+  testRecursiveFriendClassTemplate(FromTu);
+}
 
-  auto *Class =
-  FirstDeclMatcher().match(ToD, classTemplateDecl());
-  auto *Friend = FirstDeclMatcher().match(ToD, friendDecl());
-  EXPECT_NE(Friend->getFriendDecl(), Class);
-  EXPECT_EQ(Friend->getFriendDecl()->getPreviousDecl(), Class);
+TEST_P(ImportFriendClasses,
+   ImportOfRecursiveFriendClassTemplateWithNonTypeParm) {
+  Decl *FromTu = getTuDecl(
+  R"(
+  template class declToImport {
+template friend class declToImport;
+  };
+  )",
+  Lang_CXX03, "input.cc");
+  testRecursiveFriendClassTemplate(FromTu);
 }
 
 TEST_P(ImportFriendClasses, ProperPrevDeclForClassTemplateDecls) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -2857,9 +2857,13 @@
   } else if (Importer.getToContext().getLangOpts().CPlusPlus)
 IDNS |= Decl::IDNS_Ordinary | Decl::IDNS_TagFriend;
 
+  bool IsDependentContext = DC != LexicalDC ? LexicalDC->isDependentContext()
+: DC->isDependentContext();
+  bool DependentFriend = IsFriendTemplate && IsDependentContext;
+
   // We may already have a record of the same name; try to find and match it.
   RecordDecl *PrevDecl = nullptr;
-  if (!DC->isFunctionOrMethod() && !D->isLambda()) {
+  if (!DependentFriend && !DC->isFunctionOrMethod() && !D->isLambda()) {
 SmallVector ConflictingDecls;
 auto FoundDecls =
 Importer.findDeclsInToCtx(DC, SearchName);
@@ -5796,10 +5800,15 @@
   if (ToD)
 return ToD;
 
+  bool IsFriendTemplate = D->getFriendObjectKind() != Decl::FOK_None;
+  bool IsDependentContext = DC != LexicalDC ? LexicalDC->isDependentContext()
+: DC->isDependentContext();
+  bool DependentFriend = IsFriendTemplate && IsDependentContext;
+
   ClassTemplateDecl *FoundByLookup = nullptr;
 
   // We may already have a template of the same name; try to find and match it.
-  if (!DC->isFunctionOrMethod()) {
+  if (!DependentFriend && !DC->isFunctionOrMethod()) {
 SmallVector ConflictingDecls;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
 for (auto *FoundDecl : FoundDecls) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156234: [clang][deps] add support for dependency scanning with cc1 command line

2023-07-31 Thread Connor Sughrue via Phabricator via cfe-commits
cpsughrue updated this revision to Diff 545910.
cpsughrue retitled this revision from "[clang][deps] provide support for cc1 
command line scanning" to "[clang][deps] add support for dependency scanning 
with cc1 command line".
cpsughrue edited the summary of this revision.
cpsughrue added a comment.

Added llvm-lit test for commit and removed previously created unit test


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

https://reviews.llvm.org/D156234

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/Inputs/modules_cc1_cdb.json
  clang/test/ClangScanDeps/modules-cc1.cpp

Index: clang/test/ClangScanDeps/modules-cc1.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-cc1.cpp
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: rm -rf %t_clangcl.cdb
+// RUN: rm -rf %t.module-cache
+// RUN: rm -rf %t.module-cache_clangcl
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: cp %s %t.dir/modules_cdb_input2.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
+// RUN: cp %S/Inputs/header2.h %t.dir/Inputs/header2.h
+// RUN: cp %S/Inputs/module.modulemap %t.dir/Inputs/module.modulemap
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cc1_cdb.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-dependency-directives | \
+// RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO %s
+//
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs. Note that the 'NOT' check is not used
+// as it might fail if the results for `modules_cdb_input.cpp` are reported before
+// `modules_cdb_input2.cpp`.
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-dependency-directives | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-dependency-directives | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
+
+#include "header.h"
+
+// CHECK1: modules_cdb_input2.o:
+// CHECK1-NEXT: modules_cdb_input2.cpp
+// CHECK1-NEXT: Inputs{{/|\\}}module.modulemap
+// CHECK1-NEXT: Inputs{{/|\\}}header2.h
+// CHECK1: Inputs{{/|\\}}header.h
+
+// CHECK2: {{(modules_cdb_input)|(a)|(b)}}.o:
+// CHECK2-NEXT: modules_cdb_input.cpp
+// CHECK2-NEXT: Inputs{{/|\\}}module.modulemap
+// CHECK2-NEXT: Inputs{{/|\\}}header.h
+// CHECK2NO-NOT: header2
\ No newline at end of file
Index: clang/test/ClangScanDeps/Inputs/modules_cc1_cdb.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/modules_cc1_cdb.json
@@ -0,0 +1,22 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -cc1 -E DIR/modules_cdb_input2.cpp -IInputs -D INCLUDE_HEADER2 -fmodules -MT modules_cdb_input2.o -dependency-file DIR/modules_cdb2.d -fmodules-cache-path=DIR/module-cache -fcoverage-compilation-dir=DIR -fimplicit-module-maps -fmodules-validate-system-headers",
+  "file": "DIR/modules_cdb_input2.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang -cc1 -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fmodules-cache-path=DIR/module-cache -fcoverage-compilation-dir=DIR -fdebug-compilation-dir=DIR -fimplicit-module-maps -fmodules-validate-system-headers",
+  "file": "DIR/modules_cdb_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang -cc1 -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fmodules-cache-path=DIR/module-cache -fcoverage-compilation-dir=DIR -fdebug-compilation-dir=DIR -fimplicit-module-maps -fmodules-validate-system-headers -o a.o",
+  "file": "DIR/modules_cdb_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang -cc1 -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fmodules-cache-path=DIR/module-cache -fcoverage-compilation-dir=DIR -fdebug-compilation-dir=DIR -fimplicit-module-maps -fmodules-validate-system-headers -o b.o",
+  "file": "DIR/modules_cdb_input.cpp"
+}
+]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -385,6 +385,9 @@
   if (!Compilation)
 return false;
 
+  if (Compilation->containsError())
+return false;
+
   for (const driver::Command &Job : Compilation->getJobs()) {
 if (!Callback(Job))
   return false;
@@ -392,6 +395,26 @@
   return true;
 }
 
+static bool createAndRunToolInvocation(
+std::vector CommandLine, DependencyScanningAction &Action,
+FileManager &FM,

[PATCH] D156686: [AST] Simplify Type::isSizelessBuiltinType(). NFC.

2023-07-31 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/AST/Type.cpp:2356
 bool Type::isSizelessBuiltinType() const {
+  if (isSVESizelessBuiltinType())
+return true;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156686

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


[PATCH] D156771: [clang][hexagon] Handle library path arguments earlier

2023-07-31 Thread Brian Cain via Phabricator via cfe-commits
bcain created this revision.
bcain added reviewers: kparzysz, sidneym, MaskRay.
Herald added a project: All.
bcain requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The removal of the early return in 96832a6bf7e0e7f1e8d634d38c44a1b32d512923 

was an error: it would include the 'standalone' library that's not used
by linux.

Instead we reproduce the library path handling in the linux/musl block.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156771

Files:
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/test/Driver/hexagon-toolchain-linux.c


Index: clang/test/Driver/hexagon-toolchain-linux.c
===
--- clang/test/Driver/hexagon-toolchain-linux.c
+++ clang/test/Driver/hexagon-toolchain-linux.c
@@ -124,4 +124,8 @@
 // RUN:--target=hexagon-unknown-linux-musl %s 2>&1 \
 // RUN:| FileCheck -check-prefix=CHECK010 %s
 // CHECK010:   InstalledDir: [[INSTALLED_DIR:.+]]
+// CHECK010-NOT:  "-lstandalone"
+// CHECK010-NOT:  crt0_standalone.o
+// CHECK010:   crt1.o
 // CHECK010:   "-L/tmp"
+// CHECK010-NOT:  "-lstandalone"
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -383,6 +383,11 @@
   if (HTC.ShouldLinkCXXStdlib(Args))
 HTC.AddCXXStdlibLibArgs(Args, CmdArgs);
 }
+const ToolChain::path_list &LibPaths = HTC.getFilePaths();
+for (const auto &LibPath : LibPaths)
+CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+Args.ClaimAllArgs(options::OPT_L);
+return;
   }
 
   
//


Index: clang/test/Driver/hexagon-toolchain-linux.c
===
--- clang/test/Driver/hexagon-toolchain-linux.c
+++ clang/test/Driver/hexagon-toolchain-linux.c
@@ -124,4 +124,8 @@
 // RUN:--target=hexagon-unknown-linux-musl %s 2>&1 \
 // RUN:| FileCheck -check-prefix=CHECK010 %s
 // CHECK010:   InstalledDir: [[INSTALLED_DIR:.+]]
+// CHECK010-NOT:  "-lstandalone"
+// CHECK010-NOT:  crt0_standalone.o
+// CHECK010:   crt1.o
 // CHECK010:   "-L/tmp"
+// CHECK010-NOT:  "-lstandalone"
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -383,6 +383,11 @@
   if (HTC.ShouldLinkCXXStdlib(Args))
 HTC.AddCXXStdlibLibArgs(Args, CmdArgs);
 }
+const ToolChain::path_list &LibPaths = HTC.getFilePaths();
+for (const auto &LibPath : LibPaths)
+CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+Args.ClaimAllArgs(options::OPT_L);
+return;
   }
 
   //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156749: [modules] Fix error about the same module being defined in different .pcm files when using VFS overlays.

2023-07-31 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

Although there is a FIXME in the definition of `getNameAsRequested()`, it looks 
not sense to require you to fix that. It might not be an over burden for 
someone who  will be intended to fix this later. So LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156749

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


[PATCH] D156728: [Sema] Ignore nullability qualifiers when deducing types for `auto` and `__auto_type`

2023-07-31 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I think we still need to do something like what this patch is doing (i.e., drop 
the nullability qualifiers) when deducing types for `auto` or `__auto_type`, 
assuming that's the rule we want and we want to restore the previous behavior.

I agree with you that we should make the warning flow sensitive, but I was 
thinking we could do that later after fixing the type deduction bug.




Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3933
   //   type are ignored for type deduction.
+  // Ignore top level nullability qualifiers too.
   ArgType = ArgType.getUnqualifiedType();

gribozavr2 wrote:
> This comment merely duplicates the code. Please add an explanation why it is 
> done.
I guess we were dropping the nullability qualifiers for the same reason we drop 
cv qualifiers. The new variable declared with `auto` is a separate variable, so 
it doesn't inherit the qualifiers the argument type.

Of course, I'm assuming that's the rule we want, but I'm not sure as 
nullability qualifiers aren't part of the C/C++ standards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156728

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


[PATCH] D150124: [index][clangd] Consider labels when indexing function bodies

2023-07-31 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.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150124

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


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx marked an inline comment as done.
AlexVlx added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3542
+LangAS AAS = getASTAllocaAddressSpace();
+LangAS EAS = E->getType().getAddressSpace();
+if (AAS != EAS) {

rjmccall wrote:
> `E->getType().getAddressSpace()` is actually the top-level qualification of 
> the type; you need `E->getType()->getPointeeType().getAddressSpace()`.
D'oh! I will probably never avoid getting tripped by this, sorry for the noise.


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

https://reviews.llvm.org/D156539

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


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 545882.
AlexVlx added a comment.

Use pointee's address space for the check.


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

https://reviews.llvm.org/D156539

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/dynamic-alloca-with-address-space.c


Index: clang/test/CodeGen/dynamic-alloca-with-address-space.c
===
--- /dev/null
+++ clang/test/CodeGen/dynamic-alloca-with-address-space.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -DOCL12 -x cl -std=cl1.2 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CL12
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x cl -std=cl2.0 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CL20
+
+#if defined(OCL12)
+#define CAST (char *)(unsigned long)
+#else
+#define CAST (char *)
+#endif
+
+void allocas(unsigned long n) {
+char *a = CAST __builtin_alloca(n);
+char *uninitialized_a = CAST __builtin_alloca_uninitialized(n);
+char *aligned_a = CAST __builtin_alloca_with_align(n, 8);
+char *aligned_uninitialized_a = CAST 
__builtin_alloca_with_align_uninitialized(n, 8);
+}
+
+// CHECK: @allocas(
+// CHECK: store i64 %n, ptr %n.addr.ascast, align 8
+// CHECK: %0 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %1 = alloca i8, i64 %0, align 8, addrspace(5)
+// CHECK: %2 = addrspacecast ptr addrspace(5) %1 to ptr
+// CHECK: store ptr %2, ptr %a.ascast, align 8
+// CHECK: %3 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %4 = alloca i8, i64 %3, align 8, addrspace(5)
+// CHECK: %5 = addrspacecast ptr addrspace(5) %4 to ptr
+// CHECK: store ptr %5, ptr %uninitialized_a.ascast, align 8
+// CHECK: %6 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %7 = alloca i8, i64 %6, align 1, addrspace(5)
+// CHECK: %8 = addrspacecast ptr addrspace(5) %7 to ptr
+// CHECK: store ptr %8, ptr %aligned_a.ascast, align 8
+// CHECK: %9 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %10 = alloca i8, i64 %9, align 1, addrspace(5)
+// CHECK: %11 = addrspacecast ptr addrspace(5) %10 to ptr
+// CHECK: store ptr %11, ptr %aligned_uninitialized_a.ascast, align 8
+// CHECK: ret void
+// CHECK-CL12-NOT: addrspacecast
+// CHECK-CL20-NOT: addrspacecast
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3517,6 +3517,12 @@
 return RValue::get(Result);
   }
 
+  // An alloca will always return a pointer to the alloca (stack) address
+  // space. This address space need not be the same as the AST / Language
+  // default (e.g. in C / C++ auto vars are in the generic address space). At
+  // the AST level this is handled within CreateTempAlloca et al., but for the
+  // builtin / dynamic alloca we have to handle it here. We use an explicit 
cast
+  // instead of passing an AS to CreateAlloca so as to not inhibit 
optimisation.
   case Builtin::BIalloca:
   case Builtin::BI_alloca:
   case Builtin::BI__builtin_alloca_uninitialized:
@@ -3532,6 +3538,13 @@
 AI->setAlignment(SuitableAlignmentInBytes);
 if (BuiltinID != Builtin::BI__builtin_alloca_uninitialized)
   initializeAlloca(*this, AI, Size, SuitableAlignmentInBytes);
+LangAS AAS = getASTAllocaAddressSpace();
+LangAS EAS = E->getType()->getPointeeType().getAddressSpace();
+if (AAS != EAS) {
+  llvm::Type *Ty = CGM.getTypes().ConvertType(E->getType());
+  return RValue::get(getTargetHooks().performAddrSpaceCast(*this, AI, AAS,
+   EAS, Ty));
+}
 return RValue::get(AI);
   }
 
@@ -3547,6 +3560,13 @@
 AI->setAlignment(AlignmentInBytes);
 if (BuiltinID != Builtin::BI__builtin_alloca_with_align_uninitialized)
   initializeAlloca(*this, AI, Size, AlignmentInBytes);
+LangAS AAS = getASTAllocaAddressSpace();
+LangAS EAS = E->getType()->getPointeeType().getAddressSpace();
+if (AAS != EAS) {
+  llvm::Type *Ty = CGM.getTypes().ConvertType(E->getType());
+  return RValue::get(getTargetHooks().performAddrSpaceCast(*this, AI, AAS,
+   EAS, Ty));
+}
 return RValue::get(AI);
   }
 


Index: clang/test/CodeGen/dynamic-alloca-with-address-space.c
===
--- /dev/null
+++ clang/test/CodeGen/dynamic-alloca-with-address-space.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -DOCL12 -x cl -std=cl1.2 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CL12
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x cl -std=cl2.0 \
+// RUN

[PATCH] D155668: [RISCV] Upgrade Zvfh version to 1.0 and move out of experimental state.

2023-07-31 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D155668#4548454 , @jrtc27 wrote:

> Uh, why are there clang/test/Sema/aarch64* tests full of RISC-V extension 
> names? That's not right at all. One of them is coming from 
> https://reviews.llvm.org/D135011, I haven't traced the rest back, but that's 
> clearly wrong. The test looks to be a copy of the RISC-V one with tweaks to 
> change riscv(64) to arm/aarch64, and `  -target-feature +sve` (with two 
> spaces) added.

Fixed in 690edeab78ba6996a44f6fd9e8fce79cb78e7737 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155668

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


[clang] 690edea - [AArch64] Remove copy/pasted RISC-V extension names from some tests. NFC

2023-07-31 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-07-31T17:34:38-07:00
New Revision: 690edeab78ba6996a44f6fd9e8fce79cb78e7737

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

LOG: [AArch64] Remove copy/pasted RISC-V extension names from some tests. NFC

Added: 


Modified: 
clang/test/Sema/aarch64-sve-vector-exp-ops.c
clang/test/Sema/aarch64-sve-vector-log-ops.c
clang/test/Sema/aarch64-sve-vector-pow-ops.c
clang/test/Sema/aarch64-sve-vector-trig-ops.c

Removed: 




diff  --git a/clang/test/Sema/aarch64-sve-vector-exp-ops.c 
b/clang/test/Sema/aarch64-sve-vector-exp-ops.c
index 2b17442cc2cd13..f2bba8c7eeb196 100644
--- a/clang/test/Sema/aarch64-sve-vector-exp-ops.c
+++ b/clang/test/Sema/aarch64-sve-vector-exp-ops.c
@@ -1,6 +1,5 @@
-// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \
-// RUN:   -target-feature +v -target-feature +zfh  -target-feature +sve 
-target-feature +zvfh \
-// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify
 // REQUIRES: aarch64-registered-target
 
 #include 

diff  --git a/clang/test/Sema/aarch64-sve-vector-log-ops.c 
b/clang/test/Sema/aarch64-sve-vector-log-ops.c
index 493e919a3f5049..2beb616c1edb16 100644
--- a/clang/test/Sema/aarch64-sve-vector-log-ops.c
+++ b/clang/test/Sema/aarch64-sve-vector-log-ops.c
@@ -1,6 +1,5 @@
-// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \
-// RUN:   -target-feature +v -target-feature +zfh  -target-feature +sve 
-target-feature +zvfh \
-// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify
 // REQUIRES: aarch64-registered-target
 
 #include 

diff  --git a/clang/test/Sema/aarch64-sve-vector-pow-ops.c 
b/clang/test/Sema/aarch64-sve-vector-pow-ops.c
index 1024cdc2517d07..e61d752911fc3d 100644
--- a/clang/test/Sema/aarch64-sve-vector-pow-ops.c
+++ b/clang/test/Sema/aarch64-sve-vector-pow-ops.c
@@ -1,6 +1,5 @@
-// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \
-// RUN:   -target-feature +v -target-feature +zfh  -target-feature +sve 
-target-feature +experimental-zvfh \
-// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify
 // REQUIRES: aarch64-registered-target
 
 #include 

diff  --git a/clang/test/Sema/aarch64-sve-vector-trig-ops.c 
b/clang/test/Sema/aarch64-sve-vector-trig-ops.c
index 6d71088f9f540e..7ca941f578c70d 100644
--- a/clang/test/Sema/aarch64-sve-vector-trig-ops.c
+++ b/clang/test/Sema/aarch64-sve-vector-trig-ops.c
@@ -1,6 +1,5 @@
-// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \
-// RUN:   -target-feature +v -target-feature +zfh  -target-feature +sve 
-target-feature +zvfh \
-// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify
 // REQUIRES: aarch64-registered-target
 
 #include 



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


[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-07-31 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:37-39
+// CHECK: fix-it:{{.*}}:{[[@LINE+3]]:24-[[@LINE+3]]:30}:"std::span p"
+// CHECK: fix-it:{{.*}}:{[[@LINE+2]]:32-[[@LINE+2]]:39}:"std::span q"
+// CHECK: fix-it:{{.*}}:{[[@LINE+1]]:41-[[@LINE+1]]:48}:"std::span a"

NoQ wrote:
> The fix is emitted 3 times right? Once for each warning?
> 
> Would it make sense to duplicate the three `CHECK:` lines three times to 
> confirm that?
I wish there are better ways to test this.  I tried `CHECK-COUNT-3` but it 
doesn't work because it expects each line repeats 3 times consecutively.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:306
+  b[5] = 5; // expected-note{{used in buffer access here}}
+}

t-rasmud wrote:
> Can we have a test case with qualifiers on parameters and maybe another with 
> a qualifier on the function itself?
good point.  I recently added such tests for parameters and local variables in 
following open patches:

- https://reviews.llvm.org/D156189 : 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp:49--62

- https://reviews.llvm.org/D156188 : 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp:150--198


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

https://reviews.llvm.org/D153059

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


[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-07-31 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 545872.
ziqingluo-90 marked 4 inline comments as done.
ziqingluo-90 added a comment.

Carved out NFC changes from the original diff.


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

https://reviews.llvm.org/D153059

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
@@ -36,7 +36,7 @@
 void * voidPtrCall(void);
 char * charPtrCall(void);
 
-void testArraySubscripts(int *p, int **pp) { // expected-note{{change type of 'pp' to 'std::span' to preserve bounds information}}
+void testArraySubscripts(int *p, int **pp) {
 // expected-warning@-1{{'p' is an unsafe pointer used for buffer access}}
 // expected-warning@-2{{'pp' is an unsafe pointer used for buffer access}}
   foo(p[1], // expected-note{{used in buffer access here}}
@@ -109,7 +109,6 @@
   sizeof(decltype(p[1])));  // no-warning
 }
 
-// expected-note@+1{{change type of 'a' to 'std::span' to preserve bounds information}}
 void testQualifiedParameters(const int * p, const int * const q, const int a[10], const int b[10][10]) {
   // expected-warning@-1{{'p' is an unsafe pointer used for buffer access}}
   // expected-warning@-2{{'q' is an unsafe pointer used for buffer access}}
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
@@ -29,8 +29,7 @@
   int tmp;
   tmp = p[5] + q[5];
 }
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:2-[[@LINE-1]]:2}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void twoParms(int *p, int * q) {return twoParms(std::span(p, <# size #>), q);}\n"
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-2]]:2-[[@LINE-2]]:2}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void twoParms(int *p, int * q) {return twoParms(p, std::span(q, <# size #>));}\n"
+// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:2-[[@LINE-1]]:2}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void twoParms(int *p, int * q) {return twoParms(std::span(p, <# size #>), std::span(q, <# size #>));}\n"
 
 void ptrToConst(const int * x) {
   // CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:17-[[@LINE-1]]:30}:"std::span x"
@@ -100,22 +99,30 @@
 // namned
   } NAMED_S;
 
+
   // FIXME: `decltype(ANON_S)` represents an unnamed type but it can
   // be referred as "`decltype(ANON_S)`", so the analysis should
   // fix-it.
-  void decltypeSpecifier(decltype(C) * p, decltype(ANON_S) * q, decltype(NAMED_S) * r,
- decltype(NAMED_S) ** rr) {
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-2]]:26-[[@LINE-2]]:41}:"std::span p"
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-3]]:65-[[@LINE-3]]:86}:"std::span r"
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-3]]:26-[[@LINE-3]]:49}:"std::span rr"
+  // As parameter `q` cannot be fixed, fixes to parameters are all being given up.
+  void decltypeSpecifierAnon(decltype(C) * p, decltype(ANON_S) * q, decltype(NAMED_S) * r,
+			 decltype(NAMED_S) ** rr) {
+// CHECK-NOT: fix-it:{{.*}}:{[[@LINE-1]]
 if (++p) {}
 if (++q) {}
 if (++r) {}
 if (++rr) {}
   }
-  // CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:4-[[@LINE-1]]:4}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void decltypeSpecifier(decltype(C) * p, decltype(ANON_S) * q, decltype(NAMED_S) * r,\n{{.*}}decltype(NAMED_S) ** rr) {return decltypeSpecifier(std::span(p, <# size #>), q, r, rr);}\n
-  // CHECK-DAG: fix-it:{{.*}}:{[[@LINE-2]]:4-[[@LINE-2]]:4}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void decltypeSpecifier(decltype(C) * p, decltype(ANON_S) * q, decltype(NAMED_S) * r,\n{{.*}}decltype(NAMED_S) ** rr) {return decltypeSpecifier(p, q, std::span(r, <# size #>), rr);}\n"
-  // CHECK-DAG: fix-it:{{.*}}:{[[@LINE-3]]:4-[[@LINE-3]]:4}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void decltypeSpecifier(decltype(C) * p, decltype(ANON_S) * q, decltype(NAMED_S) * r,\n{{.*}}decltype(NAMED_S) ** rr) {return decltypeSpecifier(p, q, r, std::span(rr, <# size #>));}\n"
+  // CHECK-NOT: fix-it:{{.*}}:{[[@LINE-1]]
+
+  void decltypeSpecifier(decltype(C) * p, decltype(NAMED_S) * r, decltype(NAMED_S) ** rr) {
+// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:26-[[@LINE-1]]:41}:"std::span p"
+// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-2]]:43-[[@LINE-2]]:64}:"std::span r"
+// CHECK-DAG: fix-it:{{.*}}:{[[@LIN

[clang] 42c9354 - Revert "Reland "[LoongArch] Support -march=native and -mtune=""

2023-07-31 Thread Steven Wu via cfe-commits

Author: Steven Wu
Date: 2023-07-31T16:57:06-07:00
New Revision: 42c9354a928d4d9459504527085fccc91b46aed3

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

LOG: Revert "Reland "[LoongArch] Support -march=native and -mtune=""

This reverts commit c56514f21b2cf08eaa7ac3a57ba4ce403a9c8956. This
commit adds global state that is shared between clang driver and clang
cc1, which is not correct when clang is used with `-fno-integrated-cc1`
option (no integrated cc1). The -march and -mtune option needs to be
properly passed through cc1 command-line and stored in TargetInfo.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Basic/Targets/LoongArch.cpp
clang/lib/Basic/Targets/LoongArch.h
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Preprocessor/init-loongarch.c
llvm/include/llvm/TargetParser/LoongArchTargetParser.h
llvm/lib/Target/LoongArch/LoongArch.td
llvm/lib/TargetParser/LoongArchTargetParser.cpp

Removed: 
clang/test/Driver/loongarch-mtune-error.c
clang/test/Driver/loongarch-mtune.c
llvm/test/CodeGen/LoongArch/cpus-invalid.ll
llvm/test/CodeGen/LoongArch/cpus.ll



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 55189cbd659087..a6b70042cc50f9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -156,9 +156,6 @@ Windows Support
 LoongArch Support
 ^
 
-- The ``-march=native`` ``-mtune=`` options and ``__loongarch_{arch,tune}``
-  macros are now supported.
-
 RISC-V Support
 ^^
 

diff  --git a/clang/lib/Basic/Targets/LoongArch.cpp 
b/clang/lib/Basic/Targets/LoongArch.cpp
index f08e5e732b0354..6958479cd7c42d 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -15,7 +15,7 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/TargetParser/LoongArchTargetParser.h"
+#include "llvm/TargetParser/TargetParser.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -198,19 +198,7 @@ void LoongArchTargetInfo::getTargetDefines(const 
LangOptions &Opts,
   else
 Builder.defineMacro("__loongarch_frlen", "0");
 
-  // Define __loongarch_arch.
-  StringRef Arch = llvm::LoongArch::getArch();
-  if (Arch.empty())
-Arch = llvm::LoongArch::getDefaultArch(GRLen == 64);
-  if (!Arch.empty())
-Builder.defineMacro("__loongarch_arch", Arch);
-
-  // Define __loongarch_tune.
-  StringRef TuneCPU = llvm::LoongArch::getTuneCPU();
-  if (TuneCPU.empty())
-TuneCPU = Arch;
-  if (!TuneCPU.empty())
-Builder.defineMacro("__loongarch_tune", TuneCPU);
+  // TODO: define __loongarch_arch and __loongarch_tune.
 
   StringRef ABI = getABI();
   if (ABI == "lp64d" || ABI == "lp64f" || ABI == "lp64s")
@@ -282,12 +270,3 @@ bool LoongArchTargetInfo::handleTargetFeatures(
   }
   return true;
 }
-
-bool LoongArchTargetInfo::isValidTuneCPUName(StringRef Name) const {
-  return llvm::LoongArch::isValidTuneCPUName(Name);
-}
-
-void LoongArchTargetInfo::fillValidTuneCPUList(
-SmallVectorImpl &Values) const {
-  llvm::LoongArch::fillValidTuneCPUList(Values);
-}

diff  --git a/clang/lib/Basic/Targets/LoongArch.h 
b/clang/lib/Basic/Targets/LoongArch.h
index 60d545566b30fb..52c4ce4253689e 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -80,9 +80,6 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
  const std::vector &FeaturesVec) const override;
 
   bool hasFeature(StringRef Feature) const override;
-
-  bool isValidTuneCPUName(StringRef Name) const override;
-  void fillValidTuneCPUList(SmallVectorImpl &Values) const override;
 };
 
 class LLVM_LIBRARY_VISIBILITY LoongArch32TargetInfo

diff  --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp 
b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index 6cbb06b9a91f5e..856ad58f3bd9db 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -12,7 +12,6 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
-#include "llvm/TargetParser/Host.h"
 #include "llvm/TargetParser/LoongArchTargetParser.h"
 
 using namespace clang::driver;
@@ -129,29 +128,21 @@ void loongarch::getLoongArchTargetFeatures(const Driver 
&D,
std::vector &Features) {
   StringRef ArchName;
   if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
-ArchName = A->getValue();
-
-// Handle -march=native.
-if (ArchName == "native") {
-  ArchName = llvm::sys::getHostCPUName();
-  if (ArchName == "generic")
- 

[PATCH] D156641: [Clang][Frontend] Change help text for --offload-host-device

2023-07-31 Thread Anton Rydahl via Phabricator via cfe-commits
AntonRydahl updated this revision to Diff 545867.
AntonRydahl added a comment.

Running tests again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156641

Files:
  clang/include/clang/Driver/Options.td
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90


Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -80,7 +80,7 @@
 ! HELP-NEXT: -module-dir   Put MODULE files in 
 ! HELP-NEXT: -nocpp Disable predefined and command line 
preprocessor macros
 ! HELP-NEXT: --offload-device-only   Only compile for the offloading device.
-! HELP-NEXT: --offload-host-device   Only compile for the offloading host.
+! HELP-NEXT: --offload-host-device   Compile for both the offloading host and 
device (default).
 ! HELP-NEXT: --offload-host-only Only compile for the offloading host.
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -pedantic  Warn on language extensions
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -84,7 +84,7 @@
 ! CHECK-NEXT: -module-dir   Put MODULE files in 
 ! CHECK-NEXT: -nocpp Disable predefined and command line 
preprocessor macros
 ! CHECK-NEXT: --offload-device-only   Only compile for the offloading device.
-! CHECK-NEXT: --offload-host-device   Only compile for the offloading host.
+! CHECK-NEXT: --offload-host-device   Compile for both the offloading host and 
device (default).
 ! CHECK-NEXT: --offload-host-only Only compile for the offloading host.
 ! CHECK-NEXT: -o  Write output to 
 ! CHECK-NEXT: -pedantic  Warn on language extensions
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2875,7 +2875,7 @@
 def offload_host_only : Flag<["--"], "offload-host-only">, 
Flags<[FlangOption]>,
   HelpText<"Only compile for the offloading host.">;
 def offload_host_device : Flag<["--"], "offload-host-device">, 
Flags<[FlangOption]>,
-  HelpText<"Only compile for the offloading host.">;
+  HelpText<"Compile for both the offloading host and device (default).">;
 def cuda_device_only : Flag<["--"], "cuda-device-only">, 
Alias,
   HelpText<"Compile CUDA code for device only">;
 def cuda_host_only : Flag<["--"], "cuda-host-only">, Alias,


Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -80,7 +80,7 @@
 ! HELP-NEXT: -module-dir   Put MODULE files in 
 ! HELP-NEXT: -nocpp Disable predefined and command line preprocessor macros
 ! HELP-NEXT: --offload-device-only   Only compile for the offloading device.
-! HELP-NEXT: --offload-host-device   Only compile for the offloading host.
+! HELP-NEXT: --offload-host-device   Compile for both the offloading host and device (default).
 ! HELP-NEXT: --offload-host-only Only compile for the offloading host.
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -pedantic  Warn on language extensions
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -84,7 +84,7 @@
 ! CHECK-NEXT: -module-dir   Put MODULE files in 
 ! CHECK-NEXT: -nocpp Disable predefined and command line preprocessor macros
 ! CHECK-NEXT: --offload-device-only   Only compile for the offloading device.
-! CHECK-NEXT: --offload-host-device   Only compile for the offloading host.
+! CHECK-NEXT: --offload-host-device   Compile for both the offloading host and device (default).
 ! CHECK-NEXT: --offload-host-only Only compile for the offloading host.
 ! CHECK-NEXT: -o  Write output to 
 ! CHECK-NEXT: -pedantic  Warn on language extensions
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2875,7 +2875,7 @@
 def offload_host_only : Flag<["--"], "offload-host-only">, Flags<[FlangOption]>,
   HelpText<"Only compile for the offloading host.">;
 def offload_host_device : Flag<["--"], "offload-host-device">, Flags<[FlangOption]>,
-  HelpText<"Only compile for the offloading host.">;
+  HelpText<"Compile for both the offloading host and device (default).">;
 def cuda_device_only : Flag<["--"], "cuda-device-only">, Alias,
   HelpText<"Compile CUDA code for device only">;

[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-07-31 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D155824#4548921 , @SixWeining 
wrote:

> In D155824#4548677 , @steven_wu 
> wrote:
>
>> After another look, I will need to request to revert this because this 
>> implementation doesn't work with `-fno-integrated-cc1` at all. You can't 
>> setCPU/Tune in the driver into a global variable and expect that will work 
>> during compilation.
>>
>> You can reproduce with `-fno-integrated-cc1` option or build clang with 
>> cmake option `-DCLANG_SPAWN_CC1=On`.
>
> Thanks. I’ll investigate as soon as possible. BTW, did it break any buildbot?

Yes, I only know this bootstrap job (has CMAKE configuration that sets 
CLANG_SPAWN_CC1). https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto

My local revert is clean and all tests passed. I will just go ahead and revert 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-07-31 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

In D155824#4548677 , @steven_wu wrote:

> After another look, I will need to request to revert this because this 
> implementation doesn't work with `-fno-integrated-cc1` at all. You can't 
> setCPU/Tune in the driver into a global variable and expect that will work 
> during compilation.
>
> You can reproduce with `-fno-integrated-cc1` option or build clang with cmake 
> option `-DCLANG_SPAWN_CC1=On`.

Thanks. I’ll investigate as soon as possible. BTW, did it break any buildbot?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3542
+LangAS AAS = getASTAllocaAddressSpace();
+LangAS EAS = E->getType().getAddressSpace();
+if (AAS != EAS) {

`E->getType().getAddressSpace()` is actually the top-level qualification of the 
type; you need `E->getType()->getPointeeType().getAddressSpace()`.


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

https://reviews.llvm.org/D156539

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


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 545860.
AlexVlx added a comment.

Address review comments.


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

https://reviews.llvm.org/D156539

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/dynamic-alloca-with-address-space.c


Index: clang/test/CodeGen/dynamic-alloca-with-address-space.c
===
--- /dev/null
+++ clang/test/CodeGen/dynamic-alloca-with-address-space.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -DOCL12 -x cl -std=cl1.2 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CL12
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x cl -std=cl2.0 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CL20
+
+#if defined(OCL12)
+#define CAST (char *)(unsigned long)
+#else
+#define CAST (char *)
+#endif
+
+void allocas(unsigned long n) {
+char *a = CAST __builtin_alloca(n);
+char *uninitialized_a = CAST __builtin_alloca_uninitialized(n);
+char *aligned_a = CAST __builtin_alloca_with_align(n, 8);
+char *aligned_uninitialized_a = CAST 
__builtin_alloca_with_align_uninitialized(n, 8);
+}
+
+// CHECK: @allocas(
+// CHECK: store i64 %n, ptr %n.addr.ascast, align 8
+// CHECK: %0 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %1 = alloca i8, i64 %0, align 8, addrspace(5)
+// CHECK: %2 = addrspacecast ptr addrspace(5) %1 to ptr
+// CHECK: store ptr %2, ptr %a.ascast, align 8
+// CHECK: %3 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %4 = alloca i8, i64 %3, align 8, addrspace(5)
+// CHECK: %5 = addrspacecast ptr addrspace(5) %4 to ptr
+// CHECK: store ptr %5, ptr %uninitialized_a.ascast, align 8
+// CHECK: %6 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %7 = alloca i8, i64 %6, align 1, addrspace(5)
+// CHECK: %8 = addrspacecast ptr addrspace(5) %7 to ptr
+// CHECK: store ptr %8, ptr %aligned_a.ascast, align 8
+// CHECK: %9 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %10 = alloca i8, i64 %9, align 1, addrspace(5)
+// CHECK: %11 = addrspacecast ptr addrspace(5) %10 to ptr
+// CHECK: store ptr %11, ptr %aligned_uninitialized_a.ascast, align 8
+// CHECK: ret void
+// CHECK-CL12-NOT: addrspacecast
+// CHECK-CL20-NOT: addrspacecast
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3517,6 +3517,12 @@
 return RValue::get(Result);
   }
 
+  // An alloca will always return a pointer to the alloca (stack) address
+  // space. This address space need not be the same as the AST / Language
+  // default (e.g. in C / C++ auto vars are in the generic address space). At
+  // the AST level this is handled within CreateTempAlloca et al., but for the
+  // builtin / dynamic alloca we have to handle it here. We use an explicit 
cast
+  // instead of passing an AS to CreateAlloca so as to not inhibit 
optimisation.
   case Builtin::BIalloca:
   case Builtin::BI_alloca:
   case Builtin::BI__builtin_alloca_uninitialized:
@@ -3532,6 +3538,13 @@
 AI->setAlignment(SuitableAlignmentInBytes);
 if (BuiltinID != Builtin::BI__builtin_alloca_uninitialized)
   initializeAlloca(*this, AI, Size, SuitableAlignmentInBytes);
+LangAS AAS = getASTAllocaAddressSpace();
+LangAS EAS = E->getType().getAddressSpace();
+if (AAS != EAS) {
+  llvm::Type *Ty = CGM.getTypes().ConvertType(E->getType());
+  return RValue::get(getTargetHooks().performAddrSpaceCast(*this, AI, AAS,
+   EAS, Ty));
+}
 return RValue::get(AI);
   }
 
@@ -3547,6 +3560,13 @@
 AI->setAlignment(AlignmentInBytes);
 if (BuiltinID != Builtin::BI__builtin_alloca_with_align_uninitialized)
   initializeAlloca(*this, AI, Size, AlignmentInBytes);
+LangAS AAS = getASTAllocaAddressSpace();
+LangAS EAS = E->getType().getAddressSpace();
+if (AAS != EAS) {
+  llvm::Type *Ty = CGM.getTypes().ConvertType(E->getType());
+  return RValue::get(getTargetHooks().performAddrSpaceCast(*this, AI, AAS,
+   EAS, Ty));
+}
 return RValue::get(AI);
   }
 


Index: clang/test/CodeGen/dynamic-alloca-with-address-space.c
===
--- /dev/null
+++ clang/test/CodeGen/dynamic-alloca-with-address-space.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -DOCL12 -x cl -std=cl1.2 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CL12
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x cl -std=cl2.0 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=C

[PATCH] D156762: [-Wunsafe-buffer-usage][NFC] Refactor `getFixIts`---where fix-its are generated

2023-07-31 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Refactor the `getFixIts` function for better readability.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156762

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp

Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -2142,92 +2142,85 @@
   });
 }
 
-static bool impossibleToFixForVar(const FixableGadgetSets &FixablesForAllVars,
-  const Strategy &S,
-  const VarDecl * Var) {
-  for (const auto &F : FixablesForAllVars.byVar.find(Var)->second) {
-std::optional Fixits = F->getFixits(S);
-if (!Fixits) {
-  return true;
+// Erasing variables in `FixItsForVariable`, if such a variable has an unfixable
+// group mate.  A variable `v` is unfixable iff `FixItsForVariable` does not
+// contain `v`.
+static void eraseVarsForUnfixableGroupMates(
+std::map &FixItsForVariable,
+const VariableGroupsManager &VarGrpMgr) {
+  // Variables will be removed from `FixItsForVariable`:
+  SmallVector ToErase;
+
+  for (auto [VD, Ignore] : FixItsForVariable) {
+VarGrpRef Grp = VarGrpMgr.getGroupOfVar(VD);
+if (llvm::any_of(Grp,
+ [&FixItsForVariable](const VarDecl *GrpMember) -> bool {
+   return FixItsForVariable.find(GrpMember) ==
+  FixItsForVariable.end();
+ })) {
+  // At least one group member cannot be fixed, so we have to erase the
+  // whole group:
+  for (const VarDecl *Member : Grp)
+ToErase.push_back(Member);
 }
   }
-  return false;
+  for (auto *VarToErase : ToErase)
+FixItsForVariable.erase(VarToErase);
 }
 
 static std::map
 getFixIts(FixableGadgetSets &FixablesForAllVars, const Strategy &S,
 	  ASTContext &Ctx,
-  /* The function decl under analysis */ const Decl *D,
+  /* The function decl under analysis */ const FunctionDecl *FD,
   const DeclUseTracker &Tracker, UnsafeBufferUsageHandler &Handler,
   const VariableGroupsManager &VarGrpMgr) {
+  // `FixItsForVariable` will map each variable to a set of fix-its directly
+  // associated to the variable itself.  Fix-its of distict variables in
+  // `FixItsForVariable` are disjoint.
   std::map FixItsForVariable;
+
+  // Populate `FixItsForVariable` with fix-its directly associated with each
+  // variable.  Fix-its directly associated to a variable 'v' are the ones
+  // produced by the `FixableGadget`s whose claimed variable is 'v'.
   for (const auto &[VD, Fixables] : FixablesForAllVars.byVar) {
 FixItsForVariable[VD] =
-fixVariable(VD, S.lookup(VD), D, Tracker, Ctx, Handler);
+fixVariable(VD, S.lookup(VD), FD, Tracker, Ctx, Handler);
 // If we fail to produce Fix-It for the declaration we have to skip the
 // variable entirely.
 if (FixItsForVariable[VD].empty()) {
   FixItsForVariable.erase(VD);
   continue;
 }
-bool ImpossibleToFix = false;
-llvm::SmallVector FixItsForVD;
 for (const auto &F : Fixables) {
   std::optional Fixits = F->getFixits(S);
-  if (!Fixits) {
-#ifndef NDEBUG
-Handler.addDebugNoteForVar(
-VD, F->getBaseStmt()->getBeginLoc(),
-("gadget '" + F->getDebugName() + "' refused to produce a fix")
-.str());
-#endif
-ImpossibleToFix = true;
-break;
-  } else {
-const FixItList CorrectFixes = Fixits.value();
-FixItsForVD.insert(FixItsForVD.end(), CorrectFixes.begin(),
-   CorrectFixes.end());
-  }
-}
 
-if (ImpossibleToFix) {
-  FixItsForVariable.erase(VD);
-  continue;
-}
-
-
-   {
-  const auto VarGroupForVD = VarGrpMgr.getGroupOfVar(VD);
-  for (const VarDecl * V : VarGroupForVD) {
-if (V == VD) {
-  continue;
-}
-if (impossibleToFixForVar(FixablesForAllVars, S, V)) {
-  ImpossibleToFix = true;
-  break;
-}
-  }
-
-  if (ImpossibleToFix) {
-FixItsForVariable.erase(VD);
-for (const VarDecl * V : VarGroupForVD) {
-  FixItsForVariable.erase(V);
-}
+  if (Fixits) {
+FixItsForVariable[VD].insert(FixItsForVariable[VD].end(),
+ Fixits->begin(), Fixits->end());
 continue;
   }
-}
-FixItsForVariable[VD].insert(FixItsForVariable[VD].end(),
- FixItsForVD.begin(), FixItsForVD.end());
-
-// Fix-it shall not overlap with macros or/and templates:
-if (overlapWithMacro(FixItsForVariable[VD]) ||
-   

[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-31 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/SemaCXX/static-assert.cpp:44-45
+static_assert(false, L"\x1ff"// expected-warning {{encoding prefix 'L' on 
an unevaluated string literal has no effect and is incompatible with c++2c}} \
+ // expected-error {{hex escape sequence out 
of range}} \
  // expected-error {{invalid escape sequence 
'\x1ff' in an unevaluated string literal}}
  "0\x123"// expected-error {{invalid escape sequence 
'\x123' in an unevaluated string literal}}

I doubt that it is a problem, but Clang 16 accepted such hex escapes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156596

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


[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-07-31 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

After another look, I will need to request to revert this because this 
implementation doesn't work with `-fno-integrated-cc1` at all. You can't 
setCPU/Tune in the driver into a global variable and expect that will work 
during compilation.

You can reproduce with `-fno-integrated-cc1` option or build clang with cmake 
option `-DCLANG_SPAWN_CC1=On`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D156546: [Clang][WIP]Experimental implementation of data member packs declarations

2023-07-31 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:5930-5931
   break;
+case DeclaratorContext::Member:
+  // Expand for packed data members.
 case DeclaratorContext::TemplateParam:

cjdb wrote:
> dblaikie wrote:
> > Perhaps a few more words here would be good - quoting a WG21 proposal paper 
> > that this code implements, similar to the standard quotations in nearby 
> > code. (be good to mention the WG21 proposal paper/whatnot in the patch 
> > description/commit message too)
> I would suggest a link to the discourse discussion instead of [[ 
> http://wg21.link/P1858 | P1858]], since that thread talks about the proposal 
> and goes into a bit more detail than the [[ 
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1858r2.html#member-packs
>  | member packs ]] section of the proposal.
@dblaikie  This does not implement a C++ proposal - especially one that would 
be anywhere near approval (ie we had vague talk that WG21 want something in 
that space in P1858 and related papers, but no actual specification or 
consensus of any kind) and this PR also does not implement or have proposals 
for all  the complications this features has in terms of accessing such member 
packs
(ie packs in non dependent context, disambiguation between member of a variadic 
variable and pack members and combinations of the two)

This is a very interesting experiment, but we should be careful not to approve 
an extension that is going to conflict with future C++ language features


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156546

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


[PATCH] D156749: [modules] Fix error about the same module being defined in different .pcm files when using VFS overlays.

2023-07-31 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: ChuanqiXu, jansvoboda11.
Herald added a subscriber: ributzka.
Herald added a project: All.
vsapsai requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix errors like

> module 'MultiPath' is defined in both 
> 'path/to/modules.cache/3JR48BPRU7BCG/MultiPath-1352QHUF8RNMU.pcm' and 
> 'path/to/modules.cache/3JR48BPRU7BCG/MultiPath-20HNSLLIUDDV1.pcm'

To avoid building extra identical modules `-ivfsoverlay` option is not a
part of the hash like "/3JR48BPRU7BCG/". And it is build system's
responsibility to provide `-ivfsoverlay` options that don't cause
observable differences.  We also need to make sure the hash like
"-1352QHUF8RNMU" is not affected by `-ivfsoverlay`. As this hash is
defined by the module map path, use the path prior to any VFS
remappings.

rdar://111921464


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156749

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/VFS/module-map-path.m

Index: clang/test/VFS/module-map-path.m
===
--- /dev/null
+++ clang/test/VFS/module-map-path.m
@@ -0,0 +1,110 @@
+// Test the module map path is consistent between clang invocations when using VFS overlays.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// Pre-populate the module cache with the modules that don't use VFS overlays.
+// RUN: %clang_cc1 -fsyntax-only -F%t/Frameworks -I%t/include %t/prepopulate_module_cache.m \
+// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// Execute a compilation with VFS overlay. .pcm file path looks like /ModuleName-.pcm.
+//  corresponds to the compilation settings like language options.
+//  corresponds to the module map path. So if any of those change, we should use a different module.
+// But for VFS overlay we make an exception that it's not a part of  to reduce the number of built .pcm files.
+// Test that paths in overlays don't leak into  and don't cause using 2 .pcm files for the same module.
+// DEFINE: %{command} = %clang_cc1 -fsyntax-only -verify -F%t/Frameworks -I%t/include %t/test.m \
+// DEFINE:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+// RUN: sed -e "s@TMP_DIR@%{/t:regex_replacement}@g" -e "s@USE_EXTERNAL_NAMES_OPTION@@g" %t/overlay.yaml.template > %t/external-names-default.yaml
+// RUN: %{command} -ivfsoverlay %t/external-names-default.yaml
+
+// RUN: sed -e "s@TMP_DIR@%{/t:regex_replacement}@g" -e "s@USE_EXTERNAL_NAMES_OPTION@'use-external-names': true,@g" %t/overlay.yaml.template > %t/external-names-true.yaml
+// RUN: %{command} -ivfsoverlay %t/external-names-true.yaml
+
+// RUN: sed -e "s@TMP_DIR@%{/t:regex_replacement}@g" -e "s@USE_EXTERNAL_NAMES_OPTION@'use-external-names': false,@g" %t/overlay.yaml.template > %t/external-names-false.yaml
+// RUN: %{command} -ivfsoverlay %t/external-names-false.yaml
+
+//--- prepopulate_module_cache.m
+#import 
+
+//--- test.m
+// At first import multi-path modules directly, so clang decides which .pcm file they should belong to.
+#import 
+#import 
+
+// Then import a module from the module cache and all its transitive dependencies.
+// Make sure the .pcm files loaded directly are the same as 'Redirecting' is referencing.
+#import 
+// expected-no-diagnostics
+
+
+//--- Frameworks/MultiPath.framework/Headers/MultiPath.h
+void multiPathFramework(void);
+
+//--- Frameworks/MultiPath.framework/Modules/module.modulemap
+framework module MultiPath {
+header "MultiPath.h"
+export *
+}
+
+
+//--- include/MultiPathHeader.h
+void multiPathHeader(void);
+
+//--- include/module.modulemap
+module MultiPathHeader {
+header "MultiPathHeader.h"
+export *
+}
+
+
+//--- Frameworks/Redirecting.framework/Headers/Redirecting.h
+#import 
+#import 
+
+//--- Frameworks/Redirecting.framework/Modules/module.modulemap
+framework module Redirecting {
+header "Redirecting.h"
+export *
+}
+
+
+//--- BuildTemporaries/MultiPath.h
+void multiPathFramework(void);
+//--- BuildTemporaries/module.modulemap
+framework module MultiPath {
+header "MultiPath.h"
+export *
+}
+//--- BuildTemporaries/header.h
+void multiPathHeader(void);
+//--- BuildTemporaries/include.modulemap
+module MultiPathHeader {
+header "MultiPathHeader.h"
+export *
+}
+
+//--- overlay.yaml.template
+{
+  'version': 0,
+  USE_EXTERNAL_NAMES_OPTION
+  'roots': [
+{ 'name': 'TMP_DIR/Frameworks/MultiPath.framework/Headers', 'type': 'directory',
+  'contents': [
+{ 'name': 'MultiPath.h', 'type': 'file',
+  'external-contents': 'TMP_DIR/BuildTemporaries/MultiPath.h'}
+]},
+{ 'name': 'TMP_DIR/Frameworks/MultiPath.framework/Modules', 'type': 'directory',
+  'contents': [
+{ 'name': 'module.modulemap', 'type': 'file',
+  'external-contents': 'TMP_DIR/BuildTemporaries/module.modulemap'}
+]},
+{

[PATCH] D155668: [RISCV] Upgrade Zvfh version to 1.0 and move out of experimental state.

2023-07-31 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Uh, why are there clang/test/Sema/aarch64* tests full of RISC-V extension 
names? That's not right at all. One of them is coming from 
https://reviews.llvm.org/D135011, I haven't traced the rest back, but that's 
clearly wrong. The test looks to be a copy of the RISC-V one with tweaks to 
change riscv(64) to arm/aarch64, and `  -target-feature +sve` (with two spaces) 
added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155668

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


[PATCH] D156537: [CodeGen] Keep track of eagerly emitted globals

2023-07-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I would like to avoid the overhead of this when we're not emitting for a REPL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156537

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


[PATCH] D156737: clang: Add __builtin_elementwise_sqrt

2023-07-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2548
+case Builtin::BI__builtin_sqrtf128:
+case Builtin::BI__builtin_elementwise_sqrt: {
   llvm::Value *Call = emitUnaryMaybeConstrainedFPBuiltin(

bob80905 wrote:
> Nit: I think despite this code working, it should be moved to be grouped with 
> the other elementwise builtins at around line 3240.
> Consider BI__builtin_log at around 2436 and the other log builtins, the 
> bultin_elementwise_log builtin is not in that group since it's with the other 
> elementwise builtins. Writing this case here would make an inconsistency with 
> the placement of the other elementwise builtins.
I think it's more important to group with the emission of the metadata

Also don't understand why there is a broken constrained path and a redundant 
set of constrained handling in IRBuilder


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

https://reviews.llvm.org/D156737

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


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-07-31 Thread Guruprasad Hegde via Phabricator via cfe-commits
gruuprasad updated this revision to Diff 545807.
gruuprasad added a comment.

Add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156724

Files:
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/test/Analysis/html_diagnostics/notes-links.cpp


Index: clang/test/Analysis/html_diagnostics/notes-links.cpp
===
--- /dev/null
+++ clang/test/Analysis/html_diagnostics/notes-links.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 
-analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:-analyzer-output=html -o %t -verify %s
+// RUN: cat %t/report-*.html | FileCheck %s
+
+struct A {
+  int *iptr;
+  int a;  // expected-note{{uninitialized field 'this->a'}}
+  int b;  // expected-note{{uninitialized field 'this->b'}}
+
+  A (int *iptr) : iptr(iptr) {} // expected-warning{{2 uninitialized fields at 
the end of the constructor call [optin.cplusplus.UninitializedObject]}}
+};
+
+void f() {
+  A a(0);
+}
+
+//CHECK:  Note:
+//CHECK-NOT:  
+//CHECK-SAME: line 9, column 7
+//CHECK-SAME: line 10, column 7
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -592,11 +592,11 @@
 P->getLocation().asLocation().getExpansionLineNumber();
 int ColumnNumber =
 P->getLocation().asLocation().getExpansionColumnNumber();
+++NumExtraPieces;
 os << "Note:"
<< "line "
<< LineNumber << ", column " << ColumnNumber << ""
<< P->getString() << "";
-++NumExtraPieces;
   }
 }
 


Index: clang/test/Analysis/html_diagnostics/notes-links.cpp
===
--- /dev/null
+++ clang/test/Analysis/html_diagnostics/notes-links.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:-analyzer-output=html -o %t -verify %s
+// RUN: cat %t/report-*.html | FileCheck %s
+
+struct A {
+  int *iptr;
+  int a;  // expected-note{{uninitialized field 'this->a'}}
+  int b;  // expected-note{{uninitialized field 'this->b'}}
+
+  A (int *iptr) : iptr(iptr) {} // expected-warning{{2 uninitialized fields at the end of the constructor call [optin.cplusplus.UninitializedObject]}}
+};
+
+void f() {
+  A a(0);
+}
+
+//CHECK:  Note:
+//CHECK-NOT:  
+//CHECK-SAME: line 9, column 7
+//CHECK-SAME: line 10, column 7
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -592,11 +592,11 @@
 P->getLocation().asLocation().getExpansionLineNumber();
 int ColumnNumber =
 P->getLocation().asLocation().getExpansionColumnNumber();
+++NumExtraPieces;
 os << "Note:"
<< "line "
<< LineNumber << ", column " << ColumnNumber << ""
<< P->getString() << "";
-++NumExtraPieces;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156546: [Clang][WIP]Experimental implementation of data member packs declarations

2023-07-31 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao marked an inline comment as done.
SlaterLatiao added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:3292-3295
+  // FIXME: Eventually, a NULL return will mean that one of the
+  // instantiations was a semantic disaster, and we'll want to mark
+  // the declaration invalid. For now, we expect to skip some members
+  // that we can't yet handle.

dblaikie wrote:
> Worth having a test case showing that/what's broken here?
It's copied from the handling of non-pack members and possibly a duplicate that 
should be avoided. I'm not sure which case could trigger this branch. Will look 
into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156546

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


[PATCH] D156737: clang: Add __builtin_elementwise_sqrt

2023-07-31 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 added a comment.

I think you need to mention this new builtin in clang/docs/ReleaseNotes.rst.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2548
+case Builtin::BI__builtin_sqrtf128:
+case Builtin::BI__builtin_elementwise_sqrt: {
   llvm::Value *Call = emitUnaryMaybeConstrainedFPBuiltin(

Nit: I think despite this code working, it should be moved to be grouped with 
the other elementwise builtins at around line 3240.
Consider BI__builtin_log at around 2436 and the other log builtins, the 
bultin_elementwise_log builtin is not in that group since it's with the other 
elementwise builtins. Writing this case here would make an inconsistency with 
the placement of the other elementwise builtins.


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

https://reviews.llvm.org/D156737

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


[PATCH] D156743: [wip] clang/OpenCL: Add inline implementations of sqrt in builtin header

2023-07-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, svenvh, Anastasia.
Herald added a subscriber: Naghasan.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.

We want the !fpmath metadata to be attached to the sqrt intrinsic to
make it to the backend lowering.

  

Doesn't work with the default case with -fdeclare-opencl-builtins

  

Fixes #64264


https://reviews.llvm.org/D156743

Files:
  clang/lib/Headers/opencl-c.h
  clang/test/CodeGenOpenCL/sqrt-fpmath.cl

Index: clang/test/CodeGenOpenCL/sqrt-fpmath.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/sqrt-fpmath.cl
@@ -0,0 +1,119 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: amdgpu-registered-target
+
+// Test with -fdeclare-opencl-builtins
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -target-cpu hawaii -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -cl-fp32-correctly-rounded-divide-sqrt -target-cpu hawaii -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,CORRECTLYROUNDED %s
+
+// Test without -fdeclare-opencl-builtins
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header -target-cpu hawaii -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header -cl-fp32-correctly-rounded-divide-sqrt -target-cpu hawaii -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,CORRECTLYROUNDED %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+// CHECK-LABEL: define dso_local float @call_sqrt_f32
+// CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call float @_Z4sqrtf(float noundef [[X]]) #[[ATTR2:[0-9]+]]
+// CHECK-NEXT:ret float [[CALL]]
+//
+float call_sqrt_f32(float x) {
+  return sqrt(x);
+}
+
+// CHECK-LABEL: define dso_local <2 x float> @call_sqrt_v2f32
+// CHECK-SAME: (<2 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call <2 x float> @_Z4sqrtDv2_f(<2 x float> noundef [[X]]) #[[ATTR2]]
+// CHECK-NEXT:ret <2 x float> [[CALL]]
+//
+float2 call_sqrt_v2f32(float2 x) {
+  return sqrt(x);
+}
+
+// CHECK-LABEL: define dso_local <3 x float> @call_sqrt_v3f32
+// CHECK-SAME: (<3 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call <3 x float> @_Z4sqrtDv3_f(<3 x float> noundef [[X]]) #[[ATTR2]]
+// CHECK-NEXT:ret <3 x float> [[CALL]]
+//
+float3 call_sqrt_v3f32(float3 x) {
+  return sqrt(x);
+}
+
+// CHECK-LABEL: define dso_local <4 x float> @call_sqrt_v4f32
+// CHECK-SAME: (<4 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call <4 x float> @_Z4sqrtDv4_f(<4 x float> noundef [[X]]) #[[ATTR2]]
+// CHECK-NEXT:ret <4 x float> [[CALL]]
+//
+float4 call_sqrt_v4f32(float4 x) {
+  return sqrt(x);
+}
+
+// CHECK-LABEL: define dso_local <8 x float> @call_sqrt_v8f32
+// CHECK-SAME: (<8 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call <8 x float> @_Z4sqrtDv8_f(<8 x float> noundef [[X]]) #[[ATTR2]]
+// CHECK-NEXT:ret <8 x float> [[CALL]]
+//
+float8 call_sqrt_v8f32(float8 x) {
+  return sqrt(x);
+}
+
+// CHECK-LABEL: define dso_local <16 x float> @call_sqrt_v16f32
+// CHECK-SAME: (<16 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call <16 x float> @_Z4sqrtDv16_f(<16 x float> noundef [[X]]) #[[ATTR2]]
+// CHECK-NEXT:ret <16 x float> [[CALL]]
+//
+float16 call_sqrt_v16f32(float16 x) {
+  return sqrt(x);
+}
+
+// Not for f64
+// CHECK-LABEL: define dso_local double @call_sqrt_f64
+// CHECK-SAME: (double noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call double @_Z4sqrtd(double noundef [[X]]) #[[ATTR2]]
+// CHECK-NEXT:ret double [[CALL]]
+//
+double call_sqrt_f64(double x) {
+  return sqrt(x);
+}
+
+// Not for f64
+// CHECK-LABEL: define dso_local <2 x double> @call_sqrt_v2f64
+// CHECK-SAME: (<2 x double> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = tail call <2 x double> @_Z4sqrtDv2_d(<2 x double> noundef [[X]]) #[[ATTR2]]
+// CHECK-NEXT:ret <2 x double> [[CALL]]
+//
+double2 call_sqrt_v2f64(double2 x) {
+  return sqrt(x);
+}
+
+// Not for f64
+// CHECK-LABEL: define dso_local half @call_sqrt_f16
+// CHECK-SAME: (half noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0]] 

[PATCH] D156546: [Clang][WIP]Experimental implementation of data member packs declarations

2023-07-31 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao updated this revision to Diff 545804.
SlaterLatiao added a comment.

Fix code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156546

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenCXX/data_member_packs.cpp

Index: clang/test/CodeGenCXX/data_member_packs.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/data_member_packs.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 --std=c++20 %s -emit-llvm -o - -triple x86_64-linux | FileCheck %s --check-prefixes=CHECK
+
+// Tests declaration data member packs.
+template struct S1 {
+Ts... ts;
+};
+
+template struct S2 {
+T t[2];
+Ts... ts;
+};
+
+// CHECK: %struct.S1 = type { i32 }
+S1 s1;
+// CHECK-NEXT: %struct.S1.0 = type { i32, float, double }
+S1 s2;
+// Test template args as the last arg.
+// CHECK-NEXT: %struct.S2 = type { [2 x i32], float, double }
+S2 s3;
+// Test nested template args.
+// CHECK-NEXT: %struct.S1.1 = type { i32, float, %struct.S1.2 }
+// CHECK-NEXT: %struct.S1.2 = type { double, double }
+S1> s4;
+// Test empty template arg.
+// CHECK-NEXT: %struct.S1.3 = type { i8 }
+S1<> s5;
+// Test duplicate types in template args.
+// CHECK-NEXT: %struct.S1.4 = type { i32, i32 }
+S1 s6;
+
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5927,6 +5927,8 @@
  /*ExpectPackInType=*/false);
   }
   break;
+case DeclaratorContext::Member:
+  // Expand for packed data members.
 case DeclaratorContext::TemplateParam:
   // C++0x [temp.param]p15:
   //   If a template-parameter is a [...] is a parameter-declaration that
@@ -5954,7 +5956,6 @@
 case DeclaratorContext::CXXNew:
 case DeclaratorContext::AliasDecl:
 case DeclaratorContext::AliasTemplate:
-case DeclaratorContext::Member:
 case DeclaratorContext::Block:
 case DeclaratorContext::ForInit:
 case DeclaratorContext::SelectionInit:
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3267,42 +3267,74 @@
   continue;
 }
 
-Decl *NewMember = Instantiator.Visit(Member);
-if (NewMember) {
-  if (FieldDecl *Field = dyn_cast(NewMember)) {
-Fields.push_back(Field);
-  } else if (EnumDecl *Enum = dyn_cast(NewMember)) {
-// C++11 [temp.inst]p1: The implicit instantiation of a class template
-// specialization causes the implicit instantiation of the definitions
-// of unscoped member enumerations.
-// Record a point of instantiation for this implicit instantiation.
-if (TSK == TSK_ImplicitInstantiation && !Enum->isScoped() &&
-Enum->isCompleteDefinition()) {
-  MemberSpecializationInfo *MSInfo =Enum->getMemberSpecializationInfo();
-  assert(MSInfo && "no spec info for member enum specialization");
-  MSInfo->setTemplateSpecializationKind(TSK_ImplicitInstantiation);
-  MSInfo->setPointOfInstantiation(PointOfInstantiation);
-}
-  } else if (StaticAssertDecl *SA = dyn_cast(NewMember)) {
-if (SA->isFailed()) {
-  // A static_assert failed. Bail out; instantiating this
-  // class is probably not meaningful.
-  Instantiation->setInvalidDecl();
-  break;
+// Instantiate packed data members.
+if (FieldDecl *Field = dyn_cast(Member);
+Field && isa(Field->getType().getTypePtr())) {
+  QualType PatternType = Field->getType()
+ ->castAs()
+ ->getPattern();
+  std::optional NumArgumentsInExpansion =
+  getNumArgumentsInExpansion(Field->getType(), TemplateArgs);
+  assert(NumArgumentsInExpansion && "should not see unknown template argument here");
+  for (unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
+// Generate a new field from PackExpansion field.
+if (Decl *NewMember = Instantiator.Visit(Member)) {
+  FieldDecl *PackedField = cast(NewMember);
+  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, Arg);
+  QualType T =
+  SubstType(PatternType, TemplateArgs, PackedField->getLocation(),
+PackedField->getDeclName());
+  PackedField->setType(T);
+  Fields.push_back(PackedField);
+  if (NewMember->isInvalidDecl())
+Instantiation->setInvalidDecl();
+} else {
+  // FIXME: Eventually, a NULL return will mean that one of the
+  // instantiations was a semantic disaster, and we'll want to mark
+  // the declaration invali

[PATCH] D156726: Make globals with mutable members non-constant, even in custom sections

2023-07-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:14254
 int SectionFlags = ASTContext::PSF_Read;
-if (var->getType().isConstQualified()) {
-  if (HasConstInit)

rnk wrote:
> I think this is not compatible with MSVC. MSVC uses simple logic, it doesn't 
> look for mutable: https://gcc.godbolt.org/z/sj6d4saxx
> 
> The const mutable struct appears in the myrdata section in that example.
> 
> I think the solution is to separate the flag logic from the pragma stack 
> selection logic, which has to remain MSVC-compatible.
MSVC apparently looks at whether the variable is marked "const", and nothing 
else; it doesn't look at mutable, it doesn't look at whether the variable has a 
constant initializer.  So the current code isn't right either; if we're trying 
to implement MSVC-compatible logic, we shouldn't check HasConstInit.

That said, I'm not sure how precisely/in what modes we want to precisely 
emulate MSVC.  Probably anything we do here will be confusing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156726

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


[PATCH] D156705: [clang-format] Fix braced initializer formatting with templated base class initializer

2023-07-31 Thread Galen Elias via Phabricator via cfe-commits
galenelias added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:13461
   "  A() : a{} {}\n"
+  "  A() : Base{} {}\n"
   "  A(int b) : b(b) {}\n"

HazardyKnusperkeks wrote:
> Please also add nested templates.
Ok, added `A() : Base>{} {}` as a test case. I think that's what you 
mean by nested templates, but let me know if I misunderstood.


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

https://reviews.llvm.org/D156705

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


[PATCH] D156705: [clang-format] Fix braced initializer formatting with templated base class initializer

2023-07-31 Thread Galen Elias via Phabricator via cfe-commits
galenelias updated this revision to Diff 545798.
galenelias marked an inline comment as done.

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

https://reviews.llvm.org/D156705

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13458,6 +13458,8 @@
   verifyFormat(
   "class A {\n"
   "  A() : a{} {}\n"
+  "  A() : Base{} {}\n"
+  "  A() : Base>{} {}\n"
   "  A(int b) : b(b) {}\n"
   "  A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
   "  int a, b;\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -581,7 +581,8 @@
   ProbablyBracedList =
   ProbablyBracedList ||
   (NextTok->is(tok::l_brace) && LBraceStack.back().PrevTok &&
-   LBraceStack.back().PrevTok->is(tok::identifier));
+   LBraceStack.back().PrevTok->isOneOf(tok::identifier,
+   tok::greater));
 
   ProbablyBracedList =
   ProbablyBracedList ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13458,6 +13458,8 @@
   verifyFormat(
   "class A {\n"
   "  A() : a{} {}\n"
+  "  A() : Base{} {}\n"
+  "  A() : Base>{} {}\n"
   "  A(int b) : b(b) {}\n"
   "  A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
   "  int a, b;\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -581,7 +581,8 @@
   ProbablyBracedList =
   ProbablyBracedList ||
   (NextTok->is(tok::l_brace) && LBraceStack.back().PrevTok &&
-   LBraceStack.back().PrevTok->is(tok::identifier));
+   LBraceStack.back().PrevTok->isOneOf(tok::identifier,
+   tok::greater));
 
   ProbablyBracedList =
   ProbablyBracedList ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156286: [docs] Bump minimum GCC version to 7.4

2023-07-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/docs/GettingStarted.rst:284-298
 `python `_  >=3.6
Automated test suite\ :sup:`2`
 `zlib `_   >=1.2.3.4
Compression library\ :sup:`3`
 `GNU Make `_ 3.79, 3.79.1 
Makefile/build processor\ :sup:`4`
 ===  
==
 
 .. note::
 

aaron.ballman wrote:
> aaron.ballman wrote:
> > 
> I think you missed these requested changes when landing.
Sorry:( Would you mind fixing it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

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


[PATCH] D156737: clang: Add __builtin_elementwise_sqrt

2023-07-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, fhahn, bob80905.
Herald added subscribers: StephenFan, Anastasia.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.

This will be used in the opencl builtin headers to provide direct
intrinsic access with proper !fpmath metadata.


https://reviews.llvm.org/D156737

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
  clang/test/CodeGenCUDA/correctly-rounded-div.cu
  clang/test/CodeGenOpenCL/fpmath.cl
  clang/test/Sema/builtins-elementwise-math.c
  clang/test/SemaCXX/builtins-elementwise-math.cpp

Index: clang/test/SemaCXX/builtins-elementwise-math.cpp
===
--- clang/test/SemaCXX/builtins-elementwise-math.cpp
+++ clang/test/SemaCXX/builtins-elementwise-math.cpp
@@ -111,6 +111,13 @@
   static_assert(!is_const::value);
 }
 
+void test_builtin_elementwise_sqrt() {
+  const float a = 42.0;
+  float b = 42.3;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
+
 void test_builtin_elementwise_log() {
   const float a = 42.0;
   float b = 42.3;
Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -601,6 +601,27 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_sqrt(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_sqrt(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_sqrt();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_sqrt(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_sqrt(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_sqrt(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_sqrt(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
 void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_trunc(f);
Index: clang/test/CodeGenOpenCL/fpmath.cl
===
--- clang/test/CodeGenOpenCL/fpmath.cl
+++ clang/test/CodeGenOpenCL/fpmath.cl
@@ -28,6 +28,21 @@
   return __builtin_sqrtf(a);
 }
 
+float elementwise_sqrt_f32(float a) {
+  // CHECK-LABEL: @elementwise_sqrt_f32
+  // NODIVOPT: call float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD_SQRT:[0-9]+]]
+  // DIVOPT: call float @llvm.sqrt.f32(float %{{.+}}){{$}}
+  return __builtin_elementwise_sqrt(a);
+}
+
+float4 elementwise_sqrt_v4f32(float4 a) {
+  // CHECK-LABEL: @elementwise_sqrt_v4f32
+  // NODIVOPT: call <4 x float> @llvm.sqrt.v4f32(<4 x float> %{{.+}}), !fpmath ![[MD_SQRT:[0-9]+]]
+  // DIVOPT: call <4 x float> @llvm.sqrt.v4f32(<4 x float> %{{.+}}){{$}}
+  return __builtin_elementwise_sqrt(a);
+}
+
+
 #if __OPENCL_C_VERSION__ >=120
 void printf(constant char* fmt, ...);
 
@@ -61,6 +76,18 @@
   return __builtin_sqrt(a);
 }
 
+double elementwise_sqrt_f64(double a) {
+  // CHECK-LABEL: @elementwise_sqrt_f64
+  // CHECK: call double @llvm.sqrt.f64(double %{{.+}}){{$}}
+  return __builtin_elementwise_sqrt(a);
+}
+
+double4 elementwise_sqrt_v4f64(double4 a) {
+  // CHECK-LABEL: @elementwise_sqrt_v4f64
+  // CHECK: call <4 x double> @llvm.sqrt.v4f64(<4 x double> %{{.+}}){{$}}
+  return __builtin_elementwise_sqrt(a);
+}
+
 #endif
 
 // NODIVOPT: ![[MD_FDIV]] = !{float 2.50e+00}
Index: clang/test/CodeGenCUDA/correctly-rounded-div.cu
===
--- clang/test/CodeGenCUDA/correctly-rounded-div.cu
+++ clang/test/CodeGenCUDA/correctly-rounded-div.cu
@@ -46,4 +46,18 @@
   return __builtin_sqrt(a);
 }
 
+// COMMON-LABEL: @_Z28test_builtin_elementwise_f32f
+// NCRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD:[0-9]+]]
+// CRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}){{$}}
+__device__ float test_builtin_elementwise_f32(float a) {
+  return __builtin_elementwise_sqrt(a);
+}
+
+// COMMON-LABEL: @_Z28test_builtin_elementwise_f64d
+// COMMON: call contract double @llvm.sqrt.f64(double %{{.+}}){{$}}
+// COMMON-NOT: !fpmath
+__device__ double test_builtin_

[PATCH] D156733: Stop using legacy helpers indicating typed pointer types. NFC

2023-07-31 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope updated this revision to Diff 545783.
bjope added a comment.
Herald added a subscriber: ormris.

Replaced a couple of more occurances in this update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156733

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
  clang/unittests/CodeGen/TBAAMetadataTest.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/Function.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Target/ARM/ARMFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
  llvm/tools/llvm-stress/llvm-stress.cpp
  llvm/unittests/Analysis/AliasAnalysisTest.cpp
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
  llvm/unittests/Analysis/PhiValuesTest.cpp
  llvm/unittests/Analysis/SparsePropagation.cpp
  llvm/unittests/Analysis/TBAATest.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  llvm/unittests/IR/BasicBlockTest.cpp
  llvm/unittests/IR/ConstantsTest.cpp
  llvm/unittests/IR/InstructionsTest.cpp
  llvm/unittests/IR/MetadataTest.cpp
  llvm/unittests/Transforms/Utils/CloningTest.cpp
  llvm/unittests/Transforms/Utils/LocalTest.cpp
  llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp

Index: llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
===
--- llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
+++ llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
@@ -73,9 +73,9 @@
   // expansion when the value in ValueOffsetPair is a ptr and the offset
   // is not divisible by the elem type size of value.
   auto *I8Ty = Type::getInt8Ty(Context);
-  auto *I8PtrTy = Type::getInt8PtrTy(Context);
+  auto *I8PtrTy = PointerType::get(Context, 0);
   auto *I32Ty = Type::getInt32Ty(Context);
-  auto *I32PtrTy = Type::getInt32PtrTy(Context);
+  auto *I32PtrTy = PointerType::get(Context, 0);
   FunctionType *FTy =
   FunctionType::get(Type::getVoidTy(Context), std::vector(), false);
   Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
Index: llvm/unittests/Transforms/Utils/LocalTest.cpp
===
--- llvm/unittests/Transforms/Utils/LocalTest.cpp
+++ llvm/unittests/Transforms/Utils/LocalTest.cpp
@@ -154,7 +154,7 @@
   ASSERT_TRUE(Inst);
   auto *DII = dyn_cast(Inst);
   ASSERT_TRUE(DII);
-  Value *NewBase = Constant::getNullValue(Type::getInt32PtrTy(C));
+  Value *NewBase = Constant::getNullValue(PointerType::getUnqual(C));
   DIBuilder DIB(*M);
   replaceDbgDeclare(AI, NewBase, DIB, DIExpression::ApplyOffset, 0);
 
Index: llvm/unittests/Transforms/Utils/CloningTest.cpp
===
--- llvm/unittests/Transforms/Utils/CloningTest.cpp
+++ llvm/unittests/Transforms/Utils/CloningTest.cpp
@@ -137,7 +137,7 @@
 }
 
 TEST_F(CloneInstruction, Inbounds) {
-  V = new Argument(Type::getInt32PtrTy(context));
+  V = new Argument(PointerType::get(context, 0));
 
   Constant *Z = Constant::getNullValue(Type::getInt32Ty(context));
   std::vector ops;
@@ -161,8 +161,9 @@
 }
 
 TEST_F(CloneInstruction, Attributes) {
-  Type *ArgTy1[] = { Type::getInt32PtrTy(context) };
-  FunctionType *FT1 =  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
+  FunctionType *FT1 =
+  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
 
   Function *F1 = Function::Create(FT1, Function::ExternalLinkage);
   BasicBlock *BB = BasicBlock::Create(context, "", F1);
@@ -187,8 +188,9 @@
 }
 
 TEST_F(CloneInstruction, CallingConvention) {
-  Type *ArgTy1[] = { Type::getInt32PtrTy(context) };
-  FunctionType *FT1 =  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
+  FunctionType *FT1 =
+  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
 
   Function *F1 = Function::Create(FT1, Function::ExternalLinkage);
   F1->setCallingConv(CallingConv::Cold);
@@ -211,7 +213,7 @@
 }
 
 TEST_F(CloneInstruction, DuplicateInstructionsToSplit) {
-  Type *ArgTy1[] = {Type::getInt32PtrTy(context)};
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
   FunctionType *FT = FunctionTy

[PATCH] D156286: [docs] Bump minimum GCC version to 7.4

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: llvm/docs/GettingStarted.rst:284-298
 `python `_  >=3.6
Automated test suite\ :sup:`2`
 `zlib `_   >=1.2.3.4
Compression library\ :sup:`3`
 `GNU Make `_ 3.79, 3.79.1 
Makefile/build processor\ :sup:`4`
 ===  
==
 
 .. note::
 

aaron.ballman wrote:
> 
I think you missed these requested changes when landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

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


[PATCH] D156286: [docs] Bump minimum GCC version to 7.4

2023-07-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/docs/GettingStarted.rst:345
 * Apple Clang 10.0
-* GCC 7.1
+* GCC 7.4
 * Visual Studio 2019 16.7

PiotrZSL wrote:
> What about Glibc version ?
> I were using GCC 9.1 + glibc 2.13 + some old kernel to compile Clang 15, 
> after upgrading to Clang 16 I had to upgrade to kernel 3.11 and glibc 2.17 
> due to missing (I think) aligned_alloc.
glibc support is worth its own discussion. glibc 2.13 was released in 2011. 
It's possible that no others has actively used this old version.

I think 2.19 has been tested and should work, but I am unclear about the 
support of older releases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

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


[PATCH] D105671: [Intrinsics][ObjC] Mark objc_retain and friends as thisreturn.

2023-07-31 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 545781.

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

https://reviews.llvm.org/D105671

Files:
  clang/test/CodeGenObjC/arc.m
  clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp

Index: llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
===
--- llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
+++ llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
@@ -162,6 +162,16 @@
 CallInst::TailCallKind TCK = CI->getTailCallKind();
 NewCI->setTailCallKind(std::max(TCK, OverridingTCK));
 
+// Transfer the 'returned' attribute from the intrinsic to the call site.
+// By applying this only to intrinsic call sites, we avoid applying it to
+// non-ARC explicit calls to things like objc_retain which have not been
+// auto-upgraded to use the intrinsics.
+unsigned Index;
+if (F.getAttributes().hasAttrSomewhere(Attribute::Returned, &Index) &&
+Index)
+  NewCI->addParamAttr(Index - AttributeList::FirstArgIndex,
+  Attribute::Returned);
+
 if (!CI->use_empty())
   CI->replaceAllUsesWith(NewCI);
 CI->eraseFromParent();
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -720,11 +720,13 @@
 // eliminate retain and releases where possible.
 
 def int_objc_autorelease: Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_autoreleasePoolPop : Intrinsic<[], [llvm_ptr_ty]>;
 def int_objc_autoreleasePoolPush: Intrinsic<[llvm_ptr_ty], []>;
 def int_objc_autoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_copyWeak   : Intrinsic<[],
 [llvm_ptr_ty,
  llvm_ptr_ty]>;
@@ -741,13 +743,17 @@
  llvm_ptr_ty]>;
 def int_objc_release: Intrinsic<[], [llvm_ptr_ty]>;
 def int_objc_retain : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_retainAutorelease  : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_retainAutoreleaseReturnValue   : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_retainAutoreleasedReturnValue  : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_retainBlock: Intrinsic<[llvm_ptr_ty],
 [llvm_ptr_ty]>;
 def int_objc_storeStrong: Intrinsic<[],
@@ -762,7 +768,8 @@
 [llvm_vararg_ty],
 [IntrInaccessibleMemOnly]>;
 def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_retainedObject : Intrinsic<[llvm_ptr_ty],
 [llvm_ptr_ty]>;
 def int_objc_unretainedObject   : Intrinsic<[llvm_ptr_ty],
@@ -770,7 +777,8 @@
 def int_objc_unretainedPointer  : Intrinsic<[llvm_ptr_ty],
 [llvm_ptr_ty]>;
 def int_objc_retain_autorelease : Intrinsic<[llvm_ptr_ty],
-

[PATCH] D105671: [Intrinsics][ObjC] Mark objc_retain and friends as thisreturn.

2023-07-31 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

oops, uploaded the wrong patch to this review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105671

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


[PATCH] D105671: [Intrinsics][ObjC] Mark objc_retain and friends as thisreturn.

2023-07-31 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 545779.
jroelofs added a comment.

Move the `stripPointerCasts()` change into its own review: 
https://reviews.llvm.org/D156735


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105671

Files:
  llvm/include/llvm/IR/Value.h
  llvm/lib/IR/Value.cpp
  llvm/unittests/IR/InstructionsTest.cpp


Index: llvm/unittests/IR/InstructionsTest.cpp
===
--- llvm/unittests/IR/InstructionsTest.cpp
+++ llvm/unittests/IR/InstructionsTest.cpp
@@ -458,6 +458,35 @@
  wrap(V2Int32PtrAS1Ty), true));
 }
 
+TEST(InstructionsTest, StripPointerCasts) {
+  LLVMContext C;
+  Type *I64PtrTy = Type::getInt64PtrTy(C);
+  Type *I32PtrTy = Type::getInt32PtrTy(C);
+
+  Module M("M", C);
+  FunctionType *FTy =
+  FunctionType::get(I64PtrTy, {I64PtrTy}, false);
+  auto *F = Function::Create(FTy, Function::ExternalLinkage, "", M);
+  auto *BB = BasicBlock::Create(C, "bb", F);
+  IRBuilder<> Builder(C);
+  Builder.SetInsertPoint(BB);
+
+  Value *A0 = F->getArg(0);
+  Function *SSACopy = Intrinsic::getDeclaration(&M, Intrinsic::ssa_copy, 
{A0->getType()});
+  CallInst *Call = Builder.CreateCall(SSACopy, {A0});
+  Value *Cast = Builder.CreateBitCast(Call, I32PtrTy);
+
+  // When stripping for alias analysis, it is okay to look through returned
+  // argument functions, since the pointer is unchanged.
+  EXPECT_EQ(Cast->stripPointerCastsForAliasAnalysis(), A0);
+
+  // Otherwise, this is not okay.
+  EXPECT_EQ(Cast->stripPointerCasts(), Call);
+  EXPECT_EQ(Cast->stripPointerCastsAndAliases(), Call);
+  EXPECT_EQ(Cast->stripPointerCastsSameRepresentation(), Call);
+  EXPECT_EQ(Cast->stripInBoundsConstantOffsets(), Call);
+}
+
 TEST(InstructionsTest, VectorGep) {
   LLVMContext C;
 
Index: llvm/lib/IR/Value.cpp
===
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -662,7 +662,8 @@
   V = cast(V)->getIncomingValue(0);
 } else {
   if (const auto *Call = dyn_cast(V)) {
-if (const Value *RV = Call->getReturnedArgOperand()) {
+if (const Value *RV = Call->getReturnedArgOperand();
+RV && StripKind == PSK_ForAliasAnalysis) {
   V = RV;
   continue;
 }
Index: llvm/include/llvm/IR/Value.h
===
--- llvm/include/llvm/IR/Value.h
+++ llvm/include/llvm/IR/Value.h
@@ -656,7 +656,7 @@
   }
 
   /// Strip off pointer casts, all-zero GEPs, single-argument phi nodes and
-  /// invariant group info.
+  /// invariant group info.  Looks through returned arg functions.
   ///
   /// Returns the original uncasted value.  If this is called on a non-pointer
   /// value, it returns 'this'. This function should be used only in


Index: llvm/unittests/IR/InstructionsTest.cpp
===
--- llvm/unittests/IR/InstructionsTest.cpp
+++ llvm/unittests/IR/InstructionsTest.cpp
@@ -458,6 +458,35 @@
  wrap(V2Int32PtrAS1Ty), true));
 }
 
+TEST(InstructionsTest, StripPointerCasts) {
+  LLVMContext C;
+  Type *I64PtrTy = Type::getInt64PtrTy(C);
+  Type *I32PtrTy = Type::getInt32PtrTy(C);
+
+  Module M("M", C);
+  FunctionType *FTy =
+  FunctionType::get(I64PtrTy, {I64PtrTy}, false);
+  auto *F = Function::Create(FTy, Function::ExternalLinkage, "", M);
+  auto *BB = BasicBlock::Create(C, "bb", F);
+  IRBuilder<> Builder(C);
+  Builder.SetInsertPoint(BB);
+
+  Value *A0 = F->getArg(0);
+  Function *SSACopy = Intrinsic::getDeclaration(&M, Intrinsic::ssa_copy, {A0->getType()});
+  CallInst *Call = Builder.CreateCall(SSACopy, {A0});
+  Value *Cast = Builder.CreateBitCast(Call, I32PtrTy);
+
+  // When stripping for alias analysis, it is okay to look through returned
+  // argument functions, since the pointer is unchanged.
+  EXPECT_EQ(Cast->stripPointerCastsForAliasAnalysis(), A0);
+
+  // Otherwise, this is not okay.
+  EXPECT_EQ(Cast->stripPointerCasts(), Call);
+  EXPECT_EQ(Cast->stripPointerCastsAndAliases(), Call);
+  EXPECT_EQ(Cast->stripPointerCastsSameRepresentation(), Call);
+  EXPECT_EQ(Cast->stripInBoundsConstantOffsets(), Call);
+}
+
 TEST(InstructionsTest, VectorGep) {
   LLVMContext C;
 
Index: llvm/lib/IR/Value.cpp
===
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -662,7 +662,8 @@
   V = cast(V)->getIncomingValue(0);
 } else {
   if (const auto *Call = dyn_cast(V)) {
-if (const Value *RV = Call->getReturnedArgOperand()) {
+if (const Value *RV = Call->getReturnedArgOperand();
+RV && StripKind == PSK_ForAliasAnalysis) {
   V = RV;
   continue;
 }
Index: llvm/include/llvm/IR/Value.h

[PATCH] D105671: [Intrinsics][ObjC] Mark objc_retain and friends as thisreturn.

2023-07-31 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In D105671#4547848 , @nikic wrote:

> Please separate the change to stripPointerCasts() into a separate review.

https://reviews.llvm.org/D156735


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105671

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


[PATCH] D156588: feat: Add support for Rocky Linux to LLVM Distro

2023-07-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D156588#4544152 , @tbaeder wrote:

> @MaskRay Isn't this something we should be doing with config files now?

I agree. This should use 
https://clang.llvm.org/docs/UsersManual.html#configuration-files .
We should try to remove existing distribution dispatching code as well, as long 
as they can be replaced with configuration files.

https://blogs.gentoo.org/mgorny/2022/10/07/clang-in-gentoo-now-sets-default-runtimes-via-config-file/
 has some nice information.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156588

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


[PATCH] D156286: [docs] Bump minimum GCC version to 7.4

2023-07-31 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: llvm/docs/GettingStarted.rst:345
 * Apple Clang 10.0
-* GCC 7.1
+* GCC 7.4
 * Visual Studio 2019 16.7

What about Glibc version ?
I were using GCC 9.1 + glibc 2.13 + some old kernel to compile Clang 15, after 
upgrading to Clang 16 I had to upgrade to kernel 3.11 and glibc 2.17 due to 
missing (I think) aligned_alloc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

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


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx added a comment.

In D156539#4547814 , @rjmccall wrote:

> In D156539#4546834 , @AlexVlx wrote:
>
>> In D156539#4542836 , @rjmccall 
>> wrote:
>>
>>> We should probably write this code to work properly in case we add a target 
>>> that makes `__builtin_alloca` return a pointer in the private address 
>>> space.  Could you recover the target AS from the type of the expression 
>>> instead of assuming `LangAS::Default`?
>>
>> I believe it should work as written (it is possible that I misunderstand the 
>> objection, case in which I do apologise). The issue is precisely that for 
>> some targets (amdgcn being one) `alloca` returns a pointer to private, which 
>> doesn't compose with the default AS being unspecified / nonexistent, for 
>> some languages (e.g. HIP,  C/C++ etc.). For the OCL case @arsenm mentions, I 
>> believe that we make a choice based on `LangOpts.OpenCLGenericAddressSpace`, 
>> and the code above would only be valid from the OCL language perspective iff 
>> that is true. I've put together a short Godbolt that captures these (and the 
>> bug the patch should fix, please see the bitcasts between ASes in the 
>> non-OCL case): https://gcc.godbolt.org/z/sYGK76zqv.
>
> An address space conversion is required in IR if there is a difference 
> between the address space of the pointer type formally returned by the call 
> to `__builtin_alloca` and the address space produced by the `alloca` 
> operation in IR.  If Sema has set the type of `__builtin_alloca` to formally 
> return something in the stack address space, no conversion is required.  What 
> I'm saying that I'd like you to not directly refer to `LangAS::Default` in 
> this code, because you're assuming that `__builtin_alloca` is always 
> returning a pointer that's formally in `LangAS::Default`.  Please recover the 
> target address space from the type of the expression.
>
> Additionally, in IRGen we allow the target to hook address-space conversions; 
> please call `performAddrSpaceCast` instead of directly emitting an 
> `addrspacecast` instruction.

Hmm, I think I see where you are coming from, thank you for clarifying and 
apologies for not seeing it from the getgo. Before delving into it, I will note 
that this has been handled similarly, but not identically, for static allocas 
for a while e.g.: 
https://github.com/llvm/llvm-project/blob/e0b3f45d87a6677efb59d8a4f0e6deac9c346c76/clang/lib/CodeGen/CGExpr.cpp#L83.
 I guess the concern here is somewhat forward looking because today the builtin 
is defined as `BUILTIN(__builtin_alloca, "v*z"   , "Fn")`, which means that it 
won't carry an AS on its return value on the ast, and will only ever return a 
pointer to generic / default (why the query around ASTAllocaAddressSpace 
exists, I assume). AFAICT, we actually expect languages that are not OCL to 
have alloca return a pointer to LangAS::Default, please see:  
https://github.com/llvm/llvm-project/blob/5fbee1c6e300eee9ce9d18275bf8a6de0a22ba59/clang/lib/CodeGen/CGDecl.cpp#L1443.
 My sense is that, currently, on an AST level, the stack AS must be the default 
as or, iff OpenCL, opencl_private (also the `alloca` AS in OCL), but the alloca 
AS needn't be the stack AS. Which I guess could be changed in the future, but 
seems like it'd take some work. Granted, that's maybe not a reason to constrain 
the builtin, but then static and dynamic allocas will hypothetically behave 
differently.

Noted on the target-hook, will do, thank you.


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

https://reviews.llvm.org/D156539

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


[PATCH] D156286: [docs] Bump minimum GCC version to 7.4

2023-07-31 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e06b82bded6: [docs] Bump minimum GCC version to 7.4 
(authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

Files:
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/GettingStarted.rst


Index: llvm/docs/GettingStarted.rst
===
--- llvm/docs/GettingStarted.rst
+++ llvm/docs/GettingStarted.rst
@@ -281,7 +281,6 @@
 Package Version  Notes
 ===  
==
 `CMake `__   >=3.20.0 
Makefile/workspace generator
-`GCC `_>=7.1.0  C/C++ 
compiler\ :sup:`1`
 `python `_  >=3.6
Automated test suite\ :sup:`2`
 `zlib `_   >=1.2.3.4
Compression library\ :sup:`3`
 `GNU Make `_ 3.79, 3.79.1 
Makefile/build processor\ :sup:`4`
@@ -343,7 +342,7 @@
 
 * Clang 5.0
 * Apple Clang 10.0
-* GCC 7.1
+* GCC 7.4
 * Visual Studio 2019 16.7
 
 Anything older than these toolchains *may* work, but will require forcing the
@@ -409,11 +408,11 @@
 .. _github gist:
   https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
 
-Easy steps for installing GCC 7.1.0:
+Easy steps for installing a specific version of GCC:
 
 .. code-block:: console
 
-  % gcc_version=7.1.0
+  % gcc_version=7.4.0
   % wget 
https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2
   % wget 
https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2.sig
   % wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,8 +4,8 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 7.1)
-set(GCC_SOFT_ERROR 7.1)
+set(GCC_MIN 7.4)
+set(GCC_SOFT_ERROR 7.4)
 set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
 set(APPLECLANG_MIN 10.0)


Index: llvm/docs/GettingStarted.rst
===
--- llvm/docs/GettingStarted.rst
+++ llvm/docs/GettingStarted.rst
@@ -281,7 +281,6 @@
 Package Version  Notes
 ===  ==
 `CMake `__   >=3.20.0 Makefile/workspace generator
-`GCC `_>=7.1.0  C/C++ compiler\ :sup:`1`
 `python `_  >=3.6Automated test suite\ :sup:`2`
 `zlib `_   >=1.2.3.4Compression library\ :sup:`3`
 `GNU Make `_ 3.79, 3.79.1 Makefile/build processor\ :sup:`4`
@@ -343,7 +342,7 @@
 
 * Clang 5.0
 * Apple Clang 10.0
-* GCC 7.1
+* GCC 7.4
 * Visual Studio 2019 16.7
 
 Anything older than these toolchains *may* work, but will require forcing the
@@ -409,11 +408,11 @@
 .. _github gist:
   https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
 
-Easy steps for installing GCC 7.1.0:
+Easy steps for installing a specific version of GCC:
 
 .. code-block:: console
 
-  % gcc_version=7.1.0
+  % gcc_version=7.4.0
   % wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2
   % wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2.sig
   % wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,8 +4,8 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 7.1)
-set(GCC_SOFT_ERROR 7.1)
+set(GCC_MIN 7.4)
+set(GCC_SOFT_ERROR 7.4)
 set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
 set(APPLECLANG_MIN 10.0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156286: [docs] Bump minimum GCC version to 7.4

2023-07-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 545769.
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added a subscriber: bd1976llvm.

reword description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

Files:
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/GettingStarted.rst


Index: llvm/docs/GettingStarted.rst
===
--- llvm/docs/GettingStarted.rst
+++ llvm/docs/GettingStarted.rst
@@ -281,7 +281,6 @@
 Package Version  Notes
 ===  
==
 `CMake `__   >=3.20.0 
Makefile/workspace generator
-`GCC `_>=7.1.0  C/C++ 
compiler\ :sup:`1`
 `python `_  >=3.6
Automated test suite\ :sup:`2`
 `zlib `_   >=1.2.3.4
Compression library\ :sup:`3`
 `GNU Make `_ 3.79, 3.79.1 
Makefile/build processor\ :sup:`4`
@@ -343,7 +342,7 @@
 
 * Clang 5.0
 * Apple Clang 10.0
-* GCC 7.1
+* GCC 7.4
 * Visual Studio 2019 16.7
 
 Anything older than these toolchains *may* work, but will require forcing the
@@ -409,11 +408,11 @@
 .. _github gist:
   https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
 
-Easy steps for installing GCC 7.1.0:
+Easy steps for installing a specific version of GCC:
 
 .. code-block:: console
 
-  % gcc_version=7.1.0
+  % gcc_version=7.4.0
   % wget 
https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2
   % wget 
https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2.sig
   % wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,8 +4,8 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 7.1)
-set(GCC_SOFT_ERROR 7.1)
+set(GCC_MIN 7.4)
+set(GCC_SOFT_ERROR 7.4)
 set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
 set(APPLECLANG_MIN 10.0)


Index: llvm/docs/GettingStarted.rst
===
--- llvm/docs/GettingStarted.rst
+++ llvm/docs/GettingStarted.rst
@@ -281,7 +281,6 @@
 Package Version  Notes
 ===  ==
 `CMake `__   >=3.20.0 Makefile/workspace generator
-`GCC `_>=7.1.0  C/C++ compiler\ :sup:`1`
 `python `_  >=3.6Automated test suite\ :sup:`2`
 `zlib `_   >=1.2.3.4Compression library\ :sup:`3`
 `GNU Make `_ 3.79, 3.79.1 Makefile/build processor\ :sup:`4`
@@ -343,7 +342,7 @@
 
 * Clang 5.0
 * Apple Clang 10.0
-* GCC 7.1
+* GCC 7.4
 * Visual Studio 2019 16.7
 
 Anything older than these toolchains *may* work, but will require forcing the
@@ -409,11 +408,11 @@
 .. _github gist:
   https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
 
-Easy steps for installing GCC 7.1.0:
+Easy steps for installing a specific version of GCC:
 
 .. code-block:: console
 
-  % gcc_version=7.1.0
+  % gcc_version=7.4.0
   % wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2
   % wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2.sig
   % wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,8 +4,8 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 7.1)
-set(GCC_SOFT_ERROR 7.1)
+set(GCC_MIN 7.4)
+set(GCC_SOFT_ERROR 7.4)
 set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
 set(APPLECLANG_MIN 10.0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156286: [docs] Bump minimum GCC version to 7.4

2023-07-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 545768.
MaskRay retitled this revision from "[docs] Bump minimum GCC version to 7.5" to 
"[docs] Bump minimum GCC version to 7.4".
MaskRay edited the summary of this revision.
MaskRay added a comment.

7.5 => 7.4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

Files:
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/GettingStarted.rst


Index: llvm/docs/GettingStarted.rst
===
--- llvm/docs/GettingStarted.rst
+++ llvm/docs/GettingStarted.rst
@@ -281,7 +281,6 @@
 Package Version  Notes
 ===  
==
 `CMake `__   >=3.20.0 
Makefile/workspace generator
-`GCC `_>=7.1.0  C/C++ 
compiler\ :sup:`1`
 `python `_  >=3.6
Automated test suite\ :sup:`2`
 `zlib `_   >=1.2.3.4
Compression library\ :sup:`3`
 `GNU Make `_ 3.79, 3.79.1 
Makefile/build processor\ :sup:`4`
@@ -343,7 +342,7 @@
 
 * Clang 5.0
 * Apple Clang 10.0
-* GCC 7.1
+* GCC 7.4
 * Visual Studio 2019 16.7
 
 Anything older than these toolchains *may* work, but will require forcing the
@@ -409,11 +408,11 @@
 .. _github gist:
   https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
 
-Easy steps for installing GCC 7.1.0:
+Easy steps for installing a specific version of GCC:
 
 .. code-block:: console
 
-  % gcc_version=7.1.0
+  % gcc_version=7.4.0
   % wget 
https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2
   % wget 
https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2.sig
   % wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,8 +4,8 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 7.1)
-set(GCC_SOFT_ERROR 7.1)
+set(GCC_MIN 7.4)
+set(GCC_SOFT_ERROR 7.4)
 set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
 set(APPLECLANG_MIN 10.0)


Index: llvm/docs/GettingStarted.rst
===
--- llvm/docs/GettingStarted.rst
+++ llvm/docs/GettingStarted.rst
@@ -281,7 +281,6 @@
 Package Version  Notes
 ===  ==
 `CMake `__   >=3.20.0 Makefile/workspace generator
-`GCC `_>=7.1.0  C/C++ compiler\ :sup:`1`
 `python `_  >=3.6Automated test suite\ :sup:`2`
 `zlib `_   >=1.2.3.4Compression library\ :sup:`3`
 `GNU Make `_ 3.79, 3.79.1 Makefile/build processor\ :sup:`4`
@@ -343,7 +342,7 @@
 
 * Clang 5.0
 * Apple Clang 10.0
-* GCC 7.1
+* GCC 7.4
 * Visual Studio 2019 16.7
 
 Anything older than these toolchains *may* work, but will require forcing the
@@ -409,11 +408,11 @@
 .. _github gist:
   https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
 
-Easy steps for installing GCC 7.1.0:
+Easy steps for installing a specific version of GCC:
 
 .. code-block:: console
 
-  % gcc_version=7.1.0
+  % gcc_version=7.4.0
   % wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2
   % wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2.sig
   % wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,8 +4,8 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 7.1)
-set(GCC_SOFT_ERROR 7.1)
+set(GCC_MIN 7.4)
+set(GCC_SOFT_ERROR 7.4)
 set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
 set(APPLECLANG_MIN 10.0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156733: Stop using legacy helpers indicating typed pointer types. NFC

2023-07-31 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope created this revision.
Herald added subscribers: nlopes, Enna1, pmatos, asb, jeroen.dobbelaere, 
pengfei, hiraditya, jgravelle-google, sbc100, dschuff.
Herald added a project: All.
bjope requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, aheejin.
Herald added projects: clang, LLVM.

Since we no longer support typed LLVM IR pointer types, the code can
be simplified into for example using PointerType::get directly instead
of using Type::getInt8PtrTy and Type::getInt32PtrTy etc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156733

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
  clang/unittests/CodeGen/TBAAMetadataTest.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/Function.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Target/ARM/ARMFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
  llvm/unittests/Analysis/AliasAnalysisTest.cpp
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
  llvm/unittests/Analysis/PhiValuesTest.cpp
  llvm/unittests/Analysis/SparsePropagation.cpp
  llvm/unittests/Analysis/TBAATest.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  llvm/unittests/IR/BasicBlockTest.cpp
  llvm/unittests/IR/ConstantsTest.cpp
  llvm/unittests/IR/InstructionsTest.cpp
  llvm/unittests/IR/MetadataTest.cpp
  llvm/unittests/Transforms/Utils/CloningTest.cpp
  llvm/unittests/Transforms/Utils/LocalTest.cpp
  llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp

Index: llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
===
--- llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
+++ llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
@@ -73,9 +73,9 @@
   // expansion when the value in ValueOffsetPair is a ptr and the offset
   // is not divisible by the elem type size of value.
   auto *I8Ty = Type::getInt8Ty(Context);
-  auto *I8PtrTy = Type::getInt8PtrTy(Context);
+  auto *I8PtrTy = PointerType::get(Context, 0);
   auto *I32Ty = Type::getInt32Ty(Context);
-  auto *I32PtrTy = Type::getInt32PtrTy(Context);
+  auto *I32PtrTy = PointerType::get(Context, 0);
   FunctionType *FTy =
   FunctionType::get(Type::getVoidTy(Context), std::vector(), false);
   Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
Index: llvm/unittests/Transforms/Utils/LocalTest.cpp
===
--- llvm/unittests/Transforms/Utils/LocalTest.cpp
+++ llvm/unittests/Transforms/Utils/LocalTest.cpp
@@ -154,7 +154,7 @@
   ASSERT_TRUE(Inst);
   auto *DII = dyn_cast(Inst);
   ASSERT_TRUE(DII);
-  Value *NewBase = Constant::getNullValue(Type::getInt32PtrTy(C));
+  Value *NewBase = Constant::getNullValue(PointerType::getUnqual(C));
   DIBuilder DIB(*M);
   replaceDbgDeclare(AI, NewBase, DIB, DIExpression::ApplyOffset, 0);
 
Index: llvm/unittests/Transforms/Utils/CloningTest.cpp
===
--- llvm/unittests/Transforms/Utils/CloningTest.cpp
+++ llvm/unittests/Transforms/Utils/CloningTest.cpp
@@ -137,7 +137,7 @@
 }
 
 TEST_F(CloneInstruction, Inbounds) {
-  V = new Argument(Type::getInt32PtrTy(context));
+  V = new Argument(PointerType::get(context, 0));
 
   Constant *Z = Constant::getNullValue(Type::getInt32Ty(context));
   std::vector ops;
@@ -161,8 +161,9 @@
 }
 
 TEST_F(CloneInstruction, Attributes) {
-  Type *ArgTy1[] = { Type::getInt32PtrTy(context) };
-  FunctionType *FT1 =  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
+  FunctionType *FT1 =
+  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
 
   Function *F1 = Function::Create(FT1, Function::ExternalLinkage);
   BasicBlock *BB = BasicBlock::Create(context, "", F1);
@@ -187,8 +188,9 @@
 }
 
 TEST_F(CloneInstruction, CallingConvention) {
-  Type *ArgTy1[] = { Type::getInt32PtrTy(context) };
-  FunctionType *FT1 =  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
+  Type *ArgTy1[] = {PointerType::get(context, 0)};
+  FunctionType *FT1 =
+  FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
 
   Function *F1 = Function::Create(FT1, Function::ExternalLinkage);
   F1->setCallingConv(CallingConv::Cold);
@@ -211,7 +213,7 @@
 }
 
 TEST_F(CloneInstruction, DuplicateInstructionsToSplit) {
-  Type *ArgTy1[] = {Type::getInt32PtrTy(context)};
+  Type *ArgTy1[] = {PointerType::get(context, 0)};

[PATCH] D156705: [clang-format] Fix braced initializer formatting with templated base class initializer

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



Comment at: clang/unittests/Format/FormatTest.cpp:13461
   "  A() : a{} {}\n"
+  "  A() : Base{} {}\n"
   "  A(int b) : b(b) {}\n"

Please also add nested templates.


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

https://reviews.llvm.org/D156705

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


[PATCH] D156728: [Sema] Ignore nullability qualifiers when deducing types for `auto` and `__auto_type`

2023-07-31 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

I understand that this is an expedient fix that silences the warning. However, 
the fundamental problem is the simplistic implementation of the warning (that 
it is not flow-sensitive), not the inference of nullability. That is, when we 
are removing nullability qualifiers, we don't know whether there was a check or 
not. So while this change removes some false positives, it also removes some 
true positives.




Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3933
   //   type are ignored for type deduction.
+  // Ignore top level nullability qualifiers too.
   ArgType = ArgType.getUnqualifiedType();

This comment merely duplicates the code. Please add an explanation why it is 
done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156728

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


[PATCH] D156259: Fix a bug that erroneously placed function arguments on a new line despite all arguments being able to fit on the same line.

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



Comment at: clang/lib/Format/ContinuationIndenter.cpp:657-666
+  bool DisallowLineBreaksOnThisLine = [&Style = this->Style, &Current] {
+// Deal with lambda arguments in C++. The aim here is to ensure that we
+// don't over-indent lambda function bodies when lamdbas are passed as
+// arguments to function calls. We do this by ensuring that either all
+// arguments (including any lambdas) go on the same line as the function
+// call, or we break before the first argument.
+if (Style.Language != FormatStyle::LK_Cpp &&

I'd go for this.
But that's not necessary.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:659
+// Deal with lambda arguments in C++. The aim here is to ensure that we
+// don't over-indent lambda function bodies when lamdbas are passed as
+// arguments to function calls. We do this by ensuring that either all

lambdas


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156259

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


[PATCH] D156726: Make globals with mutable members non-constant, even in custom sections

2023-07-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:14254
 int SectionFlags = ASTContext::PSF_Read;
-if (var->getType().isConstQualified()) {
-  if (HasConstInit)

I think this is not compatible with MSVC. MSVC uses simple logic, it doesn't 
look for mutable: https://gcc.godbolt.org/z/sj6d4saxx

The const mutable struct appears in the myrdata section in that example.

I think the solution is to separate the flag logic from the pragma stack 
selection logic, which has to remain MSVC-compatible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156726

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


[PATCH] D156674: [clang][dataflow] Remove `Strict` suffix from accessors.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb244b6ae0b21: [clang][dataflow] Remove `Strict` suffix from 
accessors. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156674

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
  clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -1243,7 +1243,7 @@
 match(callExpr(callee(functionDecl(hasName("makeTop".bind("top"),
   *S, getASTContext());
 if (const auto *E = selectFirst("top", Matches)) {
-  Env.setValueStrict(*E, Env.makeTopBoolValue());
+  Env.setValue(*E, Env.makeTopBoolValue());
 }
   }
 
Index: clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
@@ -117,7 +117,7 @@
   auto *UnaryOpValue = State.Env.getValue(*UO);
   if (!UnaryOpValue) {
 UnaryOpValue = &State.Env.makeAtomicBoolValue();
-State.Env.setValueStrict(*UO, *UnaryOpValue);
+State.Env.setValue(*UO, *UnaryOpValue);
   }
 
   // Properties for the operand (sub expression).
@@ -137,7 +137,7 @@
 Comp = &V->formula();
   } else {
 Comp = &A.makeAtomRef(A.makeAtom());
-State.Env.setValueStrict(*BO, A.makeBoolValue(*Comp));
+State.Env.setValue(*BO, A.makeBoolValue(*Comp));
   }
 
   // FIXME Use this as well:
@@ -260,10 +260,10 @@
 Value *getOrCreateValue(const Expr *E, Environment &Env) {
   Value *Val = nullptr;
   if (E->isGLValue()) {
-StorageLocation *Loc = Env.getStorageLocationStrict(*E);
+StorageLocation *Loc = Env.getStorageLocation(*E);
 if (!Loc) {
   Loc = &Env.createStorageLocation(*E);
-  Env.setStorageLocationStrict(*E, *Loc);
+  Env.setStorageLocation(*E, *Loc);
 }
 Val = Env.getValue(*Loc);
 if (!Val) {
@@ -274,7 +274,7 @@
 Val = Env.getValue(*E);
 if (!Val) {
   Val = Env.createValue(E->getType());
-  Env.setValueStrict(*E, *Val);
+  Env.setValue(*E, *Val);
 }
   }
   assert(Val != nullptr);
Index: clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
@@ -279,9 +279,9 @@
   ASSERT_THAT(DRE, NotNull());
 
   Environment Env(DAContext, *Target);
-  EXPECT_THAT(Env.getStorageLocationStrict(*DRE), IsNull());
+  EXPECT_THAT(Env.getStorageLocation(*DRE), IsNull());
   refreshStructValue(*DRE, Env);
-  EXPECT_THAT(Env.getStorageLocationStrict(*DRE), NotNull());
+  EXPECT_THAT(Env.getStorageLocation(*DRE), NotNull());
 }
 
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -135,7 +135,7 @@
 // for the condition expression, even if just an atom.
 if (Val == nullptr) {
   Val = &Env.makeAtomicBoolValue();
-  Env.setValueStrict(Cond, *Val);
+  Env.setValue(Cond, *Val);
 }
 
 bool ConditionValue = true;
@@ -402,7 +402,7 @@
   // the `AggregateStorageLocation` already exists. We should explore if there's
   // anything that we can do to change this.
   if (Member->getType()->isReferenceType()) {
-auto *InitExprLoc = Env.getStorageLocationStrict(*InitExpr);
+auto *InitExprLoc = Env.getStorageLocation(*InitExpr);
 if (InitExprLoc == nullptr)
   return;
 
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -74,7 +74,7 @@
 // value, if any unpacking occured. Also, does the lvalue-to-rvalue conversion,
 // by skipping past the reference.
 static Value *maybeUnpackLValueExpr(const Expr &E

[PATCH] D156672: [clang][dataflow] Use `Strict` accessors where we weren't using them yet.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
mboehme marked an inline comment as done.
Closed by commit rGf76f6674d822: [clang][dataflow] Use `Strict` accessors where 
we weren't using them yet. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156672

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp

Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -141,30 +141,26 @@
   Env.setValue(*LHSLoc, *RHSVal);
 
   // Assign a storage location for the whole expression.
-  Env.setStorageLocation(*S, *LHSLoc);
+  Env.setStorageLocationStrict(*S, *LHSLoc);
   break;
 }
 case BO_LAnd:
 case BO_LOr: {
-  auto &Loc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, Loc);
-
   BoolValue &LHSVal = getLogicOperatorSubExprValue(*LHS);
   BoolValue &RHSVal = getLogicOperatorSubExprValue(*RHS);
 
   if (S->getOpcode() == BO_LAnd)
-Env.setValue(Loc, Env.makeAnd(LHSVal, RHSVal));
+Env.setValueStrict(*S, Env.makeAnd(LHSVal, RHSVal));
   else
-Env.setValue(Loc, Env.makeOr(LHSVal, RHSVal));
+Env.setValueStrict(*S, Env.makeOr(LHSVal, RHSVal));
   break;
 }
 case BO_NE:
 case BO_EQ: {
   auto &LHSEqRHSValue = evaluateBooleanEquality(*LHS, *RHS, Env);
-  auto &Loc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, Loc);
-  Env.setValue(Loc, S->getOpcode() == BO_EQ ? LHSEqRHSValue
-: Env.makeNot(LHSEqRHSValue));
+  Env.setValueStrict(*S, S->getOpcode() == BO_EQ
+ ? LHSEqRHSValue
+ : Env.makeNot(LHSEqRHSValue));
   break;
 }
 case BO_Comma: {
@@ -238,7 +234,7 @@
   VisitDeclRefExpr(DE);
   VisitMemberExpr(ME);
 
-  if (auto *Loc = Env.getStorageLocation(*ME, SkipPast::Reference))
+  if (auto *Loc = Env.getStorageLocationStrict(*ME))
 Env.setStorageLocation(*B, *Loc);
 } else if (auto *VD = B->getHoldingVar()) {
   // Holding vars are used to back the `BindingDecl`s of tuple-like
@@ -283,9 +279,7 @@
   if (SubExprVal == nullptr)
 break;
 
-  auto &ExprLoc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, ExprLoc);
-  Env.setValue(ExprLoc, *SubExprVal);
+  Env.setValueStrict(*S, *SubExprVal);
   break;
 }
 
@@ -308,12 +302,9 @@
   break;
 }
 case CK_NullToPointer: {
-  auto &Loc = Env.createStorageLocation(S->getType());
-  Env.setStorageLocation(*S, Loc);
-
   auto &NullPointerVal =
   Env.getOrCreateNullPointerValue(S->getType()->getPointeeType());
-  Env.setValue(Loc, NullPointerVal);
+  Env.setValueStrict(*S, NullPointerVal);
   break;
 }
 case CK_NullToMemberPointer:
@@ -321,15 +312,11 @@
   // with this expression.
   break;
 case CK_FunctionToPointerDecay: {
-  StorageLocation *PointeeLoc =
-  Env.getStorageLocation(*SubExpr, SkipPast::Reference);
+  StorageLocation *PointeeLoc = Env.getStorageLocationStrict(*SubExpr);
   if (PointeeLoc == nullptr)
 break;
 
-  auto &PointerLoc = Env.createStorageLocation(*S);
-  auto &PointerVal = Env.create(*PointeeLoc);
-  Env.setStorageLocation(*S, PointerLoc);
-  Env.setValue(PointerLoc, PointerVal);
+  Env.setValueStrict(*S, Env.create(*PointeeLoc));
   break;
 }
 case CK_BuiltinFnToFnPtr:
@@ -371,9 +358,7 @@
   if (SubExprVal == nullptr)
 break;
 
-  auto &ExprLoc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, ExprLoc);
-  Env.setValue(ExprLoc, Env.makeNot(*SubExprVal));
+  Env.setValueStrict(*S, Env.makeNot(*SubExprVal));
   break;
 }
 default:
@@ -388,16 +373,12 @@
   // `this` expression's pointee.
   return;
 
-auto &Loc = Env.createStorageLocation(*S);
-Env.setStorageLocation(*S, Loc);
-Env.setValue(Loc, Env.create(*ThisPointeeLoc));
+Env.setValueStrict(*S, Env.create(*ThisPointeeLoc));
   }
 
   void VisitCXXNewExpr(const CXXNewExpr *S) {
-auto &Loc = Env.createStorageLocation(*S);
-Env.setStorageLocation(*S, Loc);
 if (Value *Val = Env.createValue(S->getType()))
-  Env.setValue(Loc, *Val);
+  Env.setValueStrict(*S, *Val);
   }
 
   void VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
@@ -450,7 +431,7 @@
 if (VarDeclLoc == nullptr)
   return;
 
-Env.setStorageLocation(*S, *VarDecl

[PATCH] D156673: [clang][dataflow] Remove deprecated accessors as well as `SkipPast`.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG17ba278f7611: [clang][dataflow] Remove deprecated accessors 
as well as `SkipPast`. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156673

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -618,12 +618,6 @@
   return Loc;
 }
 
-void Environment::setStorageLocation(const Expr &E, StorageLocation &Loc) {
-  const Expr &CanonE = ignoreCFGOmittedNodes(E);
-  assert(!ExprToLoc.contains(&CanonE));
-  ExprToLoc[&CanonE] = &Loc;
-}
-
 void Environment::setStorageLocationStrict(const Expr &E,
StorageLocation &Loc) {
   // `DeclRefExpr`s to builtin function types aren't glvalues, for some reason,
@@ -631,26 +625,14 @@
   // so allow these as an exception.
   assert(E.isGLValue() ||
  E.getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn));
-  setStorageLocation(E, Loc);
-}
-
-StorageLocation *Environment::getStorageLocation(const Expr &E,
- SkipPast SP) const {
-  // FIXME: Add a test with parens.
-  auto It = ExprToLoc.find(&ignoreCFGOmittedNodes(E));
-  return It == ExprToLoc.end() ? nullptr : &*It->second;
+  setStorageLocationInternal(E, Loc);
 }
 
 StorageLocation *Environment::getStorageLocationStrict(const Expr &E) const {
   // See comment in `setStorageLocationStrict()`.
   assert(E.isGLValue() ||
  E.getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn));
-  StorageLocation *Loc = getStorageLocation(E, SkipPast::None);
-
-  if (Loc == nullptr)
-return nullptr;
-
-  return Loc;
+  return getStorageLocationInternal(E);
 }
 
 AggregateStorageLocation *Environment::getThisPointeeStorageLocation() const {
@@ -662,12 +644,11 @@
   assert(RecordPRValue.getType()->isRecordType());
   assert(RecordPRValue.isPRValue());
 
-  if (StorageLocation *ExistingLoc =
-  getStorageLocation(RecordPRValue, SkipPast::None))
+  if (StorageLocation *ExistingLoc = getStorageLocationInternal(RecordPRValue))
 return *cast(ExistingLoc);
   auto &Loc = cast(
   DACtx->getStableStorageLocation(RecordPRValue));
-  setStorageLocation(RecordPRValue, Loc);
+  setStorageLocationInternal(RecordPRValue, Loc);
   return Loc;
 }
 
@@ -690,18 +671,18 @@
 cast_or_null(getValue(E)))
   assert(&ExistingVal->getAggregateLoc() == &StructVal->getAggregateLoc());
 if ([[maybe_unused]] StorageLocation *ExistingLoc =
-getStorageLocation(E, SkipPast::None))
+getStorageLocationInternal(E))
   assert(ExistingLoc == &StructVal->getAggregateLoc());
 else
-  setStorageLocation(E, StructVal->getAggregateLoc());
+  setStorageLocationInternal(E, StructVal->getAggregateLoc());
 setValue(StructVal->getAggregateLoc(), Val);
 return;
   }
 
-  StorageLocation *Loc = getStorageLocation(E, SkipPast::None);
+  StorageLocation *Loc = getStorageLocationInternal(E);
   if (Loc == nullptr) {
 Loc = &createStorageLocation(E);
-setStorageLocation(E, *Loc);
+setStorageLocationInternal(E, *Loc);
   }
   setValue(*Loc, Val);
 }
@@ -717,16 +698,11 @@
   return getValue(*Loc);
 }
 
-Value *Environment::getValue(const Expr &E, SkipPast SP) const {
-  auto *Loc = getStorageLocation(E, SP);
-  if (Loc == nullptr)
+Value *Environment::getValue(const Expr &E) const {
+  auto It = ExprToLoc.find(&ignoreCFGOmittedNodes(E));
+  if (It == ExprToLoc.end())
 return nullptr;
-  return getValue(*Loc);
-}
-
-Value *Environment::getValueStrict(const Expr &E) const {
-  assert(E.isPRValue());
-  return getValue(E);
+  return getValue(*It->second);
 }
 
 Value *Environment::createValue(QualType Type) {
@@ -741,6 +717,18 @@
   return Val;
 }
 
+void Environment::setStorageLocationInternal(const Expr &E,
+ StorageLocation &Loc) {
+  const Expr &CanonE = ignoreCFGOmittedNodes(E);
+  assert(!ExprToLoc.contains(&CanonE));
+  ExprToLoc[&CanonE] = &Loc;
+}
+
+StorageLocation *Environment::getStorageLocationInternal(const Expr &E) const {
+  auto It = ExprToLoc.find(&ignoreCFGOmittedNodes(E));
+  return It == ExprToLoc.end() ? nullptr : &*It->second;
+}
+
 Value *Environment::createValueUnlessSelfReferential(
 QualType Type, llvm::DenseSet &Visited, int Depth,
 int &CreatedValuesCount) {
Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/incl

[clang] b244b6a - [clang][dataflow] Remove `Strict` suffix from accessors.

2023-07-31 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-07-31T19:40:09Z
New Revision: b244b6ae0b2153521c5e55ff4705a88618f503aa

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

LOG: [clang][dataflow] Remove `Strict` suffix from accessors.

For the time being, we're keeping the `Strict` versions around as deprecated 
synonyms so that clients can be migrated, but these synonyms will be removed 
soon.

Depends On D156673

Reviewed By: ymandel, xazax.hun

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index bd89c7e5c74a3c..0e5cfad263c797 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -274,7 +274,12 @@ class Environment {
   ///
   ///  `E` must not be assigned a storage location in the environment.
   ///  `E` must be a glvalue or a `BuiltinType::BuiltinFn`
-  void setStorageLocationStrict(const Expr &E, StorageLocation &Loc);
+  void setStorageLocation(const Expr &E, StorageLocation &Loc);
+
+  /// Deprecated synonym for `setStorageLocation()`.
+  void setStorageLocationStrict(const Expr &E, StorageLocation &Loc) {
+setStorageLocation(E, Loc);
+  }
 
   /// Returns the storage location assigned to the glvalue `E` in the
   /// environment, or null if `E` isn't assigned a storage location in the
@@ -285,7 +290,12 @@ class Environment {
   ///
   /// Requirements:
   ///  `E` must be a glvalue or a `BuiltinType::BuiltinFn`
-  StorageLocation *getStorageLocationStrict(const Expr &E) const;
+  StorageLocation *getStorageLocation(const Expr &E) const;
+
+  /// Deprecated synonym for `getStorageLocation()`.
+  StorageLocation *getStorageLocationStrict(const Expr &E) const {
+return getStorageLocation(E);
+  }
 
   /// Returns the storage location assigned to the `this` pointee in the
   /// environment or null if the `this` pointee has no assigned storage 
location
@@ -442,7 +452,10 @@ class Environment {
   ///  same as that of any `StructValue` that has already been associated with
   ///  `E`. This is to guarantee that the result object initialized by a 
prvalue
   ///  `StructValue` has a durable storage location.
-  void setValueStrict(const Expr &E, Value &Val);
+  void setValue(const Expr &E, Value &Val);
+
+  /// Deprecated synonym for `setValue()`.
+  void setValueStrict(const Expr &E, Value &Val) { setValue(E, Val); }
 
   /// Returns the value assigned to `Loc` in the environment or null if `Loc`
   /// isn't assigned a value in the environment.
@@ -585,11 +598,11 @@ class Environment {
   // The copy-constructor is for use in fork() only.
   Environment(const Environment &) = default;
 
-  /// Internal version of `setStorageLocationStrict()` that doesn't check if 
the
+  /// Internal version of `setStorageLocation()` that doesn't check if the
   /// expression is a prvalue.
   void setStorageLocationInternal(const Expr &E, StorageLocation &Loc);
 
-  /// Internal version of `getStorageLocationStrict()` that doesn't check if 
the
+  /// Internal version of `getStorageLocation()` that doesn't check if the
   /// expression is a prvalue.
   StorageLocation *getStorageLocationInternal(const Expr &E) const;
 

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 48f8e63a165efe..503158c91c3f4f 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -337,7 +337,7 @@ Environment Environment::pushCall(const CallExpr *Call) 
const {
 if (const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
   if (!isa(Arg))
   Env.ThisPointeeLoc =
-  cast(getStorageLocationStrict(*Arg));
+  cast(getStorageLocation(*Arg));
   // Otherwise (when the argument is `this`), retain the current
   // environment's `ThisPointeeLoc`.
 }
@@ -396,10 +396,10 @@ void Environment::popCall(const CallExpr *Call, const 
Environment &CalleeEnv) {

[clang] 17ba278 - [clang][dataflow] Remove deprecated accessors as well as `SkipPast`.

2023-07-31 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-07-31T19:40:06Z
New Revision: 17ba278f76116b12eb7a954c8963ee5a5a19c32b

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

LOG: [clang][dataflow] Remove deprecated accessors as well as `SkipPast`.

Depends On D156672

Reviewed By: ymandel, xazax.hun

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 460727973ed4c8..bd89c7e5c74a3c 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -38,19 +38,6 @@
 namespace clang {
 namespace dataflow {
 
-/// Indicates what kind of indirections should be skipped past when retrieving
-/// storage locations or values.
-///
-/// FIXME: Consider renaming this or replacing it with a more appropriate 
model.
-/// See the discussion in https://reviews.llvm.org/D116596 for context.
-enum class SkipPast {
-  /// No indirections should be skipped past.
-  None,
-  /// An optional reference should be skipped past.
-  /// This is deprecated; it is equivalent to `None` and will be removed.
-  Reference,
-};
-
 /// Indicates the result of a tentative comparison.
 enum class ComparisonResult {
   Same,
@@ -280,40 +267,15 @@ class Environment {
   /// refers directly to the referenced object, not a `ReferenceValue`.
   StorageLocation *getStorageLocation(const ValueDecl &D) const;
 
-  /// Assigns `Loc` as the storage location of `E` in the environment.
-  ///
-  /// This function is deprecated; prefer `setStorageLocationStrict()`.
-  /// For details, see https://discourse.llvm.org/t/70086.
-  ///
-  /// Requirements:
-  ///
-  ///  `E` must not be assigned a storage location in the environment.
-  void setStorageLocation(const Expr &E, StorageLocation &Loc);
-
   /// Assigns `Loc` as the storage location of the glvalue `E` in the
   /// environment.
   ///
-  /// This function is the preferred alternative to
-  /// `setStorageLocation(const Expr &, StorageLocation &)`. Once the migration
-  /// to strict handling of value categories is complete (see
-  /// https://discourse.llvm.org/t/70086), `setStorageLocation()` will be
-  /// removed and this function will be renamed to `setStorageLocation()`.
-  ///
   /// Requirements:
   ///
   ///  `E` must not be assigned a storage location in the environment.
   ///  `E` must be a glvalue or a `BuiltinType::BuiltinFn`
   void setStorageLocationStrict(const Expr &E, StorageLocation &Loc);
 
-  /// Returns the storage location assigned to `E` in the environment, or null
-  /// if `E` isn't assigned a storage location in the environment.
-  ///
-  /// The `SP` parameter has no effect.
-  ///
-  /// This function is deprecated; prefer `getStorageLocationStrict()`.
-  /// For details, see https://discourse.llvm.org/t/70086.
-  StorageLocation *getStorageLocation(const Expr &E, SkipPast SP) const;
-
   /// Returns the storage location assigned to the glvalue `E` in the
   /// environment, or null if `E` isn't assigned a storage location in the
   /// environment.
@@ -321,12 +283,6 @@ class Environment {
   /// If the storage location for `E` is associated with a
   /// `ReferenceValue RefVal`, returns `RefVal.getReferentLoc()` instead.
   ///
-  /// This function is the preferred alternative to
-  /// `getStorageLocation(const Expr &, SkipPast)`. Once the migration
-  /// to strict handling of value categories is complete (see
-  /// https://discourse.llvm.org/t/70086), `getStorageLocation()` will be
-  /// removed and this function will be renamed to `getStorageLocation()`.
-  ///
   /// Requirements:
   ///  `E` must be a glvalue or a `BuiltinType::BuiltinFn`
   StorageLocation *getStorageLocationStrict(const Expr &E) const;
@@ -498,20 +454,7 @@ class Environment {
 
   /// Equivalent to `getValue(getStorageLocation(E, SP))` if `E` is assigned a
   /// storage location in the environment, otherwise returns null.
-  ///
-  /// The `SP` parameter is deprecated and has no effect. New callers should
-  /// avoid passing this parameter.
-  Value *getValue(const Expr &E, SkipPast SP = SkipPast::None) const;
-
-  /// Returns the `Value` assigned to the prvalue `E` in the environment, or
-  /// null if `E` isn't assigned a value in the environment.
-  ///
-  /// This function is deprecated. Call `getValue(E)` instead.
-  ///
-  /// Requirements:
-  ///
-  ///  `E` must be a prvalue
-  Value *getValueStrict(const Expr &E) const;
+  Value *getValue(const Expr &E) const;
 
   // FIXME

[clang] f76f667 - [clang][dataflow] Use `Strict` accessors where we weren't using them yet.

2023-07-31 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-07-31T19:40:04Z
New Revision: f76f6674d8221f59f9e515e3cc03ad07fa72fe46

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

LOG: [clang][dataflow] Use `Strict` accessors where we weren't using them yet.

This eliminates all uses of the deprecated accessors.

Reviewed By: ymandel, xazax.hun

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

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 214e0c061ed7bc..c1cd00a73491ae 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -336,8 +336,8 @@ Environment Environment::pushCall(const CallExpr *Call) 
const {
   if (const auto *MethodCall = dyn_cast(Call)) {
 if (const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
   if (!isa(Arg))
-Env.ThisPointeeLoc = cast(
-getStorageLocation(*Arg, SkipPast::Reference));
+  Env.ThisPointeeLoc =
+  cast(getStorageLocationStrict(*Arg));
   // Otherwise (when the argument is `this`), retain the current
   // environment's `ThisPointeeLoc`.
 }
@@ -832,9 +832,8 @@ StorageLocation &Environment::createObjectInternal(const 
VarDecl *D,
 // can happen that we can't see the initializer, so `InitExpr` may still
 // be null.
 if (InitExpr) {
-  if (auto *InitExprLoc =
-  getStorageLocation(*InitExpr, SkipPast::Reference))
-return *InitExprLoc;
+  if (auto *InitExprLoc = getStorageLocationStrict(*InitExpr))
+  return *InitExprLoc;
 }
 
 // Even though we have an initializer, we might not get an
@@ -913,16 +912,13 @@ getImplicitObjectLocation(const CXXMemberCallExpr &MCE,
   Expr *ImplicitObject = MCE.getImplicitObjectArgument();
   if (ImplicitObject == nullptr)
 return nullptr;
-  StorageLocation *Loc =
-  Env.getStorageLocation(*ImplicitObject, SkipPast::Reference);
-  if (Loc == nullptr)
-return nullptr;
   if (ImplicitObject->getType()->isPointerType()) {
-if (auto *Val = cast_or_null(Env.getValue(*Loc)))
+if (auto *Val = cast_or_null(Env.getValue(*ImplicitObject)))
   return &cast(Val->getPointeeLoc());
 return nullptr;
   }
-  return cast(Loc);
+  return cast_or_null(
+  Env.getStorageLocationStrict(*ImplicitObject));
 }
 
 AggregateStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
@@ -930,15 +926,13 @@ AggregateStorageLocation *getBaseObjectLocation(const 
MemberExpr &ME,
   Expr *Base = ME.getBase();
   if (Base == nullptr)
 return nullptr;
-  StorageLocation *Loc = Env.getStorageLocation(*Base, SkipPast::Reference);
-  if (Loc == nullptr)
-return nullptr;
   if (ME.isArrow()) {
-if (auto *Val = cast_or_null(Env.getValue(*Loc)))
+if (auto *Val = cast_or_null(Env.getValue(*Base)))
   return &cast(Val->getPointeeLoc());
 return nullptr;
   }
-  return cast(Loc);
+  return cast_or_null(
+  Env.getStorageLocationStrict(*Base));
 }
 
 std::vector getFieldsForInitListExpr(const RecordDecl *RD) {

diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index ef51402e171ed6..9b0daf2d95183f 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -254,10 +254,17 @@ class HTMLLogger : public Logger {
   if (ElementIndex > 0) {
 auto S =
 Iters.back().first->Elements[ElementIndex - 1].getAs();
-if (const Expr *E = S ? llvm::dyn_cast(S->getStmt()) : nullptr)
-  if (auto *Loc = State.Env.getStorageLocation(*E, SkipPast::None))
-JOS->attributeObject(
-"value", [&] { ModelDumper(*JOS, State.Env).dump(*Loc); });
+if (const Expr *E = S ? llvm::dyn_cast(S->getStmt()) : nullptr) {
+  if (E->isPRValue()) {
+if (auto *V = State.Env.getValue(*E))
+  JOS->attributeObject(
+  "value", [&] { ModelDumper(*JOS, State.Env).dump(*V); });
+  } else {
+if (auto *Loc = State.Env.getStorageLocationStrict(*E))
+  JOS->attributeObject(
+  "value", [&] { ModelDumper(*JOS, State.Env).dump(*Loc); });
+  }
+}
   }
   if (!ContextLogs.empty()) {
 JOS->attribute("logs", ContextLogs);

diff  --git 
a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessMode

[PATCH] D156728: [Sema] Ignore nullability qualifiers when deducing types for `auto` and `__auto_type`

2023-07-31 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Also, `_Atomic` has the same problem, but it's not clear whether we want to 
strip the qualifiers. See https://github.com/llvm/llvm-project/issues/63659


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156728

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


[PATCH] D156728: [Sema] Ignore nullability qualifiers when deducing types for `auto` and `__auto_type`

2023-07-31 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3885
 ParamType = ParamType.getUnqualifiedType();
+(void)AttributedType::stripOuterNullability(ParamType);
+  }

This isn't needed to fix the test cases I added, but I think the nullability 
qualifiers should be stripped here regardless.



Comment at: clang/test/SemaCXX/nullability.cpp:150
+  int * _Nonnull c = b; // OK.
+  foo(ptr); // _Nullable on ptr is ignored when T's type is deduced.
+}

Note that the template parameter for `foo` is correctly deduced (i.e., 
`_Nullable` is ignored) without this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156728

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


[PATCH] D156728: [Sema] Ignore nullability qualifiers when deducing types for `auto` and `__auto_type`

2023-07-31 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: doug.gregor, rjmccall.
ahatanak added a project: clang.
Herald added a project: All.
ahatanak requested review of this revision.

Prior to https://reviews.llvm.org/D110216, the deduced types didn't inherit the 
nullability qualifiers of the initializer expressions. This patch restores the 
previous behavior.

See https://developer.apple.com/forums/thread/726000#72621 for background.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156728

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/Sema/nullability.c
  clang/test/SemaCXX/nullability.cpp


Index: clang/test/SemaCXX/nullability.cpp
===
--- clang/test/SemaCXX/nullability.cpp
+++ clang/test/SemaCXX/nullability.cpp
@@ -137,6 +137,21 @@
   Template tip;
 }
 
+namespace test_auto {
+
+template 
+void foo(T t) {
+  int * _Nonnull x = t; // OK.
+}
+
+void test(int * _Nullable ptr) {
+  auto b = ptr; // _Nullable on ptr is ignored when b's type is deduced.
+  int * _Nonnull c = b; // OK.
+  foo(ptr); // _Nullable on ptr is ignored when T's type is deduced.
+}
+
+}
+
 namespace GH60344 {
 class a;
 template  using c = b _Nullable; // expected-error {{'_Nullable' 
cannot be applied to non-pointer type 'GH60344::a'}}
Index: clang/test/Sema/nullability.c
===
--- clang/test/Sema/nullability.c
+++ clang/test/Sema/nullability.c
@@ -125,9 +125,11 @@
   int *a = ptr; // okay
   _Nonnull int *b = ptr; // expected-warning{{implicit conversion from 
nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * 
_Nonnull'}}
   b = ptr; // expected-warning{{implicit conversion from nullable pointer 'int 
* _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
-  __auto_type _Nonnull c = ptr; // expected-warning{{implicit conversion from 
nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * 
_Nullable _Nonnull'}}
+  __auto_type _Nonnull c = ptr; // expected-warning{{implicit conversion from 
nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * 
_Nonnull'}}
 
   accepts_nonnull_1(ptr); // expected-warning{{implicit conversion from 
nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * 
_Nonnull'}}
+  __auto_type d = ptr; // _Nullable on ptr is ignored when d's type is deduced.
+  b = d; // OK.
 }
 
 // Check nullability of conditional expressions.
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3879,8 +3879,11 @@
   // C++0x [temp.deduct.call]p3:
   //   If P is a cv-qualified type, the top level cv-qualifiers of P's type
   //   are ignored for type deduction.
-  if (ParamType.hasQualifiers())
+  // Ignore top level nullability qualifiers too.
+  if (ParamType.hasQualifiers()) {
 ParamType = ParamType.getUnqualifiedType();
+(void)AttributedType::stripOuterNullability(ParamType);
+  }
 
   //   [...] If P is a reference type, the type referred to by P is
   //   used for type deduction.
@@ -3927,7 +3930,9 @@
 else {
   // - If A is a cv-qualified type, the top level cv-qualifiers of A's
   //   type are ignored for type deduction.
+  // Ignore top level nullability qualifiers too.
   ArgType = ArgType.getUnqualifiedType();
+  (void)AttributedType::stripOuterNullability(ArgType);
 }
   }
 


Index: clang/test/SemaCXX/nullability.cpp
===
--- clang/test/SemaCXX/nullability.cpp
+++ clang/test/SemaCXX/nullability.cpp
@@ -137,6 +137,21 @@
   Template tip;
 }
 
+namespace test_auto {
+
+template 
+void foo(T t) {
+  int * _Nonnull x = t; // OK.
+}
+
+void test(int * _Nullable ptr) {
+  auto b = ptr; // _Nullable on ptr is ignored when b's type is deduced.
+  int * _Nonnull c = b; // OK.
+  foo(ptr); // _Nullable on ptr is ignored when T's type is deduced.
+}
+
+}
+
 namespace GH60344 {
 class a;
 template  using c = b _Nullable; // expected-error {{'_Nullable' cannot be applied to non-pointer type 'GH60344::a'}}
Index: clang/test/Sema/nullability.c
===
--- clang/test/Sema/nullability.c
+++ clang/test/Sema/nullability.c
@@ -125,9 +125,11 @@
   int *a = ptr; // okay
   _Nonnull int *b = ptr; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
   b = ptr; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
-  __auto_type _Nonnull c = ptr; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nullable _Nonnull'}}
+  __auto_type _Nonnull c = ptr; // expected-warning{{impl

[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-07-31 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:291
+  /// the frontend.
+  OpenMPDirectiveKind PrevMappedDirective = llvm::omp::OMPD_unknown;
+

I don't see where this field is stored/loaded for PCH support. You need add a 
support for this in Serialization.



Comment at: clang/include/clang/AST/StmtOpenMP.h:611-614
+  void setMappedDirective(OpenMPDirectiveKind MappedDirective) {
+PrevMappedDirective = MappedDirective;
+  }
+

Better to make it a part of Create member function rather than having a 
separate function for this.


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

https://reviews.llvm.org/D144634

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


[PATCH] D156565: Diagnose use of VLAs in C++ by default

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D156565#4543503 , @aaron.ballman 
wrote:

> In D156565#4543414 , @jrtc27 wrote:
>
>> Given GCC defines GNU C++ and regards this as a feature (unless you use 
>> things like -pedantic to ask for ISO C++), does it make sense to enable this 
>> for GNU C++?
>
> I think GCC should enable -Wvla by default in GNU C++ as well, for the same 
> reasons I'm proposing it for Clang. I've filed an issue for it at 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110848

The GCC conversation is leaning towards only diagnosing by default in C++ mode 
but not in GNU++ mode. I'm still trying to persuade them to diagnose in both 
modes one last time, but if it looks like they're firm about not diagnosing in 
GNU++ mode, I can live with that (for now). It at least improves our security 
posture a bit, so it's definitely a win.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156565

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


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-07-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D156724#4547891 , @gruuprasad 
wrote:

> Sure, Initially I didn't find the folder `StaticAnalysis` in the `clang/test` 
> folder, found that relevant tests are in `test/Analysis`.

Correct, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156724

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


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-07-31 Thread Guruprasad Hegde via Phabricator via cfe-commits
gruuprasad added a comment.

Sure, Initially I didn't find the folder `StaticAnalysis` in the `clang/test` 
folder, found that relevant tests are in `test/Analysis`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156724

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


[PATCH] D156244: [clang] Do not crash on use of a variadic overloaded operator

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: cor3ntin, hubert.reinterpretcast, rsmith.
aaron.ballman added inline comments.



Comment at: clang/test/SemaCXX/overloaded-operator-decl.cpp:64
+class E {};
+void operator+(E, ...) {} // expected-error{{overloaded 'operator+' cannot be 
variadic}}
+void d() { E() + E(); }

Fznamznon wrote:
> aaron.ballman wrote:
> > I think it might make sense to extend the test coverage for the other 
> > operators you can overload, just to demonstrate we diagnose them all 
> > consistently. WDYT?
> Okay, while trying to add more test cases I discovered that following
> ```
> class E {};
> bool operator<(const E& lhs, ...);
> auto operator<=>(const E& lhs, ...);
> 
> void d() {
>   E() < E();
> }
> ```
> crashes even with the patch since there is code searching for best overload 
> candidate that doesn't consider possibility for them making variadic.
> The code around overloading is actually pretty inconsistent, somewhere 
> invalid candidates are considered, and somewhere not, so I spent some time 
> not knowing what to do.
> I'm now inclined that we just shouldn't consider invalid candidates like 
> @shafik 
> suggests. WDYY?
> 
Overload resolution doesn't need to produce a candidate that's viable to call; 
C++ lets you resolve to the "best viable function" only to say "and that one 
wasn't good enough either." e.g., http://eel.is/c++draft/over#match.general-3

I've not yet spotted anything in http://eel.is/c++draft/over that says invalid 
declarations should/should not be added to the initial candidate set. I *think* 
the intention is that if name lookup can find the name, it goes into the 
candidate set. Then that set is processed to remove functions that are not 
viable (http://eel.is/c++draft/over.match.viable). Then we find the best viable 
function from that set.

I think we should be keeping the function in the candidate set so long as it 
matches the rules in http://eel.is/c++draft/over.match.viable even if the 
function is otherwise not viable. Otherwise, correcting an unrelated issue 
might change overload resolution to find a completely different function. e.g., 
in my example above, we'd select `void overloaded(int);` as the best viable 
function, but when the user corrects the `float` function, we'd change to call 
that instead. I think it's easier to understand what's going on when picking 
the `float` overload to begin with and saying "but we can't call that because 
it's busted".

CC @cor3ntin @hubert.reinterpretcast @rsmith for some extra opinions, as I'm 
not certain if I'm interpreting the standard correctly or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156244

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


[clang] 3a100ea - Fix test to not write temporary files, use -fsyntax-only instead

2023-07-31 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2023-07-31T19:01:44Z
New Revision: 3a100ea901ed79d6a06a5f018be2b4d3bbca51e8

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

LOG: Fix test to not write temporary files, use -fsyntax-only instead

Added: 


Modified: 
clang/test/CodeGen/PowerPC/builtins-ppc-vec-ins-error.c

Removed: 




diff  --git a/clang/test/CodeGen/PowerPC/builtins-ppc-vec-ins-error.c 
b/clang/test/CodeGen/PowerPC/builtins-ppc-vec-ins-error.c
index de9e4a26badb63..f5149bf4ce8fda 100644
--- a/clang/test/CodeGen/PowerPC/builtins-ppc-vec-ins-error.c
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-vec-ins-error.c
@@ -1,16 +1,16 @@
 // REQUIRES: powerpc-registered-target
 
-// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 \
+// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 -fsyntax-only \
 // RUN:   -triple powerpc64le-unknown-unknown -emit-llvm -ferror-limit 10 %s 
-verify -D __TEST_ELT_SI
-// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 \
+// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 -fsyntax-only \
 // RUN:   -triple powerpc64-unknown-unknown -emit-llvm -ferror-limit 10 %s 
-verify -D __TEST_ELT_F
-// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 \
+// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 -fsyntax-only \
 // RUN:   -triple powerpc64le-unknown-unknown -emit-llvm -ferror-limit 10 %s 
-verify -D __TEST_ELT_SLL
-// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 \
+// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 -fsyntax-only \
 // RUN:   -triple powerpc64-unknown-unknown -emit-llvm -ferror-limit 10 %s 
-verify -D __TEST_ELT_D
-// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 \
+// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 -fsyntax-only \
 // RUN:   -triple powerpc64le-unknown-unknown -emit-llvm -ferror-limit 10 %s 
-verify -D __TEST_UNALIGNED_UI
-// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 \
+// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +vsx 
-target-cpu pwr10 -fsyntax-only \
 // RUN:   -triple powerpc64-unknown-unknown -emit-llvm -ferror-limit 10 %s 
-verify
 
 #include 



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


[PATCH] D105671: [Intrinsics][ObjC] Mark objc_retain and friends as thisreturn.

2023-07-31 Thread Nikita Popov via Phabricator via cfe-commits
nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: StephenFan.

Please separate the change to stripPointerCasts() into a separate review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105671

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


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-07-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Could you please add a test for the patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156724

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


[PATCH] D105671: [Intrinsics][ObjC] Mark objc_retain and friends as thisreturn.

2023-07-31 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 545752.
Herald added a project: All.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105671

Files:
  clang/test/CodeGenObjC/arc.m
  clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/Value.h
  llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
  llvm/lib/IR/Value.cpp

Index: llvm/lib/IR/Value.cpp
===
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -662,7 +662,8 @@
   V = cast(V)->getIncomingValue(0);
 } else {
   if (const auto *Call = dyn_cast(V)) {
-if (const Value *RV = Call->getReturnedArgOperand()) {
+if (const Value *RV = Call->getReturnedArgOperand();
+RV && StripKind == PSK_ForAliasAnalysis) {
   V = RV;
   continue;
 }
Index: llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
===
--- llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
+++ llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
@@ -162,6 +162,16 @@
 CallInst::TailCallKind TCK = CI->getTailCallKind();
 NewCI->setTailCallKind(std::max(TCK, OverridingTCK));
 
+// Transfer the 'returned' attribute from the intrinsic to the call site.
+// By applying this only to intrinsic call sites, we avoid applying it to
+// non-ARC explicit calls to things like objc_retain which have not been
+// auto-upgraded to use the intrinsics.
+unsigned Index;
+if (F.getAttributes().hasAttrSomewhere(Attribute::Returned, &Index) &&
+Index)
+  NewCI->addParamAttr(Index - AttributeList::FirstArgIndex,
+  Attribute::Returned);
+
 if (!CI->use_empty())
   CI->replaceAllUsesWith(NewCI);
 CI->eraseFromParent();
Index: llvm/include/llvm/IR/Value.h
===
--- llvm/include/llvm/IR/Value.h
+++ llvm/include/llvm/IR/Value.h
@@ -656,7 +656,7 @@
   }
 
   /// Strip off pointer casts, all-zero GEPs, single-argument phi nodes and
-  /// invariant group info.
+  /// invariant group info. Looks through returned arg functions.
   ///
   /// Returns the original uncasted value.  If this is called on a non-pointer
   /// value, it returns 'this'. This function should be used only in
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -720,11 +720,13 @@
 // eliminate retain and releases where possible.
 
 def int_objc_autorelease: Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_autoreleasePoolPop : Intrinsic<[], [llvm_ptr_ty]>;
 def int_objc_autoreleasePoolPush: Intrinsic<[llvm_ptr_ty], []>;
 def int_objc_autoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_copyWeak   : Intrinsic<[],
 [llvm_ptr_ty,
  llvm_ptr_ty]>;
@@ -741,13 +743,17 @@
  llvm_ptr_ty]>;
 def int_objc_release: Intrinsic<[], [llvm_ptr_ty]>;
 def int_objc_retain : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_retainAutorelease  : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_retainAutoreleaseReturnValue   : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_retainAutoreleasedReturnValue  : Intrinsic<[llvm_ptr_ty],
-[llvm_ptr_ty]>;
+[llvm_ptr_ty],
+[Returned>]>;
 def int_objc_retainBlock

[PATCH] D156726: Make globals with mutable members non-constant, even in custom sections

2023-07-31 Thread David Blaikie via Phabricator via cfe-commits
dblaikie created this revision.
Herald added subscribers: kerbowa, jvesely.
Herald added a project: All.
dblaikie requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Turned out we were making overly simple assumptions about which sections (& 
section flags) would be used when emitting a global into a custom section. This 
lead to sections with read-only flags being used for globals of struct types 
with mutable members.

Fixed by porting the codegen function with the more nuanced handling/checking 
for mutable members out of codegen for use in the sema code that does this 
initial checking/mapping to section flags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156726

Files:
  clang/include/clang/AST/Type.h
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/sections.cpp
  clang/test/SemaCXX/attr-section.cpp

Index: clang/test/SemaCXX/attr-section.cpp
===
--- clang/test/SemaCXX/attr-section.cpp
+++ clang/test/SemaCXX/attr-section.cpp
@@ -48,3 +48,24 @@
 const int const_global_var __attribute__((section("template_fn1"))) = 42;   // expected-error {{'const_global_var' causes a section type conflict with 'template_fn1'}}
 int mut_global_var __attribute__((section("template_fn2"))) = 42;   // expected-note {{declared here}}
 template  __attribute__((section("template_fn2"))) void template_fn2() {} // expected-error {{'template_fn2' causes a section type conflict with 'mut_global_var'}}
+
+namespace mutable_member {
+struct t1 {
+  mutable int i;
+};
+extern const t1 v1;
+__attribute__((section("mutable_member"))) const t1 v1{};
+extern int i;
+__attribute__((section("mutable_member"))) int i{};
+} // namespace mutable_member
+
+namespace non_trivial_ctor {
+struct t1 {
+  t1();
+  constexpr t1(int) { }
+};
+extern const t1 v1;
+__attribute__((section("non_trivial_ctor"))) const t1 v1; // expected-note {{declared here}}
+extern const t1 v2;
+__attribute__((section("non_trivial_ctor"))) const t1 v2{3}; // expected-error {{'v2' causes a section type conflict with 'v1'}}
+} // namespace non_trivial_ctor
Index: clang/test/CodeGenCXX/sections.cpp
===
--- clang/test/CodeGenCXX/sections.cpp
+++ clang/test/CodeGenCXX/sections.cpp
@@ -74,6 +74,14 @@
 #pragma section("short_section", short)
 // Pragma section ignores "short".
 __declspec(allocate("short_section")) short short_var = 42;
+
+struct t1 { mutable int i; };
+extern const t1 mutable_var;
+__declspec(allocate("mutable_section")) const t1 mutable_var;
+
+struct t2 { t2(); };
+extern const t2 non_trivial_ctor;
+__declspec(allocate("non_trivial_ctor_section")) const t2 non_trivial_ctor_var;
 }
 
 //CHECK: @D = dso_local global i32 1
@@ -96,6 +104,8 @@
 //CHECK: @implicitly_read_write = dso_local global i32 42, section "no_section_attributes"
 //CHECK: @long_var = dso_local global i32 42, section "long_section"
 //CHECK: @short_var = dso_local global i16 42, section "short_section"
+//CHECK: @mutable_var = dso_local global %struct.t1 zeroinitializer, section "mutable_section"
+//CHECK: @non_trivial_ctor_var = internal global %struct.t2 zeroinitializer, section "non_trivial_ctor_section"
 //CHECK: define dso_local void @g()
 //CHECK: define dso_local void @h() {{.*}} section ".my_code"
 //CHECK: define dso_local void @h2() {{.*}} section ".my_code"
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14251,19 +14251,12 @@
   !inTemplateInstantiation()) {
 PragmaStack *Stack = nullptr;
 int SectionFlags = ASTContext::PSF_Read;
-if (var->getType().isConstQualified()) {
-  if (HasConstInit)
-Stack = &ConstSegStack;
-  else {
-Stack = &BSSSegStack;
-SectionFlags |= ASTContext::PSF_Write;
-  }
-} else if (var->hasInit() && HasConstInit) {
-  Stack = &DataSegStack;
-  SectionFlags |= ASTContext::PSF_Write;
+if (var->hasInit() && HasConstInit &&
+var->getType().isConstantStorage(Context, true, false)) {
+  Stack = &ConstSegStack;
 } else {
-  Stack = &BSSSegStack;
   SectionFlags |= ASTContext::PSF_Write;
+  Stack = var->hasInit() && HasConstInit ? &DataSegStack : &BSSSegStack;
 }
 if (const SectionAttr *SA = var->getAttr()) {
   if (SA->getSyntax() == AttributeCommonInfo::AS_Declspec)
Index: clang/lib/CodeGen/Targets/AMDGPU.cpp
===
--- clang/lib/CodeGen/Targets/AMDGPU.cpp
+++ clang/lib/CodeGen/T

[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D156539#4546834 , @AlexVlx wrote:

> In D156539#4542836 , @rjmccall 
> wrote:
>
>> We should probably write this code to work properly in case we add a target 
>> that makes `__builtin_alloca` return a pointer in the private address space. 
>>  Could you recover the target AS from the type of the expression instead of 
>> assuming `LangAS::Default`?
>
> I believe it should work as written (it is possible that I misunderstand the 
> objection, case in which I do apologise). The issue is precisely that for 
> some targets (amdgcn being one) `alloca` returns a pointer to private, which 
> doesn't compose with the default AS being unspecified / nonexistent, for some 
> languages (e.g. HIP,  C/C++ etc.). For the OCL case @arsenm mentions, I 
> believe that we make a choice based on `LangOpts.OpenCLGenericAddressSpace`, 
> and the code above would only be valid from the OCL language perspective iff 
> that is true. I've put together a short Godbolt that captures these (and the 
> bug the patch should fix, please see the bitcasts between ASes in the non-OCL 
> case): https://gcc.godbolt.org/z/sYGK76zqv.

An address space conversion is required in IR if there is a difference between 
the address space of the pointer type formally returned by the call to 
`__builtin_alloca` and the address space produced by the `alloca` operation in 
IR.  If Sema has set the type of `__builtin_alloca` to formally return 
something in the stack address space, no conversion is required.  What I'm 
saying that I'd like you to not directly refer to `LangAS::Default` in this 
code, because you're assuming that `__builtin_alloca` is always returning a 
pointer that's formally in `LangAS::Default`.  Please recover the target 
address space from the type of the expression.

Additionally, in IRGen we allow the target to hook address-space conversions; 
please call `performAddrSpaceCast` instead of directly emitting an 
`addrspacecast` instruction.


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

https://reviews.llvm.org/D156539

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


[PATCH] D156641: [Clang][Frontend] Change help text for --offload-host-device

2023-07-31 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D156641#4547718 , @AntonRydahl 
wrote:

> The tests that failed pass locally on my machine.

If the tests are clearly not related to your change, assume they are broken 
before or flaky.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156641

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


[PATCH] D156322: Outputs parameter comments using clang-doc and markdown generator

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG29b1af7396b0: Outputs parameter comments using clang-doc and 
markdown generator (authored by BotellaA, committed by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156322

Files:
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp


Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -347,9 +347,9 @@
 
  The description continues.
 
-**I** [out]
+**I** [out] is a parameter.
 
-**J**
+**J** is a parameter.
 
 **return**void
 
Index: clang-tools-extra/clang-doc/MDGenerator.cpp
===
--- clang-tools-extra/clang-doc/MDGenerator.cpp
+++ clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -82,10 +82,14 @@
 OS << genEmphasis(I.Name) << " " << I.Text;
   } else if (I.Kind == "ParamCommandComment") {
 std::string Direction = I.Explicit ? (" " + I.Direction).str() : "";
-OS << genEmphasis(I.ParamName) << I.Text << Direction << "\n\n";
+OS << genEmphasis(I.ParamName) << I.Text << Direction;
+for (const auto &Child : I.Children)
+  writeDescription(*Child, OS);
   } else if (I.Kind == "TParamCommandComment") {
 std::string Direction = I.Explicit ? (" " + I.Direction).str() : "";
-OS << genEmphasis(I.ParamName) << I.Text << Direction << "\n\n";
+OS << genEmphasis(I.ParamName) << I.Text << Direction;
+for (const auto &Child : I.Children)
+  writeDescription(*Child, OS);
   } else if (I.Kind == "VerbatimBlockComment") {
 for (const auto &Child : I.Children)
   writeDescription(*Child, OS);


Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -347,9 +347,9 @@
 
  The description continues.
 
-**I** [out]
+**I** [out] is a parameter.
 
-**J**
+**J** is a parameter.
 
 **return**void
 
Index: clang-tools-extra/clang-doc/MDGenerator.cpp
===
--- clang-tools-extra/clang-doc/MDGenerator.cpp
+++ clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -82,10 +82,14 @@
 OS << genEmphasis(I.Name) << " " << I.Text;
   } else if (I.Kind == "ParamCommandComment") {
 std::string Direction = I.Explicit ? (" " + I.Direction).str() : "";
-OS << genEmphasis(I.ParamName) << I.Text << Direction << "\n\n";
+OS << genEmphasis(I.ParamName) << I.Text << Direction;
+for (const auto &Child : I.Children)
+  writeDescription(*Child, OS);
   } else if (I.Kind == "TParamCommandComment") {
 std::string Direction = I.Explicit ? (" " + I.Direction).str() : "";
-OS << genEmphasis(I.ParamName) << I.Text << Direction << "\n\n";
+OS << genEmphasis(I.ParamName) << I.Text << Direction;
+for (const auto &Child : I.Children)
+  writeDescription(*Child, OS);
   } else if (I.Kind == "VerbatimBlockComment") {
 for (const auto &Child : I.Children)
   writeDescription(*Child, OS);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 29b1af7 - Outputs parameter comments using clang-doc and markdown generator

2023-07-31 Thread Aaron Ballman via cfe-commits

Author: Arnaud Botella
Date: 2023-07-31T14:27:15-04:00
New Revision: 29b1af7396b0839f076ca0a8ae3a5ac47ed55ee7

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

LOG: Outputs parameter comments using clang-doc and markdown generator

Current implementation outputs the parameter name when used with @param
(or @tparam) doxygen tag but not the comment itself.

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

Added: 


Modified: 
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/MDGenerator.cpp 
b/clang-tools-extra/clang-doc/MDGenerator.cpp
index 2f56fd99b7bdcf..795eb4b904e3ef 100644
--- a/clang-tools-extra/clang-doc/MDGenerator.cpp
+++ b/clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -82,10 +82,14 @@ static void writeDescription(const CommentInfo &I, 
raw_ostream &OS) {
 OS << genEmphasis(I.Name) << " " << I.Text;
   } else if (I.Kind == "ParamCommandComment") {
 std::string Direction = I.Explicit ? (" " + I.Direction).str() : "";
-OS << genEmphasis(I.ParamName) << I.Text << Direction << "\n\n";
+OS << genEmphasis(I.ParamName) << I.Text << Direction;
+for (const auto &Child : I.Children)
+  writeDescription(*Child, OS);
   } else if (I.Kind == "TParamCommandComment") {
 std::string Direction = I.Explicit ? (" " + I.Direction).str() : "";
-OS << genEmphasis(I.ParamName) << I.Text << Direction << "\n\n";
+OS << genEmphasis(I.ParamName) << I.Text << Direction;
+for (const auto &Child : I.Children)
+  writeDescription(*Child, OS);
   } else if (I.Kind == "VerbatimBlockComment") {
 for (const auto &Child : I.Children)
   writeDescription(*Child, OS);

diff  --git a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp 
b/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
index be9ccee3da0a35..1bbd24eebb784a 100644
--- a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -347,9 +347,9 @@ TEST(MDGeneratorTest, emitCommentMD) {
 
  The description continues.
 
-**I** [out]
+**I** [out] is a parameter.
 
-**J**
+**J** is a parameter.
 
 **return**void
 



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


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-07-31 Thread Guruprasad Hegde via Phabricator via cfe-commits
gruuprasad created this revision.
gruuprasad added reviewers: NoQ, xazax.hun.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, a.sidorin, szepet, baloghadamsoftware.
Herald added a project: All.
gruuprasad requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Link to every note with IDs start from 1 (instead of 0 as previously).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156724

Files:
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp


Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -592,11 +592,11 @@
 P->getLocation().asLocation().getExpansionLineNumber();
 int ColumnNumber =
 P->getLocation().asLocation().getExpansionColumnNumber();
+++NumExtraPieces;
 os << "Note:"
<< "line "
<< LineNumber << ", column " << ColumnNumber << ""
<< P->getString() << "";
-++NumExtraPieces;
   }
 }
 


Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -592,11 +592,11 @@
 P->getLocation().asLocation().getExpansionLineNumber();
 int ColumnNumber =
 P->getLocation().asLocation().getExpansionColumnNumber();
+++NumExtraPieces;
 os << "Note:"
<< "line "
<< LineNumber << ", column " << ColumnNumber << ""
<< P->getString() << "";
-++NumExtraPieces;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154328: [AST] Add API to iterate already loaded specializations

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D154328#4542457 , @Hahnfeld wrote:

> Let me see if I can come up a fix for that in `clang-repl` that would then 
> need this API. But for now, it's also fine for us if the patch stays pending 
> in review, still better than completely disconnected local commits...

Thank you for the explanation! I think it makes sense to hold off on landing 
this until clang-reply needs to use the API. The code changes themselves look 
correct to me, so the review should hopefully sail through once there's test 
coverage exercising the functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154328

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


[PATCH] D154475: [clang][Interp] Fix ignoring MaterializeTemporaryExprs

2023-07-31 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154475

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


  1   2   3   >