[PATCH] D135750: [clang][Interp] Track initialization state of local variables

2022-12-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/InterpBlock.h:97
   void invokeCtor() {
-std::memset(data(), 0, getSize());
+std::memset(rawData(), 0, Desc->getAllocSize());
 if (Desc->CtorFn)

aaron.ballman wrote:
> tbaeder wrote:
> > aaron.ballman wrote:
> > > tbaeder wrote:
> > > > aaron.ballman wrote:
> > > > > tbaeder wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > Why do we want to overwrite the metadata here?
> > > > > > This is only called after creating an new block, so nothing is 
> > > > > > being overwritten, the metadata hasn't been filled-in yet.
> > > > > Sounds like a good reason not to memset over that block then; it's 
> > > > > useless work that will be thrown away anyway (I worry we may come to 
> > > > > rely on this zero init accidentally)?
> > > > FWIW I looked into this and I think zeroing everything is what we want, 
> > > > so the initmap is null initially 
> > > Hmmm, would it make more sense to have the init map setting that itself 
> > > (in `allocate()`) rather than relying on `invokeCtor()` to do it?
> > It's a bit blurry to me regarding the layering with Pointer/Descriptor. 
> > Descriptors don't know anything about the metadata, but pointers know that 
> > primitive arrays have an initmap. So to keep that consistent, we'd have to 
> > create a pointer to create the initmap.
> > 
> > But I don't think it's unreasonable to expect zero-initialization for types 
> > used in the interpreter.
> > It's a bit blurry to me regarding the layering with Pointer/Descriptor. 
> > Descriptors don't know anything about the metadata, but pointers know that 
> > primitive arrays have an initmap. So to keep that consistent, we'd have to 
> > create a pointer to create the initmap.
> >
> > But I don't think it's unreasonable to expect zero-initialization for types 
> > used in the interpreter.
> 
> My concern is the overhead of doing initialization twice in the interpreter. 
> If we're going to zero init and then mostly write over the top of what we 
> initialized, the zero init busywork we don't need to perform. Secondarily, I 
> worry about relying on that zero init when it's not done as part of 
> initialization due to fragility (it's a multi-step init at this point; we 
> allocate, something else zeros, and something else fills in the data).
Right, I understand the concerns.

I have looked into using `data()` instead here, but that causes other problems 
with arrays of unknown size. (We assert in `getSize()`). But I know where the 
right place to initialize the initmap would be now.

As for performance, this shouldn't make a difference to before, since the 
metadata is always small. We might of course want to get rid of the memset 
altogether, but both that //and// not zero-ing the metadata needs a different 
patch in any case.

So I think this is okay for this patch.


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

https://reviews.llvm.org/D135750

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


[PATCH] D139257: [clang-format] Link the braces of a block in UnwrappedLineParser

2022-12-08 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

See https://github.com/llvm/llvm-project/issues/59417.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139257

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


[clang] c25cc84 - [clang] Don't including None.h (NFC)

2022-12-08 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-08T23:36:50-08:00
New Revision: c25cc84b87935feefea5a93abc16efdbc9d91640

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

LOG: [clang] Don't including None.h (NFC)

These source files no longer use None, so they do not need to include
None.h.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/AST/DeclFriend.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
clang/include/clang/Analysis/CFG.h
clang/include/clang/Lex/PreprocessingRecord.h
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
clang/lib/AST/ExternalASTSource.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Analysis/PathDiagnostic.cpp
clang/lib/Analysis/UninitializedValues.cpp
clang/lib/Driver/Compilation.cpp
clang/lib/Frontend/DiagnosticRenderer.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/lib/Tooling/Syntax/Tokens.cpp
clang/lib/Tooling/Transformer/Parsing.cpp
clang/unittests/Format/SortIncludesTest.cpp
clang/unittests/Tooling/Syntax/TokensTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclFriend.h 
b/clang/include/clang/AST/DeclFriend.h
index d1de5c504ac4a..52efbb1306318 100644
--- a/clang/include/clang/AST/DeclFriend.h
+++ b/clang/include/clang/AST/DeclFriend.h
@@ -23,7 +23,6 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/None.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"

diff  --git a/clang/include/clang/AST/TemplateBase.h 
b/clang/include/clang/AST/TemplateBase.h
index 728bdf693878c..0fce875a2f256 100644
--- a/clang/include/clang/AST/TemplateBase.h
+++ b/clang/include/clang/AST/TemplateBase.h
@@ -23,7 +23,6 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 9e2ad3c3603a6..a21de561f0259 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -52,7 +52,6 @@
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"

diff  --git a/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h 
b/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
index 8964481ee66c5..4356834adf76f 100644
--- a/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
+++ b/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
@@ -18,7 +18,6 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/None.h"
 #include "llvm/ADT/PostOrderIterator.h"
 #include 
 #include 

diff  --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h 
b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
index 385cd02f882c0..0befa8fd8068b 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -50,7 +50,6 @@
 #include "clang/Analysis/Analyses/ThreadSafetyUtil.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"

diff  --git a/clang/include/clang/Analysis/CFG.h 
b/clang/include/clang/Analysis/CFG.h
index c46d6f3ff05a4..c3721d06e9eaa 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -21,7 +21,6 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/GraphTraits.h"
-#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/PointerIntPair.h"
 #inclu

[PATCH] D139387: [NFC][Clang] Add missing test cases for segment load

2022-12-08 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 481521.
4vtomat added a comment.

Update failed test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139387

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c
@@ -8204,3 +8204,107 @@
 void test_vlseg2e16ff_v_f16m4_m (vfloat16m4_t *v0, vfloat16m4_t *v1, vbool4_t mask, vfloat16m4_t maskedoff0, vfloat16m4_t maskedoff1, const _Float16 *base, size_t *new_vl, size_t vl) {
   return vlseg2e16ff_v_f16m4_m(v0, v1, mask, maskedoff0, maskedoff1, base, new_vl, vl);
 }
+
+// CHECK-RV32-LABEL: @test_vlseg2e32ff_v_u32mf2_tuma(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call { , , i32 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i32( [[MERGE0:%.*]],  [[MERGE1:%.*]], ptr [[BASE:%.*]],  [[MASK:%.*]], i32 [[VL:%.*]], i32 2)
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = extractvalue { , , i32 } [[TMP0]], 0
+// CHECK-RV32-NEXT:store  [[TMP1]], ptr [[V0:%.*]], align 4
+// CHECK-RV32-NEXT:[[TMP2:%.*]] = extractvalue { , , i32 } [[TMP0]], 1
+// CHECK-RV32-NEXT:store  [[TMP2]], ptr [[V1:%.*]], align 4
+// CHECK-RV32-NEXT:[[TMP3:%.*]] = extractvalue { , , i32 } [[TMP0]], 2
+// CHECK-RV32-NEXT:store i32 [[TMP3]], ptr [[NEW_VL:%.*]], align 4
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: @test_vlseg2e32ff_v_u32mf2_tuma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { , , i64 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i64( [[MERGE0:%.*]],  [[MERGE1:%.*]], ptr [[BASE:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , , i64 } [[TMP0]], 0
+// CHECK-RV64-NEXT:store  [[TMP1]], ptr [[V0:%.*]], align 4
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , , i64 } [[TMP0]], 1
+// CHECK-RV64-NEXT:store  [[TMP2]], ptr [[V1:%.*]], align 4
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , , i64 } [[TMP0]], 2
+// CHECK-RV64-NEXT:store i64 [[TMP3]], ptr [[NEW_VL:%.*]], align 4
+// CHECK-RV64-NEXT:ret void
+//
+void test_vlseg2e32ff_v_u32mf2_tuma(vuint32mf2_t *v0, vuint32mf2_t *v1, vbool64_t mask, vuint32mf2_t merge0, vuint32mf2_t merge1, const uint32_t *base, size_t *new_vl, size_t vl) {
+  return vlseg2e32ff_v_u32mf2_tuma(v0, v1, mask, merge0, merge1, base, new_vl, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vlseg2e32ff_v_u32mf2_tumu(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call { , , i32 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i32( [[MERGE0:%.*]],  [[MERGE1:%.*]], ptr [[BASE:%.*]],  [[MASK:%.*]], i32 [[VL:%.*]], i32 0)
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = extractvalue { , , i32 } [[TMP0]], 0
+// CHECK-RV32-NEXT:store  [[TMP1]], ptr [[V0:%.*]], align 4
+// CHECK-RV32-NEXT:[[TMP2:%.*]] = extractvalue { , , i32 } [[TMP0]], 1
+// CHECK-RV32-NEXT:store  [[TMP2]], ptr [[V1:%.*]], align 4
+// CHECK-RV32-NEXT:[[TMP3:%.*]] = extractvalue { , , i32 } [[TMP0]], 2
+// CHECK-RV32-NEXT:store i32 [[TMP3]], ptr [[NEW_VL:%.*]], align 4
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: @test_vlseg2e32ff_v_u32mf2_tumu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { , , i64 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i64( [[MERGE0:%.*]],  [[MERGE1:%.*]], ptr [[BASE:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , , i64 } [[TMP0]], 0
+// CHECK-RV64-NEXT:store  [[TMP1]], ptr [[V0:%.*]], align 4
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , , i64 } [[TMP0]], 1
+// CHECK-RV64-NEXT:store  [[TMP2]], ptr [[V1:%.*]], align 4
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , , i64 } [[TMP0]], 2
+// CHECK-RV64-NEXT:store i64 [[TMP3]], ptr [[NEW_VL:%.*]], align 4
+// CHECK-RV64-NEXT:ret void
+//
+void test_vlseg2e32ff_v_u32mf2_tumu(vuint32mf2_t *v0, vuint32mf2_t *v1, vbool64_t mask, vuint32mf2_t merge0, vuint32mf2_t merge1, const uint32_t *base, size_t *new_vl, size_t vl) {
+  return vlseg2e32ff_v_u32mf2_tumu(v0, v1, mask, merge0, merge1, base, new_vl, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vlseg2e32ff_v_u32mf2_tama(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call { , , i32 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i32( poison,  poison, ptr [[BASE:%.*]],  [[MASK:%.*]], i32 [[VL:%.*]], i32 3)
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = extractvalue { , , i32 } [[TMP0]], 0
+// CHECK-RV32-NEXT:store  [[TMP1]], ptr [[V0:%.*]], align 4
+// CHECK-RV32-NEXT:[[TMP2:%.*]] = extractvalue { , , i32 } [[TMP0]], 1
+// CHECK-RV32-NEXT:   

[clang] 1f88fb4 - [clang] Use std::nullopt instead of None in comments (NFC)

2022-12-08 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-08T22:43:11-08:00
New Revision: 1f88fb406cc323eb36fc5f18626915b4ba75560e

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

LOG: [clang] Use std::nullopt instead of None in comments (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/Analysis/CFG.h
clang/include/clang/Analysis/ProgramPoint.h
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/CFG.h 
b/clang/include/clang/Analysis/CFG.h
index ecf5906fa1dca..c46d6f3ff05a4 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -103,7 +103,7 @@ class CFGElement {
 return t;
   }
 
-  /// Convert to the specified CFGElement type, returning None if this
+  /// Convert to the specified CFGElement type, returning std::nullopt if this
   /// CFGElement is not of the desired type.
   template
   Optional getAs() const {

diff  --git a/clang/include/clang/Analysis/ProgramPoint.h 
b/clang/include/clang/Analysis/ProgramPoint.h
index 81a1288f61c7b..1df5b74b20a36 100644
--- a/clang/include/clang/Analysis/ProgramPoint.h
+++ b/clang/include/clang/Analysis/ProgramPoint.h
@@ -144,7 +144,7 @@ class ProgramPoint {
 return t;
   }
 
-  /// Convert to the specified ProgramPoint type, returning None if this
+  /// Convert to the specified ProgramPoint type, returning std::nullopt if 
this
   /// ProgramPoint is not of the desired type.
   template
   Optional getAs() const {

diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index bed429d17422e..20f2415ddce38 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -1075,13 +1075,13 @@ class SourceManager : public 
RefCountedBase {
   StringRef getBufferData(FileID FID, bool *Invalid = nullptr) const;
 
   /// Return a StringRef to the source buffer data for the
-  /// specified FileID, returning None if invalid.
+  /// specified FileID, returning std::nullopt if invalid.
   ///
   /// \param FID The file ID whose contents will be returned.
   llvm::Optional getBufferDataOrNone(FileID FID) const;
 
   /// Return a StringRef to the source buffer data for the
-  /// specified FileID, returning None if it's not yet loaded.
+  /// specified FileID, returning std::nullopt if it's not yet loaded.
   ///
   /// \param FID The file ID whose contents will be returned.
   llvm::Optional getBufferDataIfLoaded(FileID FID) const;

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 6775d18cdefed..746e0f4ea918b 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1436,7 +1436,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   }
 
   // Get the cache line size of a given cpu. This method switches over
-  // the given cpu and returns "None" if the CPU is not found.
+  // the given cpu and returns "std::nullopt" if the CPU is not found.
   virtual Optional getCPUCacheLineSize() const {
 return std::nullopt;
   }

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index 2ae811ee33653..6a84e82ddf293 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -99,7 +99,7 @@ class SVal {
   /// the desired type.
   template  T castAs() const { return llvm::cast(*this); }
 
-  /// Convert to the specified SVal type, returning None if this SVal is
+  /// Convert to the specified SVal type, returning std::nullopt if this SVal 
is
   /// not of the desired type.
   template  Optional getAs() const {
 return llvm::dyn_cast(*this);

diff  --git a/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp 
b/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
index 77cab35cde350..d1de04ba39e0f 100644
--- a/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
+++ b/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
@@ -214,7 +214,8 @@ llvm::Optional tooling::buildAccess(const Expr 
&RawExpression,
  ASTContext &Context,
  PLTClass Classification) {
   if (RawExpression.isImplicitCXXThis())
-// Return the empty string, because `None` signifies some sort of failure.
+// Return the empty 

[PATCH] D139686: [lsan] Add lsan support for loongarch64

2022-12-08 Thread Youling Tang via Phabricator via cfe-commits
tangyouling added inline comments.



Comment at: compiler-rt/lib/lsan/lsan_common.cpp:281
+#  elif defined(__loongarch_lp64)
+  return ((p >> 47) == 0);
 #  else

xen0n wrote:
> tangyouling wrote:
> > xen0n wrote:
> > > Since our VM layout is actually flexible, would it be better to document 
> > > this, like "Support only the most common VM layout on LoongArch that 
> > > allows 47 bits of user-space VMA"? Exact wording could be optimized, I'm 
> > > only describing the gist here.
> > > Since our VM layout is actually flexible, would it be better to document 
> > > this, like "Support only the most common VM layout on LoongArch that 
> > > allows 47 bits of user-space VMA"? Exact wording could be optimized, I'm 
> > > only describing the gist here.
> > 
> > How about "Allow 47-bit user-space VMA at current"?
> "at present"; if you plan to revisit this later for properly supporting 
> variable VM layouts, omitting the justification is fine to me.
Support for variable VM layout has not been planned for some time.



Comment at: compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp:4
 // REQUIRES: leak-detection
-#include 
+#include 
 #include 

xen0n wrote:
> tangyouling wrote:
> > xen0n wrote:
> > > Why unnecessarily reorder things, especially putting this //in front of// 
> > > the standard library includes?
> > > Why unnecessarily reorder things, especially putting this //in front of// 
> > > the standard library includes?
> > 
> > An automatic adjustment of the format.
> So you mean you're actually unable to avoid this diff damage?
I will try to avoid this unnecessary auto-formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139686

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


[PATCH] D139686: [lsan] Add lsan support for loongarch64

2022-12-08 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n added inline comments.



Comment at: compiler-rt/lib/lsan/lsan_common.cpp:281
+#  elif defined(__loongarch_lp64)
+  return ((p >> 47) == 0);
 #  else

tangyouling wrote:
> xen0n wrote:
> > Since our VM layout is actually flexible, would it be better to document 
> > this, like "Support only the most common VM layout on LoongArch that allows 
> > 47 bits of user-space VMA"? Exact wording could be optimized, I'm only 
> > describing the gist here.
> > Since our VM layout is actually flexible, would it be better to document 
> > this, like "Support only the most common VM layout on LoongArch that allows 
> > 47 bits of user-space VMA"? Exact wording could be optimized, I'm only 
> > describing the gist here.
> 
> How about "Allow 47-bit user-space VMA at current"?
"at present"; if you plan to revisit this later for properly supporting 
variable VM layouts, omitting the justification is fine to me.



Comment at: compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp:4
 // REQUIRES: leak-detection
-#include 
+#include 
 #include 

tangyouling wrote:
> xen0n wrote:
> > Why unnecessarily reorder things, especially putting this //in front of// 
> > the standard library includes?
> > Why unnecessarily reorder things, especially putting this //in front of// 
> > the standard library includes?
> 
> An automatic adjustment of the format.
So you mean you're actually unable to avoid this diff damage?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139686

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


[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-08 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added inline comments.



Comment at: clang/lib/AST/JSONNodeDumper.cpp:852
 case VarDecl::ListInit: JOS.attribute("init", "list"); break;
+case VarDecl::ParenListInit:
+  JOS.attribute("init", "paren-list");

ilya-biryukov wrote:
> ayzhao wrote:
> > ilya-biryukov wrote:
> > > NIT: maybe use the same formatting as other switch cases for constistency?
> > Unfortunately clang-format insists that these be on separate lines.
> Ah, that's unfortunate. I normally just revert the effect of `clang-format` 
> for those lines, but up to you.
> Also fine to keep as is or even format the other lines according to the style 
> guide (it's just 3 more lines, so should not be a big deal).
> 
> 
Yeah, I would definitely prefer to keep the current style. The problem though 
is that the buildbots run clang format and will fail if the patch isn't 
formatted correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-08 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:5380
+  }
+  InitExprs.push_back(ER.get());
+}

ayzhao wrote:
> So the libc++ test compile failures are due to this line.
> 
> One example of a failing unit test is 
> [range.take.while/ctor.view.pass](https://github.com/llvm/llvm-project/blob/main/libcxx/test/std/ranges/range.adaptors/range.take.while/ctor.view.pass.cpp).
>  Clang calls this function twice in `TreeTransform.h` - once with 
> `VerifyOnly` set to `true`, once with it set to `false`.
> 
> For some reason, when this function tries to value-initialize the member 
> `MoveOnly mo` in `View`, `Seq.Failed()` returns false after 
> `TryValueInitialization(...)`, but the resulting `ExprResult` is `nullptr`, 
> causing the segfault we see when we push `nullptr` to `InitExprs` and pass 
> `InitExprs` to the constructor of `CXXParenListInitExpr`. One way to be fix 
> this is to move the line `ExprResult ER = Seq.Perform(...)` out of the `if 
> (!VerifyOnly)` block and check for `ER.isInvalid()` instead of 
> `Seq.Failed()`, but that results in test failures due to excess diagnostic 
> messages in `Seq.Perform(...)`
> 
> I'm still looking into this, but if anyone has any ideas, they would be very 
> welcome.
> 
> To repro the buildbot failures, just build clang with this patch, and then in 
> a separate build directory, build the target `check-cxx` using the previously 
> built clang.
I was able to get the above workaround to pass the test by clearing the 
diagnostics after calling `Seq.Perform(...)`.

IMO, this should be OK for now, but I'm open to better ideas if anyone has any.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-08 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 481508.
ayzhao added a comment.

rebase + (hopefully) fix libc++ c++2b test failures


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  clang/test/CodeGen/paren-list-agg-init.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/PCH/cxx_paren_init.cpp
  clang/test/PCH/cxx_paren_init.h
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1156,7 +1156,7 @@
 
   Parenthesized initialization of aggregates
   https://wg21.link/p0960r3";>P0960R3
-  No
+  Clang 16
 

 https://wg21.link/p1975r0";>P1975R0
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,10 @@
 K = CXCursor_RequiresExpr;
 break;
 
+  case Stmt::CXXParenListInitExprClass:
+K = CXCursor_CXXParenListInitExpr;
+break;
+
   case Stmt::MSDependentExistsStmtClass:
 K = CXCursor_UnexposedStmt;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2139,6 +2139,7 @@
   void VisitLambdaExpr(const LambdaExpr *E);
   void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E);
   void VisitRequiresExpr(const RequiresExpr *E);
+  void VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
   void VisitOMPExecutableDirective(const OMPExecutableDirective *D);
   void VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *D);
   void VisitOMPLoopDirective(const OMPLoopDirective *D);
@@ -3006,6 +3007,9 @@
   for (ParmVarDecl *VD : E->getLocalParameters())
 AddDecl(VD);
 }
+void EnqueueVisitor::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E) {
+  EnqueueChildren(E);
+}
 void EnqueueVisitor::VisitPseudoObjectExpr(const PseudoObjectExpr *E) {
   // Treat the expression like its syntactic form.
   Visit(E->getSyntacticForm());
@@ -5587,6 +5591,8 @@
 return cxstring::createRef("ConceptSpecializationExpr");
   case CXCursor_RequiresExpr:
 return cxstring::createRef("RequiresExpr");
+  case CXCursor_CXXParenListInitExpr:
+return cxstring::createRef("CXXParenListInitExpr");
   case CXCursor_UnexposedStmt:
 return cxstring::createRef("UnexposedStmt");
   case CXCursor_DeclStmt:
Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
+// RUN: %clang_cc1 -verify=expected,beforecxx20 -Wc++20-extensions -std=c++20 %s -fsyntax-only
+
+struct A { // expected-note 4{{candidate constructor}}
+  char i;
+  double j;
+};
+
+struct B {
+  A a;
+  int b[20];
+  int &&c; // expected-note {{reference member declared here}}
+};
+
+struct C { // expected-note 5{{candidate constructor}}
+  A a;
+  int b[20];
+};
+
+struct D : public C, public A {
+  int a;
+};
+
+struct E { // expected-note 3{{candidate constructor}}
+  struct F {
+F(int, int);
+  };
+  int a;
+  F f;
+};
+
+int getint(); // expected-note {{declared here}}
+
+struct F {
+  int a;
+  int b = getint(); // expected-note {{non-constexpr function 'getint' cannot be used in a constant ex

[PATCH] D139676: [libTooling] Add flag to getRangeForEdit to ignore macro expansions

2022-12-08 Thread Eric Li via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
li.zhe.hua marked an inline comment as done.
Closed by commit rGa78d4b5ba716: [libTooling] Add flag to getRangeForEdit to 
ignore macro expansions (authored by li.zhe.hua).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139676

Files:
  clang/include/clang/Tooling/Transformer/SourceCode.h
  clang/lib/Tooling/Transformer/SourceCode.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -453,7 +453,11 @@
   Visitor.runOver(Code);
 }
 
-TEST(SourceCodeTest, EditRangeWithMacroExpansionsShouldSucceed) {
+class GetRangeForEditTest : public testing::TestWithParam {};
+INSTANTIATE_TEST_SUITE_P(WithAndWithoutExpansions, GetRangeForEditTest,
+ testing::Bool());
+
+TEST_P(GetRangeForEditTest, EditRangeWithMacroExpansionsShouldSucceed) {
   // The call expression, whose range we are extracting, includes two macro
   // expansions.
   llvm::Annotations Code(R"cpp(
@@ -463,10 +467,9 @@
 )cpp");
 
   CallsVisitor Visitor;
-
   Visitor.OnCall = [&Code](CallExpr *CE, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
-EXPECT_THAT(getRangeForEdit(Range, *Context),
+EXPECT_THAT(getRangeForEdit(Range, *Context, GetParam()),
 ValueIs(AsRange(Context->getSourceManager(), Code.range("r";
   };
   Visitor.runOver(Code.code());
@@ -487,7 +490,29 @@
   Visitor.runOver(Code.code());
 }
 
-TEST(SourceCodeTest, EditPartialMacroExpansionShouldFail) {
+TEST(SourceCodeTest, EditInvolvingExpansionIgnoringExpansionShouldFail) {
+  // If we specify to ignore macro expansions, none of these call expressions
+  // should have an editable range.
+  llvm::Annotations Code(R"cpp(
+#define M1(x) x(1)
+#define M2(x, y) x ## y
+#define M3(x) foobar(x)
+int foobar(int);
+int a = M1(foobar);
+int b = M2(foo, bar(2));
+int c = M3(3);
+)cpp");
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
+EXPECT_FALSE(
+getRangeForEdit(Range, *Context, /*IncludeMacroExpansion=*/false));
+  };
+  Visitor.runOver(Code.code());
+}
+
+TEST_P(GetRangeForEditTest, EditPartialMacroExpansionShouldFail) {
   std::string Code = R"cpp(
 #define BAR 10+
 int c = BAR 3.0;
@@ -496,12 +521,12 @@
   IntLitVisitor Visitor;
   Visitor.OnIntLit = [](IntegerLiteral *Expr, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
-EXPECT_FALSE(getRangeForEdit(Range, *Context));
+EXPECT_FALSE(getRangeForEdit(Range, *Context, GetParam()));
   };
   Visitor.runOver(Code);
 }
 
-TEST(SourceCodeTest, EditWholeMacroArgShouldSucceed) {
+TEST_P(GetRangeForEditTest, EditWholeMacroArgShouldSucceed) {
   llvm::Annotations Code(R"cpp(
 #define FOO(a) a + 7.0;
 int a = FOO($r[[10]]);
@@ -510,13 +535,13 @@
   IntLitVisitor Visitor;
   Visitor.OnIntLit = [&Code](IntegerLiteral *Expr, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
-EXPECT_THAT(getRangeForEdit(Range, *Context),
+EXPECT_THAT(getRangeForEdit(Range, *Context, GetParam()),
 ValueIs(AsRange(Context->getSourceManager(), Code.range("r";
   };
   Visitor.runOver(Code.code());
 }
 
-TEST(SourceCodeTest, EditPartialMacroArgShouldSucceed) {
+TEST_P(GetRangeForEditTest, EditPartialMacroArgShouldSucceed) {
   llvm::Annotations Code(R"cpp(
 #define FOO(a) a + 7.0;
 int a = FOO($r[[10]] + 10.0);
@@ -525,7 +550,7 @@
   IntLitVisitor Visitor;
   Visitor.OnIntLit = [&Code](IntegerLiteral *Expr, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
-EXPECT_THAT(getRangeForEdit(Range, *Context),
+EXPECT_THAT(getRangeForEdit(Range, *Context, GetParam()),
 ValueIs(AsRange(Context->getSourceManager(), Code.range("r";
   };
   Visitor.runOver(Code.code());
@@ -541,7 +566,6 @@
 )cpp";
 
   CallsVisitor Visitor;
-
   Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
 EXPECT_THAT_ERROR(validateEditRange(Range, Context->getSourceManager()),
Index: clang/lib/Tooling/Transformer/SourceCode.cpp
===
--- clang/lib/Tooling/Transformer/SourceCode.cpp
+++ clang/lib/Tooling/Transformer/SourceCode.cpp
@@ -78,27 +78,43 @@
   return llvm::Error::success();
 }
 
-llvm::Optional
-clang::tooling::getRangeForEdit(const CharSourceRange &EditRange,
-const SourceManager &SM,
-  

[clang] a78d4b5 - [libTooling] Add flag to getRangeForEdit to ignore macro expansions

2022-12-08 Thread Eric Li via cfe-commits

Author: Eric Li
Date: 2022-12-08T22:40:10-05:00
New Revision: a78d4b5ba716d88a90b905c261f53e74e67a7367

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

LOG: [libTooling] Add flag to getRangeForEdit to ignore macro expansions

This commit resolves the FIXME around the behavior of
`Lexer::makeFileCharRange` that `getRangeForEdit` inherits around
source locations in macro expansions.

We add a flag to `getRangeForEdit` that allows a caller to disable the
behavior, and instead uses the spelling location instead, with checks
to ensure that the source locations are not within a macro definition.

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

Added: 


Modified: 
clang/include/clang/Tooling/Transformer/SourceCode.h
clang/lib/Tooling/Transformer/SourceCode.cpp
clang/unittests/Tooling/SourceCodeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/SourceCode.h 
b/clang/include/clang/Tooling/Transformer/SourceCode.h
index f3d119c86074..911c1bdb0f5d 100644
--- a/clang/include/clang/Tooling/Transformer/SourceCode.h
+++ b/clang/include/clang/Tooling/Transformer/SourceCode.h
@@ -91,16 +91,25 @@ llvm::Error validateEditRange(const CharSourceRange &Range,
   const SourceManager &SM);
 
 /// Attempts to resolve the given range to one that can be edited by a rewrite;
-/// generally, one that starts and ends within a particular file. It supports a
-/// limited set of cases involving source locations in macro expansions. If a
-/// value is returned, it satisfies \c validateEditRange.
+/// generally, one that starts and ends within a particular file. If a value is
+/// returned, it satisfies \c validateEditRange.
+///
+/// If \c IncludeMacroExpansion is true, a limited set of cases involving 
source
+/// locations in macro expansions is supported. For example, if we're looking 
to
+/// rewrite the int literal 3 to 6, and we have the following definition:
+///#define DO_NOTHING(x) x
+/// then
+///foo(DO_NOTHING(3))
+/// will be rewritten to
+///foo(6)
 llvm::Optional
 getRangeForEdit(const CharSourceRange &EditRange, const SourceManager &SM,
-const LangOptions &LangOpts);
+const LangOptions &LangOpts, bool IncludeMacroExpansion = 
true);
 inline llvm::Optional
-getRangeForEdit(const CharSourceRange &EditRange, const ASTContext &Context) {
+getRangeForEdit(const CharSourceRange &EditRange, const ASTContext &Context,
+bool IncludeMacroExpansion = true) {
   return getRangeForEdit(EditRange, Context.getSourceManager(),
- Context.getLangOpts());
+ Context.getLangOpts(), IncludeMacroExpansion);
 }
 } // namespace tooling
 } // namespace clang

diff  --git a/clang/lib/Tooling/Transformer/SourceCode.cpp 
b/clang/lib/Tooling/Transformer/SourceCode.cpp
index b89d74a314bf..1aff94ac5077 100644
--- a/clang/lib/Tooling/Transformer/SourceCode.cpp
+++ b/clang/lib/Tooling/Transformer/SourceCode.cpp
@@ -78,27 +78,43 @@ llvm::Error clang::tooling::validateEditRange(const 
CharSourceRange &Range,
   return llvm::Error::success();
 }
 
-llvm::Optional
-clang::tooling::getRangeForEdit(const CharSourceRange &EditRange,
-const SourceManager &SM,
-const LangOptions &LangOpts) {
-  // FIXME: makeFileCharRange() has the disadvantage of stripping off 
"identity"
-  // macros. For example, if we're looking to rewrite the int literal 3 to 6,
-  // and we have the following definition:
-  //#define DO_NOTHING(x) x
-  // then
-  //foo(DO_NOTHING(3))
-  // will be rewritten to
-  //foo(6)
-  // rather than the arguably better
-  //foo(DO_NOTHING(6))
-  // Decide whether the current behavior is desirable and modify if not.
-  CharSourceRange Range = Lexer::makeFileCharRange(EditRange, SM, LangOpts);
+static bool SpelledInMacroDefinition(SourceLocation Loc,
+ const SourceManager &SM) {
+  while (Loc.isMacroID()) {
+const auto &Expansion = SM.getSLocEntry(SM.getFileID(Loc)).getExpansion();
+if (Expansion.isMacroArgExpansion()) {
+  // Check the spelling location of the macro arg, in case the arg itself 
is
+  // in a macro expansion.
+  Loc = Expansion.getSpellingLoc();
+} else {
+  return true;
+}
+  }
+  return false;
+}
+
+llvm::Optional clang::tooling::getRangeForEdit(
+const CharSourceRange &EditRange, const SourceManager &SM,
+const LangOptions &LangOpts, bool IncludeMacroExpansion) {
+  CharSourceRange Range;
+  if (IncludeMacroExpansion) {
+Range = Lexer::makeFileCharRange(EditRange, SM, LangOpts);
+  } else {
+if (SpelledInMacroDefinition(EditRange.getBegin(), SM) ||
+SpelledInMa

[PATCH] D139676: [libTooling] Add flag to getRangeForEdit to ignore macro expansions

2022-12-08 Thread Eric Li via Phabricator via cfe-commits
li.zhe.hua marked 2 inline comments as done.
li.zhe.hua added inline comments.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:90-92
+  Loc = Expansion.getExpansionLocStart();
+  if (Loc.isFileID())
+return true;

ymandel wrote:
> can you comment on the logic here? Why isn't this just "return true", since 
> it's in a macro but not a part of a macro arg, I'd think it must be part of a 
> macro definition.
Good catch, it should just return true.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139676

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


[PATCH] D139676: [libTooling] Add flag to getRangeForEdit to ignore macro expansions

2022-12-08 Thread Eric Li via Phabricator via cfe-commits
li.zhe.hua updated this revision to Diff 481506.
li.zhe.hua added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139676

Files:
  clang/include/clang/Tooling/Transformer/SourceCode.h
  clang/lib/Tooling/Transformer/SourceCode.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -453,7 +453,11 @@
   Visitor.runOver(Code);
 }
 
-TEST(SourceCodeTest, EditRangeWithMacroExpansionsShouldSucceed) {
+class GetRangeForEditTest : public testing::TestWithParam {};
+INSTANTIATE_TEST_SUITE_P(WithAndWithoutExpansions, GetRangeForEditTest,
+ testing::Bool());
+
+TEST_P(GetRangeForEditTest, EditRangeWithMacroExpansionsShouldSucceed) {
   // The call expression, whose range we are extracting, includes two macro
   // expansions.
   llvm::Annotations Code(R"cpp(
@@ -463,10 +467,9 @@
 )cpp");
 
   CallsVisitor Visitor;
-
   Visitor.OnCall = [&Code](CallExpr *CE, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
-EXPECT_THAT(getRangeForEdit(Range, *Context),
+EXPECT_THAT(getRangeForEdit(Range, *Context, GetParam()),
 ValueIs(AsRange(Context->getSourceManager(), Code.range("r";
   };
   Visitor.runOver(Code.code());
@@ -487,7 +490,29 @@
   Visitor.runOver(Code.code());
 }
 
-TEST(SourceCodeTest, EditPartialMacroExpansionShouldFail) {
+TEST(SourceCodeTest, EditInvolvingExpansionIgnoringExpansionShouldFail) {
+  // If we specify to ignore macro expansions, none of these call expressions
+  // should have an editable range.
+  llvm::Annotations Code(R"cpp(
+#define M1(x) x(1)
+#define M2(x, y) x ## y
+#define M3(x) foobar(x)
+int foobar(int);
+int a = M1(foobar);
+int b = M2(foo, bar(2));
+int c = M3(3);
+)cpp");
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
+EXPECT_FALSE(
+getRangeForEdit(Range, *Context, /*IncludeMacroExpansion=*/false));
+  };
+  Visitor.runOver(Code.code());
+}
+
+TEST_P(GetRangeForEditTest, EditPartialMacroExpansionShouldFail) {
   std::string Code = R"cpp(
 #define BAR 10+
 int c = BAR 3.0;
@@ -496,12 +521,12 @@
   IntLitVisitor Visitor;
   Visitor.OnIntLit = [](IntegerLiteral *Expr, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
-EXPECT_FALSE(getRangeForEdit(Range, *Context));
+EXPECT_FALSE(getRangeForEdit(Range, *Context, GetParam()));
   };
   Visitor.runOver(Code);
 }
 
-TEST(SourceCodeTest, EditWholeMacroArgShouldSucceed) {
+TEST_P(GetRangeForEditTest, EditWholeMacroArgShouldSucceed) {
   llvm::Annotations Code(R"cpp(
 #define FOO(a) a + 7.0;
 int a = FOO($r[[10]]);
@@ -510,13 +535,13 @@
   IntLitVisitor Visitor;
   Visitor.OnIntLit = [&Code](IntegerLiteral *Expr, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
-EXPECT_THAT(getRangeForEdit(Range, *Context),
+EXPECT_THAT(getRangeForEdit(Range, *Context, GetParam()),
 ValueIs(AsRange(Context->getSourceManager(), Code.range("r";
   };
   Visitor.runOver(Code.code());
 }
 
-TEST(SourceCodeTest, EditPartialMacroArgShouldSucceed) {
+TEST_P(GetRangeForEditTest, EditPartialMacroArgShouldSucceed) {
   llvm::Annotations Code(R"cpp(
 #define FOO(a) a + 7.0;
 int a = FOO($r[[10]] + 10.0);
@@ -525,7 +550,7 @@
   IntLitVisitor Visitor;
   Visitor.OnIntLit = [&Code](IntegerLiteral *Expr, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
-EXPECT_THAT(getRangeForEdit(Range, *Context),
+EXPECT_THAT(getRangeForEdit(Range, *Context, GetParam()),
 ValueIs(AsRange(Context->getSourceManager(), Code.range("r";
   };
   Visitor.runOver(Code.code());
@@ -541,7 +566,6 @@
 )cpp";
 
   CallsVisitor Visitor;
-
   Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
 EXPECT_THAT_ERROR(validateEditRange(Range, Context->getSourceManager()),
Index: clang/lib/Tooling/Transformer/SourceCode.cpp
===
--- clang/lib/Tooling/Transformer/SourceCode.cpp
+++ clang/lib/Tooling/Transformer/SourceCode.cpp
@@ -78,27 +78,43 @@
   return llvm::Error::success();
 }
 
-llvm::Optional
-clang::tooling::getRangeForEdit(const CharSourceRange &EditRange,
-const SourceManager &SM,
-const LangOptions &LangOpts) {
-  // FIXME: makeFileCharRange() has the disadvantage of stripping off "identity"
-  // macros. For example, if we're looking to rewrite the int liter

[PATCH] D137059: [Driver] [C++20] [Modules] Support -fmodule-output= (2/2)

2022-12-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 481504.
ChuanqiXu retitled this revision from "[Driver] [Modules] Introduce 
-fsave-std-c++-module-file= to specify the path of the module file (2/2)" to 
"[Driver] [C++20] [Modules] Support -fmodule-output= (2/2)".
ChuanqiXu added a comment.

Rename the option to `-fmodule-output` according to the discussion from 
https://gcc.gnu.org/pipermail/gcc/2022-December/240239.html


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

https://reviews.llvm.org/D137059

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/save-std-c++-module-file.cpp


Index: clang/test/Driver/save-std-c++-module-file.cpp
===
--- clang/test/Driver/save-std-c++-module-file.cpp
+++ clang/test/Driver/save-std-c++-module-file.cpp
@@ -7,9 +7,16 @@
 //
 // RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output -o %t/output/Hello.o \
 // RUN:   -### 2>&1 | FileCheck %t/Hello.cppm -DPREFIX=%t 
--check-prefix=CHECK-WITH-OUTPUT
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/tmp/H.pcm \
+// RUN:   -### 2>&1 | FileCheck %t/Hello.cppm -DPREFIX=%t 
--check-prefix=CHECK-SPECIFIED
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/tmp/H.pcm -o 
%t/Hello.o \
+// RUN:   -### 2>&1 | FileCheck %t/Hello.cppm -DPREFIX=%t 
--check-prefix=CHECK-SPECIFIED
 
 //--- Hello.cppm
 export module Hello;
 
 // CHECK: "-o" "[[PREFIX]]/Hello.pcm"
 // CHECK-WITH-OUTPUT: "-o" "[[PREFIX]]/output/Hello.pcm"
+// CHECK-SPECIFIED: "-o" "[[PREFIX]]/tmp/H.pcm"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5530,15 +5530,21 @@
   }
 
   // If `-fmodule-output` is specfied, then:
-  // - If `-o` is specified, the module file is writing to the same path
+  // - If `-fmodule-output` has a value, the module file is
+  //   writing to the value.
+  // - Else if `-o` is specified, the module file is writing to the same path
   //   with the output file in module file's suffix. 
-  // - If `-o` is not specified, the module file is writing to the same path
+  // - Else, the module file is writing to the same path
   //   with the input file in module file's suffix.
   if (!AtTopLevel && isa(JA) &&
   JA.getType() == types::TY_ModuleFile &&
-  C.getArgs().hasArg(options::OPT_fmodule_output)) {
+  (C.getArgs().hasArg(options::OPT_fmodule_output) ||
+   C.getArgs().hasArg(options::OPT_fmodule_output_EQ))) {
 SmallString<128> TempPath;
-if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+
+if (Arg *ModuleFilePath = 
C.getArgs().getLastArg(options::OPT_fmodule_output_EQ))
+  TempPath = ModuleFilePath->getValue();
+else if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
   TempPath = FinalOutput->getValue();
 else
   TempPath = BaseInput;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2285,6 +2285,8 @@
   PosFlag,
   NegFlag, BothFlags<[NoXarchOption, CC1Option]>>;
 
+def fmodule_output_EQ : Joined<["-"], "fmodule-output=">, 
Flags<[NoXarchOption, CC1Option]>,
+  HelpText<"Save intermediate module file results when compiling a standard 
C++ module unit.">;
 def fmodule_output : Flag<["-"], "fmodule-output">, Flags<[NoXarchOption, 
CC1Option]>,
   HelpText<"Save intermediate module file results when compiling a standard 
C++ module unit.">;
 


Index: clang/test/Driver/save-std-c++-module-file.cpp
===
--- clang/test/Driver/save-std-c++-module-file.cpp
+++ clang/test/Driver/save-std-c++-module-file.cpp
@@ -7,9 +7,16 @@
 //
 // RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output -o %t/output/Hello.o \
 // RUN:   -### 2>&1 | FileCheck %t/Hello.cppm -DPREFIX=%t --check-prefix=CHECK-WITH-OUTPUT
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/tmp/H.pcm \
+// RUN:   -### 2>&1 | FileCheck %t/Hello.cppm -DPREFIX=%t --check-prefix=CHECK-SPECIFIED
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/tmp/H.pcm -o %t/Hello.o \
+// RUN:   -### 2>&1 | FileCheck %t/Hello.cppm -DPREFIX=%t --check-prefix=CHECK-SPECIFIED
 
 //--- Hello.cppm
 export module Hello;
 
 // CHECK: "-o" "[[PREFIX]]/Hello.pcm"
 // CHECK-WITH-OUTPUT: "-o" "[[PREFIX]]/output/Hello.pcm"
+// CHECK-SPECIFIED: "-o" "[[PREFIX]]/tmp/H.pcm"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5530,15 +5530,21 @@
   }
 
   // If `-fmodule-output` is specfied, then:
-  // - If `-o` is specified, the module file is writing to the same path
+  // - If `-fmodule-output` has a value, the module file is
+  //   wr

[PATCH] D137058: [Driver] [Modules] Support -fmodule-output (1/2)

2022-12-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 481503.
ChuanqiXu marked 2 inline comments as done.
ChuanqiXu retitled this revision from "[Driver] [Modules] Support 
-fsave-std-c++-module-file (1/2)" to "[Driver] [Modules] Support 
-fmodule-output (1/2)".
ChuanqiXu added a comment.

Rename the option into `-fmodule-output` according to the discussion result 
from: https://gcc.gnu.org/pipermail/gcc/2022-December/240239.html


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

https://reviews.llvm.org/D137058

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/save-std-c++-module-file.cpp


Index: clang/test/Driver/save-std-c++-module-file.cpp
===
--- /dev/null
+++ clang/test/Driver/save-std-c++-module-file.cpp
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output -### 2>&1 | \
+// RUN:   FileCheck %t/Hello.cppm -DPREFIX=%t
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output -o %t/output/Hello.o \
+// RUN:   -### 2>&1 | FileCheck %t/Hello.cppm -DPREFIX=%t 
--check-prefix=CHECK-WITH-OUTPUT
+
+//--- Hello.cppm
+export module Hello;
+
+// CHECK: "-o" "[[PREFIX]]/Hello.pcm"
+// CHECK-WITH-OUTPUT: "-o" "[[PREFIX]]/output/Hello.pcm"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5529,6 +5529,25 @@
 return "-";
   }
 
+  // If `-fmodule-output` is specfied, then:
+  // - If `-o` is specified, the module file is writing to the same path
+  //   with the output file in module file's suffix. 
+  // - If `-o` is not specified, the module file is writing to the same path
+  //   with the input file in module file's suffix.
+  if (!AtTopLevel && isa(JA) &&
+  JA.getType() == types::TY_ModuleFile &&
+  C.getArgs().hasArg(options::OPT_fmodule_output)) {
+SmallString<128> TempPath;
+if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+  TempPath = FinalOutput->getValue();
+else
+  TempPath = BaseInput;
+
+const char *Extension = types::getTypeTempSuffix(JA.getType());
+llvm::sys::path::replace_extension(TempPath, Extension);
+return C.addResultFile(C.getArgs().MakeArgString(TempPath.c_str()), &JA);
+  }
+
   if (IsDXCMode() && !C.getArgs().hasArg(options::OPT_o))
 return "-";
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2285,6 +2285,9 @@
   PosFlag,
   NegFlag, BothFlags<[NoXarchOption, CC1Option]>>;
 
+def fmodule_output : Flag<["-"], "fmodule-output">, Flags<[NoXarchOption, 
CC1Option]>,
+  HelpText<"Save intermediate module file results when compiling a standard 
C++ module unit.">;
+
 def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, 
Group,
   Flags<[CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the interval (in seconds) between attempts to prune the 
module cache">,


Index: clang/test/Driver/save-std-c++-module-file.cpp
===
--- /dev/null
+++ clang/test/Driver/save-std-c++-module-file.cpp
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output -### 2>&1 | \
+// RUN:   FileCheck %t/Hello.cppm -DPREFIX=%t
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output -o %t/output/Hello.o \
+// RUN:   -### 2>&1 | FileCheck %t/Hello.cppm -DPREFIX=%t --check-prefix=CHECK-WITH-OUTPUT
+
+//--- Hello.cppm
+export module Hello;
+
+// CHECK: "-o" "[[PREFIX]]/Hello.pcm"
+// CHECK-WITH-OUTPUT: "-o" "[[PREFIX]]/output/Hello.pcm"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5529,6 +5529,25 @@
 return "-";
   }
 
+  // If `-fmodule-output` is specfied, then:
+  // - If `-o` is specified, the module file is writing to the same path
+  //   with the output file in module file's suffix. 
+  // - If `-o` is not specified, the module file is writing to the same path
+  //   with the input file in module file's suffix.
+  if (!AtTopLevel && isa(JA) &&
+  JA.getType() == types::TY_ModuleFile &&
+  C.getArgs().hasArg(options::OPT_fmodule_output)) {
+SmallString<128> TempPath;
+if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+  TempPath = FinalOutput->getValue();
+else
+  TempPath = BaseInput;
+
+const char *Extension = types::getTypeTempSuffix(JA.getType());
+llvm::sys::path::replace_extension(TempPath, Extension);
+return C.addResultFile(C.getArgs().MakeArgString(TempPath.c_str()), &JA);
+  }
+
   if (IsDXCMode() && !C.getArgs().hasArg(optio

[PATCH] D139612: [Clang][LoongArch] Add intrinsic for iocsrrd and iocsrwr

2022-12-08 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n accepted this revision.
xen0n added a comment.
This revision is now accepted and ready to land.

This should be good enough (reminiscent of CSR ops) but let's wait for other 
reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139612

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


[PATCH] D139686: [lsan] Add lsan support for loongarch64

2022-12-08 Thread Youling Tang via Phabricator via cfe-commits
tangyouling added inline comments.



Comment at: compiler-rt/lib/lsan/lsan_common.cpp:281
+#  elif defined(__loongarch_lp64)
+  return ((p >> 47) == 0);
 #  else

xen0n wrote:
> Since our VM layout is actually flexible, would it be better to document 
> this, like "Support only the most common VM layout on LoongArch that allows 
> 47 bits of user-space VMA"? Exact wording could be optimized, I'm only 
> describing the gist here.
> Since our VM layout is actually flexible, would it be better to document 
> this, like "Support only the most common VM layout on LoongArch that allows 
> 47 bits of user-space VMA"? Exact wording could be optimized, I'm only 
> describing the gist here.

How about "Allow 47-bit user-space VMA at current"?



Comment at: compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp:4
 // REQUIRES: leak-detection
-#include 
+#include 
 #include 

xen0n wrote:
> Why unnecessarily reorder things, especially putting this //in front of// the 
> standard library includes?
> Why unnecessarily reorder things, especially putting this //in front of// the 
> standard library includes?

An automatic adjustment of the format.



Comment at: compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp:20-21
+   16 * 1024, PROT_NONE);
+  mprotect((void *)(((unsigned long)data + kPageSize - 1) & ~(kPageSize - 1)),
+   16 * 1024, PROT_NONE);
   __lsan_do_leak_check();

xen0n wrote:
> Might be better to split this part of change out of the LoongArch enablement 
> patch after all...
> Might be better to split this part of change out of the LoongArch enablement 
> patch after all...

OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139686

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


[PATCH] D139676: [libTooling] Add flag to getRangeForEdit to ignore macro expansions

2022-12-08 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:90-92
+  Loc = Expansion.getExpansionLocStart();
+  if (Loc.isFileID())
+return true;

can you comment on the logic here? Why isn't this just "return true", since 
it's in a macro but not a part of a macro arg, I'd think it must be part of a 
macro definition.



Comment at: clang/lib/Tooling/Transformer/SourceCode.cpp:111-113
+if (EditRange.isTokenRange()) {
+  E = Lexer::getLocForEndOfToken(E, 0, SM, LangOpts);
+}

LLVM style doesn't use braces for single-line ifs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139676

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


[PATCH] D139686: [lsan] Add lsan support for loongarch64

2022-12-08 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n added inline comments.



Comment at: compiler-rt/lib/lsan/lsan_common.cpp:281
+#  elif defined(__loongarch_lp64)
+  return ((p >> 47) == 0);
 #  else

Since our VM layout is actually flexible, would it be better to document this, 
like "Support only the most common VM layout on LoongArch that allows 47 bits 
of user-space VMA"? Exact wording could be optimized, I'm only describing the 
gist here.



Comment at: compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp:4
 // REQUIRES: leak-detection
-#include 
+#include 
 #include 

Why unnecessarily reorder things, especially putting this //in front of// the 
standard library includes?



Comment at: compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp:20-21
+   16 * 1024, PROT_NONE);
+  mprotect((void *)(((unsigned long)data + kPageSize - 1) & ~(kPageSize - 1)),
+   16 * 1024, PROT_NONE);
   __lsan_do_leak_check();

Might be better to split this part of change out of the LoongArch enablement 
patch after all...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139686

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


[PATCH] D139544: [clang][dataflow] Add support for structured bindings of tuple-like types.

2022-12-08 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D139544#3982821 , @isuckatcs wrote:

>> the temporary's construction should appear before, but the binding decls, 
>> which use the synthetic variables, should appear after
>
> I'm confused a bit here. Right now the CFG looks like this:
>
>   
>   
>   ...
>   
>
> Based on what you say I assume you want something to happen between 
> `constructor_call` and `binding_decl_0`. 
> Could you visualize somehow how you think the ideal CFG here looks like?

Sorry, I should have explained in more detail (refernce example: 
https://godbolt.org/z/dE9ojcjj7). *Perhaps I'm still misreading the CFG, but I 
don't see the binding decls serialized in the CFG, only the synthesized var 
decls.* That is, here's my reading of the CFG:
The resulting simplified CFG would be:

  
  
  ...
  

In more detail, here is my annotated reading of the CFG, based on our 
discussion:

  [B1]
 1: mk
 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, std::tuple 
(*)(void))
 3: [B1.2]() (CXXRecordTypedCall, [B1.4])
 4: auto = mk();  //  (with , 
 nested as children)
 5: get<0UL>
 6: [B1.5] (ImplicitCastExpr, FunctionToPointerDecay, typename 
tuple_element<0, tuple >::type (*)(tuple))
 7:  // 
 8: [B1.7] (ImplicitCastExpr, NoOp, std::tuple)
 9: [B1.8] (CXXConstructExpr, [B1.10]+0, tuple)
10: [B1.6]([B1.9])
11: [B1.10]
12: std::tuple_element<0, std::tuple>::type i0 = get<0UL>(); // 

13: get<1UL>
14: [B1.13] (ImplicitCastExpr, FunctionToPointerDecay, typename 
tuple_element<1, tuple >::type (*)(tuple))
15: // 
16: [B1.15] (ImplicitCastExpr, NoOp, std::tuple)
17: [B1.16] (CXXConstructExpr, [B1.18]+0, tuple)
18: [B1.14]([B1.17])
19: [B1.18]
20: std::tuple_element<1, std::tuple>::type i1 = get<1UL>(); // 

21: i0 // ref to 
22: (void)[B1.21] (CStyleCastExpr, ToVoid, void)

Here is the crux of the issue: per the AST, line 21 is reference is to the 
*`BindingDecl`*, not the (synthesized) `VarDecl`:

  -DeclRefExpr  'std::tuple_element<0, std::tuple>::type':'int' lvalue Binding 0x559942acf350 'i0' 'std::tuple_element<0, 
std::tuple>::type':'int'

So, in order to make sense of that reference, I need to define the 
`BindingDecl`. But, that in turn is defined in terms of the (synthesized) 
`VarDecl`. So, I want to insert between elements 20 and 21:

  20.a:  // references synthesized variable `i0` from line 12 
in its binding
  20.b:  // references synthesized variable `i1` from line 20 
in its binding

The resulting simplified CFG would be:

  
  
  ...
  
  
  ...
  

I suggested repeating the `DecompositionDecl` because it includes the 
`BindingDecls`, but spelling them out explicitly would probably be even better. 
 Right now, the only chance I get to visit the `BindingDecls` is when I 
encounter line 4, as children of the `DecompositionDecl`, at which point the 
`binding` of each decl reference as-yet-undefined (synthesized) `VarDecl`s, 
hence my dilemma.

I'm fine with a custom solution -- that's indeed what this patch contains and 
I'm happy to leave it at that.

Thank you, again, for your patience hashing this out!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139544

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


[PATCH] D138263: [clang-format] Supress aligning of trailing namespace comments

2022-12-08 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D138263#3975828 , @owenpan wrote:

> Can you rebase (preferably after landing D138402 
> )?

See D139257#3983332 . If it gets 
reverted, we have to do something like D138263#3938593 
.


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

https://reviews.llvm.org/D138263

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


[PATCH] D139257: [clang-format] Link the braces of a block in UnwrappedLineParser

2022-12-08 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

I have second thoughts about linking block braces in `UnwrappedLineParser`. 
Consider the following example:

  #if A
  while (a) { // Linked to the r_brace below
  #else
  while(b) { // Also linked to the r_brace below
  #endif
foo();
  }  // Linked to the l_brace of while(b) above

The `l_brace` of `while (a)` is still linked  to the `r_brace` that has been 
re-linked to another `l_bace`.

Because `MatchingParen` will be reset in the annotator anyway, linking it for 
block braces in `UnwrappedLineParser` has little or no value. I will revert 
this patch if no one objects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139257

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


[PATCH] D139233: [-Wunsafe-buffer-usage] Add an unsafe gadget for pointer-arithmetic operations

2022-12-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:374-375
+  : UnsafeGadget(Kind::PointerArithmetic),
+PA(Result.Nodes.getNodeAs("ptrAdd")),
+Ptr(Result.Nodes.getNodeAs("ptrAddPtr")) {}
+

Let's unhardcode the bind tags just like in the subscript patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139233

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


[PATCH] D139686: [lsan] Add lsan support for loongarch64

2022-12-08 Thread Youling Tang via Phabricator via cfe-commits
tangyouling added a comment.

  $ cat memory-leak.c 
  #include 
  void *p;
  int main() {
p = malloc(7);
p = 0; // The memory is leaked here.
return 0;
  }

  $ ./build/bin/clang -fsanitize=address -g memory-leak.c ; 
ASAN_OPTIONS=detect_leaks=1 ./a.out
  
  =
  ==636379==ERROR: LeakSanitizer: detected memory leaks
  
  Direct leak of 7 byte(s) in 1 object(s) allocated from:
  #0 0x57bac158 in __interceptor_malloc 
/home/loongson/llvm-work/llvm-project-test3/llvm-project1/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
  #1 0x57beb03c in main 
/home/loongson/llvm-work/llvm-project-test3/llvm-project1/memory-leak.c:4:7
  #2 0x723b1678  (/usr/lib64/libc.so.6+0x25678)
  
  SUMMARY: AddressSanitizer: 7 byte(s) leaked in 1 allocation(s).

  $ ./build/bin/clang -fsanitize=leak -g memory-leak.c && ./a.out
  
  =
  ==636372==ERROR: LeakSanitizer: detected memory leaks
  
  Direct leak of 7 byte(s) in 1 object(s) allocated from:
  #0 0x56a5a94c in __interceptor_malloc 
/home/loongson/llvm-work/llvm-project-test3/llvm-project1/compiler-rt/lib/lsan/lsan_interceptors.cpp:75:3
  #1 0x56a5db0c in main 
/home/loongson/llvm-work/llvm-project-test3/llvm-project1/memory-leak.c:4:7
  #2 0x711c5678  (/usr/lib64/libc.so.6+0x25678)
  
  SUMMARY: LeakSanitizer: 7 byte(s) leaked in 1 allocation(s).

  $ make check-lsan
  Testing Time: 38.19s
Unsupported  : 13
Passed   : 93
Expectedly Failed:  2
  
  4 warning(s) in tests
  Built target check-lsan


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139686

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


[PATCH] D139686: [lsan] Add lsan support for loongarch64

2022-12-08 Thread Youling Tang via Phabricator via cfe-commits
tangyouling created this revision.
tangyouling added reviewers: Sanitizers, vitalybuka, SixWeining, xen0n, xry111, 
MaskRay, XiaodongLoong, lixing-star.
Herald added subscribers: Enna1, StephenFan, s.egerton, simoncook.
Herald added a project: All.
tangyouling requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead.
Herald added projects: clang, Sanitizers.

This patch enabled lsan for loongarch64 with 47-bit VMA layout.

Also don't hardcode the page size in `leak_check_segv.cpp`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139686

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/fsanitize.c
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/lib/lsan/lsan_common.cpp
  compiler-rt/lib/lsan/lsan_common.h
  compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp
  compiler-rt/test/asan/lit.cfg.py
  compiler-rt/test/lsan/TestCases/swapcontext.cpp
  compiler-rt/test/lsan/TestCases/use_registers.cpp
  compiler-rt/test/lsan/lit.common.cfg.py

Index: compiler-rt/test/lsan/lit.common.cfg.py
===
--- compiler-rt/test/lsan/lit.common.cfg.py
+++ compiler-rt/test/lsan/lit.common.cfg.py
@@ -74,9 +74,9 @@
 config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
 
 # LeakSanitizer tests are currently supported on
-# Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
+# Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux, loongarch64 Linux and x86_64 Darwin.
 supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features
-supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['aarch64', 'x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x']
+supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['aarch64', 'x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x', 'loongarch64']
 supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64']
 supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386']
 if not (supported_android or supported_linux or supported_darwin or supported_netbsd):
Index: compiler-rt/test/lsan/TestCases/use_registers.cpp
===
--- compiler-rt/test/lsan/TestCases/use_registers.cpp
+++ compiler-rt/test/lsan/TestCases/use_registers.cpp
@@ -43,6 +43,8 @@
   "mov x14, %0"
   :
   : "r"(p));
+#elif defined(__loongarch_lp64)
+  asm("move $s8, %0" : : "r"(p));
 #elif defined(__powerpc__)
   asm("mr 30, %0"
   :
Index: compiler-rt/test/lsan/TestCases/swapcontext.cpp
===
--- compiler-rt/test/lsan/TestCases/swapcontext.cpp
+++ compiler-rt/test/lsan/TestCases/swapcontext.cpp
@@ -5,7 +5,7 @@
 // RUN: %env_lsan_opts= %run %t 2>&1
 // RUN: %env_lsan_opts= not %run %t foo 2>&1 | FileCheck %s
 // Missing 'getcontext' and 'makecontext' on Android.
-// UNSUPPORTED: arm,aarch64,powerpc64,android
+// UNSUPPORTED: arm,aarch64,loongarch64,powerpc64,android
 
 #include "sanitizer_common/sanitizer_ucontext.h"
 #include 
Index: compiler-rt/test/asan/lit.cfg.py
===
--- compiler-rt/test/asan/lit.cfg.py
+++ compiler-rt/test/asan/lit.cfg.py
@@ -202,7 +202,7 @@
 
 # Turn on leak detection on 64-bit Linux.
 leak_detection_android = config.android and 'android-thread-properties-api' in config.available_features and (config.target_arch in ['x86_64', 'i386', 'i686', 'aarch64'])
-leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386', 'riscv64'])
+leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386', 'riscv64', 'loongarch64'])
 leak_detection_mac = (config.host_os == 'Darwin') and (config.apple_platform == 'osx')
 leak_detection_netbsd = (config.host_os == 'NetBSD') and (config.target_arch in ['x86_64', 'i386'])
 if leak_detection_android or leak_detection_linux or leak_detection_mac or leak_detection_netbsd:
Index: compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp
===
--- compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp
+++ compiler-rt/test/asan/TestCases/Linux/leak_check_segv.cpp
@@ -1,18 +1,24 @@
 // Test that SIGSEGV during leak checking does not crash the process.
 // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
 // REQUIRES: leak-detection
-#include 
+#include 
 #include 
+#include 
 #include 
-#include 
+#include 
 
 char d

[PATCH] D137346: [-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffer accesses.

2022-12-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h:17
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+

Ok so this is what caused the revert 
(https://lab.llvm.org/buildbot#builders/121/builds/25877):
```lines=10
FAILED: lib/libclangSema.so.16git 
: && /usr/lib64/ccache/c++ -fPIC -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation 
-fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
-Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG  -Wl,-z,defs 
-Wl,-z,nodelete   
-Wl,-rpath-link,/home/buildbots/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/./lib
  -Wl,--gc-sections -shared -Wl,-soname,libclangSema.so.16git -o 
lib/libclangSema.so.16git 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/AnalysisBasedWarnings.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/CodeCompleteConsumer.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/DeclSpec.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/DelayedDiagnostic.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/HLSLExternalSemaSource.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/IdentifierResolver.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/JumpDiagnostics.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/MultiplexExternalSemaSource.cpp.o
 tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/ParsedAttr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Scope.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/ScopeInfo.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Sema.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAccess.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAttr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAvailability.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCXXScopeSpec.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCast.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaChecking.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCodeComplete.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaConcept.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaConsumer.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCoroutine.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaCUDA.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDecl.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclAttr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclCXX.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaDeclObjC.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaExceptionSpec.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaExpr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaExprCXX.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaExprMember.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaExprObjC.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaFixItUtils.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaHLSL.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaInit.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaLambda.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaLookup.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaModule.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaObjCProperty.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaOpenMP.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaOverload.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaPseudoObject.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaRISCVVectorLookup.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaStmt.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaStmtAsm.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaStmtAttr.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaSYCL.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplate.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateDeduction.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateInstantiate.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateInstantiateDecl.cpp.o
 tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateVariadic.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaType.cpp.o 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/TypeLocBuilder.cpp.o  
-Wl,-rpath,"\$ORIGIN/../lib"  lib/libclangAnalysis.so.16git  
lib/libclangEdit.s

[PATCH] D139653: [clang] Set ShowInSystemHeader for module-build and module-import remarks

2022-12-08 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

From my experience, `ShowInSystemHeader` for `-Rmodule-build` is overall 
useful. I haven't heard from people who want no remarks from system headers and 
the rest is just hypothetical guesses that can go both ways (some people might 
like one option while some people might like another option).

Don't have strong opinion about `-Rmodule-import` as don't use it extensively. 
But don't have any reasons to avoid consistency in this case, so 
`ShowInSystemHeader` for this flag makes sense.

A test case would be great, especially I think that at some point I've seen 
remarks from system headers (though maybe it was with `-Wsystem-header`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139653

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


[clang] 3b7af27 - Revert "Revert "[-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffers.""

2022-12-08 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2022-12-08T16:57:59-08:00
New Revision: 3b7af2796b3d1a578b7e256f5e5b60e61108ec8d

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

LOG: Revert "Revert "[-Wunsafe-buffer-usage] Initial commit - Transition away 
from raw buffers.""

This reverts commit bc0617795f8bdcd5deab3e48b120107cc2833cdc.

Be more careful with #includes to avoid linker errors on some buildbots.

Added: 
clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Analysis/CMakeLists.txt
clang/lib/Sema/AnalysisBasedWarnings.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
new file mode 100644
index 0..41ca359a73239
--- /dev/null
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
@@ -0,0 +1,39 @@
+//===- UnsafeBufferUsage.h - Replace pointers with modern C++ ---*- 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
+//
+//===--===//
+//
+//  This file defines an analysis that aids replacing buffer accesses through
+//  raw pointers with safer C++ abstractions such as containers and 
views/spans.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_UNSAFEBUFFERUSAGE_H
+#define LLVM_CLANG_ANALYSIS_ANALYSES_UNSAFEBUFFERUSAGE_H
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+
+namespace clang {
+
+/// The interface that lets the caller handle unsafe buffer usage analysis
+/// results by overriding this class's handle... methods.
+class UnsafeBufferUsageHandler {
+public:
+  UnsafeBufferUsageHandler() = default;
+  virtual ~UnsafeBufferUsageHandler() = default;
+
+  /// Invoked when an unsafe operation over raw pointers is found.
+  virtual void handleUnsafeOperation(const Stmt *Operation) = 0;
+};
+
+// This function invokes the analysis and allows the caller to react to it
+// through the handler class.
+void checkUnsafeBufferUsage(const Decl *D, UnsafeBufferUsageHandler &Handler);
+
+} // end namespace clang
+
+#endif /* LLVM_CLANG_ANALYSIS_ANALYSES_UNSAFEBUFFERUSAGE_H */

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 51f1e95eff49f..939162273c708 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11735,4 +11735,9 @@ def err_cast_from_randomized_struct : Error<
 // LoongArch-specific Diagnostics
 def err_loongarch_builtin_requires_la64 : Error<
   "this builtin requires target: loongarch64">;
+
+// Unsafe buffer usage diagnostics.
+def warn_unsafe_buffer_usage : Warning<
+  "unchecked operation on raw buffer in expression">,
+  InGroup>, DefaultIgnore;
 } // end of sema component.

diff  --git a/clang/lib/Analysis/CMakeLists.txt 
b/clang/lib/Analysis/CMakeLists.txt
index 16e3f474060cb..ea6cb59e8e199 100644
--- a/clang/lib/Analysis/CMakeLists.txt
+++ b/clang/lib/Analysis/CMakeLists.txt
@@ -32,6 +32,7 @@ add_clang_library(clangAnalysis
   ThreadSafetyLogical.cpp
   ThreadSafetyTIL.cpp
   UninitializedValues.cpp
+  UnsafeBufferUsage.cpp
 
   LINK_LIBS
   clangAST

diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
new file mode 100644
index 0..5e8ff29d51c38
--- /dev/null
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -0,0 +1,80 @@
+//===- UnsafeBufferUsage.cpp - Replace pointers with modern 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 "clang/Analysis/Analyses/UnsafeBufferUsage.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/SmallVector.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace ast_matchers;
+
+namespace {
+// TODO: Better abstractions over gadgets.
+using GadgetList = std::vector;
+}
+
+// Scan the function and return a list of gadgets found with provided kits.
+static GadgetList findGadgets(const Decl *D) {
+
+  class GadgetFinderCallback : public MatchFinder::MatchCallback {
+GadgetList &Output;
+
+  public:
+GadgetFinderCallback(Ga

[PATCH] D136515: [builtins] Add __builtin_assume_separate_storage.

2022-12-08 Thread David Goldblatt via Phabricator via cfe-commits
davidtgoldblatt updated this revision to Diff 481481.
davidtgoldblatt added a comment.

Per review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136515

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-assume-separate-storage.c
  clang/test/Sema/builtin-assume-separate-storage.c

Index: clang/test/Sema/builtin-assume-separate-storage.c
===
--- /dev/null
+++ clang/test/Sema/builtin-assume-separate-storage.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+void *nonconst(void);
+
+void test1(int *a, int *b) {
+  __builtin_assume_separate_storage(a, b);
+  // Separate storage assumptions evaluate their arguments unconditionally, like
+  // assume_aligned but *unlike* assume. Check that we don't warn on it.
+  __builtin_assume_separate_storage(a, nonconst());
+  __builtin_assume_separate_storage(nonconst(), a);
+  __builtin_assume_separate_storage(a, 3); // expected-error {{incompatible integer to pointer conversion}}
+  __builtin_assume_separate_storage(3, a); // expected-error {{incompatible integer to pointer conversion}}
+}
Index: clang/test/CodeGen/builtin-assume-separate-storage.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin-assume-separate-storage.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+void *nonconst(void);
+
+// CHECK-LABEL: @test1
+void test1(int *a, int *b) {
+  // CHECK: store ptr %a, ptr [[A_ADDR:%.+]], align
+  // CHECK: store ptr %b, ptr [[B_ADDR:%.+]], align
+  // CHECK: [[A:%.+]] = load ptr, ptr [[A_ADDR]]
+  // CHECK: [[B:%.+]] = load ptr, ptr [[B_ADDR]]
+
+  // CHECK: call void @llvm.assume(i1 true) [ "separate_storage"(ptr [[A]], ptr [[B]]) ]
+  __builtin_assume_separate_storage(a, b);
+}
+
+// Separate storage assumptions evaluate their arguments unconditionally, like
+// assume_aligned but *unlike* assume. Check that we actually do so.
+// CHECK-LABEL: @test2
+void test2(int *a, int *b) {
+  // CHECK: call ptr @nonconst()
+  // CHECK: call void @llvm.assume
+  __builtin_assume_separate_storage(a, nonconst());
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2169,6 +2169,10 @@
 if (SemaBuiltinAssumeAligned(TheCall))
   return ExprError();
 break;
+  case Builtin::BI__builtin_assume_separate_storage:
+if (SemaBuiltinAssumeSeparateStorage(TheCall))
+  return ExprError();
+break;
   case Builtin::BI__builtin_dynamic_object_size:
   case Builtin::BI__builtin_object_size:
 if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 3))
@@ -7767,6 +7771,11 @@
   return false;
 }
 
+/// Handle __builtin_assume_separate_storage. For now this is a no-op, but
+/// eventually we expect an optional multi-arg variadic version (to handle an
+/// excluded range).
+bool Sema::SemaBuiltinAssumeSeparateStorage(CallExpr *TheCall) { return false; }
+
 bool Sema::SemaBuiltinOSLogFormat(CallExpr *TheCall) {
   unsigned BuiltinID =
   cast(TheCall->getCalleeDecl())->getBuiltinID();
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2823,6 +2823,19 @@
 Builder.CreateCall(FnAssume, ArgValue);
 return RValue::get(nullptr);
   }
+  case Builtin::BI__builtin_assume_separate_storage: {
+const Expr *Arg0 = E->getArg(0);
+const Expr *Arg1 = E->getArg(1);
+
+Value *Value0 = EmitScalarExpr(Arg0);
+Value *Value1 = EmitScalarExpr(Arg1);
+
+Value *Values[] = {Value0, Value1};
+OperandBundleDefT OBD("separate_storage", Values);
+Builder.CreateAssumption(ConstantInt::getTrue(getLLVMContext()), {OBD});
+return RValue::get(nullptr);
+  }
+
   case Builtin::BI__arithmetic_fence: {
 // Create the builtin call if FastMath is selected, and the target
 // supports the builtin, otherwise just return the argument.
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -13410,6 +13410,7 @@
   bool SemaBuiltinArithmeticFence(CallExpr *TheCall);
   bool SemaBuiltinAssume(CallExpr *TheCall);
   bool SemaBuiltinAssumeAligned(CallExpr *TheCall);
+  bool SemaBuiltinAssumeSeparateStorage(CallExpr *TheCall);
   bool SemaBuiltinLongjmp(CallExpr *TheCall);
   bool SemaBuiltinSetjmp(CallExpr *TheCall);
   ExprResult SemaBuiltinAtomicOverloaded(ExprResult TheCallResult);
Index: clang/include/clang/Basic/Builtins.def
===

[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-08 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir updated this revision to Diff 481475.
schittir edited the summary of this revision.
schittir added a comment.

Add assert at the beginning of blocks pointed out by Coverity


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

https://reviews.llvm.org/D139148

Files:
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5936,6 +5936,7 @@
   // We're at the end of the line for C: it's either a write-back conversion
   // or it's a C assignment. There's no need to check anything else.
   if (!S.getLangOpts().CPlusPlus) {
+assert(Initializer && "Intializer must be non-null");
 // If allowed, check whether this is an Objective-C writeback conversion.
 if (allowObjCWritebackConversion &&
 tryObjCWritebackConversion(S, *this, Entity, Initializer)) {
@@ -5955,6 +5956,7 @@
 
   // - If the destination type is a (possibly cv-qualified) class type:
   if (DestType->isRecordType()) {
+assert(Initializer && "Intializer must be non-null");
 // - If the initialization is direct-initialization, or if it is
 //   copy-initialization where the cv-unqualified version of the
 //   source type is the same class as, or a derived class of, the
@@ -6022,6 +6024,7 @@
   //- Otherwise, if the source type is a (possibly cv-qualified) class
   //  type, conversion functions are considered.
   if (!SourceType.isNull() && SourceType->isRecordType()) {
+assert(Initializer && "Intializer must be non-null");
 // For a conversion to _Atomic(T) from either T or a class type derived
 // from T, initialize the T object then convert to _Atomic type.
 bool NeedAtomicConversion = false;


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5936,6 +5936,7 @@
   // We're at the end of the line for C: it's either a write-back conversion
   // or it's a C assignment. There's no need to check anything else.
   if (!S.getLangOpts().CPlusPlus) {
+assert(Initializer && "Intializer must be non-null");
 // If allowed, check whether this is an Objective-C writeback conversion.
 if (allowObjCWritebackConversion &&
 tryObjCWritebackConversion(S, *this, Entity, Initializer)) {
@@ -5955,6 +5956,7 @@
 
   // - If the destination type is a (possibly cv-qualified) class type:
   if (DestType->isRecordType()) {
+assert(Initializer && "Intializer must be non-null");
 // - If the initialization is direct-initialization, or if it is
 //   copy-initialization where the cv-unqualified version of the
 //   source type is the same class as, or a derived class of, the
@@ -6022,6 +6024,7 @@
   //- Otherwise, if the source type is a (possibly cv-qualified) class
   //  type, conversion functions are considered.
   if (!SourceType.isNull() && SourceType->isRecordType()) {
+assert(Initializer && "Intializer must be non-null");
 // For a conversion to _Atomic(T) from either T or a class type derived
 // from T, initialize the T object then convert to _Atomic type.
 bool NeedAtomicConversion = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139652: Add the thread sanitizer support for X86_64 WatchOS simulators

2022-12-08 Thread Julian Lettner via Phabricator via cfe-commits
yln accepted this revision.
yln added a subscriber: rsundahl.
yln added a comment.

Thank you! LGTM, with one nit.

@rsundahl: can you keep an eye on this and resolve potential conflicts?  Thanks!




Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:3280-3286
   if ((IsX86_64 || IsAArch64) && isTargetMacOSBased()) {
 Res |= SanitizerKind::Thread;
-  } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
+  } else if (isTargetIOSSimulator() || isTargetTvOSSimulator() ||
+ isTargetWatchOSSimulator()) {
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   }

Yes, for watchOS simulator.  I think we can also drop the constraint on x86_64 
and then merge the if.  TSan //should// be supported for simulators on Apple 
Silicon.  Can you add additional tests for these 3 cases?  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139652

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


[PATCH] D139137: add floor library function

2022-12-08 Thread Joshua Batista via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG500e72924305: add floor library function (authored by 
bob80905).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139137

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/floor.hlsl

Index: clang/test/CodeGenHLSL/builtins/floor.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/floor.hlsl
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+using hlsl::floor;
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.floor.f16(
+// NO_HALF: define noundef float @"?test_floor_half@@YA$halff@$halff@@Z"(
+// NO_HALF: call float @llvm.floor.f32(float %0)
+half test_floor_half ( half p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.floor.v2f16(
+// NO_HALF: define noundef <2 x float> @"?test_floor_half2@@YAT?$__vector@$halff@$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x float> @llvm.floor.v2f32(
+half2 test_floor_half2 ( half2 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.floor.v3f16(
+// NO_HALF: define noundef <3 x float> @"?test_floor_half3@@YAT?$__vector@$halff@$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x float> @llvm.floor.v3f32(
+half3 test_floor_half3 ( half3 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.floor.v4f16(
+// NO_HALF: define noundef <4 x float> @"?test_floor_half4@@YAT?$__vector@$halff@$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x float> @llvm.floor.v4f32(
+half4 test_floor_half4 ( half4 p0 ) {
+  return floor ( p0 );
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.floor.f32(
+float test_floor_float ( float p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.floor.v2f32(
+float2 test_floor_float2 ( float2 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <3 x float> @
+// CHECK: call <3 x float> @llvm.floor.v3f32(
+float3 test_floor_float3 ( float3 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <4 x float> @
+// CHECK: call <4 x float> @llvm.floor.v4f32(
+float4 test_floor_float4 ( float4 p0 ) {
+  return floor ( p0 );
+}
+
+// CHECK: define noundef double @
+// CHECK: call double @llvm.floor.f64(
+double test_floor_double ( double p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <2 x double> @
+// CHECK: call <2 x double> @llvm.floor.v2f64(
+double2 test_floor_double2 ( double2 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <3 x double> @
+// CHECK: call <3 x double> @llvm.floor.v3f64(
+double3 test_floor_double3 ( double3 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <4 x double> @
+// CHECK: call <4 x double> @llvm.floor.v4f64(
+double4 test_floor_double4 ( double4 p0 ) {
+  return floor ( p0 );
+}
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -101,6 +101,36 @@
 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
 double4 ceil(double4);
 
+// floor builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half floor(half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half2 floor(half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half3 floor(half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half4 floor(half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) float
+floor(float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+float2 floor(float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+float3 floor(float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+float4 floor(float4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) double
+floor(double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+double2 floor(double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+double3 floor(double3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+double4 floor(double4);
+
 // cos builtins
 #ifdef __HLSL_ENABLE_16_BIT
 __attribute__((clang_builtin_

[clang] 500e729 - add floor library function

2022-12-08 Thread Joshua Batista via cfe-commits

Author: Joshua Batista
Date: 2022-12-08T15:41:54-08:00
New Revision: 500e72924305c4a1fac2ffd45b16114d49c3a7d2

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

LOG: add floor library function

This change exposes the floor library function for HLSL,
excluding long, int, and long long doubles.
Floor is supported for all scalar, vector, and matrix types.

Long and long long double support is missing in this patch because those types
don't exist in HLSL. Int is missing because the floor function only works on 
floating type arguments.

The full documentation of the HLSL floor function is available here:
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-floor

Reviewed By: beanz

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

Added: 
clang/test/CodeGenHLSL/builtins/floor.hlsl

Modified: 
clang/lib/Headers/hlsl/hlsl_intrinsics.h

Removed: 




diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 35891d80d5953..e5a6869e625ab 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -101,6 +101,36 @@ double3 ceil(double3);
 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
 double4 ceil(double4);
 
+// floor builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half floor(half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half2 floor(half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half3 floor(half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half4 floor(half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) float
+floor(float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+float2 floor(float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+float3 floor(float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+float4 floor(float4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) double
+floor(double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+double2 floor(double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+double3 floor(double3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+double4 floor(double4);
+
 // cos builtins
 #ifdef __HLSL_ENABLE_16_BIT
 __attribute__((clang_builtin_alias(__builtin_elementwise_cos))) half cos(half);

diff  --git a/clang/test/CodeGenHLSL/builtins/floor.hlsl 
b/clang/test/CodeGenHLSL/builtins/floor.hlsl
new file mode 100644
index 0..38834a146206f
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/floor.hlsl
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+using hlsl::floor;
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.floor.f16(
+// NO_HALF: define noundef float @"?test_floor_half@@YA$halff@$halff@@Z"(
+// NO_HALF: call float @llvm.floor.f32(float %0)
+half test_floor_half ( half p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.floor.v2f16(
+// NO_HALF: define noundef <2 x float> 
@"?test_floor_half2@@YAT?$__vector@$halff@$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x float> @llvm.floor.v2f32(
+half2 test_floor_half2 ( half2 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.floor.v3f16(
+// NO_HALF: define noundef <3 x float> 
@"?test_floor_half3@@YAT?$__vector@$halff@$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x float> @llvm.floor.v3f32(
+half3 test_floor_half3 ( half3 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.floor.v4f16(
+// NO_HALF: define noundef <4 x float> 
@"?test_floor_half4@@YAT?$__vector@$halff@$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x float> @llvm.floor.v4f32(
+half4 test_floor_half4 ( half4 p0 ) {
+  return floor ( p0 );
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.floor.f32(
+float test_floor_float ( float p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.floor.v2f32(
+float2 test_floor_float2 ( float2 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <3 x float> @
+// CHECK: call <3 x float

[PATCH] D138861: [Clang] Implement CWG2640 Allow more characters in an n-char sequence

2022-12-08 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann requested changes to this revision.
tahonermann added a comment.
This revision now requires changes to proceed.

This looks really good. I added a suggested edit for a comment that I had a 
hard time understanding and noted an area of code that I'm not sure is working 
as expected.




Comment at: clang/lib/Lex/Lexer.cpp:3378-3379
 
-  if (LooseMatch)
+  // If no diagnostic has been emitted yet we do not want to recover here
+  // to make sure this function will be called again and a diagnostic emitted 
then.
+  if (LooseMatch && Diagnose)

I'm having a hard time understanding what this comment is trying to convey. The 
comment response to Aaron was much more helpful to me. How about this suggested 
edit?



Comment at: clang/lib/Lex/Lexer.cpp:3386
+
+  if (!Result || CurPtr - StartPtr == (ptrdiff_t)(Buffer.size() + 4))
 StartPtr = CurPtr;

This is a bit of a tangent, but under what circumstances would `CurPtr - 
StartPtr` not be equal to `Buffer.size() + 4`? Actually, I'm not sure that +4 
is correct. It looks like `StartPtr` is expected to point to `N` at the 
beginning of the function, so the initial `\` is not included in the range. If 
`N` isn't seen, the function returns early. Likewise, if either of the `{` or 
`}` delimiters is not found, the function returns early.

I think the goal of this code is to skip the `getAndAdvanceChar()` machinery 
when the buffer is being claimed (no need to parse UCNs or trigraphs in the 
character name), but it looks like, particularly with this DR, that we might 
always be able to do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138861

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


[PATCH] D139676: [libTooling] Add flag to getRangeForEdit to ignore macro expansions

2022-12-08 Thread Eric Li via Phabricator via cfe-commits
li.zhe.hua created this revision.
li.zhe.hua added a reviewer: ymandel.
Herald added a project: All.
li.zhe.hua requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This commit resolves the FIXME around the behavior of
`Lexer::makeFileCharRange` that `getRangeForEdit` inherits around
source locations in macro expansions.

We add a flag to `getRangeForEdit` that allows a caller to disable the
behavior, and instead uses the spelling location instead, with checks
to ensure that the source locations are not within a macro definition.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139676

Files:
  clang/include/clang/Tooling/Transformer/SourceCode.h
  clang/lib/Tooling/Transformer/SourceCode.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -453,7 +453,11 @@
   Visitor.runOver(Code);
 }
 
-TEST(SourceCodeTest, EditRangeWithMacroExpansionsShouldSucceed) {
+class GetRangeForEditTest : public testing::TestWithParam {};
+INSTANTIATE_TEST_SUITE_P(WithAndWithoutExpansions, GetRangeForEditTest,
+ testing::Bool());
+
+TEST_P(GetRangeForEditTest, EditRangeWithMacroExpansionsShouldSucceed) {
   // The call expression, whose range we are extracting, includes two macro
   // expansions.
   llvm::Annotations Code(R"cpp(
@@ -463,10 +467,9 @@
 )cpp");
 
   CallsVisitor Visitor;
-
   Visitor.OnCall = [&Code](CallExpr *CE, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
-EXPECT_THAT(getRangeForEdit(Range, *Context),
+EXPECT_THAT(getRangeForEdit(Range, *Context, GetParam()),
 ValueIs(AsRange(Context->getSourceManager(), Code.range("r";
   };
   Visitor.runOver(Code.code());
@@ -487,7 +490,29 @@
   Visitor.runOver(Code.code());
 }
 
-TEST(SourceCodeTest, EditPartialMacroExpansionShouldFail) {
+TEST(SourceCodeTest, EditInvolvingExpansionIgnoringExpansionShouldFail) {
+  // If we specify to ignore macro expansions, none of these call expressions
+  // should have an editable range.
+  llvm::Annotations Code(R"cpp(
+#define M1(x) x(1)
+#define M2(x, y) x ## y
+#define M3(x) foobar(x)
+int foobar(int);
+int a = M1(foobar);
+int b = M2(foo, bar(2));
+int c = M3(3);
+)cpp");
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
+EXPECT_FALSE(
+getRangeForEdit(Range, *Context, /*IncludeMacroExpansion=*/false));
+  };
+  Visitor.runOver(Code.code());
+}
+
+TEST_P(GetRangeForEditTest, EditPartialMacroExpansionShouldFail) {
   std::string Code = R"cpp(
 #define BAR 10+
 int c = BAR 3.0;
@@ -496,12 +521,12 @@
   IntLitVisitor Visitor;
   Visitor.OnIntLit = [](IntegerLiteral *Expr, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
-EXPECT_FALSE(getRangeForEdit(Range, *Context));
+EXPECT_FALSE(getRangeForEdit(Range, *Context, GetParam()));
   };
   Visitor.runOver(Code);
 }
 
-TEST(SourceCodeTest, EditWholeMacroArgShouldSucceed) {
+TEST_P(GetRangeForEditTest, EditWholeMacroArgShouldSucceed) {
   llvm::Annotations Code(R"cpp(
 #define FOO(a) a + 7.0;
 int a = FOO($r[[10]]);
@@ -510,13 +535,13 @@
   IntLitVisitor Visitor;
   Visitor.OnIntLit = [&Code](IntegerLiteral *Expr, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
-EXPECT_THAT(getRangeForEdit(Range, *Context),
+EXPECT_THAT(getRangeForEdit(Range, *Context, GetParam()),
 ValueIs(AsRange(Context->getSourceManager(), Code.range("r";
   };
   Visitor.runOver(Code.code());
 }
 
-TEST(SourceCodeTest, EditPartialMacroArgShouldSucceed) {
+TEST_P(GetRangeForEditTest, EditPartialMacroArgShouldSucceed) {
   llvm::Annotations Code(R"cpp(
 #define FOO(a) a + 7.0;
 int a = FOO($r[[10]] + 10.0);
@@ -525,7 +550,7 @@
   IntLitVisitor Visitor;
   Visitor.OnIntLit = [&Code](IntegerLiteral *Expr, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(Expr->getSourceRange());
-EXPECT_THAT(getRangeForEdit(Range, *Context),
+EXPECT_THAT(getRangeForEdit(Range, *Context, GetParam()),
 ValueIs(AsRange(Context->getSourceManager(), Code.range("r";
   };
   Visitor.runOver(Code.code());
@@ -541,7 +566,6 @@
 )cpp";
 
   CallsVisitor Visitor;
-
   Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
 auto Range = CharSourceRange::getTokenRange(CE->getSourceRange());
 EXPECT_THAT_ERROR(validateEditRange(Range, Context->getSourceManager()),
Index: clang/lib/Tooling/Transformer/SourceCode.cpp
===
--- clang/lib/Tooling/Transformer/SourceCode.cpp
+++ clang/lib/Tooling/Transformer/S

[PATCH] D139052: [NFC][Profile] Access profile through VirtualFileSystem

2022-12-08 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added inline comments.



Comment at: llvm/include/llvm/Support/PGOOptions.h:18
 #include "llvm/Support/Error.h"
+#include "llvm/Support/VirtualFileSystem.h"
 

steven_wu wrote:
> akyrtzi wrote:
> > akyrtzi wrote:
> > > I'd suggest to consider moving the `PGOOptions` constructor out-of-line, 
> > > along with
> > > ```
> > >   PGOOptions &operator=(const PGOOptions &O);
> > >   PGOOptions(const PGOOptions&);
> > >   ~PGOOptions();
> > > ```
> > >  in order to forward-declare here and avoid including the header, 
> > > avoiding the additional include dependencies for many cpp files.
> > > The default parameter needs to instantiate here and pretty much all 
> > > references to `PGOOptions` has `Optional` which requires 
> > > including VFS. I will leave this one since `PGOOptions.h` is a rare 
> > > header to include.
> > 
> > `PGOOptions.h` is transitively included by many files, if I touch that 
> > header, and then compile `clang`, there are 225 files that need to be 
> > re-compiled.
> > 
> > I thought that moving the `PGOOptions` members I mentioned out-of-line 
> > would be enough to avoid the need to include `VirtualFileSystem.h`, is this 
> > not the case?
> I see. It is included in two different headers in the backend, both of them 
> has `Optional`. During my experiment, to instantiate 
> `Optional`, it needs full declaration for PGOOptions, thus 
> FileSystem. I could be wrong but I don't see a way around that.
With this diff on top of your patch everything compiles fine, without a need to 
include the header in `PGOOptions.h`:

```
diff --git a/llvm/include/llvm/Support/PGOOptions.h 
b/llvm/include/llvm/Support/PGOOptions.h
--- a/llvm/include/llvm/Support/PGOOptions.h
+++ b/llvm/include/llvm/Support/PGOOptions.h
@@ -14,11 +14,15 @@
 #ifndef LLVM_SUPPORT_PGOOPTIONS_H
 #define LLVM_SUPPORT_PGOOPTIONS_H
 
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/VirtualFileSystem.h"
 
 namespace llvm {
 
+namespace vfs {
+class FileSystem;
+} // namespace vfs
+
 /// A struct capturing PGO tunables.
 struct PGOOptions {
   enum PGOAction { NoAction, IRInstr, IRUse, SampleUse };
@@ -28,35 +32,13 @@ struct PGOOptions {
  IntrusiveRefCntPtr FS = nullptr,
  PGOAction Action = NoAction, CSPGOAction CSAction = NoCSAction,
  bool DebugInfoForProfiling = false,
- bool PseudoProbeForProfiling = false)
-  : ProfileFile(ProfileFile), CSProfileGenFile(CSProfileGenFile),
-ProfileRemappingFile(ProfileRemappingFile), Action(Action),
-CSAction(CSAction), DebugInfoForProfiling(DebugInfoForProfiling ||
-  (Action == SampleUse &&
-   !PseudoProbeForProfiling)),
-PseudoProbeForProfiling(PseudoProbeForProfiling), FS(std::move(FS)) {
-// Note, we do allow ProfileFile.empty() for Action=IRUse LTO can
-// callback with IRUse action without ProfileFile.
-
-// If there is a CSAction, PGOAction cannot be IRInstr or SampleUse.
-assert(this->CSAction == NoCSAction ||
-   (this->Action != IRInstr && this->Action != SampleUse));
-
-// For CSIRInstr, CSProfileGenFile also needs to be nonempty.
-assert(this->CSAction != CSIRInstr || !this->CSProfileGenFile.empty());
-
-// If CSAction is CSIRUse, PGOAction needs to be IRUse as they share
-// a profile.
-assert(this->CSAction != CSIRUse || this->Action == IRUse);
+ bool PseudoProbeForProfiling = false);
 
-// If neither Action nor CSAction, DebugInfoForProfiling or
-// PseudoProbeForProfiling needs to be true.
-assert(this->Action != NoAction || this->CSAction != NoCSAction ||
-   this->DebugInfoForProfiling || this->PseudoProbeForProfiling);
+  // Out-of-line so we don't have to include `VirtualFileSystem.h` header.
+  PGOOptions(const PGOOptions&);
+  ~PGOOptions();
+  PGOOptions &operator=(const PGOOptions &O);
 
-// If we need to use the profile, the VFS cannot be nullptr.
-assert(this->FS || !(this->Action == IRUse || this->CSAction == CSIRUse));
-  }
   std::string ProfileFile;
   std::string CSProfileGenFile;
   std::string ProfileRemappingFile;
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -201,6 +201,7 @@ add_llvm_component_library(LLVMSupport
   OptimizedStructLayout.cpp
   Optional.cpp
   Parallel.cpp
+  PGOOptions.cpp
   PluginLoader.cpp
   PrettyStackTrace.cpp
   RandomNumberGenerator.cpp
diff --git a/llvm/lib/Support/PGOOptions.cpp b/llvm/lib/Support/PGOOptions.cpp
new file mode 100644
--- /dev/null
+++ b/llvm/lib/Support/PGOOptions.cpp
@@ -0,0 +1,53 @@
+//===-- PGOOptions.cpp -- PGO option tunables --*- C++ 
-*--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See ht

[PATCH] D139653: [clang] Set ShowInSystemHeader for module-build and module-import remarks

2022-12-08 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.

> We could have a separate `-Ruser-module-{build,import}` (and maybe 
> `-Rsystem-module-{build,import}`) besides the `-Rmodule-{build,import}` (that 
> would now include both).

that sounds good to me.

I'll add tests if there are no objections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139653

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


[clang] 262c303 - Revert "[AMDGPU] Disable bool range metadata to workaround backend issue"

2022-12-08 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2022-12-08T17:35:10-05:00
New Revision: 262c3034bb44cac8b4ed6d4a3bb99ceb60d9e322

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

LOG: Revert "[AMDGPU] Disable bool range metadata to workaround backend issue"

This reverts commit 107ee2613063183cb643cef97f0fad403508c9f0 to facilitate
investigating and fixing the root cause.

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

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp

Removed: 
clang/test/CodeGenCUDA/bool-range.cu



diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index b2ba3f53fa0b5..afdee52aec629 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1750,10 +1750,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address 
Addr, bool Volatile,
   if (EmitScalarRangeCheck(Load, Ty, Loc)) {
 // In order to prevent the optimizer from throwing away the check, don't
 // attach range metadata to the load.
-// TODO: Enable range metadata for AMDGCN after issue
-// https://github.com/llvm/llvm-project/issues/58176 is fixed.
-  } else if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
- !CGM.getTriple().isAMDGCN())
+  } else if (CGM.getCodeGenOpts().OptimizationLevel > 0)
 if (llvm::MDNode *RangeInfo = getRangeForLoadFromType(Ty))
   Load->setMetadata(llvm::LLVMContext::MD_range, RangeInfo);
 

diff  --git a/clang/test/CodeGenCUDA/bool-range.cu 
b/clang/test/CodeGenCUDA/bool-range.cu
deleted file mode 100644
index e33174a2ad670..0
--- a/clang/test/CodeGenCUDA/bool-range.cu
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm %s -O3 -o - -fcuda-is-device \
-// RUN:   -triple nvptx64-unknown-unknown | FileCheck %s -check-prefixes=NV
-// RUN: %clang_cc1 -emit-llvm %s -O3 -o - -fcuda-is-device \
-// RUN:   -triple amdgcn-amd-amdhsa | FileCheck %s -check-prefixes=AMD
-
-#include "Inputs/cuda.h"
-
-// NV:  %[[LD:[0-9]+]] = load i8, ptr %x,{{.*}} !range ![[MD:[0-9]+]]
-// NV:  store i8 %[[LD]], ptr %y
-// NV: ![[MD]] = !{i8 0, i8 2}
-
-// Make sure bool loaded from memory is truncated and
-// range metadata is not emitted.
-// TODO: Re-enable range metadata after issue
-// https://github.com/llvm/llvm-project/issues/58176 is fixed.
-
-// AMD:  %[[LD:[0-9]+]] = load i8, ptr {{.*}}%x
-// AMD-NOT: !range
-// AMD:  %[[AND:[0-9]+]] = and i8 %[[LD]], 1
-// AMD:  store i8 %[[AND]], ptr {{.*}}%y
-__global__ void test1(bool *x, bool *y) {
-  *y = *x != false;
-}



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


[PATCH] D137051: [Clang] Allow additional mathematical symbols in identifiers.

2022-12-08 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

Oh, also, the review summary mentions "UAX32" (twice); those should be "UAX31". 
Just please make sure the commit message is correct.

Also, I'm terribly sorry for being so slow to get this reviewed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137051

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


[PATCH] D137051: [Clang] Allow additional mathematical symbols in identifiers.

2022-12-08 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

This looks great to me. I added a minor comment regarding the grammar of the 
added diagnostic, but am accepting the review regardless.




Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:129-130
   InGroup>;
 def warn_utf8_symbol_homoglyph : Warning<
   "treating Unicode character  as identifier character rather than "
   "as '%1' symbol">, InGroup>;

I think this diagnostic should also have an "an" before "identifier" if you 
wish to take on correcting it as well.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:135-137
+def ext_mathematical_notation : ExtWarn<
+  "mathematical notation character  in identifier is a Clang extension">,
+  InGroup>;

The grammar seems slightly off here. I think there should be an "an" before 
"identifier":
  - "mathematical notation character  in an identifier is a Clang 
extension"
This would be consistent with `err_character_not_allowed_identifier` and 
`warn_c99_compat_unicode_id`.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137051

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


[PATCH] D139629: clang: Stop emitting "strictfp"

2022-12-08 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2135
-llvm::AttrBuilder FuncAttrs(F->getContext());
-FuncAttrs.addAttribute("strictfp");
-F->addFnAttrs(FuncAttrs);

I think it would better to fix this function instead of removing it entirely? 
The issue here is that there is the "strictfp" attribute and the 
llvm::Attribute::StrictFP. We could replace  
FuncAttrs.addAttribute("strictfp"); with
 FuncAttrs.addAttribute(llvm::Attribute::StrictFP); 
This function ensures that the function attribute is set when the FunctionDecl 
attribute is set. I am concerned that when it's removed, we will wind up with 
cases where the function attribute is missing! The only place where this 
function attribute is in CodeGenFunction::StartFunction. Is that enough? 
@andrew.w.kaylor Can you please weigh in on this?


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

https://reviews.llvm.org/D139629

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


[PATCH] D139544: [clang][dataflow] Add support for structured bindings of tuple-like types.

2022-12-08 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added a comment.

> the temporary's construction should appear before, but the binding decls, 
> which use the synthetic variables, should appear after

I'm confused a bit here. Right now the CFG looks like this:

  
  
  ...
  

Based on what you say I assume you want something to happen between 
`constructor_call` and `binding_decl_0`. 
Could you visualize somehow how you think the ideal CFG here looks like?

> What do you think of duplicating it in the CFG, possibly with a new 
> (statement) element kind (to mark it as a special)? 
> There are other workarounds that we could do on our end, but the duplication 
> would avoid the need for such -- for us and any other clients.

Well, I don't think duplicating a statement in the CFG is a good idea as long 
as there are other solutions for this problem. This seems to be a
very specific problem, so I think a local solution should be pursued instead if 
possible. What do you think @xazax.hun  @NoQ ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139544

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


[PATCH] D139115: [clang][ExtractAPI] Add support for single symbol SGF

2022-12-08 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added inline comments.



Comment at: clang/include/clang-c/Documentation.h:549
 
+typedef struct CXAPISetImpl *CXAPISet;
+

benlangmuir wrote:
> @dang please document what this type represents.
> 
> @akyrtzi what's the preferred implementation type name for opaque typedef 
> types? I see we have a mix right now:
> * `void *`
> * `CXOpaqueFoo *`
> * `CXFooImpl *`
There's no consistency in libclang APIs 😅 This typedef LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139115

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


[PATCH] D139653: [clang] Set ShowInSystemHeader for module-build and module-import remarks

2022-12-08 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added subscribers: vsapsai, Bigcheese.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

In D139653#3982272 , @kastiglione 
wrote:

>> Also, do you think this should be configurable on the command line?
>
> Do you have a flag in mind?

We could have a separate `-Ruser-module-{build,import}` (and maybe 
`-Rsystem-module-{build,import}`) besides the `-Rmodule-{build,import}` (that 
would now include both).

>> I'm thinking about users that are trying to debug their own modular code, 
>> but don't really care what happens in the SDK.
>
> My first question is how many of those users are there? It seems to me that 
> the module remarks are more for tooling developers than end users.

I'm not sure TBH. But I think Clang modules are used by people that are not 
familiar with the inner workings of the SDK.

> Speaking as someone working on tools, I think I would always want all 
> module-build remarks, since – correct me if I'm wrong – they're relevant only 
> to performance, and for performance I want to see all the builds.

FWIW, these remarks have been useful for me when checking correctness of 
implicit builds as well. As for performance, let's pretend I'm trying to 
optimize LLVM's modular build. I can imagine myself starting investigating our 
own modules (e.g. seeing how many times `clangFrontend` gets built), and only 
dropping down into system headers once that's optimized. Getting bombarded by 
all the modules that are built for the SDK right away would be too noisy.

> For module-import remarks, I could see it being more interesting to 
> developers, but I don't know how many developers know about and use 
> `-Rmodule-import`. If we want to proactively support those users, maybe the 
> solution is two flags, say `-Rmodule-import` and `-Rmodule-import-all` (I 
> can't think of a better spelling).
>
> For relevant comparisons, the only thing I can think about is the `-H` flag, 
> which shows all header includes, it does not exclude system headers. Speaking 
> of which, an equivalent for modules might be helpful.

I'm fine with landing current functionality provided it's tested (and people 
like @vsapsai and @Bigcheese don't have objections).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139653

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


[PATCH] D139166: [OPENMP51] Codegen support for error directive.

2022-12-08 Thread Jennifer Yu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf781f704239: [OPENMP51]Codegen for error directive. 
(authored by jyu2).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139166

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/error_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -198,6 +198,7 @@
 __OMP_RTL(__kmpc_barrier, false, Void, IdentPtr, Int32)
 __OMP_RTL(__kmpc_cancel, false, Int32, IdentPtr, Int32, Int32)
 __OMP_RTL(__kmpc_cancel_barrier, false, Int32, IdentPtr, Int32)
+__OMP_RTL(__kmpc_error, false, Void, IdentPtr, Int32, Int8Ptr)
 __OMP_RTL(__kmpc_flush, false, Void, IdentPtr)
 __OMP_RTL(__kmpc_global_thread_num, false, Int32, IdentPtr)
 __OMP_RTL(__kmpc_get_hardware_thread_id_in_block, false, Int32, )
Index: clang/test/OpenMP/error_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/error_codegen.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -std=c++11 -fopenmp -fopenmp-version=51 -triple x86_64 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -std=c++11 -fopenmp-simd -fopenmp-version=51 \
+// RUN:  -debug-info-kind=limited -triple x86_64 -emit-llvm -o - %s |  \
+// RUN:  FileCheck  --check-prefix SIMD %s
+
+//CHECK: @.str = private unnamed_addr constant [23 x i8] c"GPU compiler required.\00", align 1
+//CHECK: @0 = private unnamed_addr constant {{.*}}error_codegen.cpp;main;52;1;;\00", align 1
+//CHECK: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @0 }, align 8
+//CHECK: @.str.1 = private unnamed_addr constant [27 x i8] c"Note this is functioncall.\00", align 1
+//CHECK: @2 = private unnamed_addr constant {{.*}}error_codegen.cpp;main;54;1;;\00", align 1
+//CHECK: @3 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @2 }, align 8
+//CHECK: @.str.2 = private unnamed_addr constant [23 x i8] c"GNU compiler required.\00", align 1
+//CHECK: @4 = private unnamed_addr constant {{.*}}error_codegen.cpp;tmain;29;1;;\00", align 1
+//CHECK: @5 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @4 }, align 8
+//CHECK: @.str.3 = private unnamed_addr constant [22 x i8] c"Notice: add for loop.\00", align 1
+//CHECK: @6 = private unnamed_addr constant {{.*}}error_codegen.cpp;tmain;32;1;;\00", align 1
+//CHECK: @7 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @6 }, align 8
+//CHECK: @8 = private unnamed_addr constant {{.*}}error_codegen.cpp;tmain;38;1;;\00", align 1
+//CHECK: @9 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @8 }, align 8
+
+void foo() {}
+
+template 
+int tmain(T argc, char **argv) {
+  T b = argc, c, d, e, f, g;
+  static int a;
+#pragma omp error at(execution) severity(fatal) message("GNU compiler required.")
+  a = argv[0][0];
+  ++a;
+#pragma omp error at(execution) severity(warning) message("Notice: add for loop.")
+  {
+int b = 10;
+T c = 100;
+a = b + c;
+  }
+#pragma omp  error at(execution) severity(fatal) message("GPU compiler required.")
+  foo();
+return N;
+}
+// CHECK-LABEL: @main(
+// SIMD-LABEL: @main(
+// CHECK:call void @__kmpc_error(ptr @1, i32 2, ptr @.str)
+// SIMD-NOT:call void @__kmpc_error(ptr @1, i32 2, ptr @.str)
+// CHECK:call void @__kmpc_error(ptr @3, i32 1, ptr @.str.1)
+// SIMD-NOT:call void @__kmpc_error(ptr @3, i32 1, ptr @.str.1)
+//
+int main (int argc, char **argv) {
+  int b = argc, c, d, e, f, g;
+  static int a;
+#pragma omp error at(execution) severity(fatal) message("GPU compiler required.")
+   a=2;
+#pragma omp error at(execution) severity(warning) message("Note this is functioncall.")
+  foo();
+  tmain(argc, argv);
+}
+
+//CHECK-LABEL: @_Z5tmainIiLi10EEiT_PPc(
+//SIMD-LABEL: @_Z5tmainIiLi10EEiT_PPc(
+//CHECK: call void @__kmpc_error(ptr @5, i32 2, ptr @.str.2)
+//CHECK: call void @__kmpc_error(ptr @7, i32 1, ptr @.str.3)
+//CHECK: call void @__kmpc_error(ptr @9, i32 2, ptr @.str)
+//SIMD-NOT: call void @__kmpc_error(ptr @5, i32 2, ptr @.str.2)
+//SIMD-NOT: call void @__kmpc_error(ptr @7, i32 1, ptr @.str.3)
+//SIMD-NOT: call void @__kmpc_error(ptr @9, i32 2, ptr @.str)
+//CHECK: ret i32 10
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5246,7 +5246,13 @@
 }
 
 void CodeGenFunction::EmitOMPErrorDire

[clang] af781f7 - [OPENMP51]Codegen for error directive.

2022-12-08 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2022-12-08T13:07:08-08:00
New Revision: af781f7042392910c4cf70106c6a0c2244c69478

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

LOG: [OPENMP51]Codegen for error directive.

Added codegen for `omp error` directive.
This is to generate IR to call:
void __kmpc_error(ident_t *loc, int severity, const char *message);

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

Added: 
clang/test/OpenMP/error_codegen.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 10c88964da0ed..396075183102d 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1363,10 +1363,11 @@ static StringRef 
getIdentStringFromSourceLocation(CodeGenFunction &CGF,
 
 llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
  SourceLocation Loc,
- unsigned Flags) {
+ unsigned Flags, bool EmitLoc) 
{
   uint32_t SrcLocStrSize;
   llvm::Constant *SrcLocStr;
-  if (CGM.getCodeGenOpts().getDebugInfo() == codegenoptions::NoDebugInfo ||
+  if ((!EmitLoc &&
+   CGM.getCodeGenOpts().getDebugInfo() == codegenoptions::NoDebugInfo) ||
   Loc.isInvalid()) {
 SrcLocStr = OMPBuilder.getOrCreateDefaultSrcLocStr(SrcLocStrSize);
   } else {
@@ -2557,6 +2558,22 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction 
&CGF, SourceLocation Loc,
   Args);
 }
 
+void CGOpenMPRuntime::emitErrorCall(CodeGenFunction &CGF, SourceLocation Loc,
+Expr *ME, bool IsFatal) {
+  llvm::Value *MVL =
+  ME ? CGF.EmitStringLiteralLValue(cast(ME)).getPointer(CGF)
+ : llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
+  // Build call void __kmpc_error(ident_t *loc, int severity, const char
+  // *message)
+  llvm::Value *Args[] = {
+  emitUpdateLocation(CGF, Loc, /*Flags=*/0, /*GenLoc=*/true),
+  llvm::ConstantInt::get(CGM.Int32Ty, IsFatal ? 2 : 1),
+  CGF.Builder.CreatePointerCast(MVL, CGM.Int8PtrTy)};
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
+  CGM.getModule(), OMPRTL___kmpc_error),
+  Args);
+}
+
 /// Map the OpenMP loop schedule to the runtime enumeration.
 static OpenMPSchedType getRuntimeSchedule(OpenMPScheduleClauseKind 
ScheduleKind,
   bool Chunked, bool Ordered) {

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.h 
b/clang/lib/CodeGen/CGOpenMPRuntime.h
index ee3211858fe18..e7c1a098c7689 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -329,9 +329,10 @@ class CGOpenMPRuntime {
 
   /// Emits object of ident_t type with info for source location.
   /// \param Flags Flags for OpenMP location.
+  /// \param EmitLoc emit source location with debug-info is off.
   ///
   llvm::Value *emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc,
-  unsigned Flags = 0);
+  unsigned Flags = 0, bool EmitLoc = false);
 
   /// Emit the number of teams for a target directive.  Inspect the num_teams
   /// clause associated with a teams construct combined or closely nested
@@ -822,6 +823,11 @@ class CGOpenMPRuntime {
   /// Emits code for a taskyield directive.
   virtual void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc);
 
+  /// Emit __kmpc_error call for error directive
+  /// extern void __kmpc_error(ident_t *loc, int severity, const char 
*message);
+  virtual void emitErrorCall(CodeGenFunction &CGF, SourceLocation Loc, Expr 
*ME,
+ bool IsFatal);
+
   /// Emit a taskgroup region.
   /// \param TaskgroupOpGen Generator for the statement associated with the
   /// given taskgroup region.

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index b84fee77c66dd..cf9b704e0ae6f 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5246,7 +5246,13 @@ void CodeGenFunction::EmitOMPTaskyieldDirective(
 }
 
 void CodeGenFunction::EmitOMPErrorDirective(const OMPErrorDirective &S) {
-  llvm_unreachable("CodeGen for 'omp error' is not supported yet.");
+  const OMPMessageClause *MC = S.getSingleClause();
+  Expr *ME = MC ? MC->getMessageString() : nullptr;
+  const OMPSeverityClause *SC = S.getSingleClause();
+  bool IsFatal = false;
+  if (!SC || SC->getSeverityKind() == OMPC_SE

[PATCH] D136176: Implement support for option 'fexcess-precision'.

2022-12-08 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

ping


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

https://reviews.llvm.org/D136176

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


[PATCH] D139400: [clang] Show error when a local variables is passed as default template parameter

2022-12-08 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:11
 
+#include  // massberg
 #include "TreeTransform.h"

Please remove.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139400

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


[PATCH] D139444: [ZOS] Convert tests to check 'target={{.*}}-zos'

2022-12-08 Thread Paul Robinson via Phabricator via cfe-commits
probinson updated this revision to Diff 481421.
probinson added a comment.

Add trailing '{{.*}}' as requested.
Have not changed the encoding.ll test, waiting on @uweigand about correct value 
to test in Python.


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

https://reviews.llvm.org/D139444

Files:
  clang/test/Analysis/cfref_PR2519.c
  clang/test/CodeGen/cfstring2.c
  clang/test/Driver/as-version.s
  clang/test/Import/forward-declared-objc-class/test.m
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/Import/objc-autoreleasepool/test.m
  clang/test/Import/objc-definitions-in-expression/test.m
  clang/test/Import/objc-method/test.m
  clang/test/Import/objc-param-decl/test.m
  clang/test/Import/objc-try-catch/test.m
  clang/test/Modules/DebugInfoNamespace.cpp
  clang/test/Modules/DebugInfoTransitiveImport.m
  clang/test/Modules/ExtDebugInfo.cpp
  clang/test/Modules/ExtDebugInfo.m
  clang/test/Modules/ModuleDebugInfo.cpp
  clang/test/Modules/ModuleDebugInfo.m
  clang/test/Modules/ModuleDebugInfoDwoId.cpp
  clang/test/Modules/ModuleModuleDebugInfo.cpp
  clang/test/Modules/autolink.m
  clang/test/Modules/autolinkTBD.m
  clang/test/Modules/builtins.m
  clang/test/Modules/clang_module_file_info.m
  clang/test/Modules/cxx-irgen.cpp
  clang/test/Modules/debug-info-moduleimport-in-module.m
  clang/test/Modules/debug-info-moduleimport.m
  clang/test/Modules/direct-module-import.m
  clang/test/Modules/merge-anon-record-definition-in-objc.m
  clang/test/Modules/merge-extension-ivars.m
  clang/test/Modules/merge-objc-interface-visibility.m
  clang/test/Modules/merge-objc-interface.m
  clang/test/Modules/merge-record-definition-nonmodular.m
  clang/test/Modules/merge-record-definition-visibility.m
  clang/test/Modules/merge-record-definition.m
  clang/test/Modules/module-debuginfo-prefix.m
  clang/test/Modules/module-file-home-is-cwd.m
  clang/test/Modules/module_file_info.m
  clang/test/Modules/objc-initializer.m
  clang/test/Modules/pch-used.m
  clang/test/Modules/redecl-ivars.m
  clang/test/Modules/use-exportas-for-link.m
  clang/test/PCH/externally-retained.m
  clang/test/PCH/irgen-rdar13114142.mm
  clang/test/PCH/objc_container.m
  clang/test/PCH/objc_literals.m
  clang/test/PCH/objc_literals.mm
  clang/test/PCH/objcxx-ivar-class.mm
  clang/test/PCH/pending-ids.m
  llvm/test/MC/AsmParser/debug-no-source.s
  llvm/test/Support/encoding.ll
  llvm/test/tools/llvm-mc/no_warnings.test

Index: llvm/test/tools/llvm-mc/no_warnings.test
===
--- llvm/test/tools/llvm-mc/no_warnings.test
+++ llvm/test/tools/llvm-mc/no_warnings.test
@@ -1,4 +1,4 @@
-# UNSUPPORTED: -zos
+# UNSUPPORTED: target={{.*}}-zos{{.*}}
 # RUN: llvm-mc --no-warn %s 2>&1 | FileCheck %s
 
 # CHECK-NOT: warning:
Index: llvm/test/Support/encoding.ll
===
--- llvm/test/Support/encoding.ll
+++ llvm/test/Support/encoding.ll
@@ -1,7 +1,7 @@
 ; Checks if llc can deal with different char encodings.
 ; This is only required for z/OS.
 ;
-; UNSUPPORTED: !s390x-none-zos
+; REQUIRES: target=s390x-none-zos
 ;
 ; RUN: cat %s >%t && chtag -tc ISO8859-1 %t && llc %t -o - >/dev/null
 ; RUN: iconv -f ISO8859-1 -t IBM-1047 <%s >%t && chtag -tc IBM-1047 %t && llc %t -o - >/dev/null
Index: llvm/test/MC/AsmParser/debug-no-source.s
===
--- llvm/test/MC/AsmParser/debug-no-source.s
+++ llvm/test/MC/AsmParser/debug-no-source.s
@@ -1,4 +1,4 @@
-// UNSUPPORTED: -zos
+// UNSUPPORTED: target={{.*}}-zos{{.*}}
 // REQUIRES: object-emission
 // RUN: llvm-mc %s | FileCheck %s
 
Index: clang/test/PCH/pending-ids.m
===
--- clang/test/PCH/pending-ids.m
+++ clang/test/PCH/pending-ids.m
@@ -1,4 +1,4 @@
-// UNSUPPORTED: -zos, target={{.*}}-aix{{.*}}
+// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
 // Test for rdar://10278815
 
 // Without PCH
Index: clang/test/PCH/objcxx-ivar-class.mm
===
--- clang/test/PCH/objcxx-ivar-class.mm
+++ clang/test/PCH/objcxx-ivar-class.mm
@@ -1,4 +1,4 @@
-// UNSUPPORTED: -zos, target={{.*}}-aix{{.*}}
+// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
 // Test this without pch.
 // RUN: %clang_cc1 -no-opaque-pointers -include %S/objcxx-ivar-class.h -triple %itanium_abi_triple %s -emit-llvm -o - | FileCheck %s
 
Index: clang/test/PCH/objc_literals.mm
===
--- clang/test/PCH/objc_literals.mm
+++ clang/test/PCH/objc_literals.mm
@@ -1,4 +1,4 @@
-// UNSUPPORTED: -zos, target={{.*}}-aix{{.*}}
+// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-pch -x objective-c++ -std=c++0x -o %t %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std

[PATCH] D139647: [opt] Disincentivize new tests from using old pass syntax

2022-12-08 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

@aeubanks Thank you for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139647

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


[clang] 5131f44 - Simplify clang/test/CodeGen/annotations-global.c CHECK lines

2022-12-08 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2022-12-08T20:44:40Z
New Revision: 5131f444ee7045d58f72fc99e2ac69792e8b7158

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

LOG: Simplify clang/test/CodeGen/annotations-global.c CHECK lines

There is no need to run FileCheck 5 times, we can use CHECK-DAG instead.

Added: 


Modified: 
clang/test/CodeGen/annotations-global.c

Removed: 




diff  --git a/clang/test/CodeGen/annotations-global.c 
b/clang/test/CodeGen/annotations-global.c
index 49791094a76d..d6e6f7de8a95 100644
--- a/clang/test/CodeGen/annotations-global.c
+++ b/clang/test/CodeGen/annotations-global.c
@@ -1,10 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o -
-// RUN: %clang_cc1 %s -emit-llvm -o %t1
-// RUN: FileCheck --check-prefix=FOO %s < %t1
-// RUN: FileCheck --check-prefix=A %s < %t1
-// RUN: FileCheck --check-prefix=BAR %s < %t1
-// RUN: FileCheck --check-prefix=FOOS %s < %t1
-// RUN: FileCheck --check-prefix=ADDRSPACE %s < %t1
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s 
--implicit-check-not='section "llvm.metadata"'
 // RUN: %clang_cc1 %s -triple r600 -emit-llvm -o - | FileCheck %s 
--check-prefix AS1-GLOBALS
 // END.
 
@@ -19,34 +13,36 @@ void __attribute((annotate("ann_a_0"))) 
__attribute((annotate("ann_a_1"))) a(cha
 
 __attribute((address_space(1))) __attribute__((annotate("addrspace1_ann"))) 
char addrspace1_var;
 
-// FOOS: target triple
-// FOOS: private unnamed_addr constant [7 x i8] c"sfoo_{{.}}\00", section 
"llvm.metadata"
-// FOOS: private unnamed_addr constant [7 x i8] c"sfoo_{{.}}\00", section 
"llvm.metadata"
-// FOOS-NOT: sfoo_
-// FOOS: @llvm.global.annotations = appending global [11 x { ptr, ptr, ptr, 
i32, ptr }] {{.*}}ptr @sfoo{{.*}}ptr @sfoo{{.*}}, section "llvm.metadata"
-
-// FOO: target triple
-// FOO: private unnamed_addr constant [6 x i8] c"foo_{{.}}\00", section 
"llvm.metadata"
-// FOO: private unnamed_addr constant [6 x i8] c"foo_{{.}}\00", section 
"llvm.metadata"
-// FOO-NOT: foo_
-// FOO: @llvm.global.annotations = appending global [11 x { ptr, ptr, ptr, 
i32, ptr }] {{.*}}ptr @foo{{.*}}ptr @foo{{.*}}, section "llvm.metadata"
-
-// A: target triple
-// A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section 
"llvm.metadata"
-// A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section 
"llvm.metadata"
-// A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section 
"llvm.metadata"
-// A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section 
"llvm.metadata"
-// A-NOT: ann_a_
-// A: @llvm.global.annotations = appending global [11 x { ptr, ptr, ptr, i32, 
ptr }] {{.*}}ptr @a{{.*}}ptr @a{{.*}}ptr @a{{.*}}ptr @a{{.*}}, section 
"llvm.metadata"
-
-// BAR: target triple
-// BAR: private unnamed_addr constant [6 x i8] c"bar_{{.}}\00", section 
"llvm.metadata"
-// BAR: private unnamed_addr constant [6 x i8] c"bar_{{.}}\00", section 
"llvm.metadata"
-// BAR-NOT: bar_
-// BAR: @llvm.global.annotations = appending global [11 x { ptr, ptr, ptr, 
i32, ptr }] {{.*}}ptr @a.bar{{.*}}ptr @a.bar{{.*}}, section "llvm.metadata"
-
-// ADDRSPACE: target triple
-// ADDRSPACE: @llvm.global.annotations = appending global {{.*}} addrspacecast 
(ptr addrspace(1) @addrspace1_var to ptr), {{.*}}
+// CHECK: target triple
+// CHECK-DAG: private unnamed_addr constant [7 x i8] c"sfoo_0\00", section 
"llvm.metadata"
+// CHECK-DAG: private unnamed_addr constant [7 x i8] c"sfoo_1\00", section 
"llvm.metadata"
+
+// CHECK-DAG: private unnamed_addr constant [6 x i8] c"foo_0\00", section 
"llvm.metadata"
+// CHECK-DAG: private unnamed_addr constant [6 x i8] c"foo_1\00", section 
"llvm.metadata"
+
+// CHECK-DAG: private unnamed_addr constant [8 x i8] c"ann_a_0\00", section 
"llvm.metadata"
+// CHECK-DAG: private unnamed_addr constant [8 x i8] c"ann_a_1\00", section 
"llvm.metadata"
+// CHECK-DAG: private unnamed_addr constant [8 x i8] c"ann_a_2\00", section 
"llvm.metadata"
+// CHECK-DAG: private unnamed_addr constant [8 x i8] c"ann_a_3\00", section 
"llvm.metadata"
+
+// CHECK-DAG: private unnamed_addr constant [6 x i8] c"bar_0\00", section 
"llvm.metadata"
+// CHECK-DAG: private unnamed_addr constant [6 x i8] c"bar_1\00", section 
"llvm.metadata"
+
+// CHECK-DAG: private unnamed_addr constant [15 x i8] c"addrspace1_ann\00", 
section "llvm.metadata"
+
+// CHECK: @llvm.global.annotations = appending global [11 x { ptr, ptr, ptr, 
i32, ptr }] [{
+// CHECK-SAME: { ptr @a.bar,
+// CHECK-SAME: { ptr @a.bar,
+// CHECK-SAME: { ptr @a,
+// CHECK-SAME: { ptr @a,
+// CHECK-SAME: { ptr @a,
+// CHECK-SAME: { ptr @a,
+// CHECK-SAME: { ptr @sfoo,
+// CHECK-SAME: { ptr @sfoo,
+// CHECK-SAME: { ptr @foo,
+// CHECK-SAME: { ptr @foo,
+// CHECK-SAME: { ptr addrspacecast (ptr addrspace(1) @addrspace1_var to ptr),
+// CHECK-SAME: }], section "llvm.met

[clang] 121a89f - Fix annotations-field.c CHECK lines being ignored

2022-12-08 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2022-12-08T20:44:40Z
New Revision: 121a89fc2aedf48ca4aee43288b67e27b71e72ed

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

LOG: Fix annotations-field.c CHECK lines being ignored

Pointed out by @jrtc27 in https://reviews.llvm.org/D138722.

Added: 


Modified: 
clang/test/CodeGen/annotations-field.c

Removed: 




diff  --git a/clang/test/CodeGen/annotations-field.c 
b/clang/test/CodeGen/annotations-field.c
index 2815c1dd849d1..e40b409ce272c 100644
--- a/clang/test/CodeGen/annotations-field.c
+++ b/clang/test/CodeGen/annotations-field.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64 -emit-llvm -o - %s | FileCheck %s 
'-D$MANGLE_AS=p0' '-D$CONST_AS=' --check-prefix=X86
-// RUN: %clang_cc1 -triple amdgcn -emit-llvm -o - %s | FileCheck %s 
'-D$MANGLE_AS=p4' '-D$CONST_AS= addrspace(4)' --check-prefix=AMDGPU
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm -o - %s | FileCheck %s 
'-D$MANGLE_AS=p0' '-D$CONST_AS=' --check-prefixes=CHECK,X86
+// RUN: %clang_cc1 -triple amdgcn -emit-llvm -o - %s | FileCheck %s 
'-D$MANGLE_AS=p4' '-D$CONST_AS= addrspace(4)' --check-prefixes=CHECK,AMDGPU
 // END.
 
 // CHECK: private unnamed_addr[[$CONST_AS]] constant [8 x i8] 
c"v_ann_{{.}}\00", section "llvm.metadata"



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


[PATCH] D139400: [clang] Show error when a local variables is passed as default template parameter

2022-12-08 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/SemaTemplate/default-template-arguments.cpp:9
+
+  auto lambda1 = []  {}; // expected-error {{default argument 
references local variable x of enclosing function}}
+  auto lambda2 = []  {};

To clarify my comment about, I think w/ the ODR use checking this should pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139400

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


[PATCH] D131830: [OpenMP] Clang Support for taskwait nowait clause

2022-12-08 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG100dfe7a8ad3: [OpenMP] Clang Support for taskwait nowait 
clause (authored by koops, committed by ABataev).
Herald added projects: clang, OpenMP.
Herald added subscribers: openmp-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131830

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/task_codegen.cpp
  clang/test/OpenMP/task_if_codegen.cpp
  clang/test/OpenMP/taskwait_ast_print.cpp
  clang/test/OpenMP/taskwait_codegen.cpp
  clang/test/OpenMP/taskwait_depend_codegen.cpp
  clang/test/OpenMP/taskwait_depend_nowait_codegen.cpp
  clang/test/OpenMP/taskwait_nowait_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  mlir/test/Target/LLVMIR/openmp-llvm.mlir
  openmp/runtime/src/dllexports
  openmp/runtime/src/kmp.h
  openmp/runtime/src/kmp_taskdeps.cpp
  openmp/runtime/src/kmp_tasking.cpp

Index: openmp/runtime/src/kmp_tasking.cpp
===
--- openmp/runtime/src/kmp_tasking.cpp
+++ openmp/runtime/src/kmp_tasking.cpp
@@ -2049,7 +2049,8 @@
 template 
 static kmp_int32 __kmpc_omp_taskwait_template(ident_t *loc_ref, kmp_int32 gtid,
   void *frame_address,
-  void *return_address) {
+  void *return_address,
+  kmp_int32 has_no_wait) {
   kmp_taskdata_t *taskdata = nullptr;
   kmp_info_t *thread;
   int thread_finished = FALSE;
@@ -2162,23 +2163,34 @@
 OMPT_NOINLINE
 static kmp_int32 __kmpc_omp_taskwait_ompt(ident_t *loc_ref, kmp_int32 gtid,
   void *frame_address,
-  void *return_address) {
+  void *return_address,
+  kmp_int32 has_no_wait) {
   return __kmpc_omp_taskwait_template(loc_ref, gtid, frame_address,
-return_address);
+return_address, has_no_wait);
 }
 #endif // OMPT_SUPPORT && OMPT_OPTIONAL
 
 // __kmpc_omp_taskwait: Wait until all tasks generated by the current task are
 // complete
 kmp_int32 __kmpc_omp_taskwait(ident_t *loc_ref, kmp_int32 gtid) {
+  return __kmpc_omp_taskwait_51(loc_ref, gtid, false);
+}
+
+/* __kmpc_omp_taskwait_51 : Function for OpenMP 5.1 nowait clause.
+ *  Placeholder for taskwait with nowait clause.
+ *  The code is a copy of __kmpc_omp_taskwait.*/
+kmp_int32 __kmpc_omp_taskwait_51(ident_t *loc_ref, kmp_int32 gtid,
+ kmp_int32 has_no_wait) {
 #if OMPT_SUPPORT && OMPT_OPTIONAL
   if (UNLIKELY(ompt_enabled.enabled)) {
 OMPT_STORE_RETURN_ADDRESS(gtid);
 return __kmpc_omp_taskwait_ompt(loc_ref, gtid, OMPT_GET_FRAME_ADDRESS(0),
-OMPT_LOAD_RETURN_ADDRESS(gtid));
+OMPT_LOAD_RETURN_ADDRESS(gtid),
+has_no_wait);
   }
 #endif
-  return __kmpc_omp_taskwait_template(loc_ref, gtid, NULL, NULL);
+  return __kmpc_omp_taskwait_template(loc_ref, gtid, NULL, NULL,
+ has_no_wait);
 }
 
 // __kmpc_omp_taskyield: switch to a different task
Index: openmp/runtime/src/kmp_taskdeps.cpp
===
--- openmp/runtime/src/kmp_taskdeps.cpp
+++ openmp/runtime/src/kmp_taskdeps.cpp
@@ -744,10 +744,24 @@
 void __kmpc_omp_wait_deps(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps,
   kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias,
   kmp_depend

[clang] 100dfe7 - [OpenMP] Clang Support for taskwait nowait clause

2022-12-08 Thread Alexey Bataev via cfe-commits

Author: Sunil K
Date: 2022-12-08T12:40:44-08:00
New Revision: 100dfe7a8ad3789a98df623482b88d9a3a02e176

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

LOG: [OpenMP] Clang Support for taskwait nowait clause

Support for taskwait nowait clause with placeholder for runtime changes.

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/taskwait_depend_nowait_codegen.cpp
clang/test/OpenMP/taskwait_nowait_codegen.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/target_depend_codegen.cpp
clang/test/OpenMP/target_enter_data_depend_codegen.cpp
clang/test/OpenMP/target_exit_data_depend_codegen.cpp
clang/test/OpenMP/target_parallel_depend_codegen.cpp
clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
clang/test/OpenMP/target_simd_depend_codegen.cpp
clang/test/OpenMP/target_teams_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
clang/test/OpenMP/target_update_depend_codegen.cpp
clang/test/OpenMP/task_codegen.cpp
clang/test/OpenMP/task_if_codegen.cpp
clang/test/OpenMP/taskwait_ast_print.cpp
clang/test/OpenMP/taskwait_codegen.cpp
clang/test/OpenMP/taskwait_depend_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
mlir/test/Target/LLVMIR/openmp-llvm.mlir
openmp/runtime/src/dllexports
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_taskdeps.cpp
openmp/runtime/src/kmp_tasking.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 51f364fac8d1b..10c88964da0ed 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4739,7 +4739,7 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, 
SourceLocation Loc,
   Region->emitUntiedSwitch(CGF);
   };
 
-  llvm::Value *DepWaitTaskArgs[6];
+  llvm::Value *DepWaitTaskArgs[7];
   if (!Data.Dependences.empty()) {
 DepWaitTaskArgs[0] = UpLoc;
 DepWaitTaskArgs[1] = ThreadID;
@@ -4747,6 +4747,8 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, 
SourceLocation Loc,
 DepWaitTaskArgs[3] = DependenciesArray.getPointer();
 DepWaitTaskArgs[4] = CGF.Builder.getInt32(0);
 DepWaitTaskArgs[5] = llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
+DepWaitTaskArgs[6] =
+llvm::ConstantInt::get(CGF.Int32Ty, Data.HasNowaitClause);
   }
   auto &M = CGM.getModule();
   auto &&ElseCodeGen = [this, &M, &TaskArgs, ThreadID, NewTaskNewTaskTTy,
@@ -4758,9 +4760,9 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, 
SourceLocation Loc,
 // ndeps_noalias, kmp_depend_info_t *noalias_dep_list); if dependence info
 // is specified.
 if (!Data.Dependences.empty())
-  CGF.EmitRuntimeCall(
-  OMPBuilder.getOrCreateRuntimeFunction(M, 
OMPRTL___kmpc_omp_wait_deps),
-  DepWaitTaskArgs);
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
+  M, OMPRTL___kmpc_omp_taskwait_deps_51),
+  DepWaitTaskArgs);
 // Call proxy_task_entry(gtid, new_task);
 auto &&CodeGen = [TaskEntry, ThreadID, NewTaskNewTaskTTy,
   Loc](CodeGenFunction &CGF, PrePostActionTy &Action) {
@@ -5799,7 +5801,7 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction 
&CGF, SourceLocation Loc,
 
   if (CGF.CGM.getLangOpts().OpenMPIRBuilder && Data.Dependences.empty()) {
 // TODO: Need to support taskwait with dependences in the OpenMPIRBuilder.
-OMPBuilder.createTaskwait(CGF.Builder);
+OMPBuilder.createTaskwait(CGF.Builder, Data.HasNowaitClause);
   } else {
 llvm::Value *ThreadID = getThreadID(CGF, Loc);
 llvm::Value *UpLoc = emitUpdateLocation(CGF, Loc);
@@ -5808,34 +5810,38 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction 
&CGF, SourceLocation Loc,
 llvm::Value *NumOfElements;
 std::tie(NumOfElements, DependenciesArray) =
 emitDependClause(CGF, Data.Dependences, Loc);
-llvm::Value *DepWaitTaskArgs[6];
 if (!Data.Dependences.empty()) {
+  llvm::Value *DepWaitTaskArgs[7];
   DepWaitTaskArgs[0] = UpLoc;
   DepWaitTaskArgs[1] = ThreadID;
   DepWaitTaskArgs[2] = NumOfE

[PATCH] D136554: Implement CWG2631

2022-12-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 481411.
cor3ntin added a comment.

Correctly visit array filer when marking 
default member init as ODR-used


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/UsedDeclVisitor.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/CXX/class/class.local/p1-0x.cpp
  clang/test/CXX/drs/dr26xx.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/CodeGenCXX/default-arguments-with-immediate.cpp
  clang/test/CodeGenCXX/meminit-initializers-odr.cpp
  clang/test/PCH/default-argument-with-immediate-calls.cpp
  clang/test/SemaCXX/cxx11-default-member-initializers.cpp
  clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
  clang/test/SemaCXX/source_location.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -15593,7 +15593,7 @@
 https://wg21.link/cwg2631";>2631
 DR
 Immediate function evaluations in default arguments
-Unknown
+Clang 16
   
   
 https://wg21.link/cwg2632";>2632
Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -verify %s
 // expected-no-diagnostics
 
 #define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
@@ -8,15 +9,22 @@
 template 
 struct Printer;
 
+#ifdef USE_CONSTEVAL
+#define SOURCE_LOC_EVAL_KIND consteval
+#else
+#define SOURCE_LOC_EVAL_KIND constexpr
+#endif
+
 namespace std {
 class source_location {
   struct __impl;
 
 public:
-  static constexpr source_location current(const __impl *__p = __builtin_source_location()) noexcept {
-source_location __loc;
-__loc.__m_impl = __p;
-return __loc;
+  static SOURCE_LOC_EVAL_KIND source_location
+current(const __impl *__p = __builtin_source_location()) noexcept {
+  source_location __loc;
+  __loc.__m_impl = __p;
+  return __loc;
   }
   constexpr source_location() = default;
   constexpr source_location(source_location const &) = default;
@@ -593,3 +601,51 @@
   }
   static_assert(test());
 }
+
+namespace Lambda {
+#line 8000 "TestLambda.cpp"
+constexpr int nested_lambda(int l = []{
+  return SL::current().line();
+}()) {
+  return l;
+}
+static_assert(nested_lambda() == __LINE__ - 4);
+
+constexpr int lambda_param(int l = [](int l = SL::current().line()) {
+  return l;
+}()) {
+  return l;
+}
+static_assert(lambda_param() == __LINE__);
+
+
+}
+
+constexpr int compound_literal_fun(int a =
+  (int){ SL::current().line() }
+) { return a ;}
+static_assert(compound_literal_fun() == __LINE__);
+
+struct CompoundLiteral {
+  int a = (int){ SL::current().line() };
+};
+static_assert(CompoundLiteral{}.a == __LINE__);
+
+
+// FIXME
+// Init captures are subexpressions of the lambda expression
+// so according to the standard immediate invocations in init captures
+// should be evaluated at the call site.
+// However Clang does not yet implement this as it would introduce
+// a fair bit of complexity.
+// We intend to implement that functionality once we find real world
+// use cases that require it.
+constexpr int test_init_capture(int a =
+[b = SL::current().line()] { return b; }()) {
+  return a;
+}
+#ifdef USE_CONSTEVAL
+static_assert(test_init_capture() == __LINE__ - 4);
+#else
+static_assert(test_init_capture() == __LINE__ );
+#endif
Index: clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2b %s
+
+consteval int undefined();  // expected-note 4 {{declared here}}
+
+void check_lambdas_unused(
+int a = []
+{
+// The body of a lambda is not a subexpression of the lambda
+// so this is immediately evaluated even if the parameter
+// is never used.
+return undefined();  // expected-error {{not a constant express

[PATCH] D136554: Implement CWG2631

2022-12-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin reopened this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

In D136554#3982161 , @aeubanks wrote:

> the following now produces a link error:
>
>   $ cat /tmp/a.cc
>   #include 
>   #include 
>   
>   struct S {
>   std::map a;
>   };
>   
>   using T = std::array;
>   
>   class C {
>   T t{};
>   };
>   
>   int main() {
>   C c;
>   }
>   $ ./build/rel/bin/clang++ -o /dev/null /tmp/a.cc -stdlib=libc++ -fuse-ld=lld
>   ld.lld: error: undefined hidden symbol: std::__2::map std::__2::less, std::__2::allocator int>>>::map[abi:v16]()
>   >>> referenced by a.cc
>   >>>   /tmp/a-042a0e.o:(C::C())
>   clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
>
> using a ToT libc++
>
> is this expected?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D139400: [clang] Show error when a local variables is passed as default template parameter

2022-12-08 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:1594
+  if (VarDecl *VD = dyn_cast(DRE->getDecl())) {
+if (VD->isLocalVarDecl()) {
+  Diag(DRE->getLocation(),

So if we look at `CheckDefaultArgumentVisitor::VistDeclRefExpr` it has a 
comment about having to check ODR use due to [cwg 
2346](https://cplusplus.github.io/CWG/issues/2346.html) and I believe you 
should be using that as well.

Which would make your example below pass since the variable is `const` see: 
https://godbolt.org/z/78Tojh6q5

It looks like neither gcc nor MSVC implement this DR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139400

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


[PATCH] D139544: [clang][dataflow] Add support for structured bindings of tuple-like types.

2022-12-08 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Domján -- thanks for the detailed explanations -- this has been really helpful.

> After this the get<>() calls simply use this unnamed copy to initialize the 
> elements from first to last, so everything seems to proceed in order in the 
> CFG.

Agreed -- it definitely should appear before, but I think it would be good to 
appear _after_ as well. That is, I think there's a catch-22: the temporary's 
construction should appear before, but the binding decls, which use the 
synthetic variables, should appear after.

What do you think of duplicating it in the CFG, possibly with a new (statement) 
element kind (to mark it as a special)?  There are other workarounds that we 
could do on our end, but the duplication would avoid the need for such -- for 
us and any other clients.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139544

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


[PATCH] D139608: [Clang][NFC] Add default `getBFloat16Mangling` impl

2022-12-08 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel added a comment.

I don't normally handle name mangling, so I can't comment too much here, but I 
will note that Itanium ABI is planning on using DF16b for `std::bfloat16_t`: 
https://github.com/itanium-cxx-abi/cxx-abi/pull/147


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139608

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


[PATCH] D138571: Update ninja and cmake installation commands on LibASTMatchersTutorial

2022-12-08 Thread Justin Bogner via Phabricator via cfe-commits
bogner accepted this revision.
bogner added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138571

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


[PATCH] D139627: clang/X86: Don't emit "min-legal-vector-width"="0"

2022-12-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D139627#3982381 , @craig.topper 
wrote:

> In D139627#3982349 , @jdoerfert 
> wrote:
>
>> Isn't this (inherently) X86 specific?
>
> Yes it is. We could qualify the attribute emission with the targeting being 
> X86?

That would hide the annoyance from me, but I still think the implementation of 
this concept is poor and should be treated like other optimization hint 
attributes


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

https://reviews.llvm.org/D139627

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


[PATCH] D139627: clang/X86: Don't emit "min-legal-vector-width"="0"

2022-12-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D139627#3982385 , @arsenm wrote:

>> [1] `"min-legal-vector-width" = "0"` was clear to indicate there are only 
>> scalar operations.
>
> It's not remotely clear what this means

It also doesn't mean that, because the IR doesn't have to be consistent with 
the attribute. The IR exists independent of the attribute, and the attribute 
can only provide performance hints.


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

https://reviews.llvm.org/D139627

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


[PATCH] D139627: clang/X86: Don't emit "min-legal-vector-width"="0"

2022-12-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D139627#3981475 , @pengfei wrote:

> The use of `min-legal-vector-width` doesn't look great to me either. I'm more 
> than glad if we can remove it totally without any user perceivable affects.
> I cannot agree with this change because it neither eliminates the clutter 
> (but makes it even worse [1]) nor is NFC to end user.
> I think we used `UINT32_MAX` just to be compatible with BCs that generated 
> before introduing the attribute. This change definitely breaks the 
> compatibility.

What I'm getting is this is only a performance hint, and definitively doesn't 
matter for ABI purposes. Bitcode backwards performance compatibility is not 
important. That would also be recovered by having a proper attribute 
propagation done as an optimization.

I think all of clang's handling of this should be purged, except for the part 
where it's passing through the user attribute.

> Placing a `"min-legal-vector-width" = "512"` doesn't make any sense either. 
> For one thing, we cannot place the attribute in pre-built BC files, for 
> another `512` is the current max vector suppoted on X86, we cannot guarantee 
> no `1024`, `2048` etc. in future and we cannot change it too once compiled 
> into BC files.

It's a test for specific behavior, with a specific configuration that exists 
today. It doesn't matter what this would be in the future for larger testcases

> [1] `"min-legal-vector-width" = "0"` was clear to indicate there are only 
> scalar operations.

It's not remotely clear what this means


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

https://reviews.llvm.org/D139627

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


[PATCH] D139627: clang/X86: Don't emit "min-legal-vector-width"="0"

2022-12-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D139627#3982349 , @jdoerfert wrote:

> Isn't this (inherently) X86 specific?

Yes it is. We could qualify the attribute emission with the targeting being X86?


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

https://reviews.llvm.org/D139627

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


[PATCH] D139627: clang/X86: Don't emit "min-legal-vector-width"="0"

2022-12-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Isn't this (inherently) X86 specific?


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

https://reviews.llvm.org/D139627

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


[clang] 4a1ccfe - When merging lambdas, keep track of the capture lists from each version.

2022-12-08 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-12-08T11:37:00-08:00
New Revision: 4a1ccfe8a3cfd4569bc962a38b6117a9a2b8ad21

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

LOG: When merging lambdas, keep track of the capture lists from each version.

Different versions of a lambda will in general refer to different
enclosing variable declarations, because we do not merge most
block-scope declarations, such as local variables. Keep track of all the
declarations that correspond to a lambda's capture fields so that we can
rewrite the name of any of those variables to the lambda capture,
regardless of which copy of the body of `operator()` we look at.

Added: 
clang/test/Modules/lambda-merge.cpp

Modified: 
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index feee56017da5..3836a2faaaf2 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -410,9 +410,11 @@ class CXXRecordDecl : public RecordDecl {
 /// or within a data member initializer.
 LazyDeclPtr ContextDecl;
 
-/// The list of captures, both explicit and implicit, for this
-/// lambda.
-Capture *Captures = nullptr;
+/// The lists of captures, both explicit and implicit, for this
+/// lambda. One list is provided for each merged copy of the lambda.
+/// The first list corresponds to the canonical definition.
+/// The destructor is registered by AddCaptureList when necessary.
+llvm::TinyPtrVector Captures;
 
 /// The type of the call method.
 TypeSourceInfo *MethodTyInfo;
@@ -430,6 +432,9 @@ class CXXRecordDecl : public RecordDecl {
   Aggregate = false;
   PlainOldData = false;
 }
+
+// Add a list of captures.
+void AddCaptureList(ASTContext &Ctx, Capture *CaptureList);
   };
 
   struct DefinitionData *dataPtr() const {
@@ -1058,6 +1063,11 @@ class CXXRecordDecl : public RecordDecl {
   ///
   /// \note No entries will be added for init-captures, as they do not capture
   /// variables.
+  ///
+  /// \note If multiple versions of the lambda are merged together, they may
+  /// have 
diff erent variable declarations corresponding to the same capture.
+  /// In that case, all of those variable declarations will be added to the
+  /// Captures list, so it may have more than one variable listed per field.
   void
   getCaptureFields(llvm::DenseMap &Captures,
FieldDecl *&ThisCapture) const;
@@ -1070,7 +1080,9 @@ class CXXRecordDecl : public RecordDecl {
   }
 
   capture_const_iterator captures_begin() const {
-return isLambda() ? getLambdaData().Captures : nullptr;
+if (!isLambda()) return nullptr;
+LambdaDefinitionData &LambdaData = getLambdaData();
+return LambdaData.Captures.empty() ? nullptr : LambdaData.Captures.front();
   }
 
   capture_const_iterator captures_end() const {

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 603075702a83..812cbabc00b8 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1462,6 +1462,15 @@ void 
CXXRecordDecl::finishedDefaultedOrDeletedMember(CXXMethodDecl *D) {
   }
 }
 
+void CXXRecordDecl::LambdaDefinitionData::AddCaptureList(ASTContext &Ctx,
+ Capture *CaptureList) 
{
+  Captures.push_back(CaptureList);
+  if (Captures.size() == 2) {
+// The TinyPtrVector member now needs destruction.
+Ctx.addDestruction(&Captures);
+  }
+}
+
 void CXXRecordDecl::setCaptures(ASTContext &Context,
 ArrayRef Captures) {
   CXXRecordDecl::LambdaDefinitionData &Data = getLambdaData();
@@ -1469,9 +1478,9 @@ void CXXRecordDecl::setCaptures(ASTContext &Context,
   // Copy captures.
   Data.NumCaptures = Captures.size();
   Data.NumExplicitCaptures = 0;
-  Data.Captures = (LambdaCapture *)Context.Allocate(sizeof(LambdaCapture) *
-Captures.size());
-  LambdaCapture *ToCapture = Data.Captures;
+  auto *ToCapture = (LambdaCapture *)Context.Allocate(sizeof(LambdaCapture) *
+  Captures.size());
+  Data.AddCaptureList(Context, ToCapture);
   for (unsigned I = 0, N = Captures.size(); I != N; ++I) {
 if (Captures[I].isExplicit())
   ++Data.NumExplicitCaptures;
@@ -1595,15 +1604,17 @@ void CXXRecordDecl::getCaptureFields(
   ThisCapture = nullptr;
 
   LambdaDefinitionData &Lambda = getLambdaData();
-  RecordDecl::field_iterator Field = field_begin();
-  for (const LambdaCapture *C = Lambda.Captures, *CEnd = C + 
Lamb

[PATCH] D139653: [clang] Set ShowInSystemHeader for module-build and module-import remarks

2022-12-08 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.

> Also, do you think this should be configurable on the command line?

Do you have a flag in mind? I have worked around the current behavior with 
`-Wno-system-header`, but there are two problems with that: first, it's not 
obvious that it's needed (I had to debug clang to figure out why diagnostics 
were missing, most people wouldn't do that), and second it can result in many 
many warnings, which – if you are only interested in module remarks, represents 
a bunch of noise.

> I'm thinking about users that are trying to debug their own modular code, but 
> don't really care what happens in the SDK.

My first question is how many of those users are there? It seems to me that the 
module remarks are more for tooling developers than end users. Speaking as 
someone working on tools, I think I would always want all module-build remarks, 
since – correct me if I'm wrong – they're relevant only to performance, and for 
performance I want to see all the builds.

For module-import remarks, I could see it being more interesting to developers, 
but I don't know how many developers know about and use `-Rmodule-import`. If 
we want to proactively support those users, maybe the solution is two flags, 
say `-Rmodule-import` and `-Rmodule-import-all` (I can't think of a better 
spelling).

For relevant comparisons, the only thing I can think about is the `-H` flag, 
which shows all header includes, it does not exclude system headers. Speaking 
of which, an equivalent for modules might be helpful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139653

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


[clang] 05dbdb0 - Revert "[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1 (2nd try)"

2022-12-08 Thread Sanjay Patel via cfe-commits

Author: Sanjay Patel
Date: 2022-12-08T14:16:46-05:00
New Revision: 05dbdb0088a3f5541d9e91c61a564d0aa4704f4f

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

LOG: Revert "[InstCombine] canonicalize trunc + insert as bitcast + shuffle, 
part 1 (2nd try)"

This reverts commit e71b81cab09bf33e3b08ed600418b72cc4117461.

As discussed in the planned follow-on to this patch (D138874),
this and the subsequent patches in this set can cause trouble for
the backend, and there's probably no quick fix. We may even
want to canonicalize in the opposite direction (towards insertelt).

Added: 


Modified: 
clang/test/Headers/wasm.c
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/test/Transforms/InstCombine/insert-trunc.ll
llvm/test/Transforms/InstCombine/vec_phi_extract-inseltpoison.ll
llvm/test/Transforms/InstCombine/vec_phi_extract.ll
llvm/test/Transforms/LoopVectorize/ARM/pointer_iv.ll
llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll

Removed: 




diff  --git a/clang/test/Headers/wasm.c b/clang/test/Headers/wasm.c
index 79dc67eaa4ef8..53acbf4de4c96 100644
--- a/clang/test/Headers/wasm.c
+++ b/clang/test/Headers/wasm.c
@@ -1475,8 +1475,8 @@ v128_t test_f64x2_ge(v128_t a, v128_t b) {
 
 // CHECK-LABEL: @test_v128_not(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[NOT_I:%.*]] = xor <4 x i32> [[A:%.*]], 
-// CHECK-NEXT:ret <4 x i32> [[NOT_I]]
+// CHECK-NEXT:[[NEG_I:%.*]] = xor <4 x i32> [[A:%.*]], 
+// CHECK-NEXT:ret <4 x i32> [[NEG_I]]
 //
 v128_t test_v128_not(v128_t a) {
   return wasm_v128_not(a);
@@ -1511,8 +1511,8 @@ v128_t test_v128_xor(v128_t a, v128_t b) {
 
 // CHECK-LABEL: @test_v128_andnot(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[NOT_I:%.*]] = xor <4 x i32> [[B:%.*]], 
-// CHECK-NEXT:[[AND_I:%.*]] = and <4 x i32> [[NOT_I]], [[A:%.*]]
+// CHECK-NEXT:[[NEG_I:%.*]] = xor <4 x i32> [[B:%.*]], 
+// CHECK-NEXT:[[AND_I:%.*]] = and <4 x i32> [[NEG_I]], [[A:%.*]]
 // CHECK-NEXT:ret <4 x i32> [[AND_I]]
 //
 v128_t test_v128_andnot(v128_t a, v128_t b) {
@@ -1596,11 +1596,12 @@ v128_t test_i8x16_popcnt(v128_t a) {
 // CHECK-LABEL: @test_i8x16_shl(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[VEC___B_I:%.*]] = bitcast i32 [[B:%.*]] to <4 x i8>
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <4 x i8> [[VEC___B_I]], <4 
x i8> poison, <16 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i8
+// CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i8> undef, i8 [[TMP1]], 
i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP2]], <16 x 
i8> poison, <16 x i32> zeroinitializer
 // CHECK-NEXT:[[SHL_I:%.*]] = shl <16 x i8> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[SHL_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHL_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP3]]
 //
 v128_t test_i8x16_shl(v128_t a, uint32_t b) {
   return wasm_i8x16_shl(a, b);
@@ -1609,11 +1610,12 @@ v128_t test_i8x16_shl(v128_t a, uint32_t b) {
 // CHECK-LABEL: @test_i8x16_shr(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[VEC___B_I:%.*]] = bitcast i32 [[B:%.*]] to <4 x i8>
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <4 x i8> [[VEC___B_I]], <4 
x i8> poison, <16 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i8
+// CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i8> undef, i8 [[TMP1]], 
i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP2]], <16 x 
i8> poison, <16 x i32> zeroinitializer
 // CHECK-NEXT:[[SHR_I:%.*]] = ashr <16 x i8> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP3]]
 //
 v128_t test_i8x16_shr(v128_t a, uint32_t b) {
   return wasm_i8x16_shr(a, b);
@@ -1622,11 +1624,12 @@ v128_t test_i8x16_shr(v128_t a, uint32_t b) {
 // CHECK-LABEL: @test_u8x16_shr(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[VEC___B_I:%.*]] = bitcast i32 [[B:%.*]] to <4 x i8>
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <4 x i8> [[VEC___B_I]], <4 
x i8> poison, <16 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i8
+// CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i8> undef, i8 [[TMP1]], 
i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP2]], <1

[PATCH] D139302: [RISCV] Add Syntacore SCR1 CPU model

2022-12-08 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVSchedSCR1.td:14
+// This model covers SCR1_CFG_RV32IMC_MAX configuration (scr1-max).
+// SCR1_CFG_RV32EC_MIN (scr1-min) and SCR1_CFG_RV32IC_BASE (scr1-base)
+// configurations have essentially same scheduling characteristics.

`SCR1_CFG_RV32EC_MIN (scr1-min)` -- this should be removed from comment as well 
since patch doesn't cover `scr1-min`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139302

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


[PATCH] D137337: Replace LLVM_LIBDIR_SUFFIX by CMAKE_INSTALL_LIBDIR

2022-12-08 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: bolt/lib/RuntimeLibs/RuntimeLibrary.cpp:32
   SmallString<128> LibPath = llvm::sys::path::parent_path(Dir);
-  llvm::sys::path::append(LibPath, "lib" LLVM_LIBDIR_SUFFIX);
+  llvm::sys::path::append(LibPath, CMAKE_INSTALL_LIBDIR);
   if (!llvm::sys::fs::exists(LibPath)) {

serge-sans-paille wrote:
> Ericson2314 wrote:
> > mgorny wrote:
> > > Well, one thing I immediately notice is that technically 
> > > `CMAKE_INSTALL_LIBDIR` can be an absolute path, while in many locations 
> > > you are assuming it will always be relative. Not saying that's a blocker 
> > > but I think you should add checks for that into `CMakeLists.txt`.
> > Yes I was working on this, and I intend to use `CMAKE_INSTALL_LIBDIR` with 
> > an absolute path.
> > 
> > OK if this isn't supported initially but we should ovoid regressing where 
> > possible.
> Turns out LLVM_LIBDIR_SUFFIX is used in several situations: (a) for the 
> library install dir or (b) for the location where build artifact as stored in 
> CMAKE_BINARY_DIR. (a) could accept a path but not (b), unless we derive it 
> from (a) but I can see a lot of complication there for the testing step. 
> Would that be ok to choke on CMAKE_INSTALL_LIBDIR being a path and not a 
> directory component?
> 
I think that is absolutely reasonable.  There is the 
`CMAKE_INSTALL_FULL_LIBDIR` which should be the relatively absolute path (it is 
relative to `DESTDIR`).  The `CMAKE_INSTALL_LIBDIR` should be the relative 
component which is added to `CMAKE_INSTALL_PREFIX`.


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

https://reviews.llvm.org/D137337

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


[PATCH] D139653: [clang] Set ShowInSystemHeader for module-build and module-import remarks

2022-12-08 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Nice. It would be nice to have tests for this, though.

Also, do you think this should be configurable on the command line? I'm 
thinking about users that are trying to debug their own modular code, but don't 
really care what happens in the SDK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139653

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


[PATCH] D139444: [ZOS] Convert tests to check 'target={{.*}}-zos'

2022-12-08 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D139444#3978189 , @uweigand wrote:

> In D139444#3975182 , @probinson 
> wrote:
>
>> The changes in this patch assume that there aren't any possible suffixes 
>> after the `-zos` part of the triple (no version numbers, like you might find 
>> with darwin or macos, and nothing like `-elf` or `-eabi` like some targets 
>> have).  If there are suffixes, I'll happily revise to put `{{.*}}` after 
>> everything.
>
> I think for consistency with other targets, and to be safe for future 
> extensions of the target triple, it would be better to add the `{{.*}}`

Okay.

> [for encoding.ll] To express that restriction on the *host* system, you 
> should be using a `REQUIRES: system-zos` line.   However, it looks like this 
> capability is not actually currently implemented - you'll have to add it to 
> the code in `utils/lit/lit/llvm/config.py` here:
>
>   [...]
>   elif platform.system() == 'NetBSD':
>   features.add('system-netbsd')
>   elif platform.system() == 'AIX':
>   features.add('system-aix')
>   elif platform.system() == 'SunOS':
>   features.add('system-solaris')
>
> (Note that you probably still should add the `-mtriple` because the test case 
> requires *both* running on a z/OS host *and* compiling for the z/OS target.)

If you can tell me the `platform.system()` value to look for to detect z/OS, I 
can do that.  Probably as a separate patch, as it would be going beyond the 
mechanical replacement that I'm doing for everything else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139444

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


[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2022-12-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:572
 PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn));
+  } else if (D->hasConstantInitialization() && !(D->hasAttr())) 
{
+OrderGlobalInitsOrStermFinalizers Key(201,

zahiraam wrote:
> efriedma wrote:
> > zahiraam wrote:
> > > efriedma wrote:
> > > > zahiraam wrote:
> > > > > efriedma wrote:
> > > > > > zahiraam wrote:
> > > > > > > efriedma wrote:
> > > > > > > > How is ConstInitAttr relevant here?
> > > > > > > This change made (without the !(D->hasAttr()) made 
> > > > > > > the LIT behavior of aix-static-init.cpp. The IR generated for 
> > > > > > > namespace test3 {
> > > > > > >   struct Test3 {
> > > > > > > constexpr Test3() {};
> > > > > > > ~Test3() {};
> > > > > > >   };
> > > > > > > 
> > > > > > >   constinit Test3 t;
> > > > > > > } // namespace test3
> > > > > > > 
> > > > > > > was different. I would have thought that the change we made for 
> > > > > > > constexpr wouldn't affter constinit? 
> > > > > > I think the significant bit there isn't the use of constinit; it's 
> > > > > > the non-trivial destructor.  I think the priority modification 
> > > > > > should only affect constructors, not destructors.  (Not sure how to 
> > > > > > make that work, at first glance.)
> > > > > Let's see if this is an acceptable solution.
> > > > To fake constant initialization, we need to initialize the variable 
> > > > before anything else runs.  But the rearranged prioritization isn't 
> > > > supposed to affect the destructor.  From [basic.start.term]: "If an 
> > > > object is initialized statically, the object is destroyed in the same 
> > > > order as if the object was dynamically initialized."
> > > > 
> > > > What you're doing here isn't exactly implementing that.  What you're 
> > > > doing here is delaying both the initialization and the destruction if 
> > > > the variable has a non-trivial destructor.  We need to separate the two 
> > > > to get the behavior we want.
> > > Could we consider adding a field to EvaluatedStmt called 
> > > "HasTrivialDestrutor" and only perform the prioritization change when 
> > > !D->HasTrivialDesctructor?  Instead of using the test for 
> > > D->hasConstantInitialization(). This seems to be englobing to many cases.
> > > 
> > > I considered returning null for HasConstantInitialization in case of var 
> > > has a non-trivial destructor but that doesn't seem to work.
> > Once you separate out the initialization from the destruction, the rest 
> > should come together naturally, I think? I'm not sure what other cases 
> > could be caught by hasConstantInitialization().
> Does this change accomplish this? Thanks.
When a global variable is dynamically initialized, there are two parts to the 
initialization:

- Constructing the variable (calling the constructor, or equivalent)
- Registering the destructor with the runtime (atexit on Windows)

If an object is initialized statically, the two parts are separated: the 
variable is emitted already initialized by the compiler.  But we still register 
the destructor at the same time, in the same way.

If a dllimport object is initialized statically, we need to make it appear to 
user code that the same thing happened.  So we need to initialize the object 
early, but we need to register the destructor at the same time we would have 
otherwise registered it.  To make this work, we need two separate initializer 
functions with different priorities.


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

https://reviews.llvm.org/D137107

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


[PATCH] D139115: [clang][ExtractAPI] Add support for single symbol SGF

2022-12-08 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added subscribers: akyrtzi, benlangmuir.
benlangmuir added inline comments.



Comment at: clang/include/clang-c/Documentation.h:549
 
+typedef struct CXAPISetImpl *CXAPISet;
+

@dang please document what this type represents.

@akyrtzi what's the preferred implementation type name for opaque typedef 
types? I see we have a mix right now:
* `void *`
* `CXOpaqueFoo *`
* `CXFooImpl *`



Comment at: clang/include/clang-c/Documentation.h:551
+
+CINDEX_LINKAGE enum CXErrorCode clang_createAPISet(CXTranslationUnit tu,
+   CXAPISet *out_api);

Please add documentation comments to all the new functions. For this one, we 
should explicitly include
* That the user needs to call `clang_disposeAPISet` for the output
* Whether `out_api` is modified on failure -- e.g. is it null?



Comment at: clang/include/clang-c/Documentation.h:556
+
+CINDEX_LINKAGE CXString clang_getSingleSymbolSGFForUSR(const char *usr,
+   CXAPISet api);

Does SGF stand for "Symbol Graph Fragment"?  How well-known is this 
abbreviation?  And how commonly-used do you expect these functions to be?  My 
gut reaction would be to use the full name here.

We should document the null return value for unknown symbols.  Are there other 
ways this could fail?  Is it ever interesting to know why this failed, or is 
success/fail always good enough?   Same applies to the function below.



Comment at: clang/tools/libclang/CXExtractAPI.cpp:40
+
+void WalkupFromMostDerivedType(ExtractAPIVisitor &Visitor, Decl *D);
+

Nit: we use `static` for global functions and only use anon namespaces for 
types.  Same for the below.



Comment at: clang/tools/libclang/CXExtractAPI.cpp:73
+enum CXErrorCode clang_createAPISet(CXTranslationUnit tu, CXAPISet *out_api) {
+  ASTUnit *Unit = cxtu::getASTUnit(tu);
+

```
  if (isNotUsableTU(tu) || !out_api)
return CXError_InvalidArguments;
```



Comment at: clang/tools/libclang/CXExtractAPI.cpp:92
+
+CINDEX_LINKAGE CXString clang_getSingleSymbolSGFForUSR(const char *usr,
+   CXAPISet api) {

We don't want `CINDEX_LINKAGE` in the implementation, only the header needs it. 
 Same for the other functions



Comment at: clang/tools/libclang/CXExtractAPI.cpp:97
+  if (auto SGF = SymbolGraphSerializer::serializeSingleSymbolSGF(usr, *API)) {
+std::string BackingString;
+llvm::raw_string_ostream OS(BackingString);

Nit: maybe `SmallString` and `raw_svector_ostream`?



Comment at: clang/tools/libclang/CXExtractAPI.cpp:108
+CINDEX_LINKAGE CXString clang_getSingleSymbolSGF(CXCursor cursor) {
+  const CXCursorKind &Kind = clang_getCursorKind(cursor);
+  if (clang_isDeclaration(Kind)) {

This is binding a temporary; you probably want `CXCursorKind` by value.



Comment at: clang/tools/libclang/CXExtractAPI.cpp:129
+SmallString<128> USR;
+index::generateUSRForDecl(D, USR);
+

Probably should check the return value here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139115

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


[clang] 49c86ea - Revert "Implement CWG2631"

2022-12-08 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-12-08T19:57:58+01:00
New Revision: 49c86eab627b0c4089c8d25dac48728c656448a9

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

LOG: Revert "Implement CWG2631"

This patch causes another link error,
reverting until I can investigate.

This reverts commit a96a6ed83230265f3eab09a94f0e9525d05f8a74.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/Stmt.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/Parse/ParseCXXInlineMethods.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Sema/UsedDeclVisitor.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/CXX/class/class.local/p1-0x.cpp
clang/test/CXX/drs/dr26xx.cpp
clang/test/CodeGenCXX/builtin-source-location.cpp
clang/test/SemaCXX/cxx11-default-member-initializers.cpp
clang/test/SemaCXX/source_location.cpp
clang/www/cxx_dr_status.html

Removed: 
clang/test/CodeGenCXX/default-arguments-with-immediate.cpp
clang/test/CodeGenCXX/meminit-initializers-odr.cpp
clang/test/PCH/default-argument-with-immediate-calls.cpp
clang/test/SemaCXX/cxx2a-consteval-default-params.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6bd038fbdc16f..53155b0e2a492 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -642,11 +642,6 @@ C++ Language Changes in Clang
 - Implemented DR2358 allowing init captures in lambdas in default arguments.
 - implemented `DR2654 `_ which undeprecates
   all compound assignements operations on volatile qualified variables.
-- Implemented DR2631. Invalid ``consteval`` calls in default arguments and 
default
-  member initializers are diagnosed when and if the default is used.
-  This Fixes `Issue 56379 `_
-  and changes the value of ``std::source_location::current()``
-  used in default parameters calls compared to previous versions of Clang.
 
 C++20 Feature Support
 ^

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 9d3fd98f65e29..81267ff568c5b 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1245,12 +1245,8 @@ class CXXThrowExpr : public Expr {
 /// This wraps up a function call argument that was created from the
 /// corresponding parameter's default argument, when the call did not
 /// explicitly supply arguments for all of the parameters.
-class CXXDefaultArgExpr final
-: public Expr,
-  private llvm::TrailingObjects {
+class CXXDefaultArgExpr final : public Expr {
   friend class ASTStmtReader;
-  friend class ASTReader;
-  friend TrailingObjects;
 
   /// The parameter whose default is being used.
   ParmVarDecl *Param;
@@ -1259,7 +1255,7 @@ class CXXDefaultArgExpr final
   DeclContext *UsedContext;
 
   CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *Param,
-Expr *RewrittenExpr, DeclContext *UsedContext)
+DeclContext *UsedContext)
   : Expr(SC,
  Param->hasUnparsedDefaultArg()
  ? Param->getType().getNonReferenceType()
@@ -1268,58 +1264,28 @@ class CXXDefaultArgExpr final
  Param->getDefaultArg()->getObjectKind()),
 Param(Param), UsedContext(UsedContext) {
 CXXDefaultArgExprBits.Loc = Loc;
-CXXDefaultArgExprBits.HasRewrittenInit = RewrittenExpr != nullptr;
-if (RewrittenExpr)
-  *getTrailingObjects() = RewrittenExpr;
 setDependence(computeDependence(this));
   }
 
-  CXXDefaultArgExpr(EmptyShell Empty, bool HasRewrittenInit)
-  : Expr(CXXDefaultArgExprClass, Empty) {
-CXXDefaultArgExprBits.HasRewrittenInit = HasRewrittenInit;
-  }
-
-  size_t numTrailingObjects() const {
-return CXXDefaultArgExprBits.HasRewrittenInit;
-  }
-
 public:
-  static CXXDefaultArgExpr *CreateEmpty(const ASTContext &C,
-bool HasRewrittenInit);
+  CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
 
   // \p Param is the parameter whose default argument is used by this
   // expression.
   static CXXDefaultArgExpr *Create(const ASTContext &C, SourceLocation Loc,
-   ParmVarDecl *Param, Expr *RewrittenExpr,
-   DeclContext *UsedContext);
+

[PATCH] D139429: [clang] Add test for CWG418

2022-12-08 Thread Vlad Serebrennikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90d4cbb87ce2: [clang] Add test for CWG418 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139429

Files:
  clang/test/CXX/drs/dr4xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -2547,7 +2547,7 @@
 https://wg21.link/cwg418";>418
 CD6
 Imperfect wording on error on multiple default arguments on a called 
function
-Unknown
+No
   
   
 https://wg21.link/cwg419";>419
Index: clang/test/CXX/drs/dr4xx.cpp
===
--- clang/test/CXX/drs/dr4xx.cpp
+++ clang/test/CXX/drs/dr4xx.cpp
@@ -315,6 +315,50 @@
   }
 }
 
+namespace dr418 { // dr418: no
+namespace example1 {
+void f1(int, int = 0);
+void f1(int = 0, int);
+
+void g() { f1(); }
+} // namespace example1
+
+namespace example2 {
+namespace A {
+void f2(int); // #dr418-f2-decl
+}
+namespace B {
+using A::f2;
+}
+namespace A {
+void f2(int = 3);
+}
+void g2() {
+  using B::f2;
+  f2(); // expected-error {{no matching function}}
+  // expected-note@#dr418-f2-decl {{requires 1 argument}}
+}
+} // namespace example2
+
+// example from [over.match.best]/4
+namespace example3 {
+namespace A {
+extern "C" void f(int = 5);
+}
+namespace B {
+extern "C" void f(int = 5);
+}
+
+using A::f;
+using B::f;
+
+void use() {
+  f(3);
+  f(); // FIXME: this should fail
+}
+} // namespace example3
+} // namespace dr418
+
 namespace dr420 { // dr420: yes
   template struct ptr {
 T *operator->() const;


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -2547,7 +2547,7 @@
 https://wg21.link/cwg418";>418
 CD6
 Imperfect wording on error on multiple default arguments on a called function
-Unknown
+No
   
   
 https://wg21.link/cwg419";>419
Index: clang/test/CXX/drs/dr4xx.cpp
===
--- clang/test/CXX/drs/dr4xx.cpp
+++ clang/test/CXX/drs/dr4xx.cpp
@@ -315,6 +315,50 @@
   }
 }
 
+namespace dr418 { // dr418: no
+namespace example1 {
+void f1(int, int = 0);
+void f1(int = 0, int);
+
+void g() { f1(); }
+} // namespace example1
+
+namespace example2 {
+namespace A {
+void f2(int); // #dr418-f2-decl
+}
+namespace B {
+using A::f2;
+}
+namespace A {
+void f2(int = 3);
+}
+void g2() {
+  using B::f2;
+  f2(); // expected-error {{no matching function}}
+  // expected-note@#dr418-f2-decl {{requires 1 argument}}
+}
+} // namespace example2
+
+// example from [over.match.best]/4
+namespace example3 {
+namespace A {
+extern "C" void f(int = 5);
+}
+namespace B {
+extern "C" void f(int = 5);
+}
+
+using A::f;
+using B::f;
+
+void use() {
+  f(3);
+  f(); // FIXME: this should fail
+}
+} // namespace example3
+} // namespace dr418
+
 namespace dr420 { // dr420: yes
   template struct ptr {
 T *operator->() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 90d4cbb - [clang] Add test for CWG418

2022-12-08 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2022-12-08T21:57:07+03:00
New Revision: 90d4cbb87ce297d93159d39528767f5f46aa4da4

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

LOG: [clang] Add test for CWG418

P1787: //[[ https://cplusplus.github.io/CWG/issues/418.html | CWG418 ]] is 
resolved by trivial rephrasing along with that necessary for the new 
using-declaration interpretation.//
Wording: see changes to [dcl.fct.default]/9 and [over.match.best]/4.

[over.match.best]/4 includes [[ 
https://eel.is/c++draft/over.match.best#general-example-8 | an example ]] that 
is not properly diagnosed by Clang.

Reviewed By: #clang-language-wg, shafik

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

Added: 


Modified: 
clang/test/CXX/drs/dr4xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr4xx.cpp b/clang/test/CXX/drs/dr4xx.cpp
index 1814f5ac32185..3617af8b683c0 100644
--- a/clang/test/CXX/drs/dr4xx.cpp
+++ b/clang/test/CXX/drs/dr4xx.cpp
@@ -315,6 +315,50 @@ namespace dr417 { // dr417: no
   }
 }
 
+namespace dr418 { // dr418: no
+namespace example1 {
+void f1(int, int = 0);
+void f1(int = 0, int);
+
+void g() { f1(); }
+} // namespace example1
+
+namespace example2 {
+namespace A {
+void f2(int); // #dr418-f2-decl
+}
+namespace B {
+using A::f2;
+}
+namespace A {
+void f2(int = 3);
+}
+void g2() {
+  using B::f2;
+  f2(); // expected-error {{no matching function}}
+  // expected-note@#dr418-f2-decl {{requires 1 argument}}
+}
+} // namespace example2
+
+// example from [over.match.best]/4
+namespace example3 {
+namespace A {
+extern "C" void f(int = 5);
+}
+namespace B {
+extern "C" void f(int = 5);
+}
+
+using A::f;
+using B::f;
+
+void use() {
+  f(3);
+  f(); // FIXME: this should fail
+}
+} // namespace example3
+} // namespace dr418
+
 namespace dr420 { // dr420: yes
   template struct ptr {
 T *operator->() const;

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index e8cb4318addfc..1c880bab52957 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -2547,7 +2547,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg418";>418
 CD6
 Imperfect wording on error on multiple default arguments on a called 
function
-Unknown
+No
   
   
 https://wg21.link/cwg419";>419



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


[PATCH] D139166: [OPENMP51] Codegen support for error directive.

2022-12-08 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139166

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


[PATCH] D135269: [AMDGPU] Disable bool range metadata to workaround backend issue

2022-12-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D135269#3982103 , @jrbyrnes wrote:

> In D135269#3981856 , @yaxunl wrote:
>
>> In D135269#3981561 , @nikic wrote:
>>
>>> Checking back here again on whether there is any progress on finding the 
>>> root cause of the issue. If no progress is expected in the near future, I'd 
>>> ask for this patch to be reverted.
>>
>> @jrbyrnes is working on the root cause of this issue. Any updates? Thanks.
>
> Thanks for the ping. I would also like to see this reverted as it enables 
> some optimizations. I do not have a definitive answer at the moment (w.r.t 
> reverting this), but hope to provide one soon
>
> As for now, the issue we are seeing from 
> (https://github.com/llvm/llvm-project/commit/8018d6be3459780e81a5da128a9915eb27909902)
>  seems most likely to be a source code issue (first document of issue 
> https://github.com/pytorch/pytorch/issues/54789 . upstream PyTorch currently 
> skips problematic test 
> https://github.com/pytorch/pytorch/blob/b738da8c8e4d9142ad38a1bd8c35d0bfef4b5e3c/torch/testing/_internal/common_methods_invocations.py#L14891)
>  . I will provide a better update soon.

I will revert this patch. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135269

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


[PATCH] D136554: Implement CWG2631

2022-12-08 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

the following now produces a link error:

  $ cat /tmp/a.cc
  #include 
  #include 
  
  struct S {
  std::map a;
  };
  
  using T = std::array;
  
  class C {
  T t{};
  };
  
  int main() {
  C c;
  }
  $ ./build/rel/bin/clang++ -o /dev/null /tmp/a.cc -stdlib=libc++ -fuse-ld=lld
  ld.lld: error: undefined hidden symbol: std::__2::map, std::__2::allocator>>::map[abi:v16]()
  >>> referenced by a.cc
  >>>   /tmp/a-042a0e.o:(C::C())
  clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

using a ToT libc++

is this expected?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D139166: [OPENMP51] Codegen support for error directive.

2022-12-08 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.h:334
   llvm::Value *emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc,
-  unsigned Flags = 0);
+  unsigned Flags = 0, bool EmitLoc = false);
 

ABataev wrote:
> Why do you need this location? To output it for the user in the runtime 
> library call?
Thanks Alexey!
Yes.  When run time emit error, the location will be presented like:

OMP: Warning #283: test_error_directive.cpp:6:1: Encountered user-directed 
warning: 2 or more procs required..

...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139166

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


[PATCH] D139653: [clang] Set ShowInSystemHeader for module-build and module-import remarks

2022-12-08 Thread Dave Lee via Phabricator via cfe-commits
kastiglione created this revision.
kastiglione added a reviewer: jansvoboda11.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Without this change, the use of `-Rmodule-build` and `-Rmodule-import` only 
produces diagnostics for modules built or imported by non-system code.

For example, if a project source file requires the Foundation module to be 
built, then `-Rmodule-build` will show a single diagnostic for Foundation, but 
not in turn for any of Foundation's (direct or indirect) dependencies. This is 
because the locations of those transitive module builds are initiated from 
system headers, which are ignored by default. When wanting to observe module 
building/importing, the system modules can represent a significant amount of 
module diagnostics, and I think should be shown by default when 
`-Rmodule-build` and `-Rmodule-import` are specified.

I noticed some other remarks use `ShowInSystemHeader`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139653

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticSerializationKinds.td


Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -75,6 +75,7 @@
 
 def remark_module_import : Remark<
   "importing module '%0'%select{| into '%3'}2 from '%1'">,
+  ShowInSystemHeader,
   InGroup;
 
 def err_imported_module_not_found : Error<
Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td
===
--- clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -241,6 +241,7 @@
 def note_module_def_undef_here : Note<
   "macro was %select{defined|#undef'd}0 here">;
 def remark_module_build : Remark<"building module '%0' as '%1'">,
+  ShowInSystemHeader,
   InGroup;
 def remark_module_build_done : Remark<"finished building module '%0'">,
   InGroup;


Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -75,6 +75,7 @@
 
 def remark_module_import : Remark<
   "importing module '%0'%select{| into '%3'}2 from '%1'">,
+  ShowInSystemHeader,
   InGroup;
 
 def err_imported_module_not_found : Error<
Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td
===
--- clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -241,6 +241,7 @@
 def note_module_def_undef_here : Note<
   "macro was %select{defined|#undef'd}0 here">;
 def remark_module_build : Remark<"building module '%0' as '%1'">,
+  ShowInSystemHeader,
   InGroup;
 def remark_module_build_done : Remark<"finished building module '%0'">,
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139652: Add the thread sanitizer support for X86_64 WatchOS simulators

2022-12-08 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

Thanks for the change.

The description is a bit misleading, this would be better:

  Allow TSan in clang driver for X86_64 WatchOS simulator.
  
  It was already functional, and Apple's downstream fork of clang allows it, 
but that change had not made it upstream yet.

cc+=yln FYI, though this change seems obvious enough I'm comfortable to approve 
it directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139652

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


[PATCH] D135269: [AMDGPU] Disable bool range metadata to workaround backend issue

2022-12-08 Thread Jeffrey Byrnes via Phabricator via cfe-commits
jrbyrnes added a comment.

In D135269#3981856 , @yaxunl wrote:

> In D135269#3981561 , @nikic wrote:
>
>> Checking back here again on whether there is any progress on finding the 
>> root cause of the issue. If no progress is expected in the near future, I'd 
>> ask for this patch to be reverted.
>
> @jrbyrnes is working on the root cause of this issue. Any updates? Thanks.

Thanks for the ping. I would also like to see this reverted as it enables some 
optimizations. I do not have a definitive answer at the moment (w.r.t reverting 
this), but hope to provide one soon

As for now, the issue we are seeing from 
(https://github.com/llvm/llvm-project/commit/8018d6be3459780e81a5da128a9915eb27909902)
 seems most likely to be a source code issue (first document of issue 
https://github.com/pytorch/pytorch/issues/54789 . upstream PyTorch currently 
skips problematic test 
https://github.com/pytorch/pytorch/blob/b738da8c8e4d9142ad38a1bd8c35d0bfef4b5e3c/torch/testing/_internal/common_methods_invocations.py#L14891)
 . I will provide a better update soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135269

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


[PATCH] D138263: [clang-format] Supress aligning of trailing namespace comments

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



Comment at: clang/lib/Format/WhitespaceManager.cpp:991
+bool DontAlignThisComment =
+i > 0 && Changes[i - 1].Tok->is(TT_NamespaceRBrace);
 bool WasAlignedWithStartOfNextLine = false;

owenpan wrote:
> Don't we still need to check `Changes[i].NewlinesBefore == 0`? How would this 
> format the code below with `FixNamespaceComments: false`?
> ```
> namespace A {
>   ...
> }
> // comment
> ```
Will check.



Comment at: clang/unittests/Format/FormatTestComments.cpp:71-83
+  void verifyFormat(llvm::StringRef Expected, llvm::StringRef Code,
+const FormatStyle &Style = getLLVMStyle()) {
+EXPECT_EQ(Expected.str(), format(Expected, Style))
+<< "Expected code is not stable";
+EXPECT_EQ(Expected.str(), format(test::messUp(Code), Style));
+  }
+

owenpan wrote:
> Was this already done in D138402?
The first yes, the second no. I did just not update this diff, my commit is 
updated.



Comment at: clang/unittests/Format/FormatTestComments.cpp:3094
+TEST_F(FormatTestComments, DontAlignNamespaceComments) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceIndentation = FormatStyle::NI_All;

owenpan wrote:
> Should we add tests for `FixNamespaceComments: false`?
Will do.



Comment at: clang/unittests/Format/FormatTestComments.cpp:3137
+"}  // namespace C\n"
+"  }// TESTSUITE(B)\n"
+"} // NaMeSpAcE A",

owenpan wrote:
> Why would `TCAS_Leave` result in no space before the trailing comment?
It just did, didn't investigate or decide.
Most likely clang-format just adds it there and the space just comes from the 
other formatting, which is disabled with `Leave`. I'd say this is fine, `Leave` 
just means the coder decides on the position of the comments, and if that 
comment is added he can just move it around and clang-format will not touch it 
any further.


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

https://reviews.llvm.org/D138263

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


[PATCH] D139652: Add the thread sanitizer support for X86_64 WatchOS simulators

2022-12-08 Thread Yifan Yang via Phabricator via cfe-commits
yfyang created this revision.
yfyang added a reviewer: jyknight.
Herald added a subscriber: pengfei.
Herald added a project: All.
yfyang requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Thread sanitizer for x86_64 architecutre is supported currently for TVOS and 
iOS simulators.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139652

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/fsanitize.c


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -463,6 +463,9 @@
 // RUN: %clang --target=x86_64-apple-ios-simulator -fsanitize=thread %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
 // CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option
 
+// RUN: %clang --target=x86_64-apple-watchos-simulator -fsanitize=thread %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-WATCHOSSIMULATOR
+// CHECK-TSAN-X86-64-WATCHOSSIMULATOR-NOT: unsupported option
+
 // RUN: %clang --target=x86_64-apple-tvos-simulator -fsanitize=thread %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-TVOSSIMULATOR
 // CHECK-TSAN-X86-64-TVOSSIMULATOR-NOT: unsupported option
 
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -3279,7 +3279,8 @@
 
   if ((IsX86_64 || IsAArch64) && isTargetMacOSBased()) {
 Res |= SanitizerKind::Thread;
-  } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
+  } else if (isTargetIOSSimulator() || isTargetTvOSSimulator() ||
+ isTargetWatchOSSimulator()) {
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   }


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -463,6 +463,9 @@
 // RUN: %clang --target=x86_64-apple-ios-simulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
 // CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option
 
+// RUN: %clang --target=x86_64-apple-watchos-simulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-WATCHOSSIMULATOR
+// CHECK-TSAN-X86-64-WATCHOSSIMULATOR-NOT: unsupported option
+
 // RUN: %clang --target=x86_64-apple-tvos-simulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-TVOSSIMULATOR
 // CHECK-TSAN-X86-64-TVOSSIMULATOR-NOT: unsupported option
 
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -3279,7 +3279,8 @@
 
   if ((IsX86_64 || IsAArch64) && isTargetMacOSBased()) {
 Res |= SanitizerKind::Thread;
-  } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
+  } else if (isTargetIOSSimulator() || isTargetTvOSSimulator() ||
+ isTargetWatchOSSimulator()) {
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139629: clang: Stop emitting "strictfp"

2022-12-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D139629#3982052 , @arsenm wrote:

> In D139629#3981991 , @zahiraam 
> wrote:
>
>> Can you please be more verbose in your summary? This change is related to 
>> the use of -ffp-exception-behavior=strict right? 
>> This attribute is set here 
>> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenFunction.cpp#L987
>>  but under a condition. Is that condition always satisfied when the 
>> attribute needs to be set?
>
> I don't know if there are other cases that misses; if so it's broken anyway. 
> Nothing reads this string formed version

It's coming from the FunctionDecl and the other case is broader. Only question 
would be of reachability


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

https://reviews.llvm.org/D139629

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


[PATCH] D139629: clang: Stop emitting "strictfp"

2022-12-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D139629#3981991 , @zahiraam wrote:

> Can you please be more verbose in your summary? This change is related to the 
> use of -ffp-exception-behavior=strict right? 
> This attribute is set here 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenFunction.cpp#L987
>  but under a condition. Is that condition always satisfied when the attribute 
> needs to be set?

I don't know if there are other cases that misses; if so it's broken anyway. 
Nothing reads this string formed version


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

https://reviews.llvm.org/D139629

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


[PATCH] D139052: [NFC][Profile] Access profile through VirtualFileSystem

2022-12-08 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1729
+  if (!Opts.ProfileInstrumentUsePath.empty()) {
+auto FS = llvm::vfs::getRealFileSystem();
+setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath, *FS, Diags);

akyrtzi wrote:
> steven_wu wrote:
> > akyrtzi wrote:
> > > Could we propagate the VFS that the `CompilerInvocation` is going to 
> > > create here? Otherwise this seems like a hidden "landmine" that someone 
> > > is bound to trip on later on.
> > Currently, Profile look up doesn't go through any VFS, so vfs overlay has 
> > no effect on profiles. Putting through VFS is changing behavior, even I 
> > think it is for good.
> > 
> > It also has the potential to make code harder to read because creating VFS 
> > relies on a compiler invocation which we are creating here.
> > 
> > Let me add a fixme here first. 
> > Currently, Profile look up doesn't go through any VFS, so vfs overlay has 
> > no effect on profiles. Putting through VFS is changing behavior, even I 
> > think it is for good.
> 
> Your patch is already changing behavior; CodeGen will load profiles using 
> clang's VFS, so vfs overlay will affect how profiles are loaded. The mismatch 
> is that CodeGen will load the path using clang's VFS but 
> `setPGOUseInstrumentor` will load it directly from real file-system, so they 
> can be out-of-sync.
> 
> On second look, `setPGOUseInstrumentor` seems to create a throw-away 
> `IndexedInstrProfReader` just for reading a couple of settings to set some 
> flags. This seems redundant, could we move the determination of these flags 
> at the point where `CodeGenModule` is creating its own 
> `IndexedInstrProfReader` and remove `setPGOUseInstrumentor` from 
> `CompilerInvocation::ParseCodeGenArgs` entirely?
I will take a look. The current implementation is not very good as it just read 
it to determine the type of the profile to set the action. I agree the 
disconnect between two reads is bad.



Comment at: llvm/include/llvm/Support/PGOOptions.h:18
 #include "llvm/Support/Error.h"
+#include "llvm/Support/VirtualFileSystem.h"
 

akyrtzi wrote:
> akyrtzi wrote:
> > I'd suggest to consider moving the `PGOOptions` constructor out-of-line, 
> > along with
> > ```
> >   PGOOptions &operator=(const PGOOptions &O);
> >   PGOOptions(const PGOOptions&);
> >   ~PGOOptions();
> > ```
> >  in order to forward-declare here and avoid including the header, avoiding 
> > the additional include dependencies for many cpp files.
> > The default parameter needs to instantiate here and pretty much all 
> > references to `PGOOptions` has `Optional` which requires 
> > including VFS. I will leave this one since `PGOOptions.h` is a rare header 
> > to include.
> 
> `PGOOptions.h` is transitively included by many files, if I touch that 
> header, and then compile `clang`, there are 225 files that need to be 
> re-compiled.
> 
> I thought that moving the `PGOOptions` members I mentioned out-of-line would 
> be enough to avoid the need to include `VirtualFileSystem.h`, is this not the 
> case?
I see. It is included in two different headers in the backend, both of them has 
`Optional`. During my experiment, to instantiate 
`Optional`, it needs full declaration for PGOOptions, thus 
FileSystem. I could be wrong but I don't see a way around that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139052

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


[clang] d694e24 - Update the status of a few more C DRs

2022-12-08 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-12-08T13:19:29-05:00
New Revision: d694e2490af8b2e92c79b2c1b543bcc4bb3981d1

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

LOG: Update the status of a few more C DRs

This includes tests for DR085 and DR259.

Added: 
clang/test/C/drs/dr259.c

Modified: 
clang/test/C/drs/dr0xx.c
clang/www/c_dr_status.html

Removed: 




diff  --git a/clang/test/C/drs/dr0xx.c b/clang/test/C/drs/dr0xx.c
index 942e83bef886c..6a3717f0729b6 100644
--- a/clang/test/C/drs/dr0xx.c
+++ b/clang/test/C/drs/dr0xx.c
@@ -70,6 +70,9 @@
  * WG14 DR080: yes
  * Merging of string constants
  *
+ * WG14 DR085: yes
+ * Returning from main
+ *
  * WG14 DR086: yes
  * Object-like macros in system headers
  *

diff  --git a/clang/test/C/drs/dr259.c b/clang/test/C/drs/dr259.c
new file mode 100644
index 0..0bd039e04bef5
--- /dev/null
+++ b/clang/test/C/drs/dr259.c
@@ -0,0 +1,21 @@
+/* RUN: %clang_cc1 -std=c89 -E -verify %s | FileCheck %s
+   RUN: %clang_cc1 -std=c99 -E -verify %s | FileCheck %s
+   RUN: %clang_cc1 -std=c11 -E -verify %s | FileCheck %s
+   RUN: %clang_cc1 -std=c17 -E -verify %s | FileCheck %s
+   RUN: %clang_cc1 -std=c2x -E -verify %s | FileCheck %s
+ */
+
+/* expected-no-diagnostics */
+
+/* WG14 DR259: yes
+ * Macro invocations with no arguments
+ */
+#define m0() replacement
+#define m1(x) begin x end
+
+m0() m1()
+
+/*
+CHECK: replacement begin end
+*/
+

diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index ea38597717363..15e92c5eb2ccb 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -565,7 +565,7 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_085.html";>85
 C89
 Returning from main
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_086.html";>86
@@ -1488,7 +1488,7 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_259.htm";>259
 NAD
 Macro invocations with no arguments
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_260.htm";>260



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


[PATCH] D139166: [OPENMP51] Codegen support for error directive.

2022-12-08 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.h:334
   llvm::Value *emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc,
-  unsigned Flags = 0);
+  unsigned Flags = 0, bool EmitLoc = false);
 

Why do you need this location? To output it for the user in the runtime library 
call?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139166

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


[PATCH] D139629: clang: Stop emitting "strictfp"

2022-12-08 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

Can you please be more verbose in your summary? This change is related to the 
use of -ffp-exception-behavior=strict right? 
This attribute is set here 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CodeGenFunction.cpp#L987
 but under a condition. Is that condition always satisfied when the attribute 
needs to be set?


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

https://reviews.llvm.org/D139629

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


[PATCH] D133289: [C2X] N3007 Type inference for object definitions

2022-12-08 Thread Guillot Tony via Phabricator via cfe-commits
to268 updated this revision to Diff 481339.
to268 added a comment.

Removed compound literal diagnostic in ParseExpr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/C/C2x/n3007.c
  clang/test/CodeGen/auto.c
  clang/test/Parser/c2x-auto.c
  clang/test/Sema/c2x-auto.c
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1192,7 +1192,7 @@
 
   Type inference for object declarations
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3007.htm";>N3007
-  No
+  Clang 16
 
 
   constexpr for object definitions
Index: clang/test/Sema/c2x-auto.c
===
--- /dev/null
+++ clang/test/Sema/c2x-auto.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x %s
+
+void test_basic_types(void) {
+  auto undefined; // expected-error {{declaration of variable 'undefined' with deduced type 'auto' requires an initializer}}
+  auto auto_int = 4;
+  auto auto_long = 4UL;
+}
+
+void test_sizeof_typeof(void) {
+  auto auto_size = sizeof(auto);  // expected-error {{expected expression}}
+  typeof(auto) tpof = 4;  // expected-error {{expected expression}}
+}
+
+void test_casts(void) {
+  auto int_cast = (int)(4 + 3);
+  auto double_cast = (double)(1 / 3);
+  auto long_cast = (long)(4UL + 3UL);
+  auto auto_cast = (auto)(4 + 3); // expected-error {{expected expression}}
+}
+
+void test_compound_literral(void) {
+  auto int_cl = (int){13};
+  auto double_cl = (double){2.5};
+  auto array[] = { 1, 2, 3 }; // expected-error {{'array' declared as array of 'auto'}}
+
+  // FIXME: This should be accepted per C2x 6.5.2.5p4
+  auto auto_cl = (auto){13};  // expected-error {{expected expression}}
+}
+
+void test_array_pointers(void) {
+  double array[3] = { 0 };
+  auto a = array;
+  auto b = &array;
+}
+
+void test_qualifiers(const int y) {
+  const auto a = 12;
+  auto b = y;
+  static auto c = 1UL;
+  int* pa = &a; // expected-warning {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}}
+  const int* pb = &b;
+  int* pc = &c; // expected-warning {{incompatible pointer types initializing 'int *' with an expression of type 'unsigned long *'}}
+
+}
+
+void test_strings(void) {
+  auto str = "this is a string";
+  // FIXME: This should work for char*
+  auto str2[] = "this is a string"; // expected-error {{str2' declared as array of 'auto'}}
+  auto (str3) = "this is a string";
+  auto (((str4))) = "this is a string";
+}
+
+// FIXME: All these statements should fails (cannot declare a variable as a auto*)
+void test_pointers(void) {
+  auto a = 12;
+  auto *ptr = &a; // expected-error {{cannot declare 'ptr' as an explcit 'auto*' in C2x}}
+  auto *str = "this is a string"; // expected-error {{cannot declare 'str' as an explcit 'auto*' in C2x}}
+  const auto *str2 = "this is a string";  // expected-error {{cannot declare 'str2' as an explcit 'auto*' in C2x}}
+  auto *b = &a;   // expected-error {{cannot declare 'b' as an explcit 'auto*' in C2x}}
+  *b = &a;
+}
+
+void test_scopes(void) {
+  double a = 7;
+  double b = 9;
+  {
+auto a = a * a; // expected-error {{variable 'a' declared with deduced type 'auto' cannot appear in its own initializer}} \
+   expected-error {{variable 'a' declared with deduced type 'auto' cannot appear in its own initializer}}
+  }
+  {
+auto b = a * a;
+auto a = b;
+  }
+}
Index: clang/test/Parser/c2x-auto.c
===
--- /dev/null
+++ clang/test/Parser/c2x-auto.c
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c17 -std=c17 %s
+
+#define AUTO_MACRO(_NAME, ARG, ARG2, ARG3) \
+  auto _NAME = ARG + (ARG2 / ARG3);
+
+struct S {
+int a;
+auto b;   // c2x-error {{'auto' not allowed in struct member}} \
+ c17-error {{type name does not allow storage class to be specified}} \
+ c17-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
+union {
+  char c;
+  auto smth;  // c2x-error {{'auto' not allowed in union member}} \
+ c17-error {{type name does not allow storage class to be specified}} \
+ c17-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
+} u;
+};
+
+enum E : auto { // c2x-error {{'auto' not allowed here}} \
+   c17-error {{expected a type}} \
+ 

[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions

2022-12-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie reopened this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

(just a side note I discovered while looking into this: seems someone else had 
this idea before & came to similar conclusions: 
https://reviews.llvm.org/D104118#2840490 )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138597

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


[PATCH] D135269: [AMDGPU] Disable bool range metadata to workaround backend issue

2022-12-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a subscriber: jrbyrnes.
yaxunl added a comment.

In D135269#3981561 , @nikic wrote:

> Checking back here again on whether there is any progress on finding the root 
> cause of the issue. If no progress is expected in the near future, I'd ask 
> for this patch to be reverted.

@jrbyrnes is working on the root cause of this issue. Any updates? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135269

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


[PATCH] D139166: [OPENMP51] Codegen support for error directive.

2022-12-08 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 481319.
jyu2 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139166

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/error_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -198,6 +198,7 @@
 __OMP_RTL(__kmpc_barrier, false, Void, IdentPtr, Int32)
 __OMP_RTL(__kmpc_cancel, false, Int32, IdentPtr, Int32, Int32)
 __OMP_RTL(__kmpc_cancel_barrier, false, Int32, IdentPtr, Int32)
+__OMP_RTL(__kmpc_error, false, Void, IdentPtr, Int32, Int8Ptr)
 __OMP_RTL(__kmpc_flush, false, Void, IdentPtr)
 __OMP_RTL(__kmpc_global_thread_num, false, Int32, IdentPtr)
 __OMP_RTL(__kmpc_get_hardware_thread_id_in_block, false, Int32, )
Index: clang/test/OpenMP/error_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/error_codegen.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -std=c++11 -fopenmp -fopenmp-version=51 -triple x86_64 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -std=c++11 -fopenmp-simd -fopenmp-version=51 \
+// RUN:  -debug-info-kind=limited -triple x86_64 -emit-llvm -o - %s |  \
+// RUN:  FileCheck  --check-prefix SIMD %s
+
+//CHECK: @.str = private unnamed_addr constant [23 x i8] c"GPU compiler required.\00", align 1
+//CHECK: @0 = private unnamed_addr constant {{.*}}error_codegen.cpp;main;52;1;;\00", align 1
+//CHECK: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @0 }, align 8
+//CHECK: @.str.1 = private unnamed_addr constant [27 x i8] c"Note this is functioncall.\00", align 1
+//CHECK: @2 = private unnamed_addr constant {{.*}}error_codegen.cpp;main;54;1;;\00", align 1
+//CHECK: @3 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @2 }, align 8
+//CHECK: @.str.2 = private unnamed_addr constant [23 x i8] c"GNU compiler required.\00", align 1
+//CHECK: @4 = private unnamed_addr constant {{.*}}error_codegen.cpp;tmain;29;1;;\00", align 1
+//CHECK: @5 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @4 }, align 8
+//CHECK: @.str.3 = private unnamed_addr constant [22 x i8] c"Notice: add for loop.\00", align 1
+//CHECK: @6 = private unnamed_addr constant {{.*}}error_codegen.cpp;tmain;32;1;;\00", align 1
+//CHECK: @7 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @6 }, align 8
+//CHECK: @8 = private unnamed_addr constant {{.*}}error_codegen.cpp;tmain;38;1;;\00", align 1
+//CHECK: @9 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 {{.*}}, ptr @8 }, align 8
+
+void foo() {}
+
+template 
+int tmain(T argc, char **argv) {
+  T b = argc, c, d, e, f, g;
+  static int a;
+#pragma omp error at(execution) severity(fatal) message("GNU compiler required.")
+  a = argv[0][0];
+  ++a;
+#pragma omp error at(execution) severity(warning) message("Notice: add for loop.")
+  {
+int b = 10;
+T c = 100;
+a = b + c;
+  }
+#pragma omp  error at(execution) severity(fatal) message("GPU compiler required.")
+  foo();
+return N;
+}
+// CHECK-LABEL: @main(
+// SIMD-LABEL: @main(
+// CHECK:call void @__kmpc_error(ptr @1, i32 2, ptr @.str)
+// SIMD-NOT:call void @__kmpc_error(ptr @1, i32 2, ptr @.str)
+// CHECK:call void @__kmpc_error(ptr @3, i32 1, ptr @.str.1)
+// SIMD-NOT:call void @__kmpc_error(ptr @3, i32 1, ptr @.str.1)
+//
+int main (int argc, char **argv) {
+  int b = argc, c, d, e, f, g;
+  static int a;
+#pragma omp error at(execution) severity(fatal) message("GPU compiler required.")
+   a=2;
+#pragma omp error at(execution) severity(warning) message("Note this is functioncall.")
+  foo();
+  tmain(argc, argv);
+}
+
+//CHECK-LABEL: @_Z5tmainIiLi10EEiT_PPc(
+//SIMD-LABEL: @_Z5tmainIiLi10EEiT_PPc(
+//CHECK: call void @__kmpc_error(ptr @5, i32 2, ptr @.str.2)
+//CHECK: call void @__kmpc_error(ptr @7, i32 1, ptr @.str.3)
+//CHECK: call void @__kmpc_error(ptr @9, i32 2, ptr @.str)
+//SIMD-NOT: call void @__kmpc_error(ptr @5, i32 2, ptr @.str.2)
+//SIMD-NOT: call void @__kmpc_error(ptr @7, i32 1, ptr @.str.3)
+//SIMD-NOT: call void @__kmpc_error(ptr @9, i32 2, ptr @.str)
+//CHECK: ret i32 10
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5246,7 +5246,13 @@
 }
 
 void CodeGenFunction::EmitOMPErrorDirective(const OMPErrorDirective &S) {
-  llvm_unreachable("CodeGen for 'omp error' is not supported yet.");
+  const OMPMessageClause *MC = S.getSingle

[PATCH] D139302: [RISCV] Add Syntacore SCR1 CPU model

2022-12-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Should the names be prefixed with "syntacore-". I assume there could be an 
SCR2, etc. in the future?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139302

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


[PATCH] D139302: [RISCV] Add Syntacore SCR1 CPU model

2022-12-08 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/include/llvm/Support/RISCVTargetParser.def:22
 PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"})
+PROC(SCR1_BASE, {"scr1-base"}, FK_NONE, {"rv32ic"})
+PROC(SCR1_MAX, {"scr1-max"}, FK_NONE, {"rv32imc"})

Alphabetise (with the exception of INVALID)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139302

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


  1   2   >