[clang] [clang-repl] Extend the C support. (PR #89804)

2024-05-19 Thread Vassil Vassilev via cfe-commits


@@ -407,6 +406,16 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit 
) {
   }
 }
   }
+
+  // FIXME: We should de-allocate MostRecentTU
+  for (Decl *D : MostRecentTU->decls()) {
+if (!isa(D))
+  continue;
+// Check if we need to clean up the IdResolver chain.
+NamedDecl *ND = cast(D);

vgvassilev wrote:

The `isa` + `cast` saves a few instructions in the case where `D` is not a 
`NamedDecl`. I'd prefer to stay the way it is although we are not expecting a 
lot of declarations that are not `NamedDecl`s.

https://github.com/llvm/llvm-project/pull/89804
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Chris Apple via cfe-commits


@@ -0,0 +1,106 @@
+//===--- radsan_context.cpp - Realtime Sanitizer --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//===--===//
+
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+using namespace __sanitizer;
+
+namespace detail {
+
+static pthread_key_t Key;

cjappl wrote:

Great thanks!! Before I go through and edit these, `snake_case` is preferred 
for variables in all contexts?

Really appreciate the review. Pushing up most of your requested changes now.

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d316a0b - [NFC] Remove unused ASTWriter::getTypeID

2024-05-19 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2024-05-20T13:36:46+08:00
New Revision: d316a0bd48ceb4a0ee851d729291a2cdcc8818eb

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

LOG: [NFC] Remove unused ASTWriter::getTypeID

As the title suggests, the `ASTWriter:getTypeID` method is not used.
This patch removes it.

Added: 


Modified: 
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Serialization/ASTCommon.h
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 6aa2796a41e0c..88192e439a3f0 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -715,9 +715,6 @@ class ASTWriter : public ASTDeserializationListener,
   /// Force a type to be emitted and get its ID.
   serialization::TypeID GetOrCreateTypeID(QualType T);
 
-  /// Determine the type ID of an already-emitted type.
-  serialization::TypeID getTypeID(QualType T) const;
-
   /// Find the first local declaration of a given local redeclarable
   /// decl.
   const Decl *getFirstLocalDecl(const Decl *D);

diff  --git a/clang/lib/Serialization/ASTCommon.h 
b/clang/lib/Serialization/ASTCommon.h
index 296642e3674a4..0230908d3e052 100644
--- a/clang/lib/Serialization/ASTCommon.h
+++ b/clang/lib/Serialization/ASTCommon.h
@@ -46,30 +46,6 @@ enum DeclUpdateKind {
 
 TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
 
-template 
-TypeID MakeTypeID(ASTContext , QualType T, IdxForTypeTy IdxForType) {
-  if (T.isNull())
-return PREDEF_TYPE_NULL_ID;
-
-  unsigned FastQuals = T.getLocalFastQualifiers();
-  T.removeLocalFastQualifiers();
-
-  if (T.hasLocalNonFastQualifiers())
-return IdxForType(T).asTypeID(FastQuals);
-
-  assert(!T.hasLocalQualifiers());
-
-  if (const BuiltinType *BT = dyn_cast(T.getTypePtr()))
-return TypeIdxFromBuiltin(BT).asTypeID(FastQuals);
-
-  if (T == Context.AutoDeductTy)
-return TypeIdx(PREDEF_TYPE_AUTO_DEDUCT).asTypeID(FastQuals);
-  if (T == Context.AutoRRefDeductTy)
-return TypeIdx(PREDEF_TYPE_AUTO_RREF_DEDUCT).asTypeID(FastQuals);
-
-  return IdxForType(T).asTypeID(FastQuals);
-}
-
 unsigned ComputeHash(Selector Sel);
 
 /// Retrieve the "definitive" declaration that provides all of the

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 2a107e4c56a3a..1d6d96932ba2c 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -6074,6 +6074,31 @@ void ASTWriter::AddTypeRef(QualType T, RecordDataImpl 
) {
   Record.push_back(GetOrCreateTypeID(T));
 }
 
+template 
+static TypeID MakeTypeID(ASTContext , QualType T,
+ IdxForTypeTy IdxForType) {
+  if (T.isNull())
+return PREDEF_TYPE_NULL_ID;
+
+  unsigned FastQuals = T.getLocalFastQualifiers();
+  T.removeLocalFastQualifiers();
+
+  if (T.hasLocalNonFastQualifiers())
+return IdxForType(T).asTypeID(FastQuals);
+
+  assert(!T.hasLocalQualifiers());
+
+  if (const BuiltinType *BT = dyn_cast(T.getTypePtr()))
+return TypeIdxFromBuiltin(BT).asTypeID(FastQuals);
+
+  if (T == Context.AutoDeductTy)
+return TypeIdx(PREDEF_TYPE_AUTO_DEDUCT).asTypeID(FastQuals);
+  if (T == Context.AutoRRefDeductTy)
+return TypeIdx(PREDEF_TYPE_AUTO_RREF_DEDUCT).asTypeID(FastQuals);
+
+  return IdxForType(T).asTypeID(FastQuals);
+}
+
 TypeID ASTWriter::GetOrCreateTypeID(QualType T) {
   assert(Context);
   return MakeTypeID(*Context, T, [&](QualType T) -> TypeIdx {
@@ -6097,19 +6122,6 @@ TypeID ASTWriter::GetOrCreateTypeID(QualType T) {
   });
 }
 
-TypeID ASTWriter::getTypeID(QualType T) const {
-  assert(Context);
-  return MakeTypeID(*Context, T, [&](QualType T) -> TypeIdx {
-if (T.isNull())
-  return TypeIdx();
-assert(!T.getLocalFastQualifiers());
-
-TypeIdxMap::const_iterator I = TypeIdxs.find(T);
-assert(I != TypeIdxs.end() && "Type not emitted!");
-return I->second;
-  });
-}
-
 void ASTWriter::AddEmittedDeclRef(const Decl *D, RecordDataImpl ) {
   if (!wasDeclEmitted(D))
 return;



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


[clang] [Coverage] Rework !SystemHeadersCoverage (PR #91446)

2024-05-19 Thread NAKAMURA Takumi via cfe-commits


@@ -2064,7 +2082,20 @@ struct CounterCoverageMappingBuilder
 createDecisionRegion(E, DecisionParams);
   }
 
+  /// Check if E belongs to system headers.
+  bool isExprInSystemHeader(const BinaryOperator *E) const {

chapuni wrote:

I assume each visitor (`visitBinLAnd` `visitBinLOr`) will not receive nullptr.

https://github.com/llvm/llvm-project/pull/91446
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Introduce `SemaRISCV` (PR #92682)

2024-05-19 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

I think it's a good rewrite. Added more RISCV guys.

https://github.com/llvm/llvm-project/pull/92682
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Chris Apple via cfe-commits


@@ -0,0 +1,71 @@
+# -*- Python -*-
+
+import os
+
+# Setup config name.
+config.name = "RADSAN" + config.name_suffix
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)

cjappl wrote:

Yes, the lit tests may be placed directly in `compiler-rt/test/radsan/` and 
they run as intended. Just checked on our branch that has them implemented.

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] add unnamed_addr function attribute (PR #92499)

2024-05-19 Thread YAMAMOTO Takashi via cfe-commits


@@ -1944,6 +1944,13 @@ def ReturnsTwice : InheritableAttr {
   let SimpleHandler = 1;
 }
 
+def UnnamedAddr : InheritableAttr {
+  let Spellings = [Clang<"unnamed_addr">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];

yamt wrote:

i added documentation

https://github.com/llvm/llvm-project/pull/92499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] add unnamed_addr function attribute (PR #92499)

2024-05-19 Thread YAMAMOTO Takashi via cfe-commits

https://github.com/yamt updated https://github.com/llvm/llvm-project/pull/92499

>From 52b744c91bdba1cf8cda9d6164ec8fc130d75fab Mon Sep 17 00:00:00 2001
From: YAMAMOTO Takashi 
Date: Fri, 17 May 2024 14:47:06 +0900
Subject: [PATCH 1/3] [clang] add unnamed_addr function attribute

It simply applies the LLVM attribute with the same name to the function.

Sometimes, a programmer knows that function pointer uniqueness doesn't
really matter for some of their functions. In that case, this attribute
opens a possibility of certain optimizations like mergefunc with aliases.
It's especially useful for code generators.
---
 clang/include/clang/Basic/Attr.td  | 7 +++
 clang/lib/CodeGen/CodeGenModule.cpp| 4 
 .../Misc/pragma-attribute-supported-attributes-list.test   | 1 +
 3 files changed, 12 insertions(+)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52552ba488560..3ee7d43d339f1 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1944,6 +1944,13 @@ def ReturnsTwice : InheritableAttr {
   let SimpleHandler = 1;
 }
 
+def UnnamedAddr : InheritableAttr {
+  let Spellings = [Clang<"unnamed_addr">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+  let SimpleHandler = 1;
+}
+
 def DisableTailCalls : InheritableAttr {
   let Spellings = [Clang<"disable_tail_calls">];
   let Subjects = SubjectList<[Function, ObjCMethod]>;
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 489c08a4d4819..ac9f082a1049b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2506,6 +2506,10 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   B.addAttribute(llvm::Attribute::MinSize);
   }
 
+  if (D->hasAttr()) {
+F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
+  }
+
   F->addFnAttrs(B);
 
   unsigned alignment = D->getMaxAlignment() / Context.getCharWidth();
diff --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test 
b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index 318bfb2df2a7a..62ab5cee27a71 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -199,6 +199,7 @@
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: TrivialABI (SubjectMatchRule_record)
 // CHECK-NEXT: Uninitialized (SubjectMatchRule_variable_is_local)
+// CHECK-NEXT: UnnamedAddr (SubjectMatchRule_function)
 // CHECK-NEXT: UnsafeBufferUsage (SubjectMatchRule_function)
 // CHECK-NEXT: UseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: VecReturn (SubjectMatchRule_record)

>From d96139b848f7536c927505d11a71c933d782a938 Mon Sep 17 00:00:00 2001
From: YAMAMOTO Takashi 
Date: Mon, 20 May 2024 13:57:26 +0900
Subject: [PATCH 2/3] style fix

---
 clang/lib/CodeGen/CodeGenModule.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index ac9f082a1049b..84b0ddf58059a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2506,9 +2506,8 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   B.addAttribute(llvm::Attribute::MinSize);
   }
 
-  if (D->hasAttr()) {
+  if (D->hasAttr())
 F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-  }
 
   F->addFnAttrs(B);
 

>From 68e92e93b05f956b10121953ee519297bf83c09a Mon Sep 17 00:00:00 2001
From: YAMAMOTO Takashi 
Date: Mon, 20 May 2024 14:16:20 +0900
Subject: [PATCH 3/3] document clang unnamed_addr attribute

---
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/include/clang/Basic/AttrDocs.td | 13 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 3ee7d43d339f1..0e19dce3b59f3 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1947,7 +1947,7 @@ def ReturnsTwice : InheritableAttr {
 def UnnamedAddr : InheritableAttr {
   let Spellings = [Clang<"unnamed_addr">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [UnnamedAddrDocs];
   let SimpleHandler = 1;
 }
 
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f351822ac74bd..96ff6e38286c0 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4960,6 +4960,19 @@ templates.
   }];
 }
 
+def UnnamedAddrDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``unnamed_addr`` attribute instructs the backend that the pointer of
+the marked function is not significant.
+While this attribute opens a possibility of certain optimizations 

[clang] [clang] Introduce `SemaCoroutine` (PR #92645)

2024-05-19 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> While I am not against the idea about splitting Sema, the implementation 
> detail makes me slightly concerning. What I had in mind is to split SemaC, 
> SemaCXX (this can be derived class of SemaCXX), SemaObjC and other dialects 
> (e.g., ACC or CUDA) out of Sema.

Inheritance is problematic, because it can't work off forward declarations of 
base classes. I believe there is still hope that we can reduce the blast radius 
of header changes in terms of TUs being recompiled.

Also note that language dialects you have in mind have already been moved 
outside of `Sema`.

> Then big features of C++ can be member of SemaCXX as SemaCoroutine, 
> SemaConcept...

This would mean even more hierarchy than just `Sema` containing a flat list of 
references to its parts. I'm not particularly opposed to it, but it's not on my 
radar at the moment. It would impact usage side, e.g. 
`Actions.CXX().Coroutine().ActOnCoawaitExpr()`, and I can see why people would 
be opposed to it.

https://github.com/llvm/llvm-project/pull/92645
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Introduce `SemaRISCV` (PR #92682)

2024-05-19 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

It is, but I guess significant enough to not be disguised by labeling as NFC.

https://github.com/llvm/llvm-project/pull/92682
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV] Remove unneeded multiply in RISCV CodeGenTypes (PR #92644)

2024-05-19 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/92644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Introduce `SemaRISCV` (PR #92682)

2024-05-19 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

Is it a NFC?

https://github.com/llvm/llvm-project/pull/92682
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)

2024-05-19 Thread Hubert Tong via cfe-commits


@@ -3622,15 +3623,15 @@ def Fma : FPMathTemplate, LibBuiltin<"math.h"> {
 
 def Fmax : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["fmax"];
-  let Attributes = [NoThrow, Const];
+  let Attributes = [NoThrow, Const, Constexpr];

hubert-reinterpretcast wrote:

Same comment re: making the non-prefixed versions `constexpr` only for C++23 
and up.

https://github.com/llvm/llvm-project/pull/88978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)

2024-05-19 Thread Hubert Tong via cfe-commits


@@ -3622,15 +3623,15 @@ def Fma : FPMathTemplate, LibBuiltin<"math.h"> {
 
 def Fmax : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["fmax"];
-  let Attributes = [NoThrow, Const];
+  let Attributes = [NoThrow, Const, Constexpr];
   let Prototype = "T(T, T)";
   let AddBuiltinPrefixedAlias = 1;
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
 def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["fmin"];
-  let Attributes = [NoThrow, Const];
+  let Attributes = [NoThrow, Const, Constexpr];

hubert-reinterpretcast wrote:

Same comment re: making the non-prefixed versions `constexpr` only for C++23 
and up.

https://github.com/llvm/llvm-project/pull/88978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MC/DC][Coverage] Add assertions into emitSourceRegions() (PR #89572)

2024-05-19 Thread Jessica Paquette via cfe-commits


@@ -190,6 +190,16 @@ class SourceMappingRegion {
 
   bool isBranch() const { return FalseCount.has_value(); }
 
+  bool isMCDCBranch() const {
+const auto *BranchParams = 
std::get_if();
+assert(BranchParams == nullptr || BranchParams->ID >= 0);
+return (BranchParams != nullptr);
+  }
+
+  const auto () const {

ornata wrote:

unused function?

https://github.com/llvm/llvm-project/pull/89572
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Coverage] Rework !SystemHeadersCoverage (PR #91446)

2024-05-19 Thread Jessica Paquette via cfe-commits


@@ -2064,7 +2082,20 @@ struct CounterCoverageMappingBuilder
 createDecisionRegion(E, DecisionParams);
   }
 
+  /// Check if E belongs to system headers.
+  bool isExprInSystemHeader(const BinaryOperator *E) const {

ornata wrote:

assert E is not nullptr?

https://github.com/llvm/llvm-project/pull/91446
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)

2024-05-19 Thread Jessica Paquette via cfe-commits


@@ -517,7 +552,7 @@ class CoverageMappingBuilder {
 SourceRegionFilter Filter;
 for (const auto  : FileIDMapping) {
   SourceLocation ExpandedLoc = FM.second.second;
-  SourceLocation ParentLoc = getIncludeOrExpansionLoc(ExpandedLoc);
+  SourceLocation ParentLoc = getIncludeOrExpansionLoc(ExpandedLoc, false);

ornata wrote:

The boolean parameter for this function is only used in this single callsite. 
Do we need it at all?

https://github.com/llvm/llvm-project/pull/89869
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV] Remove unneeded multiply in RISCV CodeGenTypes (PR #92644)

2024-05-19 Thread Kito Cheng via cfe-commits

https://github.com/kito-cheng approved this pull request.


https://github.com/llvm/llvm-project/pull/92644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,71 @@
+# -*- Python -*-
+
+import os
+
+# Setup config name.
+config.name = "RADSAN" + config.name_suffix
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)

MaskRay wrote:

`msan`, `lsan`, `gwp_asan` places lit tests directly under the directory, while 
some use `TestCases/`. Avoiding `TestCases` is preferred. Is the lit set up to 
avoid `TestCases`?

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,413 @@
+//===--- radsan_interceptors.cpp - Realtime Sanitizer --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//===--===//
+
+#include "radsan/radsan_interceptors.h"
+
+#include "sanitizer_common/sanitizer_platform.h"
+#include "sanitizer_common/sanitizer_platform_interceptors.h"
+
+#include "interception/interception.h"
+#include "radsan/radsan_context.h"
+
+#if !SANITIZER_LINUX && !SANITIZER_APPLE
+#error Sorry, radsan does not yet support this platform
+#endif
+
+#if SANITIZER_APPLE
+#include 
+#include 
+#endif
+
+#if SANITIZER_INTERCEPT_MEMALIGN || SANITIZER_INTERCEPT_PVALLOC
+#include 
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace __sanitizer;
+
+namespace radsan {
+void ExpectNotRealtime(const char *InterceptedFunctionName) {
+  GetContextForThisThread().ExpectNotRealtime(InterceptedFunctionName);
+}
+} // namespace radsan
+
+/*

MaskRay wrote:

Avoid `/*` in C++ files

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,38 @@
+//===--- radsan_context.h - Realtime Sanitizer --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//===--===//
+
+#pragma once
+
+namespace radsan {

MaskRay wrote:

`__radsan` to avoid conflicts with user programs

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,52 @@
+//===--- radsan_stack.cpp - Realtime Sanitizer --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//===--===//
+
+#include 
+#include 
+
+using namespace __sanitizer;
+
+// We must define our own implementation of this method for our runtime.
+// This one is just copied from UBSan.
+
+namespace __sanitizer {
+void BufferedStackTrace::UnwindImpl(uptr pc, uptr bp, void *context,
+bool request_fast, u32 max_depth) {
+  uptr top = 0;
+  uptr bottom = 0;
+  GetThreadStackTopAndBottom(false, , );
+  bool fast = StackTrace::WillUseFastUnwind(request_fast);
+  Unwind(max_depth, pc, bp, context, top, bottom, fast);
+}
+} // namespace __sanitizer
+
+namespace {
+void SetGlobalStackTraceFormat() {
+  SetCommonFlagsDefaults();
+  CommonFlags cf;
+  cf.CopyFrom(*common_flags());
+  cf.stack_trace_format = "DEFAULT";
+  cf.external_symbolizer_path = GetEnv("RADSAN_SYMBOLIZER_PATH");
+  OverrideCommonFlags(cf);
+}
+} // namespace
+
+namespace radsan {
+void PrintStackTrace() {

MaskRay wrote:

https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions

`void radsan::PrintStackTrace`

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,106 @@
+//===--- radsan_context.cpp - Realtime Sanitizer --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//===--===//
+
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+using namespace __sanitizer;
+
+namespace detail {
+
+static pthread_key_t Key;

MaskRay wrote:

Avoid `VariableName` in new compiler-rt code.

Use the recommended `variable_name` like asan/hwasan/lsan. Some new compiler-rt 
subprojects used `Variable` as cargo culting llvm/ and clang/, which is a pity 
(you can also read https://llvm.org/docs/Proposals/VariableNames.html for more 
history)

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,50 @@
+//===--- radsan.h - Realtime Sanitizer --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//===--===//
+
+#pragma once
+
+#include "sanitizer_common/sanitizer_internal_defs.h"
+
+extern "C" {
+
+/**  Initialise radsan interceptors.
+
+  A call to this method is added to the preinit array on Linux systems.
+*/
+SANITIZER_INTERFACE_ATTRIBUTE void radsan_init();
+
+/** Enter real-time context.
+
+  When in a real-time context, RADSan interceptors will error if realtime
+  violations are detected. Calls to this method are injected at the code
+  generation stage when RADSan is enabled.
+*/
+SANITIZER_INTERFACE_ATTRIBUTE void radsan_realtime_enter();

MaskRay wrote:

Use `__*` names to avoid conflicts with user code. Use `//`.

If there are user APIs, define them at `include/sanitizer/*_interface.h`

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,52 @@
+//===--- radsan_stack.cpp - Realtime Sanitizer --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//===--===//
+
+#include 
+#include 
+
+using namespace __sanitizer;
+
+// We must define our own implementation of this method for our runtime.
+// This one is just copied from UBSan.
+
+namespace __sanitizer {
+void BufferedStackTrace::UnwindImpl(uptr pc, uptr bp, void *context,
+bool request_fast, u32 max_depth) {
+  uptr top = 0;
+  uptr bottom = 0;
+  GetThreadStackTopAndBottom(false, , );
+  bool fast = StackTrace::WillUseFastUnwind(request_fast);
+  Unwind(max_depth, pc, bp, context, top, bottom, fast);
+}
+} // namespace __sanitizer
+
+namespace {
+void SetGlobalStackTraceFormat() {

MaskRay wrote:

https://llvm.org/docs/CodingStandards.html#anonymous-namespaces

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,71 @@
+# -*- Python -*-

MaskRay wrote:

Delete

Some older `lit.cfg.py` files might use this because previously they were named 
`lit.cfg`

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][driver] add pointer qualifier to auto type (PR #91874)

2024-05-19 Thread Mohammed Keyvanzadeh via cfe-commits

VoltrexKeyva wrote:

Pinging are there haven't been any reviews in a week.

https://github.com/llvm/llvm-project/pull/91874
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-19 Thread Shengchen Kan via cfe-commits




KanRobert wrote:

Merge the two tests into one and put it under apx directory.

https://github.com/llvm/llvm-project/pull/92338
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)

2024-05-19 Thread Hubert Tong via cfe-commits


@@ -14683,6 +14710,23 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
   default:
 return false;
 
+  case Builtin::BI__builtin_frexp:
+  case Builtin::BI__builtin_frexpf:
+  case Builtin::BI__builtin_frexpl: {

hubert-reinterpretcast wrote:

`__builtin_frexpf16` and `__builtin_frexp128` should probably be added at the 
same time as the other `__builtin_*` cases.

https://github.com/llvm/llvm-project/pull/88978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)

2024-05-19 Thread Hubert Tong via cfe-commits


@@ -3452,9 +3452,10 @@ def Fmod : FPMathTemplate, LibBuiltin<"math.h"> {
 
 def Frexp : FPMathTemplate, LibBuiltin<"math.h"> {

hubert-reinterpretcast wrote:

There is a separate `FrexpF16F128` that should probably also be updated.

https://github.com/llvm/llvm-project/pull/88978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Serialization] Read the initializer for interesting static variables before consuming it (PR #92353)

2024-05-19 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 closed 
https://github.com/llvm/llvm-project/pull/92353
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fc0144a - [Serialization] Read the initializer for interesting static variables before consuming it (#92353)

2024-05-19 Thread via cfe-commits

Author: Chuanqi Xu
Date: 2024-05-20T10:36:03+08:00
New Revision: fc0144a30cf20d6405411da141d11bfde143d3d2

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

LOG: [Serialization] Read the initializer for interesting static variables 
before consuming it (#92353)

Close https://github.com/llvm/llvm-project/issues/91418

Since we load the variable's initializers lazily, it'd be problematic if
the initializers dependent on each other. So here we try to load the
initializers of static variables to make sure they are passed to code
generator by order. If we read any thing interesting, we would consume
that before emitting the current declaration.

Added: 
clang/test/Modules/pr91418.cppm

Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp
clang/test/OpenMP/nvptx_lambda_capturing.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 0c647086e304a..a6254b70560c3 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -4186,12 +4186,35 @@ void ASTReader::PassInterestingDeclsToConsumer() {
 GetDecl(ID);
   EagerlyDeserializedDecls.clear();
 
-  while (!PotentiallyInterestingDecls.empty()) {
-Decl *D = PotentiallyInterestingDecls.front();
-PotentiallyInterestingDecls.pop_front();
+  auto ConsumingPotentialInterestingDecls = [this]() {
+while (!PotentiallyInterestingDecls.empty()) {
+  Decl *D = PotentiallyInterestingDecls.front();
+  PotentiallyInterestingDecls.pop_front();
+  if (isConsumerInterestedIn(D))
+PassInterestingDeclToConsumer(D);
+}
+  };
+  std::deque MaybeInterestingDecls =
+  std::move(PotentiallyInterestingDecls);
+  assert(PotentiallyInterestingDecls.empty());
+  while (!MaybeInterestingDecls.empty()) {
+Decl *D = MaybeInterestingDecls.front();
+MaybeInterestingDecls.pop_front();
+// Since we load the variable's initializers lazily, it'd be problematic
+// if the initializers dependent on each other. So here we try to load the
+// initializers of static variables to make sure they are passed to code
+// generator by order. If we read anything interesting, we would consume
+// that before emitting the current declaration.
+if (auto *VD = dyn_cast(D);
+VD && VD->isFileVarDecl() && !VD->isExternallyVisible())
+  VD->getInit();
+ConsumingPotentialInterestingDecls();
 if (isConsumerInterestedIn(D))
   PassInterestingDeclToConsumer(D);
   }
+
+  // If we add any new potential interesting decl in the last call, consume it.
+  ConsumingPotentialInterestingDecls();
 }
 
 void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord ) {

diff  --git a/clang/test/Modules/pr91418.cppm b/clang/test/Modules/pr91418.cppm
new file mode 100644
index 0..b507df162643b
--- /dev/null
+++ b/clang/test/Modules/pr91418.cppm
@@ -0,0 +1,65 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -x c++-header 
%t/foo.h \
+// RUN: -emit-pch -o %t/foo.pch
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/use.cpp 
-include-pch \
+// RUN: %t/foo.pch -emit-llvm -o - | FileCheck %t/use.cpp
+
+//--- foo.h
+#ifndef FOO_H
+#define FOO_H
+typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
+
+static __inline__ __m128 __attribute__((__always_inline__, 
__min_vector_width__(128)))
+_mm_setr_ps(float __z, float __y, float __x, float __w)
+{
+  return __extension__ (__m128){ __z, __y, __x, __w };
+}
+
+typedef __m128 VR;
+
+inline VR MakeVR( float X, float Y, float Z, float W )
+{
+ return _mm_setr_ps( X, Y, Z, W );
+}
+
+extern "C" float sqrtf(float);
+
+namespace VectorSinConstantsSSE
+{
+  float a = (16 * sqrtf(0.225f));
+  VR A = MakeVR(a, a, a, a);
+  static const float b = (16 * sqrtf(0.225f));
+  static const VR B = MakeVR(b, b, b, b);
+}
+
+#endif // FOO_H
+
+//--- use.cpp
+#include "foo.h"
+float use() {
+return VectorSinConstantsSSE::A[0] + VectorSinConstantsSSE::A[1] +
+   VectorSinConstantsSSE::A[2] + VectorSinConstantsSSE::A[3] +
+   VectorSinConstantsSSE::B[0] + VectorSinConstantsSSE::B[1] +
+   VectorSinConstantsSSE::B[2] + VectorSinConstantsSSE::B[3];
+}
+
+// CHECK: define{{.*}}@__cxx_global_var_init(
+// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSE1aE
+
+// CHECK: define{{.*}}@__cxx_global_var_init.1(
+// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSE1AE
+
+// CHECK: define{{.*}}@__cxx_global_var_init.2(
+// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSEL1BE
+
+// CHECK: define{{.*}}@__cxx_global_var_init.3(
+// CHECK: store{{.*}}, ptr @_ZN21VectorSinConstantsSSEL1bE
+
+// CHECK: 

[clang] [serialization] no transitive decl change (PR #92083)

2024-05-19 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

@jansvoboda11 @Bigcheese gentle ping

https://github.com/llvm/llvm-project/pull/92083
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Introduce `SemaCoroutine` (PR #92645)

2024-05-19 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

While I am not against the idea about splitting Sema, the implementation detail 
makes me slightly concerning. What I had in mind is to split `SemaC`, `SemaCXX` 
(this can be derived class of `SemaCXX`), `SemaObjC` and other dialects (e.g., 
ACC or CUDA) out of `Sema`. Then big features of C++ can be member of `SemaCXX` 
as `SemaCoroutine`, `SemaConcept`...

https://github.com/llvm/llvm-project/pull/92645
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -1382,6 +1382,10 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
   StaticRuntimes.push_back("asan_cxx");
   }
 
+  if (!SanArgs.needsSharedRt() && SanArgs.needsRadsanRt()) {
+StaticRuntimes.push_back("radsan");
+  }

MaskRay wrote:

I have some notes at 
https://maskray.me/blog/2023-01-08-all-about-sanitizer-interceptors#static-runtime

Nit: we omit braces in this single-line statement case 
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

https://github.com/llvm/llvm-project/pull/92460
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-19 Thread Freddy Ye via cfe-commits

FreddyLeaf wrote:

ping for review

https://github.com/llvm/llvm-project/pull/92338
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)

2024-05-19 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata closed 
https://github.com/llvm/llvm-project/pull/92708
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] d102ee6 - [clang] Use operator==(StringRef, StringRef) (NFC) (#92708)

2024-05-19 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-05-19T16:51:07-07:00
New Revision: d102ee63e849cdaa586fd1aaae900c1399bf2b76

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

LOG: [clang] Use operator==(StringRef, StringRef) (NFC) (#92708)

Added: 


Modified: 
clang-tools-extra/modularize/ModularizeUtilities.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 53e8a49d1a548..b202b3aae8f8a 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -435,11 +435,9 @@ static std::string replaceDotDot(StringRef Path) {
   llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),
 E = llvm::sys::path::end(Path);
   while (B != E) {
-if (B->compare(".") == 0) {
-}
-else if (B->compare("..") == 0)
+if (*B == "..")
   llvm::sys::path::remove_filename(Buffer);
-else
+else if (*B != ".")
   llvm::sys::path::append(Buffer, *B);
 ++B;
   }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c3e6d563f3bd2..6d2015b2cd156 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1522,7 +1522,7 @@ static void CollectARMPACBTIOptions(const ToolChain , 
const ArgList ,
   auto isPAuthLR = [](const char *member) {
 llvm::AArch64::ExtensionInfo pauthlr_extension =
 llvm::AArch64::getExtensionByID(llvm::AArch64::AEK_PAUTHLR);
-return (pauthlr_extension.Feature.compare(member) == 0);
+return pauthlr_extension.Feature == member;
   };
 
   if (std::any_of(CmdArgs.begin(), CmdArgs.end(), isPAuthLR))

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index aafbf1f40949a..ca7630adfbb7b 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1845,7 +1845,7 @@ static LateAttrParseKind getLateAttrParseKind(const 
Record *Attr) {
 PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
   "`should only have one super class");
 
-  if (SuperClasses[0]->getName().compare(LateAttrParseKindStr) != 0)
+  if (SuperClasses[0]->getName() != LateAttrParseKindStr)
 PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
   "`should only have type `" +
   llvm::Twine(LateAttrParseKindStr) +



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


[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)

2024-05-19 Thread Kazu Hirata via cfe-commits


@@ -435,9 +435,8 @@ static std::string replaceDotDot(StringRef Path) {
   llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),
 E = llvm::sys::path::end(Path);
   while (B != E) {
-if (B->compare(".") == 0) {
-}
-else if (B->compare("..") == 0)
+if (*B == ".") {
+} else if (*B == "..")
   llvm::sys::path::remove_filename(Buffer);
 else

kazutakahirata wrote:

Thank you for reviewing the patch!  Fixed.

https://github.com/llvm/llvm-project/pull/92708
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)

2024-05-19 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata updated 
https://github.com/llvm/llvm-project/pull/92708

>From cf3992f72b340cd402709c24bb8363a2f896635e Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 19 May 2024 09:22:14 -0700
Subject: [PATCH 1/2] [clang] Use operator==(StringRef, StringRef) (NFC)

---
 clang-tools-extra/modularize/ModularizeUtilities.cpp | 5 ++---
 clang/lib/Driver/ToolChains/Clang.cpp| 2 +-
 clang/utils/TableGen/ClangAttrEmitter.cpp| 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 53e8a49d1a548..8752946822fed 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -435,9 +435,8 @@ static std::string replaceDotDot(StringRef Path) {
   llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),
 E = llvm::sys::path::end(Path);
   while (B != E) {
-if (B->compare(".") == 0) {
-}
-else if (B->compare("..") == 0)
+if (*B == ".") {
+} else if (*B == "..")
   llvm::sys::path::remove_filename(Buffer);
 else
   llvm::sys::path::append(Buffer, *B);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c3e6d563f3bd2..6d2015b2cd156 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1522,7 +1522,7 @@ static void CollectARMPACBTIOptions(const ToolChain , 
const ArgList ,
   auto isPAuthLR = [](const char *member) {
 llvm::AArch64::ExtensionInfo pauthlr_extension =
 llvm::AArch64::getExtensionByID(llvm::AArch64::AEK_PAUTHLR);
-return (pauthlr_extension.Feature.compare(member) == 0);
+return pauthlr_extension.Feature == member;
   };
 
   if (std::any_of(CmdArgs.begin(), CmdArgs.end(), isPAuthLR))
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index aafbf1f40949a..ca7630adfbb7b 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1845,7 +1845,7 @@ static LateAttrParseKind getLateAttrParseKind(const 
Record *Attr) {
 PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
   "`should only have one super class");
 
-  if (SuperClasses[0]->getName().compare(LateAttrParseKindStr) != 0)
+  if (SuperClasses[0]->getName() != LateAttrParseKindStr)
 PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
   "`should only have type `" +
   llvm::Twine(LateAttrParseKindStr) +

>From 924326be4d21d6eb3f1428ad12184ccd6c8d0b55 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 19 May 2024 16:43:35 -0700
Subject: [PATCH 2/2] Address a comment.

---
 clang-tools-extra/modularize/ModularizeUtilities.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 8752946822fed..b202b3aae8f8a 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -435,10 +435,9 @@ static std::string replaceDotDot(StringRef Path) {
   llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),
 E = llvm::sys::path::end(Path);
   while (B != E) {
-if (*B == ".") {
-} else if (*B == "..")
+if (*B == "..")
   llvm::sys::path::remove_filename(Buffer);
-else
+else if (*B != ".")
   llvm::sys::path::append(Buffer, *B);
 ++B;
   }

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


[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)

2024-05-19 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay approved this pull request.

LGTM with a nit

https://github.com/llvm/llvm-project/pull/92708
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -435,9 +435,8 @@ static std::string replaceDotDot(StringRef Path) {
   llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),
 E = llvm::sys::path::end(Path);
   while (B != E) {
-if (B->compare(".") == 0) {
-}
-else if (B->compare("..") == 0)
+if (*B == ".") {
+} else if (*B == "..")
   llvm::sys::path::remove_filename(Buffer);
 else

MaskRay wrote:

Refactor this to `else if (*B != ".")`

https://github.com/llvm/llvm-project/pull/92708
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)

2024-05-19 Thread Hubert Tong via cfe-commits


@@ -3452,9 +3452,10 @@ def Fmod : FPMathTemplate, LibBuiltin<"math.h"> {
 
 def Frexp : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["frexp"];
-  let Attributes = [NoThrow];
+  let Attributes = [NoThrow, Constexpr];

hubert-reinterpretcast wrote:

> IMO we'd probably want to introduce the concept of "constexpr since C++xy".

@philnik777, are you envisioning something where `LangOptions` are passed into 
`Builtin::Context::isConstantEvaluated`?
https://github.com/llvm/llvm-project/blob/fb2c6597e39e9e1a775525ea0236b2f89e46acff/clang/include/clang/Basic/Builtins.h#L279

I think the existing `Constexpr`/"`E`" attribute can be left alone for use in 
"always `constexpr`" cases.

For the selectively-`constexpr` cases, `LibBuiltin` in 
`clang/include/clang/Basic/BuiltinsBase.td` should have 
`OnlyBuiltinPrefixedAliasIsConstexpr` renamed to 
`BuiltinPrefixedAliasIsConstexpr`. Then adding a new string property for 
`UnprefixedOnlyConstexprSince` makes sense to me. It can be encoded into 
`Builtin::Info` (and I think using the `LangFeatures` enumeration from 
`"clang/Basic/LangStandard.h"` is not terribly wrong).


https://github.com/llvm/llvm-project/pull/88978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)

2024-05-19 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Kazu Hirata (kazutakahirata)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/92708.diff


3 Files Affected:

- (modified) clang-tools-extra/modularize/ModularizeUtilities.cpp (+2-3) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-1) 
- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+1-1) 


``diff
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 53e8a49d1a548..8752946822fed 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -435,9 +435,8 @@ static std::string replaceDotDot(StringRef Path) {
   llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),
 E = llvm::sys::path::end(Path);
   while (B != E) {
-if (B->compare(".") == 0) {
-}
-else if (B->compare("..") == 0)
+if (*B == ".") {
+} else if (*B == "..")
   llvm::sys::path::remove_filename(Buffer);
 else
   llvm::sys::path::append(Buffer, *B);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c3e6d563f3bd2..6d2015b2cd156 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1522,7 +1522,7 @@ static void CollectARMPACBTIOptions(const ToolChain , 
const ArgList ,
   auto isPAuthLR = [](const char *member) {
 llvm::AArch64::ExtensionInfo pauthlr_extension =
 llvm::AArch64::getExtensionByID(llvm::AArch64::AEK_PAUTHLR);
-return (pauthlr_extension.Feature.compare(member) == 0);
+return pauthlr_extension.Feature == member;
   };
 
   if (std::any_of(CmdArgs.begin(), CmdArgs.end(), isPAuthLR))
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index aafbf1f40949a..ca7630adfbb7b 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1845,7 +1845,7 @@ static LateAttrParseKind getLateAttrParseKind(const 
Record *Attr) {
 PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
   "`should only have one super class");
 
-  if (SuperClasses[0]->getName().compare(LateAttrParseKindStr) != 0)
+  if (SuperClasses[0]->getName() != LateAttrParseKindStr)
 PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
   "`should only have type `" +
   llvm::Twine(LateAttrParseKindStr) +

``




https://github.com/llvm/llvm-project/pull/92708
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)

2024-05-19 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata edited 
https://github.com/llvm/llvm-project/pull/92708
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)

2024-05-19 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/92708

 StringRef) (NFC),

>From cf3992f72b340cd402709c24bb8363a2f896635e Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 19 May 2024 09:22:14 -0700
Subject: [PATCH] [clang] Use operator==(StringRef, StringRef) (NFC)

---
 clang-tools-extra/modularize/ModularizeUtilities.cpp | 5 ++---
 clang/lib/Driver/ToolChains/Clang.cpp| 2 +-
 clang/utils/TableGen/ClangAttrEmitter.cpp| 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 53e8a49d1a548..8752946822fed 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -435,9 +435,8 @@ static std::string replaceDotDot(StringRef Path) {
   llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),
 E = llvm::sys::path::end(Path);
   while (B != E) {
-if (B->compare(".") == 0) {
-}
-else if (B->compare("..") == 0)
+if (*B == ".") {
+} else if (*B == "..")
   llvm::sys::path::remove_filename(Buffer);
 else
   llvm::sys::path::append(Buffer, *B);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c3e6d563f3bd2..6d2015b2cd156 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1522,7 +1522,7 @@ static void CollectARMPACBTIOptions(const ToolChain , 
const ArgList ,
   auto isPAuthLR = [](const char *member) {
 llvm::AArch64::ExtensionInfo pauthlr_extension =
 llvm::AArch64::getExtensionByID(llvm::AArch64::AEK_PAUTHLR);
-return (pauthlr_extension.Feature.compare(member) == 0);
+return pauthlr_extension.Feature == member;
   };
 
   if (std::any_of(CmdArgs.begin(), CmdArgs.end(), isPAuthLR))
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index aafbf1f40949a..ca7630adfbb7b 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1845,7 +1845,7 @@ static LateAttrParseKind getLateAttrParseKind(const 
Record *Attr) {
 PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
   "`should only have one super class");
 
-  if (SuperClasses[0]->getName().compare(LateAttrParseKindStr) != 0)
+  if (SuperClasses[0]->getName() != LateAttrParseKindStr)
 PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
   "`should only have type `" +
   llvm::Twine(LateAttrParseKindStr) +

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


[clang] 2d5e488 - [clang-format][NFC] Clean up SortIncludesTest.cpp

2024-05-19 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2024-05-19T15:19:05-07:00
New Revision: 2d5e488c98225108aebfe4aa4acfe6ec1f234a37

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

LOG: [clang-format][NFC] Clean up SortIncludesTest.cpp

Wherever applicable, replace EXPECT_EQ with verifyFormat and std::string
with StringRef. Also, change a raw string literal to a regular one.

Added: 


Modified: 
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index 824fa0078cd03..52ba19627182b 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -53,35 +53,35 @@ class SortIncludesTest : public test::FormatTestBase {
 };
 
 TEST_F(SortIncludesTest, BasicSorting) {
-  EXPECT_EQ("#include \"a.h\"\n"
-"#include \"b.h\"\n"
-"#include \"c.h\"",
-sort("#include \"a.h\"\n"
- "#include \"c.h\"\n"
- "#include \"b.h\""));
-
-  EXPECT_EQ("// comment\n"
-"#include \n"
-"#include ",
-sort("// comment\n"
- "#include \n"
- "#include ",
- {tooling::Range(25, 1)}));
+  verifyFormat("#include \"a.h\"\n"
+   "#include \"b.h\"\n"
+   "#include \"c.h\"",
+   sort("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"#include \"b.h\""));
+
+  verifyFormat("// comment\n"
+   "#include \n"
+   "#include ",
+   sort("// comment\n"
+"#include \n"
+"#include ",
+{tooling::Range(25, 1)}));
 }
 
 TEST_F(SortIncludesTest, TrailingComments) {
-  EXPECT_EQ("#include \"a.h\"\n"
-"#include \"b.h\" /* long\n"
-"  * long\n"
-"  * comment*/\n"
-"#include \"c.h\"\n"
-"#include \"d.h\"",
-sort("#include \"a.h\"\n"
- "#include \"c.h\"\n"
- "#include \"b.h\" /* long\n"
- "  * long\n"
- "  * comment*/\n"
- "#include \"d.h\""));
+  verifyFormat("#include \"a.h\"\n"
+   "#include \"b.h\" /* long\n"
+   "  * long\n"
+   "  * comment*/\n"
+   "#include \"c.h\"\n"
+   "#include \"d.h\"",
+   sort("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"#include \"b.h\" /* long\n"
+"  * long\n"
+"  * comment*/\n"
+"#include \"d.h\""));
 }
 
 TEST_F(SortIncludesTest, SortedIncludesUsingSortPriorityAttribute) {
@@ -100,531 +100,531 @@ TEST_F(SortIncludesTest, 
SortedIncludesUsingSortPriorityAttribute) {
   {"", 8, 10, false},
   {"^\".*\\.h\"", 10, 12, false}};
-  EXPECT_EQ("#include \n"
-"#include \n"
-"#include \n"
-"#include \n"
-"#include \n"
-"#include \n"
-"\n"
-"#include \n"
-"#include \n"
-"#include \n"
-"#include \n"
-"#include \n"
-"\n"
-"#include \n"
-"#include \n"
-"#include \n"
-"#include \n"
-"#include \n"
-"\n"
-"#include \n"
-"\n"
-"#include \"pathnames.h\"",
-sort("#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include \"pathnames.h\"\n"
- "#include \n"
- "#include \n"
- "#include \n"
- "#include "));
+  verifyFormat("#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "\n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "\n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "\n"
+   

[clang] [clang] Macro for constant rounding mode (PR #92699)

2024-05-19 Thread Eli Friedman via cfe-commits


@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux -Wno-unknown-pragmas %s -o - 
| FileCheck %s

efriedma-quic wrote:

Since this is a preprocessor testcase, can you just use -E?

https://github.com/llvm/llvm-project/pull/92699
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-05-19 Thread Andreas Jonson via cfe-commits


@@ -1427,8 +1429,20 @@ static void AddParamAndFnBasicAttributes(const CallBase 
,
   ValidExactParamAttrs[ArgNo].getAlignment().valueOrOne())
 AL = AL.removeParamAttribute(Context, I, Attribute::Alignment);
 
+  auto ExistingRange = AL.getParamRange(I);
   AL = AL.addParamAttributes(Context, I, ValidExactParamAttrs[ArgNo]);
 
+  // For range we use the exact intersection.
+  if (ExistingRange.has_value()) {
+if (auto NewRange = ValidExactParamAttrs[ArgNo].getRange()) {
+  auto CombinedRange = 
ExistingRange->exactIntersectWith(*NewRange);

andjo403 wrote:

What is the reason to poison all values if exactIntersectWith is returning 
nullopt? is it not better to remove the range attribute instead of setting an 
empty range? or selecting the smallest range as is done by calling 
`intersectWith` feels like it is possible to assume that both ranges are valid 
only that the intersection gives multiple ranges.

https://github.com/llvm/llvm-project/pull/91101
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-05-19 Thread Andreas Jonson via cfe-commits


@@ -1427,8 +1429,20 @@ static void AddParamAndFnBasicAttributes(const CallBase 
,
   ValidExactParamAttrs[ArgNo].getAlignment().valueOrOne())
 AL = AL.removeParamAttribute(Context, I, Attribute::Alignment);
 
+  auto ExistingRange = AL.getParamRange(I);
   AL = AL.addParamAttributes(Context, I, ValidExactParamAttrs[ArgNo]);
 
+  // For range we use the exact intersection.
+  if (ExistingRange.has_value()) {
+if (auto NewRange = ValidExactParamAttrs[ArgNo].getRange()) {
+  auto CombinedRange = 
ExistingRange->exactIntersectWith(*NewRange);
+  if (!CombinedRange.has_value())
+CombinedRange =
+ConstantRange::getEmpty(NewRange->getBitWidth());
+  AL = AL.removeParamAttribute(Context, I, Attribute::Range);

andjo403 wrote:

Is this to make it more clear what is happening that removeParamAttribute is 
called? as addRangeParamAttr will replace the current value there is no need to 
call removeParamAttribute.

https://github.com/llvm/llvm-project/pull/91101
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix bad spacing of macro after lambda introducer (PR #92673)

2024-05-19 Thread Matthew Olsson via cfe-commits

https://github.com/mattco98 converted_to_draft 
https://github.com/llvm/llvm-project/pull/92673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix bad spacing of macro after lambda introducer (PR #92673)

2024-05-19 Thread Matthew Olsson via cfe-commits

mattco98 wrote:

@nico pointed out that calling `handleAttributes()` in `tryToParseLambda()` 
might be a better way to fix this, and I might be able to fix his other 
attribute issue while I'm at it. Going to draft this for now.

https://github.com/llvm/llvm-project/pull/92673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)

2024-05-19 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast edited 
https://github.com/llvm/llvm-project/pull/88978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [inline] Clone return range attribute on the callsite into inlined call (PR #92666)

2024-05-19 Thread Andreas Jonson via cfe-commits

andjo403 wrote:

hmm noticed #91101 now looks like I need to coordinate with that PR

https://github.com/llvm/llvm-project/pull/92666
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Default and Relaxed Availability Diagnostics (PR #92704)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/92704

>From 433b8e142d05a8fe2206ae0cec62423b21e792d2 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Sun, 19 May 2024 11:10:38 -0700
Subject: [PATCH 1/3] HLSL Default and Relaxed Availability Diagnostics (#3)

---
 clang/include/clang/Basic/Attr.td |  52 +++
 clang/include/clang/Basic/DiagnosticGroups.td |   3 +
 .../clang/Basic/DiagnosticSemaKinds.td|   7 +
 clang/include/clang/Sema/SemaHLSL.h   |   1 +
 clang/lib/Sema/Sema.cpp   |   3 +
 clang/lib/Sema/SemaAvailability.cpp   |  14 +-
 clang/lib/Sema/SemaHLSL.cpp   | 296 ++
 ...attr-availability-shadermodel-compute.hlsl |  68 
 .../attr-availability-shadermodel-mesh.hlsl   |  68 
 .../attr-availability-shadermodel-pixel.hlsl  |  61 
 .../Sema/attr-availability-shadermodel.hlsl   |  11 +
 .../avail-diag-default-compute.hlsl   |  98 ++
 .../Availability/avail-diag-default-lib.hlsl  | 108 +++
 .../avail-diag-relaxed-compute.hlsl   |  98 ++
 .../Availability/avail-diag-relaxed-lib.hlsl  | 108 +++
 .../avail-lib-multiple-stages.hlsl|  57 
 .../SemaHLSL/WaveBuiltinAvailability.hlsl |   9 +-
 17 files changed, 1056 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/Sema/attr-availability-shadermodel-compute.hlsl
 create mode 100644 clang/test/Sema/attr-availability-shadermodel-mesh.hlsl
 create mode 100644 clang/test/Sema/attr-availability-shadermodel-pixel.hlsl
 create mode 100644 clang/test/Sema/attr-availability-shadermodel.hlsl
 create mode 100644 
clang/test/SemaHLSL/Availability/avail-diag-default-compute.hlsl
 create mode 100644 clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl
 create mode 100644 
clang/test/SemaHLSL/Availability/avail-diag-relaxed-compute.hlsl
 create mode 100644 clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl
 create mode 100644 
clang/test/SemaHLSL/Availability/avail-lib-multiple-stages.hlsl

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7008bea483c87..e5c23d54ab826 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1068,11 +1068,37 @@ static llvm::StringRef 
getPrettyEnviromentName(llvm::StringRef Environment) {
  .Case("hull", "hull shader")
  .Case("domain", "domain shader")
  .Case("compute", "compute shader")
+ .Case("raygeneration", "ray generation shader")
+ .Case("intersection", "intersection shader")
+ .Case("anyhit", "anyhit shader")
+ .Case("closesthit", "closesthit shader")
+ .Case("miss", "miss shader")
+ .Case("callable", "callable shader")
  .Case("mesh", "mesh shader")
  .Case("amplification", "amplification shader")
  .Case("library", "shader library")
  .Default(Environment);
 }
+static llvm::StringRef getEnvironmentString(llvm::Triple::EnvironmentType 
EnvironmentType) {
+  switch (EnvironmentType) {
+case llvm::Triple::EnvironmentType::Pixel: return "pixel";
+case llvm::Triple::EnvironmentType::Vertex: return "vertex";
+case llvm::Triple::EnvironmentType::Geometry: return "geometry";
+case llvm::Triple::EnvironmentType::Hull: return "hull";
+case llvm::Triple::EnvironmentType::Domain: return "domain";
+case llvm::Triple::EnvironmentType::Compute: return "compute";
+case llvm::Triple::EnvironmentType::RayGeneration: return "ray generation";
+case llvm::Triple::EnvironmentType::Intersection: return "intersection";
+case llvm::Triple::EnvironmentType::AnyHit: return "any hit";
+case llvm::Triple::EnvironmentType::ClosestHit: return "closest hit";
+case llvm::Triple::EnvironmentType::Miss: return "miss";
+case llvm::Triple::EnvironmentType::Callable: return "callable";
+case llvm::Triple::EnvironmentType::Mesh: return "mesh";
+case llvm::Triple::EnvironmentType::Amplification: return "amplification";
+case llvm::Triple::EnvironmentType::Library: return "library";
+default: return "";
+  }
+}
 static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef 
Environment) {
 return llvm::StringSwitch(Environment)
  .Case("pixel", llvm::Triple::Pixel)
@@ -1081,6 +1107,12 @@ static llvm::Triple::EnvironmentType 
getEnvironmentType(llvm::StringRef Environm
  .Case("hull", llvm::Triple::Hull)
  .Case("domain", llvm::Triple::Domain)
  .Case("compute", llvm::Triple::Compute)
+ .Case("raygeneration", llvm::Triple::RayGeneration)
+ .Case("intersection", llvm::Triple::Intersection)
+ .Case("anyhit", llvm::Triple::AnyHit)
+ .Case("closesthit", llvm::Triple::ClosestHit)
+ .Case("miss", llvm::Triple::Miss)
+ .Case("callable", 

[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,100 @@
+# RUN: llvm-mc -filetype=obj -crel -triple=x86_64 %s -o %t.o
+# RUN: llvm-readelf -Sr -x .crelrodata2 -x .crelrodata16 %t.o | FileCheck %s
+
+# RUN: %if aarch64-registered-target %{ llvm-mc -filetype=obj -crel 
-triple=aarch64_be %s -o %t.be.o %}
+# RUN: %if aarch64-registered-target %{ llvm-readelf -r %t.be.o | FileCheck %s 
--check-prefix=A64BE %}
+
+# CHECK:  [ 4] .data PROGBITS   {{.*}} 
08 00  WA  0   0  1
+# CHECK-NEXT: [ 5] .crel.dataCREL   {{.*}} 
2a 01   I 14   4  1
+# CHECK-NEXT: [ 6] .rodata   PROGBITS   {{.*}} 
2b 00   A  0   0  1
+# CHECK-NEXT: [ 7] .crel.rodata  CREL   {{.*}} 
10 01   I 14   6  1
+# CHECK-NEXT: [ 8] rodata2   PROGBITS   {{.*}} 
08 00   A  0   0  1
+# CHECK-NEXT: [ 9] .crelrodata2  CREL   {{.*}} 
05 01   I 14   8  1
+# CHECK-NEXT: [10] rodata16  PROGBITS   {{.*}} 
10 00   A  0   0  1
+# CHECK-NEXT: [11] .crelrodata16 CREL   {{.*}} 
04 01   I 14  10  1
+# CHECK-NEXT: [12] noalloc   PROGBITS   {{.*}} 
04 00  0   0  1
+# CHECK-NEXT: [13] .crelnoalloc  CREL   {{.*}} 
05 01   I 14  12  1
+# CHECK-NEXT: [14] .symtab   SYMTAB
+
+# CHECK:  Relocation section '.crel.data' at offset {{.*}} contains 7 
entries:
+# CHECK-NEXT: Offset Info Type   
Symbol's Value  Symbol's Name + Addend
+# CHECK-NEXT:   {{.*}}   R_X86_64_NONE  
 a0 + 0
+# CHECK-NEXT: 0001  {{.*}}   R_X86_64_NONE  
 a1 - 1
+# CHECK-NEXT: 0002  {{.*}}   R_X86_64_NONE  
 a2 - 1
+# CHECK-NEXT: 0003  {{.*}}   R_X86_64_32
 a3 + 4000
+# CHECK-NEXT: 0004  {{.*}}   R_X86_64_64
 a0 - 8000
+# CHECK-NEXT: 0005  {{.*}}   R_X86_64_64
 a1 + 7fff
+# CHECK-NEXT: 0005  {{.*}}   R_X86_64_32
 a1 - 1
+# CHECK-EMPTY:
+# CHECK-NEXT: Relocation section '.crel.rodata' at offset {{.*}} contains 4 
entries:
+# CHECK-NEXT: Offset Info Type   
Symbol's Value  Symbol's Name + Addend
+# CHECK-NEXT:   {{.*}}   R_X86_64_PC32  
 foo + 0
+# CHECK-NEXT: 000f  {{.*}}   R_X86_64_PC32  
 foo + 3f
+# CHECK-NEXT: 001f  {{.*}}   R_X86_64_PC64  
 foo + 7f
+# CHECK-NEXT: 0027  {{.*}}   R_X86_64_PC32  
 _start - 1f81
+# CHECK-EMPTY:
+# CHECK-NEXT: Relocation section '.crelrodata2' at offset {{.*}} contains 2 
entries:
+# CHECK-NEXT: Offset Info Type   
Symbol's Value  Symbol's Name + Addend
+# CHECK-NEXT: 0002  {{.*}}   R_X86_64_32
 .data + 0
+# CHECK-NEXT: 0008  {{.*}}   R_X86_64_32
 .data + 0
+# CHECK-EMPTY:
+# CHECK-NEXT: Relocation section '.crelrodata16' at offset {{.*}} contains 1 
entries:
+# CHECK-NEXT: Offset Info Type   
Symbol's Value  Symbol's Name + Addend
+# CHECK-NEXT: 0008  {{.*}}   R_X86_64_64
 rodata16 + 0
+# CHECK-EMPTY:
+# CHECK-NEXT: Relocation section '.crelnoalloc' at offset {{.*}} contains 1 
entries:
+# CHECK-NEXT: Offset Info Type   
Symbol's Value  Symbol's Name + Addend
+# CHECK-NEXT:   {{.*}}   R_X86_64_32
 .text + 4
+
+## count * 8 + 4 + shift = 2*8+4+1 = 21
+# CHECK:  Hex dump of section '.crelrodata2':
+# CHECK-NEXT: 0x 150b020a 18 .
+## count * 8 + 4 + shift = 1*8+4+3 = 15
+# CHECK:  Hex dump of section '.crelrodata16':
+# CHECK-NEXT: 0x 0f0b0301 .
+
+# A64BE:    {{.*}}   R_AARCH64_NONE 
 a0 + 0
+# A64BE-NEXT: 0001  {{.*}}   R_AARCH64_NONE 
 a1 - 1
+# A64BE-NEXT: 0002  {{.*}}   R_AARCH64_NONE 
 a2 - 1
+# A64BE-NEXT: 0003  {{.*}}   R_AARCH64_ABS32
 a3 + 4000
+# A64BE-NEXT: 0004  {{.*}}   R_AARCH64_ABS64
 a0 - 8000
+# A64BE-NEXT: 0005  {{.*}}   R_AARCH64_ABS64
 a1 + 7fff
+# A64BE-NEXT: 0005  {{.*}}   

[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -1278,29 +1285,69 @@ void ELFState::writeSectionContent(
   if (!Section.Relocations)
 return;
 
+  const bool IsCrel = Section.Type == llvm::ELF::SHT_CREL;
   const bool IsRela = Section.Type == llvm::ELF::SHT_RELA;
+  typename ELFT::uint OffsetMask = 8, Offset = 0, Addend = 0;
+  uint32_t Symidx = 0, Type = 0;
+  uint64_t CurrentOffset = CBA.getOffset();
+  if (IsCrel)
+for (const ELFYAML::Relocation  : *Section.Relocations)
+  OffsetMask |= Rel.Offset;
+  const int Shift = llvm::countr_zero(OffsetMask);
+  if (IsCrel)
+CBA.writeULEB128(Section.Relocations->size() * 8 + 4 + Shift);
   for (const ELFYAML::Relocation  : *Section.Relocations) {
 const bool IsDynamic = Section.Link && (*Section.Link == ".dynsym");
-unsigned SymIdx =
+uint32_t CurSymidx =
 Rel.Symbol ? toSymbolIndex(*Rel.Symbol, Section.Name, IsDynamic) : 0;
-if (IsRela) {
+if (IsCrel) {

MaskRay wrote:

I've thought about an abstraction. However, the variable and `toSymbolIndex` 
mechanism are different, making me feel that code sharing would be cumbersome...

https://github.com/llvm/llvm-project/pull/91280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -3840,14 +3849,15 @@ void GNUELFDumper::printRelRelaReloc(const 
Relocation ,
 
 template 
 static void printRelocHeaderFields(formatted_raw_ostream , unsigned SType,
-   const typename ELFT::Ehdr ) {
+   const typename ELFT::Ehdr ,
+   uint64_t CrelHdr = 0) {
   bool IsRela = SType == ELF::SHT_RELA || SType == ELF::SHT_ANDROID_RELA;
   if (ELFT::Is64Bits)
 OS << "Offset Info Type   Symbol's 
"
   "Value  Symbol's Name";
   else
 OS << " Offset InfoTypeSym. Value  Symbol's Name";
-  if (IsRela)
+  if (IsRela || (SType == ELF::SHT_CREL && (CrelHdr & 4)))

MaskRay wrote:

Defined `CREL_HDR_ADDEND` and used it here

https://github.com/llvm/llvm-project/pull/91280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -86,6 +86,8 @@ DYNAMIC_TAG(RELRSZ, 35)  // Size of Relr relocation table.
 DYNAMIC_TAG(RELR, 36)// Address of relocation table (Relr entries).
 DYNAMIC_TAG(RELRENT, 37) // Size of a Relr relocation entry.
 
+DYNAMIC_TAG(CREL,  38)   // CREL relocation table
+

MaskRay wrote:

The commit message mentions:

> Without linker/dynamic loader concern, there is even less concern for people 
> unintentionally using this.

I tentatively think it is not worth the trouble to avoid the generic range.

> Although not strictly necessary a CREL Size (CRELSZ?) could be useful for a 
> consumer to read all the CRELs into memory without having to read the header 
> first to find the size. Again not worth doing unless we have a definite need 
> for it.

I've thought about this but believe CRELSZ is not so necessary.

https://github.com/llvm/llvm-project/pull/91280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -32,12 +32,17 @@ FileHeader:
 # RUN: --match-full-lines --check-prefixes=GNU-RELOCS,GNU-PLTRELA
 
 # LLVM-RELOCS:  Dynamic Relocations {
+# LLVM-RELOCS-NEXT:   0x8 R_X86_64_64 foo 0x0
 # LLVM-RELOCS-NEXT:   0x1 R_X86_64_NONE foo 0x0
 # LLVM-RELOCS-NEXT:   0x2 R_X86_64_NONE foo
-# LLVM-RELOCS-NEXT:   0x4 R_X86_64_RELATIVE
+# LLVM-RELOCS-NEXT:   0x4 R_X86_64_RELATIVE -

MaskRay wrote:

llvm-readobj (LLVM style) displays `-` when the symbol index is 0.
This line in the absence of the patch contains a `-` as well.

https://github.com/llvm/llvm-project/pull/91280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -123,6 +123,12 @@ class ContiguousBlobAccumulator {
 return encodeULEB128(Val, OS);
   }
 
+  unsigned writeSLEB128(int64_t Val) {
+if (!checkLimit(10))

MaskRay wrote:

Yes, LEB128 representing 64-bit integer needs at most 10 bytes.
I added a change detector test to `relocation-crel.yaml` to catch the case.



The limit in writeULEB128 is incorrect, which can be fixed separately.

https://github.com/llvm/llvm-project/pull/91280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,18 @@
+# REQUIRES: powerpc-registered-target
+## Test CREL for a 32-bit big-endian target.

MaskRay wrote:

Thanks for the suggestion. Changed ppc to arm.

For static relocations, the RELA form is exclusively used as recommended 
toolchain practice.

https://github.com/llvm/llvm-project/pull/91280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -934,10 +943,51 @@ void ELFWriter::WriteSecHdrEntry(uint32_t Name, uint32_t 
Type, uint64_t Flags,
   WriteWord(EntrySize); // sh_entsize
 }
 
+template 
+static void encodeCrel(ArrayRef Relocs, raw_ostream ) {
+  uint OffsetMask = 8, Offset = 0, Addend = 0;
+  uint32_t Symidx = 0, Type = 0;
+  // hdr & 4 indicates 3 flag bits in delta offset and flags members.
+  for (unsigned i = 0, e = Relocs.size(); i != e; ++i)

MaskRay wrote:

Fixed

https://github.com/llvm/llvm-project/pull/91280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits


@@ -1278,29 +1285,69 @@ void ELFState::writeSectionContent(
   if (!Section.Relocations)
 return;
 
+  const bool IsCrel = Section.Type == llvm::ELF::SHT_CREL;
   const bool IsRela = Section.Type == llvm::ELF::SHT_RELA;
+  typename ELFT::uint OffsetMask = 8, Offset = 0, Addend = 0;
+  uint32_t Symidx = 0, Type = 0;
+  uint64_t CurrentOffset = CBA.getOffset();
+  if (IsCrel)

MaskRay wrote:

The comments in ELFObjectWriter.cpp and ELFEmitter.cpp are the same. The one in 
ELFEmitter.cpp is indended more, leading to a difference in text wrapping.

https://github.com/llvm/llvm-project/pull/91280
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

2024-05-19 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/91280

>From a0cfafb82db825512b0ca44778fa9d4bb435563d Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Mon, 6 May 2024 15:37:50 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 clang/include/clang/Basic/CodeGenOptions.def  |   1 +
 .../clang/Basic/DiagnosticDriverKinds.td  |   3 +
 clang/include/clang/Driver/Options.td |   3 +
 clang/lib/CodeGen/BackendUtil.cpp |   1 +
 clang/lib/Driver/ToolChains/Clang.cpp |  18 ++
 clang/lib/Driver/ToolChains/CommonArgs.cpp|  21 ++
 clang/test/Driver/crel.c  |  24 +++
 clang/test/Misc/cc1as-crel.s  |   6 +
 clang/tools/driver/cc1as_main.cpp |   6 +
 .../include/llvm/BinaryFormat/DynamicTags.def |   2 +
 llvm/include/llvm/BinaryFormat/ELF.h  |   1 +
 llvm/include/llvm/MC/MCTargetOptions.h|   3 +
 .../llvm/MC/MCTargetOptionsCommandFlags.h |   1 +
 llvm/include/llvm/Object/ELF.h|   5 +
 llvm/include/llvm/Object/ELFObjectFile.h  |  70 ++-
 llvm/include/llvm/Object/ELFTypes.h   |  25 +++
 llvm/lib/MC/ELFObjectWriter.cpp   | 110 ---
 llvm/lib/MC/MCTargetOptionsCommandFlags.cpp   |   6 +
 llvm/lib/Object/ELF.cpp   |  63 ++
 llvm/lib/ObjectYAML/ELFEmitter.cpp|  60 +-
 llvm/lib/ObjectYAML/ELFYAML.cpp   |   2 +
 llvm/test/MC/ELF/crel-32.s|  16 ++
 llvm/test/MC/ELF/crel.s   | 100 ++
 llvm/test/tools/llvm-readobj/ELF/crel.test| 180 ++
 .../tools/llvm-readobj/ELF/dynamic-reloc.test |  31 ++-
 .../llvm-readobj/ELF/relocation-errors.test   |  19 +-
 .../yaml2obj/ELF/dynamic-relocations.yaml |   5 +-
 .../yaml2obj/ELF/reloc-sec-entry-size.yaml|   5 +
 .../tools/yaml2obj/ELF/relocation-crel.yaml   |  63 ++
 .../ELF/relocation-missing-symbol.yaml|   3 +-
 .../tools/yaml2obj/ELF/relocation-type.yaml   |   4 +-
 llvm/tools/llvm-readobj/ELFDumper.cpp |  81 +++-
 32 files changed, 883 insertions(+), 55 deletions(-)
 create mode 100644 clang/test/Driver/crel.c
 create mode 100644 clang/test/Misc/cc1as-crel.s
 create mode 100644 llvm/test/MC/ELF/crel-32.s
 create mode 100644 llvm/test/MC/ELF/crel.s
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/crel.test
 create mode 100644 llvm/test/tools/yaml2obj/ELF/relocation-crel.yaml

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 340b08dd7e2a3..3229f77eef1fc 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -36,6 +36,7 @@ VALUE_CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
+CODEGENOPT(Crel, 1, 0) ///< -Wa,--crel
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9781fcaa4ff5e..e9cea8967c133 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -809,6 +809,9 @@ def warn_drv_missing_multilib : Warning<
 def note_drv_available_multilibs : Note<
   "available multilibs are:%0">;
 
+def err_drv_experimental_crel : Error<
+  "-Wa,--experimental-crel must be specified to use -Wa,--crel. CREL is 
experimental and takes a non-standard section type code">;
+
 def warn_android_unversioned_fallback : Warning<
   "Using unversioned Android target directory %0 for target %1. Unversioned"
   " directories will not be used in Clang 19. Provide a versioned directory"
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c9f7c4e5f718b..55f0c9aff6a49 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6958,6 +6958,9 @@ def massembler_no_warn : Flag<["-"], 
"massembler-no-warn">,
 def massembler_fatal_warnings : Flag<["-"], "massembler-fatal-warnings">,
   HelpText<"Make assembler warnings fatal">,
   MarshallingInfoFlag>;
+def crel : Flag<["--"], "crel">,
+  HelpText<"Enable CREL relocation format (ELF only)">,
+  MarshallingInfoFlag>;
 def mrelax_relocations_no : Flag<["-"], "mrelax-relocations=no">,
 HelpText<"Disable x86 relax relocations">,
 MarshallingInfoNegativeFlag>;
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 22c3f8642ad8e..ed37085d69ac5 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ 

[clang] [HLSL] Default and Relaxed Availability Diagnostics (PR #92704)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/92704

>From 433b8e142d05a8fe2206ae0cec62423b21e792d2 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Sun, 19 May 2024 11:10:38 -0700
Subject: [PATCH 1/2] HLSL Default and Relaxed Availability Diagnostics (#3)

---
 clang/include/clang/Basic/Attr.td |  52 +++
 clang/include/clang/Basic/DiagnosticGroups.td |   3 +
 .../clang/Basic/DiagnosticSemaKinds.td|   7 +
 clang/include/clang/Sema/SemaHLSL.h   |   1 +
 clang/lib/Sema/Sema.cpp   |   3 +
 clang/lib/Sema/SemaAvailability.cpp   |  14 +-
 clang/lib/Sema/SemaHLSL.cpp   | 296 ++
 ...attr-availability-shadermodel-compute.hlsl |  68 
 .../attr-availability-shadermodel-mesh.hlsl   |  68 
 .../attr-availability-shadermodel-pixel.hlsl  |  61 
 .../Sema/attr-availability-shadermodel.hlsl   |  11 +
 .../avail-diag-default-compute.hlsl   |  98 ++
 .../Availability/avail-diag-default-lib.hlsl  | 108 +++
 .../avail-diag-relaxed-compute.hlsl   |  98 ++
 .../Availability/avail-diag-relaxed-lib.hlsl  | 108 +++
 .../avail-lib-multiple-stages.hlsl|  57 
 .../SemaHLSL/WaveBuiltinAvailability.hlsl |   9 +-
 17 files changed, 1056 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/Sema/attr-availability-shadermodel-compute.hlsl
 create mode 100644 clang/test/Sema/attr-availability-shadermodel-mesh.hlsl
 create mode 100644 clang/test/Sema/attr-availability-shadermodel-pixel.hlsl
 create mode 100644 clang/test/Sema/attr-availability-shadermodel.hlsl
 create mode 100644 
clang/test/SemaHLSL/Availability/avail-diag-default-compute.hlsl
 create mode 100644 clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl
 create mode 100644 
clang/test/SemaHLSL/Availability/avail-diag-relaxed-compute.hlsl
 create mode 100644 clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl
 create mode 100644 
clang/test/SemaHLSL/Availability/avail-lib-multiple-stages.hlsl

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7008bea483c87..e5c23d54ab826 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1068,11 +1068,37 @@ static llvm::StringRef 
getPrettyEnviromentName(llvm::StringRef Environment) {
  .Case("hull", "hull shader")
  .Case("domain", "domain shader")
  .Case("compute", "compute shader")
+ .Case("raygeneration", "ray generation shader")
+ .Case("intersection", "intersection shader")
+ .Case("anyhit", "anyhit shader")
+ .Case("closesthit", "closesthit shader")
+ .Case("miss", "miss shader")
+ .Case("callable", "callable shader")
  .Case("mesh", "mesh shader")
  .Case("amplification", "amplification shader")
  .Case("library", "shader library")
  .Default(Environment);
 }
+static llvm::StringRef getEnvironmentString(llvm::Triple::EnvironmentType 
EnvironmentType) {
+  switch (EnvironmentType) {
+case llvm::Triple::EnvironmentType::Pixel: return "pixel";
+case llvm::Triple::EnvironmentType::Vertex: return "vertex";
+case llvm::Triple::EnvironmentType::Geometry: return "geometry";
+case llvm::Triple::EnvironmentType::Hull: return "hull";
+case llvm::Triple::EnvironmentType::Domain: return "domain";
+case llvm::Triple::EnvironmentType::Compute: return "compute";
+case llvm::Triple::EnvironmentType::RayGeneration: return "ray generation";
+case llvm::Triple::EnvironmentType::Intersection: return "intersection";
+case llvm::Triple::EnvironmentType::AnyHit: return "any hit";
+case llvm::Triple::EnvironmentType::ClosestHit: return "closest hit";
+case llvm::Triple::EnvironmentType::Miss: return "miss";
+case llvm::Triple::EnvironmentType::Callable: return "callable";
+case llvm::Triple::EnvironmentType::Mesh: return "mesh";
+case llvm::Triple::EnvironmentType::Amplification: return "amplification";
+case llvm::Triple::EnvironmentType::Library: return "library";
+default: return "";
+  }
+}
 static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef 
Environment) {
 return llvm::StringSwitch(Environment)
  .Case("pixel", llvm::Triple::Pixel)
@@ -1081,6 +1107,12 @@ static llvm::Triple::EnvironmentType 
getEnvironmentType(llvm::StringRef Environm
  .Case("hull", llvm::Triple::Hull)
  .Case("domain", llvm::Triple::Domain)
  .Case("compute", llvm::Triple::Compute)
+ .Case("raygeneration", llvm::Triple::RayGeneration)
+ .Case("intersection", llvm::Triple::Intersection)
+ .Case("anyhit", llvm::Triple::AnyHit)
+ .Case("closesthit", llvm::Triple::ClosestHit)
+ .Case("miss", llvm::Triple::Miss)
+ .Case("callable", 

[clang] [HLSL] Default and Relaxed Availability Diagnostics (PR #92704)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/92704
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] HLSL Default and Relaxed Availability Diagnostics (PR #92704)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/92704
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] HLSL Default and Relaxed Availability Diagnostics (PR #92704)

2024-05-19 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 3f33c4c14e79e68007cf1460e4a0e606eb199da5 
433b8e142d05a8fe2206ae0cec62423b21e792d2 -- clang/include/clang/Sema/SemaHLSL.h 
clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaAvailability.cpp 
clang/lib/Sema/SemaHLSL.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 9dfa7b3b3a..8ee40d3e0d 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1352,7 +1352,8 @@ void Sema::ActOnEndOfTranslationUnit() {
   }
 
   if (LangOpts.HLSL)
-
HLSL().DiagnoseAvailabilityViolations(getASTContext().getTranslationUnitDecl());
+HLSL().DiagnoseAvailabilityViolations(
+getASTContext().getTranslationUnitDecl());
 
   // If there were errors, disable 'unused' warnings since they will mostly be
   // noise. Don't warn for a use from a module: either we should warn on all
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 286bd1354f..6e407cfc4e 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -341,7 +341,7 @@ class DiagnoseHLSLAvailability
   unsigned CurrentShaderStageBit;
 
   // True if scanning a function that was already scanned in a different
-  // shader stage context, and therefore we should not report issues that 
+  // shader stage context, and therefore we should not report issues that
   // depend only on shader model version because they would be duplicate.
   bool ReportOnlyShaderStageIssues;
 

``




https://github.com/llvm/llvm-project/pull/92704
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] - do not merge - Default and Relaxed Availability Diagnostics (PR #92703)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota closed https://github.com/llvm/llvm-project/pull/92703
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] - do not merge - Default and Relaxed Availability Diagnostics (PR #92703)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/92703
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] HLSL Default and Relaxed Availability Diagnostics (PR #92704)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota created 
https://github.com/llvm/llvm-project/pull/92704

None

>From 433b8e142d05a8fe2206ae0cec62423b21e792d2 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Sun, 19 May 2024 11:10:38 -0700
Subject: [PATCH] HLSL Default and Relaxed Availability Diagnostics (#3)

---
 clang/include/clang/Basic/Attr.td |  52 +++
 clang/include/clang/Basic/DiagnosticGroups.td |   3 +
 .../clang/Basic/DiagnosticSemaKinds.td|   7 +
 clang/include/clang/Sema/SemaHLSL.h   |   1 +
 clang/lib/Sema/Sema.cpp   |   3 +
 clang/lib/Sema/SemaAvailability.cpp   |  14 +-
 clang/lib/Sema/SemaHLSL.cpp   | 296 ++
 ...attr-availability-shadermodel-compute.hlsl |  68 
 .../attr-availability-shadermodel-mesh.hlsl   |  68 
 .../attr-availability-shadermodel-pixel.hlsl  |  61 
 .../Sema/attr-availability-shadermodel.hlsl   |  11 +
 .../avail-diag-default-compute.hlsl   |  98 ++
 .../Availability/avail-diag-default-lib.hlsl  | 108 +++
 .../avail-diag-relaxed-compute.hlsl   |  98 ++
 .../Availability/avail-diag-relaxed-lib.hlsl  | 108 +++
 .../avail-lib-multiple-stages.hlsl|  57 
 .../SemaHLSL/WaveBuiltinAvailability.hlsl |   9 +-
 17 files changed, 1056 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/Sema/attr-availability-shadermodel-compute.hlsl
 create mode 100644 clang/test/Sema/attr-availability-shadermodel-mesh.hlsl
 create mode 100644 clang/test/Sema/attr-availability-shadermodel-pixel.hlsl
 create mode 100644 clang/test/Sema/attr-availability-shadermodel.hlsl
 create mode 100644 
clang/test/SemaHLSL/Availability/avail-diag-default-compute.hlsl
 create mode 100644 clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl
 create mode 100644 
clang/test/SemaHLSL/Availability/avail-diag-relaxed-compute.hlsl
 create mode 100644 clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl
 create mode 100644 
clang/test/SemaHLSL/Availability/avail-lib-multiple-stages.hlsl

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7008bea483c87..e5c23d54ab826 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1068,11 +1068,37 @@ static llvm::StringRef 
getPrettyEnviromentName(llvm::StringRef Environment) {
  .Case("hull", "hull shader")
  .Case("domain", "domain shader")
  .Case("compute", "compute shader")
+ .Case("raygeneration", "ray generation shader")
+ .Case("intersection", "intersection shader")
+ .Case("anyhit", "anyhit shader")
+ .Case("closesthit", "closesthit shader")
+ .Case("miss", "miss shader")
+ .Case("callable", "callable shader")
  .Case("mesh", "mesh shader")
  .Case("amplification", "amplification shader")
  .Case("library", "shader library")
  .Default(Environment);
 }
+static llvm::StringRef getEnvironmentString(llvm::Triple::EnvironmentType 
EnvironmentType) {
+  switch (EnvironmentType) {
+case llvm::Triple::EnvironmentType::Pixel: return "pixel";
+case llvm::Triple::EnvironmentType::Vertex: return "vertex";
+case llvm::Triple::EnvironmentType::Geometry: return "geometry";
+case llvm::Triple::EnvironmentType::Hull: return "hull";
+case llvm::Triple::EnvironmentType::Domain: return "domain";
+case llvm::Triple::EnvironmentType::Compute: return "compute";
+case llvm::Triple::EnvironmentType::RayGeneration: return "ray generation";
+case llvm::Triple::EnvironmentType::Intersection: return "intersection";
+case llvm::Triple::EnvironmentType::AnyHit: return "any hit";
+case llvm::Triple::EnvironmentType::ClosestHit: return "closest hit";
+case llvm::Triple::EnvironmentType::Miss: return "miss";
+case llvm::Triple::EnvironmentType::Callable: return "callable";
+case llvm::Triple::EnvironmentType::Mesh: return "mesh";
+case llvm::Triple::EnvironmentType::Amplification: return "amplification";
+case llvm::Triple::EnvironmentType::Library: return "library";
+default: return "";
+  }
+}
 static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef 
Environment) {
 return llvm::StringSwitch(Environment)
  .Case("pixel", llvm::Triple::Pixel)
@@ -1081,6 +1107,12 @@ static llvm::Triple::EnvironmentType 
getEnvironmentType(llvm::StringRef Environm
  .Case("hull", llvm::Triple::Hull)
  .Case("domain", llvm::Triple::Domain)
  .Case("compute", llvm::Triple::Compute)
+ .Case("raygeneration", llvm::Triple::RayGeneration)
+ .Case("intersection", llvm::Triple::Intersection)
+ .Case("anyhit", llvm::Triple::AnyHit)
+ .Case("closesthit", llvm::Triple::ClosestHit)
+ .Case("miss", llvm::Triple::Miss)
+ .Case("callable", 

[clang] [HLSL] Default and Relaxed Availability Diagnostics (PR #92703)

2024-05-19 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 3f33c4c14e79e68007cf1460e4a0e606eb199da5 
35d72822b298d77b4d73cb6b92fd218c4722e6b6 -- clang/include/clang/Sema/SemaHLSL.h 
clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaAvailability.cpp 
clang/lib/Sema/SemaHLSL.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 9dfa7b3b3a..8ee40d3e0d 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1352,7 +1352,8 @@ void Sema::ActOnEndOfTranslationUnit() {
   }
 
   if (LangOpts.HLSL)
-
HLSL().DiagnoseAvailabilityViolations(getASTContext().getTranslationUnitDecl());
+HLSL().DiagnoseAvailabilityViolations(
+getASTContext().getTranslationUnitDecl());
 
   // If there were errors, disable 'unused' warnings since they will mostly be
   // noise. Don't warn for a use from a module: either we should warn on all
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 286bd1354f..6e407cfc4e 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -341,7 +341,7 @@ class DiagnoseHLSLAvailability
   unsigned CurrentShaderStageBit;
 
   // True if scanning a function that was already scanned in a different
-  // shader stage context, and therefore we should not report issues that 
+  // shader stage context, and therefore we should not report issues that
   // depend only on shader model version because they would be duplicate.
   bool ReportOnlyShaderStageIssues;
 

``




https://github.com/llvm/llvm-project/pull/92703
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota closed https://github.com/llvm/llvm-project/pull/89809
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3f33c4c - [Clang][HLSL] Add environment parameter to availability attribute (#89809)

2024-05-19 Thread via cfe-commits

Author: Helena Kotas
Date: 2024-05-19T10:46:12-07:00
New Revision: 3f33c4c14e79e68007cf1460e4a0e606eb199da5

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

LOG: [Clang][HLSL] Add environment parameter to availability attribute (#89809)

Add `environment` parameter to Clang availability attribute. The allowed
values for this parameter are a subset of values allowed in the
`llvm::Triple` environment component. If the `environment` parameters is
present, the declared availability attribute applies only to targets
with the same platform and environment.

This new parameter will be initially used for annotating HLSL functions
for the `shadermodel` platform because in HLSL built-in function
availability can depend not just on the shader model version (mapped to
`llvm::Triple::OSType`) but also on the target shader stage (mapped to
`llvm::Triple::EnvironmentType`). See example in #89802 and
microsoft/hlsl-specs#204 for more details.

The environment parameter is currently supported only for HLSL.

Fixes #89802

Added: 
clang/test/SemaHLSL/Availability/attr-availability-compute.hlsl
clang/test/SemaHLSL/Availability/attr-availability-errors.hlsl
clang/test/SemaHLSL/Availability/attr-availability-mesh.hlsl
clang/test/SemaHLSL/Availability/attr-availability-pixel.hlsl

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/DeclBase.cpp
clang/lib/Headers/hlsl/hlsl_intrinsics.h
clang/lib/Index/CommentToXML.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaAPINotes.cpp
clang/lib/Sema/SemaAvailability.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Parser/attr-availability.c
clang/test/Sema/attr-availability-ios.c
clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl

Removed: 
clang/test/SemaHLSL/AvailabilityMarkup.hlsl



diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 38ee8356583be..7008bea483c87 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -999,7 +999,7 @@ def Availability : InheritableAttr {
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
   BoolArgument<"strict">, StringArgument<"replacement">,
-  IntArgument<"priority">];
+  IntArgument<"priority">, IdentifierArgument<"environment">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)
@@ -1019,7 +1019,7 @@ def Availability : InheritableAttr {
  .Case("xros", "visionOS")
  .Case("xros_app_extension", "visionOS (App Extension)")
  .Case("swift", "Swift")
- .Case("shadermodel", "HLSL ShaderModel")
+ .Case("shadermodel", "Shader Model")
  .Case("ohos", "OpenHarmony OS")
  .Default(llvm::StringRef());
 }
@@ -1059,7 +1059,34 @@ static llvm::StringRef 
canonicalizePlatformName(llvm::StringRef Platform) {
  .Case("visionos_app_extension", "xros_app_extension")
  .Case("ShaderModel", "shadermodel")
  .Default(Platform);
-} }];
+}
+static llvm::StringRef getPrettyEnviromentName(llvm::StringRef Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", "pixel shader")
+ .Case("vertex", "vertex shader")
+ .Case("geometry", "geometry shader")
+ .Case("hull", "hull shader")
+ .Case("domain", "domain shader")
+ .Case("compute", "compute shader")
+ .Case("mesh", "mesh shader")
+ .Case("amplification", "amplification shader")
+ .Case("library", "shader library")
+ .Default(Environment);
+}
+static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef 
Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", llvm::Triple::Pixel)
+ .Case("vertex", llvm::Triple::Vertex)
+ .Case("geometry", llvm::Triple::Geometry)
+ .Case("hull", llvm::Triple::Hull)
+ .Case("domain", llvm::Triple::Domain)
+ .Case("compute", llvm::Triple::Compute)
+ .Case("mesh", llvm::Triple::Mesh)
+ .Case("amplification", llvm::Triple::Amplification)
+ .Case("library", llvm::Triple::Library)
+ 

[clang] [clang] Macro for constant rounding mode (PR #92699)

2024-05-19 Thread Serge Pavlov via cfe-commits

https://github.com/spavloff updated 
https://github.com/llvm/llvm-project/pull/92699

>From f8cd2539fb7f0388d7f3955f58b61b09da03bf0c Mon Sep 17 00:00:00 2001
From: Serge Pavlov 
Date: Sun, 19 May 2024 18:43:08 +0700
Subject: [PATCH] [clang] Macro for constant rounding mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The forthcoming C standard defines pragma FENV_ROUND to support constant
rounding mode. It also requires some functions to be evaluated with such
mode, N3096 7.6.2p4 states:

Within the scope of an FENV_ROUND pragma establishing a mode other
than FE_DYNAMIC ... invocations of functions indicated in the table
below, for which macro replacement has not been suppressed (7.1.4),
shall be evaluated according to the specified constant rounding mode
... . Invocations of functions for which macro replacement has been
suppressed and invocations of functions other than those indicated
in the table below shall not be affected by constant rounding modes
– they are affected by (and affect) only the dynamic mode.

The way this requirement is formulated indicates that it could be
implemented using preprocessor facility. Such implementation would
require a builtin macro that is set in the region where pragma
FENV_ROUND is in effect and reflects constant rounding mode.

This change introduces macro __ROUNDING_MODE__, which is a string
dependent on the constant rounding mode:

FE_TOWARDZERO"_rtz"
FE_TONEAREST "_rte"
FE_DOWNWARD  "_rtp"
FE_UPWARD"_rtn"
FE_TONEARESTFROMZERO "_rta"
FE_DYNAMIC   empty string

All these values except "_rta" are OpenCL rounding mode modifiers.
Default value, when no pragma FENV_ROUND is specified, is empty string.
Concatenation of a function name with the builtin macro can be used to
obtain name of the function variant for particular rounding mode, like
"sin_rtz", or "__builtin_cos_rtd". The test "macro_rounding_mode.c"
added in this change provides an example of possible use.

The macro is implemented in the same way as FLT_EVAL_METHOD, which also
depends on the results of semantic analysis.
---
 clang/include/clang/Lex/Preprocessor.h| 12 
 clang/lib/Lex/PPMacroExpansion.cpp| 25 +
 clang/lib/Sema/Sema.cpp   |  1 +
 clang/lib/Sema/SemaAttr.cpp   |  1 +
 clang/test/Preprocessor/macro_rounding_mode.c | 55 +++
 5 files changed, 94 insertions(+)
 create mode 100644 clang/test/Preprocessor/macro_rounding_mode.c

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index c0850a8fa9f7f..295633b2e3c73 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -181,6 +181,7 @@ class Preprocessor {
   IdentifierInfo *Ident__is_target_variant_os;
   IdentifierInfo *Ident__is_target_variant_environment;
   IdentifierInfo *Ident__FLT_EVAL_METHOD__;// __FLT_EVAL_METHOD
+  IdentifierInfo *Ident__ROUNDING_MODE__;  // __ROUNDING_MODE__
 
   // Weak, only valid (and set) while InMacroArgs is true.
   Token* ArgMacro;
@@ -201,6 +202,9 @@ class Preprocessor {
   LangOptions::FPEvalMethodKind TUFPEvalMethod =
   LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine;
 
+  LangOptions::RoundingMode CurrentRoundingMode =
+  LangOptions::RoundingMode::Dynamic;
+
   // Next __COUNTER__ value, starts at 0.
   unsigned CounterValue = 0;
 
@@ -2356,6 +2360,14 @@ class Preprocessor {
 TUFPEvalMethod = Val;
   }
 
+  LangOptions::RoundingMode getCurrentRoundingMode() const {
+return CurrentRoundingMode;
+  }
+
+  void setCurrentRoundingMode(LangOptions::RoundingMode RM) {
+CurrentRoundingMode = RM;
+  }
+
   /// Retrieves the module that we're currently building, if any.
   Module *getCurrentModule();
 
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 8af4a97d00cb8..519fbfd666375 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -344,6 +344,7 @@ void Preprocessor::RegisterBuiltinMacros() {
   Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__");
   Ident_Pragma  = RegisterBuiltinMacro(*this, "_Pragma");
   Ident__FLT_EVAL_METHOD__ = RegisterBuiltinMacro(*this, 
"__FLT_EVAL_METHOD__");
+  Ident__ROUNDING_MODE__ = RegisterBuiltinMacro(*this, "__ROUNDING_MODE__");
 
   // C++ Standing Document Extensions.
   if (getLangOpts().CPlusPlus)
@@ -1654,6 +1655,30 @@ void Preprocessor::ExpandBuiltinMacro(Token ) {
   Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
   Diag(getLastFPEvalPragmaLocation(), diag::note_pragma_entered_here);
 }
+  } else if (II == Ident__ROUNDING_MODE__) {
+switch (getCurrentRoundingMode()) {
+case LangOptions::RoundingMode::TowardZero:
+  OS << "_rtz";
+  break;
+case LangOptions::RoundingMode::NearestTiesToEven:
+  OS << 

[clang] [clang] Macro for constant rounding mode (PR #92699)

2024-05-19 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 643f36184bd3d9a95cbfd608af6f169e0187 
15b6edbcc8fe4559e9a9d8930f88dbbb6ed38b8c -- 
clang/test/Preprocessor/macro_rounding_mode.c 
clang/include/clang/Lex/Preprocessor.h clang/lib/Lex/PPMacroExpansion.cpp 
clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaAttr.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 519fbfd666..4186872533 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1799,8 +1799,7 @@ void Preprocessor::ExpandBuiltinMacro(Token ) {
 
 return false;
   });
-  } else if (II == Ident__has_cpp_attribute ||
- II == Ident__has_c_attribute) {
+  } else if (II == Ident__has_cpp_attribute || II == Ident__has_c_attribute) {
 bool IsCXX = II == Ident__has_cpp_attribute;
 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
 [&](Token , bool ) -> int {
@@ -1830,8 +1829,7 @@ void Preprocessor::ExpandBuiltinMacro(Token ) {
getLangOpts())
 : 0;
 });
-  } else if (II == Ident__has_include ||
- II == Ident__has_include_next) {
+  } else if (II == Ident__has_include || II == Ident__has_include_next) {
 // The argument to these two builtins should be a parenthesized
 // file name string literal using angle brackets (<>) or
 // double-quotes ("").

``




https://github.com/llvm/llvm-project/pull/92699
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Macro for constant rounding mode (PR #92699)

2024-05-19 Thread Serge Pavlov via cfe-commits

https://github.com/spavloff created 
https://github.com/llvm/llvm-project/pull/92699

The forthcoming C standard defines pragma FENV_ROUND to support constant 
rounding mode. It also requires some functions to be evaluated with such mode, 
N3096 7.6.2p4 states:

Within the scope of an FENV_ROUND pragma establishing a mode other
than FE_DYNAMIC ... invocations of functions indicated in the table
below, for which macro replacement has not been suppressed (7.1.4),
shall be evaluated according to the specified constant rounding mode
... . Invocations of functions for which macro replacement has been
suppressed and invocations of functions other than those indicated
in the table below shall not be affected by constant rounding modes
– they are affected by (and affect) only the dynamic mode.

The way this requirement is formulated indicates that it could be implemented 
using preprocessor facility. Such implementation would require a builtin macro 
that is set in the region where pragma FENV_ROUND is in effect and reflects 
constant rounding mode.

This change introduces macro __ROUNDING_MODE__, which is a string dependent on 
the constant rounding mode:

FE_TOWARDZERO"_rtz"
FE_TONEAREST "_rte"
FE_DOWNWARD  "_rtp"
FE_UPWARD"_rtn"
FE_TONEARESTFROMZERO "_rta"
FE_DYNAMIC   empty string

All these values except "_rta" are OpenCL rounding mode modifiers. Default 
value, when no pragma FENV_ROUND is specified, is empty string. Concatenation 
of a function name with the builtin macro can be used to obtain name of the 
function variant for particular rounding mode, like "sin_rtz", or 
"__builtin_cos_rtd". The test "macro_rounding_mode.c" added in this change 
provides an example of possible use.

The macro is implemented in the same way as FLT_EVAL_METHOD, which also depends 
on the results of semantic analysis.

>From 15b6edbcc8fe4559e9a9d8930f88dbbb6ed38b8c Mon Sep 17 00:00:00 2001
From: Serge Pavlov 
Date: Sun, 19 May 2024 18:43:08 +0700
Subject: [PATCH] [clang] Macro for constant rounding mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The forthcoming C standard defines pragma FENV_ROUND to support constant
rounding mode. It also requires some functions to be evaluated with such
mode, N3096 7.6.2p4 states:

Within the scope of an FENV_ROUND pragma establishing a mode other
than FE_DYNAMIC ... invocations of functions indicated in the table
below, for which macro replacement has not been suppressed (7.1.4),
shall be evaluated according to the specified constant rounding mode
... . Invocations of functions for which macro replacement has been
suppressed and invocations of functions other than those indicated
in the table below shall not be affected by constant rounding modes
– they are affected by (and affect) only the dynamic mode.

The way this requirement is formulated indicates that it could be
implemented using preprocessor facility. Such implementation would
require a builtin macro that is set in the region where pragma
FENV_ROUND is in effect and reflects constant rounding mode.

This change introduces macro __ROUNDING_MODE__, which is a string
dependent on the constant rounding mode:

FE_TOWARDZERO"_rtz"
FE_TONEAREST "_rte"
FE_DOWNWARD  "_rtp"
FE_UPWARD"_rtn"
FE_TONEARESTFROMZERO "_rta"
FE_DYNAMIC   empty string

All these values except "_rta" are OpenCL rounding mode modifiers.
Default value, when no pragma FENV_ROUND is specified, is empty string.
Concatenation of a function name with the builtin macro can be used to
obtain name of the function variant for particular rounding mode, like
"sin_rtz", or "__builtin_cos_rtd". The test "macro_rounding_mode.c"
added in this change provides an example of possible use.

The macro is implemented in the same way as FLT_EVAL_METHOD, which also
depends on the results of semantic analysis.
---
 clang/include/clang/Lex/Preprocessor.h| 12 
 clang/lib/Lex/PPMacroExpansion.cpp| 25 +
 clang/lib/Sema/Sema.cpp   |  1 +
 clang/lib/Sema/SemaAttr.cpp   |  1 +
 clang/test/Preprocessor/macro_rounding_mode.c | 55 +++
 5 files changed, 94 insertions(+)
 create mode 100644 clang/test/Preprocessor/macro_rounding_mode.c

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index c0850a8fa9f7f..295633b2e3c73 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -181,6 +181,7 @@ class Preprocessor {
   IdentifierInfo *Ident__is_target_variant_os;
   IdentifierInfo *Ident__is_target_variant_environment;
   IdentifierInfo *Ident__FLT_EVAL_METHOD__;// __FLT_EVAL_METHOD
+  IdentifierInfo *Ident__ROUNDING_MODE__;  // __ROUNDING_MODE__
 
   // Weak, only valid (and 

[clang] 643f361 - HLSL availability diagnostics design doc (#92207)

2024-05-19 Thread via cfe-commits

Author: Helena Kotas
Date: 2024-05-19T09:27:56-07:00
New Revision: 643f36184bd3d9a95cbfd608af6f169e0187

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

LOG: HLSL availability diagnostics design doc (#92207)

Design document for the HLSL availability diagnostic modes

Fixes microsoft/hlsl-specs#190

-

Co-authored-by: Xiang Li 

Added: 
clang/docs/HLSL/AvailabilityDiagnostics.rst

Modified: 
clang/docs/HLSL/HLSLDocs.rst

Removed: 




diff  --git a/clang/docs/HLSL/AvailabilityDiagnostics.rst 
b/clang/docs/HLSL/AvailabilityDiagnostics.rst
new file mode 100644
index 0..bb9d02f21dde6
--- /dev/null
+++ b/clang/docs/HLSL/AvailabilityDiagnostics.rst
@@ -0,0 +1,137 @@
+=
+HLSL Availability Diagnostics
+=
+
+.. contents::
+   :local:
+
+Introduction
+
+
+HLSL availability diagnostics emits errors or warning when unavailable shader 
APIs are used. Unavailable shader APIs are APIs that are exposed in HLSL code 
but are not available in the target shader stage or shader model version.
+
+There are three modes of HLSL availability diagnostic:
+
+#. **Default mode** - compiler emits an error when an unavailable API is found 
in a code that is reachable from the shader entry point function or from an 
exported library function (when compiling a shader library)
+
+#. **Relaxed mode** - same as default mode except the compiler emits a 
warning. This mode is enabled by ``-Wno-error=hlsl-availability``.
+
+#. **Strict mode** - compiler emits an error when an unavailable API is found 
in parsed code regardless of whether it can be reached from the shader entry 
point or exported functions, or not. This mode is enabled by 
``-fhlsl-strict-availability``.
+
+Implementation Details
+==
+
+Environment Parameter
+-
+
+In order to encode API availability based on the shader model version and 
shader model stage a new ``environment`` parameter was added to the existing 
Clang ``availability`` attribute.
+
+The values allowed for this parameter are a subset of values allowed as the 
``llvm::Triple`` environment component. If the environment parameters is 
present, the declared availability attribute applies only to targets with the 
same platform and environment.
+
+Default and Relaxed Diagnostic Modes
+
+
+This mode is implemented in ``DiagnoseHLSLAvailability`` class in 
``SemaHLSL.cpp`` and it is invoked after the whole translation unit is parsed 
(from ``Sema::ActOnEndOfTranslationUnit``). The implementation iterates over 
all shader entry points and exported library functions in the translation unit 
and performs an AST traversal of each function body.
+
+When a reference to another function or member method is found 
(``DeclRefExpr`` or ``MemberExpr``) and it has a body, the AST of the 
referenced function is also scanned. This chain of AST traversals will reach 
all of the code that is reachable from the initial shader entry point or 
exported library function and avoids the need to generate a call graph.
+
+All shader APIs have an availability attribute that specifies the shader model 
version (and environment, if applicable) when this API was first 
introduced.When a reference to a function without a definition is found and it 
has an availability attribute, the version of the attribute is checked against 
the target shader model version and shader stage (if shader stage context is 
known), and an appropriate diagnostic is generated as needed.
+
+All shader entry functions have ``HLSLShaderAttr`` attribute that specifies 
what type of shader this function represents. However, for exported library 
functions the target shader stage is unknown, so in this case the HLSL API 
availability will be only checked against the shader model version. It means 
that for exported library functions the diagnostic of APIs with availability 
specific to shader stage will be deferred until DXIL linking time.
+
+A list of functions that were already scanned is kept in order to avoid 
duplicate scans and diagnostics (see 
``DiagnoseHLSLAvailability::ScannedDecls``). It might happen that a shader 
library has multiple shader entry points for 
diff erent shader stages that all call into the same shared function. It is 
therefore important to record not just that a function has been scanned, but 
also in which shader stage context. This is done by using ``llvm::DenseMap`` 
that maps ``FunctionDecl *`` to a ``unsigned`` bitmap that represents a set of 
shader stages (or environments) the function has been scanned for. The ``N``'th 
bit in the set is set if the function has been scanned in shader environment 
whose ``HLSLShaderAttr::ShaderType`` integer 

[clang] HLSL availability diagnostics design doc (PR #92207)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota closed https://github.com/llvm/llvm-project/pull/92207
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] HLSL availability diagnostics design doc (PR #92207)

2024-05-19 Thread Helena Kotas via cfe-commits

https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/92207
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Skip tautological comparison if the comparison involves the 'size_t' type (PR #74427)

2024-05-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/74427
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Skip tautological comparison if the comparison involves the 'size_t' type (PR #74427)

2024-05-19 Thread Shivam Gupta via cfe-commits

xgupta wrote:

Sorry, I do have motivation to continue this patch now, hence closing it. Thank 
to reviewers for reviewing it.

https://github.com/llvm/llvm-project/pull/74427
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits


@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,

simonzgx wrote:

done

https://github.com/llvm/llvm-project/pull/91720
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits


@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s -Wno-c++17-extensions

simonzgx wrote:

I removed the redundant unit tests, but no new test cases were added. I'm not 
sure if that's acceptable, because `[[msvc::noinline]]` is just an alias for 
`[[clang::noinline]]`. What do you think?

https://github.com/llvm/llvm-project/pull/91720
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Don't build CXXDependentScopeMemberExprs for potentially implicit class member access expressions (PR #92318)

2024-05-19 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/92318
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Introduce `SemaCoroutine` (PR #92645)

2024-05-19 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> Was there ever an RFC on this whole 'splitting up Sema' project?

It was quite extensively discussed in #84184, but it wasn't deemed necessary to 
go through RFC process for a non-functional change that doesn't affect stable 
interfaces.

> I think starting up from the easier bits is a risky proposition, as we might 
> realize this whole thing will fail when we get to the harder parts.

`Sema` has grown so big and interconnected that it's virtually impossible to 
wrap a head around it to solve hard problems first. 

> I also think this can lead in the future to the same sort of problems 
> overusing const got us in the first place: needing large amount of repetitive 
> changes all around when a commonly used or deeply nested component starts 
> depending on a larger chunk of Sema.

I recently looked into our `const` situation, and I definitely agree that it's 
overused. I believe one of the reasons it's hard to address systematically at 
the `Sema` level is again its size and tight coupling of everything to 
everything, which makes it hard to figure out "leaves" of call chains to start 
to rectify the situation without viral changes.

> Also, this will further cement current design lines, without considering 
> where we want to be in the future.

I believe cemented design line between `Sema` and `Parser` served us well, even 
if it's limiting sometimes. That said, changes I'm making doesn't really cement 
anything yet. Everything is still available from everywhere (save for static 
functions). The difference is that dependencies between parts of `Sema` become 
more visible.

> And lastly, it seems this will lead to large amounts of code churn without 
> proportional benefit, impacting in-tree development as well as external 
> projects.

I believe that we're significantly improving maintainability here, and the 
churn is worth it in the long run. For instance, #82217 took me whopping 20-25 
hours of non-stop work to finish. Doing that in one step was requested by 
downstreams.

https://github.com/llvm/llvm-project/pull/92645
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

2024-05-19 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx closed 
https://github.com/llvm/llvm-project/pull/88182
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 10edb49 - [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (#88182)

2024-05-19 Thread via cfe-commits

Author: Alex Voicu
Date: 2024-05-19T14:59:03+01:00
New Revision: 10edb4991c12738e60843d55cd9edbf6d702d9eb

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

LOG: [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 
(#88182)

At the moment, Clang is rather liberal in assuming that 0 (and by extension 
unqualified) is always a safe default. This does not work for targets that 
actually use a different value for the default / generic AS (for example, the 
SPIRV that obtains from HIPSPV or SYCL). This patch is a first, fairly safe 
step towards trying to clear things up by querying a modules' default AS from 
the target, rather than assuming it's 0, alongside fixing a few places where 
things break / we encode the 0 == DefaultAS assumption. A bunch of existing 
tests are extended to check for non-zero default AS usage.

Added: 


Modified: 
clang/lib/CodeGen/CGException.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenTypeCache.h
clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
clang/test/CodeGenCXX/eh.cpp
clang/test/CodeGenCXX/nrvo.cpp
clang/test/CodeGenCXX/template-param-objects-address-space.cpp
clang/test/CodeGenCXX/throw-expression-typeinfo-in-address-space.cpp
clang/test/CodeGenCXX/try-catch-with-address-space.cpp
clang/test/CodeGenCXX/typeid-cxx11-with-address-space.cpp
clang/test/CodeGenCXX/typeid-with-address-space.cpp
clang/test/CodeGenCXX/typeinfo-with-address-space.cpp
clang/test/CodeGenCXX/vtable-assume-load-address-space.cpp
clang/test/CodeGenCXX/vtable-pointer-initialization-address-space.cpp
clang/test/CodeGenCXX/vtt-address-space.cpp
clang/test/CodeGenCXX/wasm-eh.cpp
llvm/examples/ExceptionDemo/ExceptionDemo.cpp
llvm/include/llvm/IR/Intrinsics.td
llvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll
llvm/test/Transforms/GVNHoist/infinite-loop-indirect.ll
llvm/test/Transforms/Inline/inline_invoke.ll
llvm/test/Transforms/LICM/scalar-promote-unwind.ll
llvm/test/Transforms/LowerTypeTests/cfi-unwind-direct-call.ll
llvm/test/Transforms/NewGVN/2011-09-07-TypeIdFor.ll
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/test/Target/LLVMIR/Import/intrinsic.ll
mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index 34f289334a7df..8acda3f2eb864 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1052,7 +1052,8 @@ static void emitWasmCatchPadBlock(CodeGenFunction ,
   CGF.Builder.CreateStore(Exn, CGF.getExceptionSlot());
   llvm::CallInst *Selector = CGF.Builder.CreateCall(GetSelectorFn, CPI);
 
-  llvm::Function *TypeIDFn = 
CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_typeid_for);
+  llvm::Function *TypeIDFn =
+  CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_typeid_for, {CGF.VoidPtrTy});
 
   // If there's only a single catch-all, branch directly to its handler.
   if (CatchScope.getNumHandlers() == 1 &&
@@ -1137,7 +1138,7 @@ static void emitCatchDispatchBlock(CodeGenFunction ,
 
   // Select the right handler.
   llvm::Function *llvm_eh_typeid_for =
-CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_typeid_for);
+  CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_typeid_for, {CGF.VoidPtrTy});
   llvm::Type *argTy = llvm_eh_typeid_for->getArg(0)->getType();
   LangAS globAS = CGF.CGM.GetGlobalVarAddressSpace(nullptr);
 

diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index c18c36d3f3f32..0cfdb7effe470 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -2216,7 +2216,12 @@ static llvm::Value *EmitTypeidFromVTable(CodeGenFunction 
, const Expr *E,
 }
 
 llvm::Value *CodeGenFunction::EmitCXXTypeidExpr(const CXXTypeidExpr *E) {
-  llvm::Type *PtrTy = llvm::PointerType::getUnqual(getLLVMContext());
+  // Ideally, we would like to use GlobalsInt8PtrTy here, however, we cannot,
+  // primarily because the result of applying typeid is a value of type
+  // type_info, which is declared & defined by the standard library
+  // implementation and expects to operate on the generic (default) AS.
+  // https://reviews.llvm.org/D157452 has more context, and a possible 
solution.
+  llvm::Type *PtrTy = Int8PtrTy;
   LangAS GlobAS = CGM.GetGlobalVarAddressSpace(nullptr);
 
   auto MaybeASCast = [=](auto &) {

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 489c08a4d4819..227813ad44e8b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -368,7 +368,8 @@ CodeGenModule::CodeGenModule(ASTContext ,
   IntTy = llvm::IntegerType::get(LLVMContext, 

[clang] [clang-tools-extra] [Clang][Sema] Diagnose current instantiation used as an incomplete base class (PR #92597)

2024-05-19 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov approved this pull request.

The change itself looks pretty good, but note that GCC only warns about this, 
and more importantly MSVC still accepts the code without complaint.

So this means that we could find out from user feedback that we will need to 
keep the old behavior around behind a flag and for ms-compat mode.

But I would be much in favor of going ahead, only making that change later 
depending on impact.

https://github.com/llvm/llvm-project/pull/92597
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Introduce `SemaCoroutine` (PR #92645)

2024-05-19 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

Was there ever an RFC on this whole 'splitting up Sema' project?

I have my own reservations as well.

I think starting up from the easier bits is a risky proposition, as we might 
realize this whole thing will fail when we get to the harder parts.

I also think this can lead in the future to the same sort of problems overusing 
const got us in the first place: needing large amount of repetitive changes all 
around when a commonly used or deeply nested component starts depending on a 
larger chunk of Sema.

Also, this will further cement current design lines, without considering where 
we want to be in the future.

And lastly, it seems this will lead to large amounts of code churn without 
proportional benefit, impacting in-tree development as well as external 
projects.

https://github.com/llvm/llvm-project/pull/92645
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c587483 - Revert "[Bounds-Safety] Fix `pragma-attribute-supported-attributes-list.test`"

2024-05-19 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-05-19T06:21:40-07:00
New Revision: c587483da0b50efa04146fde205da1d16731e12e

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

LOG: Revert "[Bounds-Safety] Fix 
`pragma-attribute-supported-attributes-list.test`"

Issue #92687

This reverts commit 112eadd55f06bee15caadff688ea0b45acbfa804.

Added: 


Modified: 
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test 
b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index 99732694f72a5..fd0e6d71baa80 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -63,6 +63,7 @@
 // CHECK-NEXT: CoroOnlyDestroyWhenComplete (SubjectMatchRule_record)
 // CHECK-NEXT: CoroReturnType (SubjectMatchRule_record)
 // CHECK-NEXT: CoroWrapper (SubjectMatchRule_function)
+// CHECK-NEXT: CountedBy (SubjectMatchRule_field)
 // CHECK-NEXT: DLLExport (SubjectMatchRule_function, 
SubjectMatchRule_variable, SubjectMatchRule_record, 
SubjectMatchRule_objc_interface)
 // CHECK-NEXT: DLLImport (SubjectMatchRule_function, 
SubjectMatchRule_variable, SubjectMatchRule_record, 
SubjectMatchRule_objc_interface)
 // CHECK-NEXT: Destructor (SubjectMatchRule_function)



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


[clang] 6447abe - Revert "[BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (#90786)"

2024-05-19 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-05-19T05:44:40-07:00
New Revision: 6447abe067c8088a5cc093fe872719374e174068

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

LOG: Revert "[BoundsSafety] Allow 'counted_by' attribute on pointers in structs 
in C (#90786)"

Memory leak: https://lab.llvm.org/buildbot/#/builders/5/builds/43403

Issue #92687

This reverts commit 0ec3b972e58bcbcdc1bebe1696ea37f2931287c3.

Added: 
clang/test/Sema/attr-counted-by.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Type.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Type.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseObjc.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h

Removed: 
clang/test/AST/attr-counted-by-late-parsed-struct-ptrs.c
clang/test/AST/attr-counted-by-struct-ptrs.c
clang/test/Sema/attr-counted-by-late-parsed-off.c
clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c
clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c
clang/test/Sema/attr-counted-by-struct-ptrs.c
clang/test/Sema/attr-counted-by-vla-sizeless-types.c
clang/test/Sema/attr-counted-by-vla.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2f83f5c6d54e9..7af5869d21768 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -317,8 +317,7 @@ New Compiler Flags
 
 - ``-fexperimental-late-parse-attributes`` enables an experimental feature to
   allow late parsing certain attributes in specific contexts where they would
-  not normally be late parsed. Currently this allows late parsing the
-  `counted_by` attribute in C. See `Attribute Changes in Clang`_.
+  not normally be late parsed.
 
 - ``-fseparate-named-sections`` uses separate unique sections for global
   symbols in named special sections (i.e. symbols annotated with
@@ -407,24 +406,6 @@ Attribute Changes in Clang
 - The ``clspv_libclc_builtin`` attribute has been added to allow clspv
   (`OpenCL-C to Vulkan SPIR-V compiler `_) to 
identify functions coming from libclc
   (`OpenCL-C builtin library `_).
-- The ``counted_by`` attribute is now allowed on pointers that are members of a
-  struct in C.
-
-- The ``counted_by`` attribute can now be late parsed in C when
-  ``-fexperimental-late-parse-attributes`` is passed but only when attribute is
-  used in the declaration attribute position. This allows using the
-  attribute on existing code where it previously impossible to do so without
-  re-ordering struct field declarations would break ABI as shown below.
-
-  .. code-block:: c
-
- struct BufferTy {
-   /* Refering to `count` requires late parsing */
-   char* buffer __counted_by(count);
-   /* Swapping `buffer` and `count` to avoid late parsing would break ABI 
*/
-   size_t count;
- };
-
 
 Improvements to Clang's diagnostics
 ---

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index c7a8e785913b3..da3834f19ca04 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2515,7 +2515,6 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isRecordType() const;
   bool isClassType() const;
   bool isStructureType() const;
-  bool isStructureTypeWithFlexibleArrayMember() const;
   bool isObjCBoxableRecordType() const;
   bool isInterfaceType() const;
   bool isStructureOrClassType() const;

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7a7721239a28f..38ee8356583be 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2229,8 +2229,7 @@ def TypeNullUnspecified : TypeAttr {
 def CountedBy : DeclOrTypeAttr {
   let Spellings = [Clang<"counted_by">];
   let Subjects = SubjectList<[Field], ErrorDiag>;
-  let Args = [ExprArgument<"Count">, IntArgument<"NestedLevel", 1>];
-  let LateParsed = LateAttrParseExperimentalExt;
+  let Args = [ExprArgument<"Count">, IntArgument<"NestedLevel">];
   let ParseArgumentsAsUnevaluated = 1;
   let Documentation = [CountedByDocs];
   let LangOpts = [COnly];

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8e6596410c5d0..09b1874f9fddd 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6533,10 +6533,8 @@ def warn_superclass_variable_sized_type_not_at_end : 
Warning<
 
 def 

[clang] ed9007d - Revert "[Bounds-Safety] Temporarily relax a `counted_by` attribute restriction on flexible array members"

2024-05-19 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-05-19T05:44:40-07:00
New Revision: ed9007d0d219726db01f211e9c9ab72fbfe4ecb1

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

LOG: Revert "[Bounds-Safety] Temporarily relax a `counted_by` attribute 
restriction on flexible array members"

Together with 0ec3b972e58bcbcdc1bebe1696ea37f2931287c3
breaks https://lab.llvm.org/buildbot/#/builders/5/builds/43403

Issue #92687

This reverts commit cef6387e52578366c2332275dad88b9953b55336.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Sema/attr-counted-by-vla.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 4fad4d1a0eca7..4cb4f3d999f7a 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1447,10 +1447,6 @@ def FunctionMultiVersioning
 
 def NoDeref : DiagGroup<"noderef">;
 
-// -fbounds-safety and bounds annotation related warnings
-def BoundsSafetyCountedByEltTyUnknownSize :
-  DiagGroup<"bounds-safety-counted-by-elt-type-unknown-size">;
-
 // A group for cross translation unit static analysis related warnings.
 def CrossTU : DiagGroup<"ctu">;
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1efa3af121c10..8e6596410c5d0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6552,7 +6552,7 @@ def err_counted_by_attr_refer_to_union : Error<
 def note_flexible_array_counted_by_attr_field : Note<
   "field %0 declared here">;
 def err_counted_by_attr_pointee_unknown_size : Error<
-  "'counted_by' %select{cannot|should not}3 be applied to %select{"
+  "'counted_by' cannot be applied to %select{"
 "a pointer with pointee|" // pointer
 "an array with element}0" // array
   " of unknown size because %1 is %select{"
@@ -6561,14 +6561,8 @@ def err_counted_by_attr_pointee_unknown_size : Error<
 "a function type|" // CountedByInvalidPointeeTypeKind::FUNCTION
 // CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER
 "a struct type with a flexible array member"
-"%select{|. This will be an error in a future compiler version}3"
-""
   "}2">;
 
-def warn_counted_by_attr_elt_type_unknown_size :
-  Warning,
-  InGroup;
-
 let CategoryName = "ARC Semantic Issue" in {
 
 // ARC-mode diagnostics.

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e816ea3647a7c..c8b71631076ba 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -8687,7 +8687,6 @@ static bool CheckCountedByAttrOnField(
   // Note: The `Decl::isFlexibleArrayMemberLike` check earlier on means
   // only `PointeeTy->isStructureTypeWithFlexibleArrayMember()` is reachable
   // when `FieldTy->isArrayType()`.
-  bool ShouldWarn = false;
   if (PointeeTy->isIncompleteType()) {
 InvalidTypeKind = CountedByInvalidPointeeTypeKind::INCOMPLETE;
   } else if (PointeeTy->isSizelessType()) {
@@ -8695,25 +8694,13 @@ static bool CheckCountedByAttrOnField(
   } else if (PointeeTy->isFunctionType()) {
 InvalidTypeKind = CountedByInvalidPointeeTypeKind::FUNCTION;
   } else if (PointeeTy->isStructureTypeWithFlexibleArrayMember()) {
-if (FieldTy->isArrayType()) {
-  // This is a workaround for the Linux kernel that has already adopted
-  // `counted_by` on a FAM where the pointee is a struct with a FAM. This
-  // should be an error because computing the bounds of the array cannot be
-  // done correctly without manually traversing every struct object in the
-  // array at runtime. To allow the code to be built this error is
-  // downgraded to a warning.
-  ShouldWarn = true;
-}
 InvalidTypeKind = CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER;
   }
 
   if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID) {
-unsigned DiagID = ShouldWarn
-  ? diag::warn_counted_by_attr_elt_type_unknown_size
-  : diag::err_counted_by_attr_pointee_unknown_size;
-S.Diag(FD->getBeginLoc(), DiagID)
+S.Diag(FD->getBeginLoc(), diag::err_counted_by_attr_pointee_unknown_size)
 << SelectPtrOrArr << PointeeTy << (int)InvalidTypeKind
-<< (ShouldWarn ? 1 : 0) << FD->getSourceRange();
+<< FD->getSourceRange();
 return true;
   }
 

diff  --git a/clang/test/Sema/attr-counted-by-vla.c 
b/clang/test/Sema/attr-counted-by-vla.c
index b25f719f3b95a..3de6bd55e2d8e 100644
--- a/clang/test/Sema/attr-counted-by-vla.c
+++ b/clang/test/Sema/attr-counted-by-vla.c
@@ 

[clang] [clang][NFC] Refactor `Sema::TagUseKind` (PR #92689)

2024-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This patch makes `TagUseKind` a scoped enumeration, and moves it outside of 
`Sema` class, making it eligible for forward declaring.

---

Patch is 55.02 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/92689.diff


7 Files Affected:

- (modified) clang/include/clang/Parse/Parser.h (+1-1) 
- (modified) clang/include/clang/Sema/Sema.h (+7-7) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+16-17) 
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+25-25) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+48-43) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+7-6) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+56-51) 


``diff
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index af50164a8f93f..690b1ef66af9f 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2814,7 +2814,7 @@ class Parser : public CodeCompletionHandler {
SourceLocation CorrectLocation);
 
   void stripTypeAttributesOffDeclSpec(ParsedAttributes , DeclSpec ,
-  Sema::TagUseKind TUK);
+  TagUseKind TUK);
 
   // FixItLoc = possible correct location for the attributes
   void ProhibitAttributes(ParsedAttributes ,
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d4d4a82525a02..071c0f8d9c406 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -445,6 +445,13 @@ enum class CheckedConversionKind {
   ForBuiltinOverloadedOp
 };
 
+enum class TagUseKind {
+  Reference,   // Reference to a tag:  'struct foo *X;'
+  Declaration, // Fwd decl of a tag:   'struct foo;'
+  Definition,  // Definition of a tag: 'struct foo { int X; } Y;'
+  Friend   // Friend declaration:  'friend struct foo;'
+};
+
 /// Sema - This implements semantic analysis and AST building for C.
 /// \nosubgrouping
 class Sema final : public SemaBase {
@@ -3161,13 +3168,6 @@ class Sema final : public SemaBase {
 bool isDefinition, SourceLocation 
NewTagLoc,
 const IdentifierInfo *Name);
 
-  enum TagUseKind {
-TUK_Reference,   // Reference to a tag:  'struct foo *X;'
-TUK_Declaration, // Fwd decl of a tag:   'struct foo;'
-TUK_Definition,  // Definition of a tag: 'struct foo { int X; } Y;'
-TUK_Friend   // Friend declaration:  'friend struct foo;'
-  };
-
   enum OffsetOfKind {
 // Not parsing a type within __builtin_offsetof.
 OOK_Outside,
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 8405b44685ae4..5873a2633fc80 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -1905,9 +1905,8 @@ void 
Parser::DiagnoseCXX11AttributeExtension(ParsedAttributes ) {
 // variable.
 // This function moves attributes that should apply to the type off DS to 
Attrs.
 void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributes ,
-DeclSpec ,
-Sema::TagUseKind TUK) {
-  if (TUK == Sema::TUK_Reference)
+DeclSpec , TagUseKind TUK) {
+  if (TUK == TagUseKind::Reference)
 return;
 
   llvm::SmallVector ToBeMoved;
@@ -5359,9 +5358,9 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
   // enum foo {..};  void bar() { enum foo; }<- new foo in bar.
   // enum foo {..};  void bar() { enum foo x; }  <- use of old foo.
   //
-  Sema::TagUseKind TUK;
+  TagUseKind TUK;
   if (AllowEnumSpecifier == AllowDefiningTypeSpec::No)
-TUK = Sema::TUK_Reference;
+TUK = TagUseKind::Reference;
   else if (Tok.is(tok::l_brace)) {
 if (DS.isFriendSpecified()) {
   Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
@@ -5373,9 +5372,9 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
   ScopedEnumKWLoc = SourceLocation();
   IsScopedUsingClassTag = false;
   BaseType = TypeResult();
-  TUK = Sema::TUK_Friend;
+  TUK = TagUseKind::Friend;
 } else {
-  TUK = Sema::TUK_Definition;
+  TUK = TagUseKind::Definition;
 }
   } else if (!isTypeSpecifier(DSC) &&
  (Tok.is(tok::semi) ||
@@ -5384,7 +5383,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 // An opaque-enum-declaration is required to be standalone (no preceding or
 // following tokens in the declaration). Sema enforces this separately by
 // diagnosing anything else in the DeclSpec.
-TUK = DS.isFriendSpecified() ? Sema::TUK_Friend : Sema::TUK_Declaration;
+TUK = DS.isFriendSpecified() ? TagUseKind::Friend : 
TagUseKind::Declaration;
 if (Tok.isNot(tok::semi)) {
   // A semicolon was missing after this declaration. Diagnose and 

[clang] [clang][NFC] Refactor `Sema::TagUseKind` (PR #92689)

2024-05-19 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

I'll merge this when CI passes.

https://github.com/llvm/llvm-project/pull/92689
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Refactor `Sema::TagUseKind` (PR #92689)

2024-05-19 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/92689

This patch makes `TagUseKind` a scoped enumeration, and moves it outside of 
`Sema` class, making it eligible for forward declaring.

>From 9c89a7b451221d79f96fd1fc1d015c6a22b9f66e Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 19 May 2024 15:00:38 +0300
Subject: [PATCH] [clang][NFC] Refactor `Sema::TagUseKind`

This patch makes `TagUseKind` a scoped enumeration, and moves it outside of 
`Sema` class, making it eligible for forward declaring.
---
 clang/include/clang/Parse/Parser.h |   2 +-
 clang/include/clang/Sema/Sema.h|  14 ++--
 clang/lib/Parse/ParseDecl.cpp  |  33 +
 clang/lib/Parse/ParseDeclCXX.cpp   |  50 +++---
 clang/lib/Sema/SemaDecl.cpp|  91 
 clang/lib/Sema/SemaDeclCXX.cpp |  13 ++--
 clang/lib/Sema/SemaTemplate.cpp| 107 +++--
 7 files changed, 160 insertions(+), 150 deletions(-)

diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index af50164a8f93f..690b1ef66af9f 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2814,7 +2814,7 @@ class Parser : public CodeCompletionHandler {
SourceLocation CorrectLocation);
 
   void stripTypeAttributesOffDeclSpec(ParsedAttributes , DeclSpec ,
-  Sema::TagUseKind TUK);
+  TagUseKind TUK);
 
   // FixItLoc = possible correct location for the attributes
   void ProhibitAttributes(ParsedAttributes ,
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d4d4a82525a02..071c0f8d9c406 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -445,6 +445,13 @@ enum class CheckedConversionKind {
   ForBuiltinOverloadedOp
 };
 
+enum class TagUseKind {
+  Reference,   // Reference to a tag:  'struct foo *X;'
+  Declaration, // Fwd decl of a tag:   'struct foo;'
+  Definition,  // Definition of a tag: 'struct foo { int X; } Y;'
+  Friend   // Friend declaration:  'friend struct foo;'
+};
+
 /// Sema - This implements semantic analysis and AST building for C.
 /// \nosubgrouping
 class Sema final : public SemaBase {
@@ -3161,13 +3168,6 @@ class Sema final : public SemaBase {
 bool isDefinition, SourceLocation 
NewTagLoc,
 const IdentifierInfo *Name);
 
-  enum TagUseKind {
-TUK_Reference,   // Reference to a tag:  'struct foo *X;'
-TUK_Declaration, // Fwd decl of a tag:   'struct foo;'
-TUK_Definition,  // Definition of a tag: 'struct foo { int X; } Y;'
-TUK_Friend   // Friend declaration:  'friend struct foo;'
-  };
-
   enum OffsetOfKind {
 // Not parsing a type within __builtin_offsetof.
 OOK_Outside,
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 8405b44685ae4..5873a2633fc80 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -1905,9 +1905,8 @@ void 
Parser::DiagnoseCXX11AttributeExtension(ParsedAttributes ) {
 // variable.
 // This function moves attributes that should apply to the type off DS to 
Attrs.
 void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributes ,
-DeclSpec ,
-Sema::TagUseKind TUK) {
-  if (TUK == Sema::TUK_Reference)
+DeclSpec , TagUseKind TUK) {
+  if (TUK == TagUseKind::Reference)
 return;
 
   llvm::SmallVector ToBeMoved;
@@ -5359,9 +5358,9 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
   // enum foo {..};  void bar() { enum foo; }<- new foo in bar.
   // enum foo {..};  void bar() { enum foo x; }  <- use of old foo.
   //
-  Sema::TagUseKind TUK;
+  TagUseKind TUK;
   if (AllowEnumSpecifier == AllowDefiningTypeSpec::No)
-TUK = Sema::TUK_Reference;
+TUK = TagUseKind::Reference;
   else if (Tok.is(tok::l_brace)) {
 if (DS.isFriendSpecified()) {
   Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
@@ -5373,9 +5372,9 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
   ScopedEnumKWLoc = SourceLocation();
   IsScopedUsingClassTag = false;
   BaseType = TypeResult();
-  TUK = Sema::TUK_Friend;
+  TUK = TagUseKind::Friend;
 } else {
-  TUK = Sema::TUK_Definition;
+  TUK = TagUseKind::Definition;
 }
   } else if (!isTypeSpecifier(DSC) &&
  (Tok.is(tok::semi) ||
@@ -5384,7 +5383,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 // An opaque-enum-declaration is required to be standalone (no preceding or
 // following tokens in the declaration). Sema enforces this separately by
 // diagnosing anything else in the DeclSpec.
-TUK = DS.isFriendSpecified() ? 

[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits

https://github.com/simonzgx updated 
https://github.com/llvm/llvm-project/pull/91720

>From 54b69712d2ffc3536d41d56194e67da802b92049 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 01:24:24 +0800
Subject: [PATCH 1/4] [Clang] Add support for [[msvc::noinline]] attribute.
 (#90941)

---
 clang/include/clang/Basic/Attr.td   | 5 -
 clang/include/clang/Basic/AttrDocs.td   | 2 ++
 clang/test/CodeGen/attr-ms-noinline.cpp | 0
 clang/test/Sema/attr-ms-noinline.cpp| 0
 4 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-ms-noinline.cpp
 create mode 100644 clang/test/Sema/attr-ms-noinline.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7a7721239a28f..8532e5c47fe47 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
-C23<"clang", "noinline">]>];
+C23<"clang", "noinline">,
+CXX11<"msvc", "noinline">,
+C23<"msvc", "noinline">]>];
   let Documentation = [NoInlineDocs];
   let Subjects = SubjectList<[Function, Stmt], WarnDiag,
  "functions and statements">;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b48aaf65558ac..7442f7e828462 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,6 +597,8 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
+``[[msvc::noinline]]`` 
+
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Sema/attr-ms-noinline.cpp 
b/clang/test/Sema/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d

>From bbc27cb48f616a98d4d379b8ac72e0c408c8ca64 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 17:46:40 +0800
Subject: [PATCH 2/4] add unit test

---
 clang/include/clang/Basic/AttrDocs.td   |  2 -
 clang/test/CodeGen/attr-ms-noinline.cpp | 53 
 clang/test/Sema/attr-ms-noinline.cpp| 66 +
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 7442f7e828462..b48aaf65558ac 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,8 +597,6 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
-``[[msvc::noinline]]`` 
-
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
index e69de29bb2d1d..99b0a05af715d 100644
--- a/clang/test/CodeGen/attr-ms-noinline.cpp
+++ b/clang/test/CodeGen/attr-ms-noinline.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
+
+bool bar();
+void f(bool, bool);
+void g(bool);
+
+static int baz(int x) {
+return x * 10;
+}
+
+[[msvc::noinline]] bool noi() { }
+
+void foo(int i) {
+  [[msvc::noinline]] bar();
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
+  [[msvc::noinline]] i = baz(i);
+// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] (i = 4, bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] (void)(bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] f(bar(), bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] [] { bar(); 

[clang] [clang] Introduce `SemaCoroutine` (PR #92645)

2024-05-19 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/92645

>From 4fe09a3411e54561857d2f9d8c1808cb2728e299 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 18 May 2024 13:33:04 +0300
Subject: [PATCH 1/3] [clang] Introduce `SemaCoroutine`

---
 clang/include/clang/Sema/Sema.h  |  58 +-
 clang/include/clang/Sema/SemaCoroutine.h |  73 
 clang/lib/Parse/ParseExpr.cpp|   3 +-
 clang/lib/Parse/ParseExprCXX.cpp |   3 +-
 clang/lib/Parse/ParseStmt.cpp|   3 +-
 clang/lib/Sema/Sema.cpp  |   4 +-
 clang/lib/Sema/SemaCoroutine.cpp | 218 ---
 clang/lib/Sema/SemaDecl.cpp  |  16 +-
 clang/lib/Sema/SemaStmt.cpp  |   9 +-
 clang/lib/Sema/TreeTransform.h   |  25 +--
 10 files changed, 227 insertions(+), 185 deletions(-)
 create mode 100644 clang/include/clang/Sema/SemaCoroutine.h

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d4d4a82525a02..1d0fbeacfe061 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -168,6 +168,7 @@ class PseudoDestructorTypeStorage;
 class PseudoObjectExpr;
 class QualType;
 class SemaCodeCompletion;
+class SemaCoroutine;
 class SemaCUDA;
 class SemaHLSL;
 class SemaObjC;
@@ -989,6 +990,11 @@ class Sema final : public SemaBase {
 return *CodeCompletionPtr;
   }
 
+  SemaCoroutine () {
+assert(CoroutinePtr);
+return *CoroutinePtr;
+  }
+
   SemaCUDA () {
 assert(CUDAPtr);
 return *CUDAPtr;
@@ -1050,6 +1056,7 @@ class Sema final : public SemaBase {
   mutable IdentifierInfo *Ident_super;
 
   std::unique_ptr CodeCompletionPtr;
+  std::unique_ptr CoroutinePtr;
   std::unique_ptr CUDAPtr;
   std::unique_ptr HLSLPtr;
   std::unique_ptr ObjCPtr;
@@ -2267,57 +2274,6 @@ class Sema final : public SemaBase {
   //
   //
 
-  /// \name C++ Coroutines
-  /// Implementations are in SemaCoroutine.cpp
-  ///@{
-
-public:
-  /// The C++ "std::coroutine_traits" template, which is defined in
-  /// \
-  ClassTemplateDecl *StdCoroutineTraitsCache;
-
-  bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc,
-   StringRef Keyword);
-  ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E);
-  ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E);
-  StmtResult ActOnCoreturnStmt(Scope *S, SourceLocation KwLoc, Expr *E);
-
-  ExprResult BuildOperatorCoawaitLookupExpr(Scope *S, SourceLocation Loc);
-  ExprResult BuildOperatorCoawaitCall(SourceLocation Loc, Expr *E,
-  UnresolvedLookupExpr *Lookup);
-  ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand,
-  Expr *Awaiter, bool IsImplicit = false);
-  ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand,
-UnresolvedLookupExpr *Lookup);
-  ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E);
-  StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E,
-   bool IsImplicit = false);
-  StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs);
-  bool buildCoroutineParameterMoves(SourceLocation Loc);
-  VarDecl *buildCoroutinePromise(SourceLocation Loc);
-  void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *);
-
-  // As a clang extension, enforces that a non-coroutine function must be 
marked
-  // with [[clang::coro_wrapper]] if it returns a type marked with
-  // [[clang::coro_return_type]].
-  // Expects that FD is not a coroutine.
-  void CheckCoroutineWrapper(FunctionDecl *FD);
-  /// Lookup 'coroutine_traits' in std namespace and std::experimental
-  /// namespace. The namespace found is recorded in Namespace.
-  ClassTemplateDecl *lookupCoroutineTraits(SourceLocation KwLoc,
-   SourceLocation FuncLoc);
-  /// Check that the expression co_await promise.final_suspend() shall not be
-  /// potentially-throwing.
-  bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
-
-  ///@}
-
-  //
-  //
-  // -
-  //
-  //
-
   /// \name C++ Scope Specifiers
   /// Implementations are in SemaCXXScopeSpec.cpp
   ///@{
diff --git a/clang/include/clang/Sema/SemaCoroutine.h 
b/clang/include/clang/Sema/SemaCoroutine.h
new file mode 100644
index 0..20f1fffc970f8
--- /dev/null
+++ b/clang/include/clang/Sema/SemaCoroutine.h
@@ -0,0 +1,73 @@
+//===- SemaCUDA.h - Semantic Analysis for C++20 coroutines 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+/// \file
+/// This file declares semantic 

[clang] [llvm] [clang][dataflow] Make `CNFFormula` externally accessible. (PR #92401)

2024-05-19 Thread Stanislav Gatev via cfe-commits

https://github.com/sgatev edited https://github.com/llvm/llvm-project/pull/92401
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >