[clang] [Serialization] Load Specializations Lazily (1/2) (PR #76774)

2024-01-03 Thread Vassil Vassilev via cfe-commits

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


[clang] [Serialization] Load Specializations Lazily (1/2) (PR #76774)

2024-01-03 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev commented:

This is a great way to start a new year ;)

The phab link is https://reviews.llvm.org/D41416.

In general I was wondering could we simplify the implementation by loading the 
specialization hash table upon module load. That should be relatively cheap as 
we will read 2 integers per specialization.

Perhaps we should put both patches together and that'd allow us to test them if 
they are on par with https://reviews.llvm.org/D41416 which we use downstream.

Thanks for working on this!


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


[clang] [Serialization] Load Specializations Lazily (1/2) (PR #76774)

2024-01-03 Thread Vassil Vassilev via cfe-commits


@@ -1249,3 +1249,5 @@ void ODRHash::AddQualType(QualType T) {
 void ODRHash::AddBoolean(bool Value) {
   Bools.push_back(Value);
 }
+
+void ODRHash::AddInteger(unsigned Value) { ID.AddInteger(Value); }

vgvassilev wrote:

I remember @hahnjo and @zygoloid discussing that the odr-hasher is probably not 
the best way to has template arguments because the hasher would not take into 
account semantic aspects of template arguments. For example, a fully qualified 
template argument would not compare the same to a non-qualified one. We might 
need to implement our own folding set logic.

@hahnjo, could you help me out dig that discussion.

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


[clang] [Serialization] Load Specializations Lazily (1/2) (PR #76774)

2024-01-03 Thread Vassil Vassilev via cfe-commits


@@ -2431,10 +2434,14 @@ void 
ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   mergeRedeclarableTemplate(D, Redecl);
 
   if (ThisDeclID == Redecl.getFirstID()) {
-// This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of
-// the specializations.
+// This ClassTemplateDecl owns a CommonPtr; read it to keep track of all
+// of the specializations.
 SmallVector SpecIDs;
 readDeclIDList(SpecIDs);
+
+if (Record.readInt())
+  ReadDeclsSpecs(*Loc.F, D, Loc.F->DeclsCursor);

vgvassilev wrote:

What if the TemplateDecl came from a different module file and this module file 
contains only specializations?

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


[clang] [Serialization] Load Specializations Lazily (1/2) (PR #76774)

2024-01-03 Thread Vassil Vassilev via cfe-commits


@@ -150,6 +150,11 @@ class ExternalASTSource : public 
RefCountedBase {
   virtual bool
   FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name);
 
+  /// Load all the external specialzations for the Decl and the corresponding
+  /// template arguments.
+  virtual void LoadExternalSpecs(const Decl *D,

vgvassilev wrote:

```suggestion
  virtual void FindExternalSpecialization(const Decl *D,
```
sounds more consistent to the surroundings here.


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


[clang] [Serialization] Load Specializations Lazily (1/2) (PR #76774)

2024-01-03 Thread Vassil Vassilev via cfe-commits


@@ -527,6 +527,10 @@ class ASTWriter : public ASTDeserializationListener,
   bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
   bool isLookupResultEntirelyExternal(StoredDeclsList &Result, DeclContext 
*DC);
 
+  uint64_t
+  WriteSpecsLookupTable(NamedDecl *D,

vgvassilev wrote:

Generally `spec` would read as specification not specialization. Maybe we 
should use the full word.

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


[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)

2024-01-03 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 



@@ -8938,6 +8957,11 @@ static void processTypeAttrs(TypeProcessingState &state, 
QualType &type,
   attr.setUsedAsTypeAttr();
   break;
 }
+case ParsedAttr::AT_RequiresCapability: {
+  HandleRequiresCapabilityAttr(state, type, attr);
+  attr.setUsedAsTypeAttr();
+  break;
+}

tbaederr wrote:

Meh, it seems like adding a pointer to `FunctionType::ExtInfo` would blow it up 
a lot, and just a bit isn't enough to save the information.

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


[clang] [clang][ASTImporter] import InstantiatedFromMember of ClassTemplateSpecializationDecl (PR #76493)

2024-01-03 Thread Balázs Kéri via cfe-commits


@@ -9342,6 +9342,38 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportConflictTypeAliasTemplate) {
   EXPECT_FALSE(ImportedCallable);
 }
 
+AST_MATCHER(ClassTemplateSpecializationDecl, hasInstantiatedFromMember) {
+  if (auto Instantiate = Node.getInstantiatedFrom()) {
+if (auto *FromPartialSpecialization =
+Instantiate.get()) {
+  return nullptr != FromPartialSpecialization->getInstantiatedFromMember();
+}
+  }
+  return false;
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) {
+  const char *Code =
+  R"(
+  template  struct B {
+template  union D;
+template  union D {};
+D d;
+  };
+  B b;
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromA = FirstDeclMatcher().match(

balazske wrote:

```suggestion
  auto *FromD = FirstDeclMatcher().match(
```

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


[clang] [clang][ASTImporter] import InstantiatedFromMember of ClassTemplateSpecializationDecl (PR #76493)

2024-01-03 Thread Balázs Kéri via cfe-commits


@@ -9342,6 +9342,38 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportConflictTypeAliasTemplate) {
   EXPECT_FALSE(ImportedCallable);
 }
 
+AST_MATCHER(ClassTemplateSpecializationDecl, hasInstantiatedFromMember) {
+  if (auto Instantiate = Node.getInstantiatedFrom()) {
+if (auto *FromPartialSpecialization =
+Instantiate.get()) {
+  return nullptr != FromPartialSpecialization->getInstantiatedFromMember();
+}
+  }
+  return false;
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) {
+  const char *Code =
+  R"(
+  template  struct B {
+template  union D;
+template  union D {};
+D d;
+  };
+  B b;
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromA = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("D"),
+  hasInstantiatedFromMember()));
+  auto *FromPartialSpecialization =
+  cast(
+  FromA->getInstantiatedFrom());
+  auto *ImportedPartialSpecialization =

balazske wrote:

ASSERT_TRUE(FromPartialSpecialization->getInstantiatedFromMember());

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


[clang] [clang][ASTImporter] import InstantiatedFromMember of ClassTemplateSpecializationDecl (PR #76493)

2024-01-03 Thread Balázs Kéri via cfe-commits


@@ -9342,6 +9342,38 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportConflictTypeAliasTemplate) {
   EXPECT_FALSE(ImportedCallable);
 }
 
+AST_MATCHER(ClassTemplateSpecializationDecl, hasInstantiatedFromMember) {
+  if (auto Instantiate = Node.getInstantiatedFrom()) {
+if (auto *FromPartialSpecialization =
+Instantiate.get()) {
+  return nullptr != FromPartialSpecialization->getInstantiatedFromMember();
+}
+  }
+  return false;
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) {
+  const char *Code =
+  R"(
+  template  struct B {
+template  union D;
+template  union D {};
+D d;
+  };
+  B b;
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromA = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("D"),
+  hasInstantiatedFromMember()));
+  auto *FromPartialSpecialization =
+  cast(
+  FromA->getInstantiatedFrom());

balazske wrote:

```suggestion
  FromD->getInstantiatedFrom());
```

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


[compiler-rt] [flang] [lldb] [libcxx] [lld] [clang] [clang-tools-extra] [libc] [llvm] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2024-01-03 Thread Matt Arsenault via cfe-commits


@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 setRegScore(RegNo, T, CurrScore);
   }
 }
-if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) {
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+if (Inst.mayStore() &&
+(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
+  // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
+  // written can be accessed. A load from LDS to VMEM does not need a wait.
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal

arsenm wrote:

PseudoSourceValue::mayAlias is supposed to report aliasing to possible IR 
values. It looks like it's layered weirdly, and expects you to go through 
MachineInstr::mayAlias. MachineInstr::mayAlias ought to be using the AA tags, 
it shouldn't be a fundamental limitation 

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


[flang] [compiler-rt] [lld] [llvm] [clang] [clang-tools-extra] [libcxx] [lldb] [libc] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2024-01-03 Thread Matt Arsenault via cfe-commits


@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 setRegScore(RegNo, T, CurrScore);
   }
 }
-if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) {
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+if (Inst.mayStore() &&
+(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
+  // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
+  // written can be accessed. A load from LDS to VMEM does not need a wait.
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal

arsenm wrote:

It looks to me like it does use it if you pass UseTBAA=true. Not sure why this 
would be a parameter in the first place 

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


[flang] [compiler-rt] [lld] [llvm] [clang] [clang-tools-extra] [libcxx] [lldb] [libc] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2024-01-03 Thread Matt Arsenault via cfe-commits


@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 setRegScore(RegNo, T, CurrScore);
   }
 }
-if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) {
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+if (Inst.mayStore() &&
+(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
+  // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
+  // written can be accessed. A load from LDS to VMEM does not need a wait.
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal

arsenm wrote:

The values don't need to be identical, that's the point of the AA query. 
BasicAA will parse through the offsets 

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


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Balázs Kéri via cfe-commits


@@ -2511,10 +2511,12 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 .ArgConstraint(NotNull(ArgNo(0;
 
 // char *mkdtemp(char *template);
-// FIXME: Improve for errno modeling.
 addToFunctionSummaryMap(
 "mkdtemp", Signature(ArgTypes{CharPtrTy}, RetType{CharPtrTy}),
-Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
+Summary(NoEvalCall)
+.Case({NotNull(Ret)}, ErrnoMustNotBeChecked, GenericSuccessMsg)

balazske wrote:

It should work in this way (returned value is the same as "template").
```suggestion
.Case({ReturnValueCondition(BO_EQ, ArgNo(0))},
  ErrnoMustNotBeChecked, GenericSuccessMsg)
```

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


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Balázs Kéri via cfe-commits


@@ -54,3 +51,25 @@ int errno_lseek(int fildes, off_t offset) {
   }
   return 0;
 }
+
+void errno_mkstemp(char *template) {
+  int FD = mkstemp(template);
+  if (FD >= 0) {
+if (errno) {}// expected-warning{{An undefined value 
may be read from 'errno'}}
+close(FD);
+  } else {
+clang_analyzer_eval(FD == -1);   // expected-warning{{TRUE}}
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+if (errno) {}// no warning
+  }
+}
+
+void errno_mkdtemp(char *template) {
+  char *Dir = mkdtemp(template);
+  if (Dir == NULL) {
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+if (errno) {}// no warning
+  } else {

balazske wrote:

```suggestion
  } else {
`clang_analyzer_eval(Dir == template); // expected-warning{{TRUE}}`
```

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


[clang] [clang][ASTImporter][StructuralEquivalence] improve StructuralEquivalence on recordType (PR #76226)

2024-01-03 Thread Balázs Kéri via cfe-commits


@@ -1491,6 +1492,12 @@ static bool 
IsRecordContextStructurallyEquivalent(RecordDecl *D1,
 return false;
 }
 
+if (auto *D1Spec = dyn_cast(DC1)) {
+  auto *D2Spec = dyn_cast(DC2);

balazske wrote:

I see now that the old code was better, there is a previous check 
`DC1->getDeclKind() != DC2->getDeclKind()`, this should ensure that the type is 
the same.

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


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/76671

>From 0c586914ac977920140472d172ee357dea43f2c5 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Mon, 1 Jan 2024 18:48:27 +0800
Subject: [PATCH 1/2] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp'

---
 .../Checkers/StdLibraryFunctionsChecker.cpp   |  6 ++--
 .../test/Analysis/errno-stdlibraryfunctions.c | 29 +++
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 4ca49b9c0546d9..6f249b6b880283 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -2511,10 +2511,12 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 .ArgConstraint(NotNull(ArgNo(0;
 
 // char *mkdtemp(char *template);
-// FIXME: Improve for errno modeling.
 addToFunctionSummaryMap(
 "mkdtemp", Signature(ArgTypes{CharPtrTy}, RetType{CharPtrTy}),
-Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
+Summary(NoEvalCall)
+.Case({NotNull(Ret)}, ErrnoMustNotBeChecked, GenericSuccessMsg)
+.Case({IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg)
+.ArgConstraint(NotNull(ArgNo(0;
 
 // char *getcwd(char *buf, size_t size);
 // FIXME: Improve for errno modeling.
diff --git a/clang/test/Analysis/errno-stdlibraryfunctions.c 
b/clang/test/Analysis/errno-stdlibraryfunctions.c
index dafda764af9f38..de31de8cfea39b 100644
--- a/clang/test/Analysis/errno-stdlibraryfunctions.c
+++ b/clang/test/Analysis/errno-stdlibraryfunctions.c
@@ -7,12 +7,9 @@
 // RUN:   -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true
 
 #include "Inputs/errno_var.h"
+#include "Inputs/std-c-library-functions-POSIX.h"
 
-typedef typeof(sizeof(int)) size_t;
-typedef __typeof(sizeof(int)) off_t;
-typedef size_t ssize_t;
-ssize_t send(int sockfd, const void *buf, size_t len, int flags);
-off_t lseek(int fildes, off_t offset, int whence);
+#define NULL ((void *) 0)
 
 void clang_analyzer_warnIfReached();
 void clang_analyzer_eval(int);
@@ -54,3 +51,25 @@ int errno_lseek(int fildes, off_t offset) {
   }
   return 0;
 }
+
+void errno_mkstemp(char *template) {
+  int FD = mkstemp(template);
+  if (FD >= 0) {
+if (errno) {}// expected-warning{{An undefined value 
may be read from 'errno'}}
+close(FD);
+  } else {
+clang_analyzer_eval(FD == -1);   // expected-warning{{TRUE}}
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+if (errno) {}// no warning
+  }
+}
+
+void errno_mkdtemp(char *template) {
+  char *Dir = mkdtemp(template);
+  if (Dir == NULL) {
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+if (errno) {}// no warning
+  } else {
+if (errno) {}// expected-warning{{An undefined value 
may be read from 'errno'}}
+  }
+}

>From 47dce8c0c13bda1753aa7f5bdb4bd9cc45d707be Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Wed, 3 Jan 2024 17:13:29 +0800
Subject: [PATCH 2/2] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp'

---
 .../StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | 3 ++-
 clang/test/Analysis/errno-stdlibraryfunctions.c| 7 ---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 6f249b6b880283..4adc91b85071a8 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -2514,7 +2514,8 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 addToFunctionSummaryMap(
 "mkdtemp", Signature(ArgTypes{CharPtrTy}, RetType{CharPtrTy}),
 Summary(NoEvalCall)
-.Case({NotNull(Ret)}, ErrnoMustNotBeChecked, GenericSuccessMsg)
+.Case({ReturnValueCondition(BO_EQ, ArgNo(0))},
+  ErrnoMustNotBeChecked, GenericSuccessMsg)
 .Case({IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg)
 .ArgConstraint(NotNull(ArgNo(0;
 
diff --git a/clang/test/Analysis/errno-stdlibraryfunctions.c 
b/clang/test/Analysis/errno-stdlibraryfunctions.c
index de31de8cfea39b..80e14c4e2923ca 100644
--- a/clang/test/Analysis/errno-stdlibraryfunctions.c
+++ b/clang/test/Analysis/errno-stdlibraryfunctions.c
@@ -67,9 +67,10 @@ void errno_mkstemp(char *template) {
 void errno_mkdtemp(char *template) {
   char *Dir = mkdtemp(template);
   if (Dir == NULL) {
-clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
-if (errno) {}// no warning
+clang_analyzer_eval(errno != 0);  // expected-warning{{TRUE}}
+if (errno) {}

[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Ben Shi via cfe-commits


@@ -2511,10 +2511,12 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 .ArgConstraint(NotNull(ArgNo(0;
 
 // char *mkdtemp(char *template);
-// FIXME: Improve for errno modeling.
 addToFunctionSummaryMap(
 "mkdtemp", Signature(ArgTypes{CharPtrTy}, RetType{CharPtrTy}),
-Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
+Summary(NoEvalCall)
+.Case({NotNull(Ret)}, ErrnoMustNotBeChecked, GenericSuccessMsg)

benshi001 wrote:

Fixed. Thanks.

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


[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)

2024-01-03 Thread kadir çetinkaya via cfe-commits

https://github.com/kadircet created 
https://github.com/llvm/llvm-project/pull/76795

This restores a subset of functionality that was forego in
d68826dfbd987377ef6771d40c1d984f09ee3b9e.

Streaming multiple string literals is rare enough in practice, hence
that change makes sense in general. But it seems people were
incidentally relying on this for having line breaks after string
literals that ended with `\n`.

This patch tries to restore that behavior to prevent regressions in the
upcoming LLVM release, until we can implement some configuration based
approach as proposed in https://github.com/llvm/llvm-project/pull/69859.


From b09c89ee1dc88e030040bcf30063ea16ec5a0b58 Mon Sep 17 00:00:00 2001
From: Kadir Cetinkaya 
Date: Wed, 3 Jan 2024 09:28:35 +0100
Subject: [PATCH] [clang-format] Break after string literals with trailing line
 breaks

This restores a subset of functionality that was forego in
d68826dfbd987377ef6771d40c1d984f09ee3b9e.

Streaming multiple string literals is rare enough in practice, hence
that change makes sense in general. But it seems people were
incidentally relying on this for having line breaks after string
literals that ended with `\n`.

This patch tries to restore that behavior to prevent regressions in the
upcoming LLVM release, until we can implement some configuration based
approach as proposed in https://github.com/llvm/llvm-project/pull/69859.
---
 clang/lib/Format/TokenAnnotator.cpp   |  8 
 clang/unittests/Format/TokenAnnotatorTest.cpp | 10 ++
 2 files changed, 18 insertions(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3ac3aa3c5e3a22..27c6bb0ef6fe4f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5151,6 +5151,14 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
&Line,
 return true;
   if (Left.IsUnterminatedLiteral)
 return true;
+  if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
+  // FIXME: Breaking after newlines seems useful in general. Turn this into
+  // an option and Recognize more cases like endl etc, and break 
independent
+  // of what comes after operator lessless.
+  Right.Next->is(tok::string_literal) &&
+  Left.TokenText.ends_with("\\n\"")) {
+return true;
+  }
   if (Right.is(TT_RequiresClause)) {
 switch (Style.RequiresClausePosition) {
 case FormatStyle::RCPS_OwnLine:
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 2cafc0438ffb46..cd3ffb611839d2 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -10,6 +10,7 @@
 
 #include "FormatTestUtils.h"
 #include "TestLexer.h"
+#include "clang/Basic/TokenKinds.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -2499,6 +2500,15 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
   EXPECT_BRACE_KIND(Tokens[6], BK_Block);
 }
 
+TEST_F(TokenAnnotatorTest, StreamOperator) {
+  auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_FALSE(Tokens[1]->MustBreakBefore);
+  EXPECT_FALSE(Tokens[3]->MustBreakBefore);
+  // Only break between string literals if the former ends with \n.
+  EXPECT_TRUE(Tokens[5]->MustBreakBefore);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang

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


[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)

2024-01-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: kadir çetinkaya (kadircet)


Changes

This restores a subset of functionality that was forego in
d68826dfbd987377ef6771d40c1d984f09ee3b9e.

Streaming multiple string literals is rare enough in practice, hence
that change makes sense in general. But it seems people were
incidentally relying on this for having line breaks after string
literals that ended with `\n`.

This patch tries to restore that behavior to prevent regressions in the
upcoming LLVM release, until we can implement some configuration based
approach as proposed in https://github.com/llvm/llvm-project/pull/69859.


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


2 Files Affected:

- (modified) clang/lib/Format/TokenAnnotator.cpp (+8) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+10) 


``diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3ac3aa3c5e3a22..27c6bb0ef6fe4f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5151,6 +5151,14 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
&Line,
 return true;
   if (Left.IsUnterminatedLiteral)
 return true;
+  if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
+  // FIXME: Breaking after newlines seems useful in general. Turn this into
+  // an option and Recognize more cases like endl etc, and break 
independent
+  // of what comes after operator lessless.
+  Right.Next->is(tok::string_literal) &&
+  Left.TokenText.ends_with("\\n\"")) {
+return true;
+  }
   if (Right.is(TT_RequiresClause)) {
 switch (Style.RequiresClausePosition) {
 case FormatStyle::RCPS_OwnLine:
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 2cafc0438ffb46..cd3ffb611839d2 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -10,6 +10,7 @@
 
 #include "FormatTestUtils.h"
 #include "TestLexer.h"
+#include "clang/Basic/TokenKinds.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -2499,6 +2500,15 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
   EXPECT_BRACE_KIND(Tokens[6], BK_Block);
 }
 
+TEST_F(TokenAnnotatorTest, StreamOperator) {
+  auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_FALSE(Tokens[1]->MustBreakBefore);
+  EXPECT_FALSE(Tokens[3]->MustBreakBefore);
+  // Only break between string literals if the former ends with \n.
+  EXPECT_TRUE(Tokens[5]->MustBreakBefore);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang

``




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


[clang] [clang-format] unexpected break after binOp '<<' (PR #69859)

2024-01-03 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

sent out https://github.com/llvm/llvm-project/pull/76795 for implementation

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


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Balázs Kéri via cfe-commits

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

LGTM (if the tests pass)

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


[flang] [llvm] [libcxx] [lld] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-03 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/17] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[llvm] [clang-tools-extra] [clang] [clang] Accept recursive non-dependent calls to functions with deduced return type (PR #75456)

2024-01-03 Thread Mariya Podchishchaeva via cfe-commits

Fznamznon wrote:

Thanks @erichkeane for review!
@zygoloid , I would really appreciate if you took a look as well. Otherwise 
I'll try to merge in a couple of days.

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


[clang] [clang-format] unexpected break after binOp '<<' (PR #69859)

2024-01-03 Thread Tsarkov Maksim via cfe-commits

s1Sharp wrote:

> @s1Sharp are there any conclusions here? our code also incidentally relied on 
> having new lines between string literals, mostly for the sake of having a 
> line break after string literals that end with `\n`.
> 
> what do people think about restoring the functionality to break after string 
> literals that end with `\n`? 
> https://github.com/search?q=%2F%5C%5Cn%5C%22%5Cn%5Cs*%3C%3C%5C+%5C%22%2F+language%3AC%2B%2B+&type=code&ref=advsearch
>  shows a lot of examples of such pattern, so i feel like having that without 
> an option initially easy relatively easy and likely to preserve 
> clang-format's behavior for a lot of existing code for the next release. 
> afterwards we can discuss introducing more options again.

First, I want to show how this works with the current code.
As an example, here are a couple of output statements.

.clang-format:
```
Language: Cpp
BasedOnStyle: Google

IndentWidth: 4

ColumnLimit: 70
```

before clang-format:
```C++
  cout << "hello\n" << "World\n" << "HELLO" << "world" << "hello" << "World" << 
"HELLO" << "world" << "hello" << "World" << "HELLO" << "world";

  cout << "hello" << std::endl << "World" << "hello" << '\n' << "another hello" 
<< "world";

  cout << "hello\n"
   << "World" << std::endl
   << "HELLO" << "world";
```

after clang-format:
```C++
cout << "hello\n"
 << "World\n"
 << "HELLO" << "world" << "hello" << "World" << "HELLO"
 << "world" << "hello" << "World" << "HELLO" << "world";

cout << "hello" << std::endl
 << "World" << "hello" << '\n'
 << "another hello" << "world";

cout << "hello\n" << "World" << std::endl << "HELLO" << "world";

```

A bit unexpected results, right? Formatting applies to single-line expressions 
and breaks to another line after the \n and std::endl characters. And if the 
code has already been manually formatted (as in 3rd cout), then clang-format 
groups this code into a single-line expression.

I agree with your suggestion that to maintain compatibility with the old 
behavior of clang-format.


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


[clang] [clang][ASTImporter][StructuralEquivalence] improve StructuralEquivalence on recordType (PR #76226)

2024-01-03 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/76226

>From 77976022454865df8bee1e4a09682a16658ed035 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Fri, 22 Dec 2023 17:56:32 +0800
Subject: [PATCH] [clang][ASTImporter][StructuralEquivalence] improve
 StructuralEquivalence on recordType

---
 clang/lib/AST/ASTStructuralEquivalence.cpp| 13 ---
 .../AST/StructuralEquivalenceTest.cpp | 23 +++
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp 
b/clang/lib/AST/ASTStructuralEquivalence.cpp
index 6bb4bf14b873d7..277532696305e3 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1463,8 +1463,9 @@ 
IsStructurallyEquivalentLambdas(StructuralEquivalenceContext &Context,
 }
 
 /// Determine if context of a class is equivalent.
-static bool IsRecordContextStructurallyEquivalent(RecordDecl *D1,
-  RecordDecl *D2) {
+static bool
+IsRecordContextStructurallyEquivalent(StructuralEquivalenceContext &Context,
+  RecordDecl *D1, RecordDecl *D2) {
   // The context should be completely equal, including anonymous and inline
   // namespaces.
   // We compare objects as part of full translation units, not subtrees of
@@ -1491,6 +1492,12 @@ static bool 
IsRecordContextStructurallyEquivalent(RecordDecl *D1,
 return false;
 }
 
+if (auto *D1Spec = dyn_cast(DC1)) {
+  auto *D2Spec = dyn_cast(DC2);
+  if (!IsStructurallyEquivalent(Context, D1Spec, D2Spec))
+return false;
+}
+
 DC1 = DC1->getParent()->getNonTransparentContext();
 DC2 = DC2->getParent()->getNonTransparentContext();
   }
@@ -1544,7 +1551,7 @@ static bool 
IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
   // If the records occur in different context (namespace), these should be
   // different. This is specially important if the definition of one or both
   // records is missing.
-  if (!IsRecordContextStructurallyEquivalent(D1, D2))
+  if (!IsRecordContextStructurallyEquivalent(Context, D1, D2))
 return false;
 
   // If both declarations are class template specializations, we know
diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp 
b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 44d950cfe758f1..22c7b82460f0a0 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1024,6 +1024,29 @@ TEST_F(StructuralEquivalenceRecordContextTest, 
TransparentContextInNamespace) {
   EXPECT_TRUE(testStructuralMatch(Decls));
 }
 
+TEST_F(StructuralEquivalenceRecordContextTest,
+   ClassTemplateSpecializationContext) {
+  std::string Code =
+  R"(
+  template  struct O {
+struct M {};
+  };
+  )";
+  auto t = makeDecls(Code + R"(
+  typedef O::M MT1;
+  MT1 A;
+  )",
+  Code + R"(
+  namespace {
+struct I {};
+  } // namespace
+  typedef O::M MT2;
+  MT2 A;
+  )",
+  Lang_CXX11, varDecl(hasName("A")));
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
 TEST_F(StructuralEquivalenceTest, NamespaceOfRecordMember) {
   auto Decls = makeNamedDecls(
   R"(

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


[clang] [clang][ASTImporter][StructuralEquivalence] improve StructuralEquivalence on recordType (PR #76226)

2024-01-03 Thread Qizhi Hu via cfe-commits


@@ -1491,6 +1492,12 @@ static bool 
IsRecordContextStructurallyEquivalent(RecordDecl *D1,
 return false;
 }
 
+if (auto *D1Spec = dyn_cast(DC1)) {
+  auto *D2Spec = dyn_cast(DC2);

jcsxky wrote:

revert

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


[clang-tools-extra] [flang] [llvm] [Flang] make ppc unsupported for x86_64 test case (NFC) (PR #73903)

2024-01-03 Thread via cfe-commits

https://github.com/madanial0 updated 
https://github.com/llvm/llvm-project/pull/73903

>From 272167eb482838cd432f33bffc01d43562adb873 Mon Sep 17 00:00:00 2001
From: Mark Danial 
Date: Thu, 30 Nov 2023 02:14:20 -0500
Subject: [PATCH] [Flang] make ppc unsupported for x86_64 testcase (NFC)

---
 flang/test/Semantics/kinds04_q10.f90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/test/Semantics/kinds04_q10.f90 
b/flang/test/Semantics/kinds04_q10.f90
index 07da32e92c0f78..c94235f859d618 100644
--- a/flang/test/Semantics/kinds04_q10.f90
+++ b/flang/test/Semantics/kinds04_q10.f90
@@ -7,7 +7,7 @@
 !
 ! This test is for x86_64, where exponent-letter 'q' is for
 ! 10-byte extended precision
-! UNSUPPORTED: system-windows
+! UNSUPPORTED: system-windows, target=powerpc{{.*}}
 
 subroutine s(var)
   real :: realvar1 = 4.0E6_4

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


[clang-tools-extra] [flang] [llvm] [Flang] make ppc unsupported for x86_64 test case (NFC) (PR #73903)

2024-01-03 Thread via cfe-commits

https://github.com/madanial0 updated 
https://github.com/llvm/llvm-project/pull/73903

>From 272167eb482838cd432f33bffc01d43562adb873 Mon Sep 17 00:00:00 2001
From: Mark Danial 
Date: Thu, 30 Nov 2023 02:14:20 -0500
Subject: [PATCH] [Flang] make ppc unsupported for x86_64 testcase (NFC)

---
 flang/test/Semantics/kinds04_q10.f90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/test/Semantics/kinds04_q10.f90 
b/flang/test/Semantics/kinds04_q10.f90
index 07da32e92c0f78..c94235f859d618 100644
--- a/flang/test/Semantics/kinds04_q10.f90
+++ b/flang/test/Semantics/kinds04_q10.f90
@@ -7,7 +7,7 @@
 !
 ! This test is for x86_64, where exponent-letter 'q' is for
 ! 10-byte extended precision
-! UNSUPPORTED: system-windows
+! UNSUPPORTED: system-windows, target=powerpc{{.*}}
 
 subroutine s(var)
   real :: realvar1 = 4.0E6_4

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


[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

2024-01-03 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov created 
https://github.com/llvm/llvm-project/pull/76804

This addresses a problem with formatting attributes. Some context:
- 199fc973ced20016b04ba540cf63a1d4914fa513 changed `isStartOfName` to fix 
problems inside macro directives (judging by the added tests), but this 
behavior changed formatting of attribute macros in an undesirable way.
- efeb546865c233dfa7706ee0316c676de9f69897 changed Google format style to fix 
some widely used attributes.

Instead of changing the format style, this commit specializes behavior 
introduced in 199fc973ced20016b04ba540cf63a1d4914fa513 to macro directives. 
This seems to work well in both cases.

Also update the test with two `GUARDED_BY` directives. While the formatting 
after efeb546865c233dfa7706ee0316c676de9f69897 seems better, this case is rare 
enough to not warrant the extra complexity. We are reverting it back to the 
state it had before
efeb546865c233dfa7706ee0316c676de9f69897.

>From d8598a382fb1496a96d6ff8317c06cf73606ad84 Mon Sep 17 00:00:00 2001
From: Ilya Biryukov 
Date: Wed, 3 Jan 2024 11:07:17 +0100
Subject: [PATCH] [Format] Fix isStartOfName to recognize attributes

This addresses a problem with formatting attributes in a different way
as before. For some context:
- 199fc973ced20016b04ba540cf63a1d4914fa513 changed `isStartOfName` to
  fix problems inside macro directives (judging by the added tests), but
  this behavior changed formatting of attribute macros in an undesirable
  way.
- efeb546865c233dfa7706ee0316c676de9f69897 changed Google format style
  to fix some widely used attributes.

Instead of changing the format style, this commit specializes behavior
introduced in 199fc973ced20016b04ba540cf63a1d4914fa513 to macro
directives. This seems to work well in both cases.

Also update the test with two `GUARDED_BY` directives. While the
formatting after efeb546865c233dfa7706ee0316c676de9f69897 seems better,
this case is rare enough to not warrant the extra complexity. We are
reverting it back to the state it had before
efeb546865c233dfa7706ee0316c676de9f69897.
---
 clang/lib/Format/Format.cpp | 2 --
 clang/lib/Format/TokenAnnotator.cpp | 3 ++-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f798d555bf9929..38974f578fe1d2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1698,8 +1698,6 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind 
Language) {
   /*BasedOnStyle=*/"google",
   },
   };
-  GoogleStyle.AttributeMacros.push_back("GUARDED_BY");
-  GoogleStyle.AttributeMacros.push_back("ABSL_GUARDED_BY");
 
   GoogleStyle.SpacesBeforeTrailingComments = 2;
   GoogleStyle.Standard = FormatStyle::LS_Auto;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3ac3aa3c5e3a22..94fe5b21cfc6e6 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2209,7 +2209,8 @@ class AnnotatingParser {
 (!NextNonComment && !Line.InMacroBody) ||
 (NextNonComment &&
  (NextNonComment->isPointerOrReference() ||
-  NextNonComment->isOneOf(tok::identifier, tok::string_literal {
+  (Line.InPragmaDirective &&
+   NextNonComment->isOneOf(tok::identifier, tok::string_literal) {
   return false;
 }
 

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


[libcxx] [flang] [openmp] [llvm] [lld] [clang] [mlir] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-03 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/18] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, ios_base::o

[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

2024-01-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Ilya Biryukov (ilya-biryukov)


Changes

This addresses a problem with formatting attributes. Some context:
- 199fc973ced20016b04ba540cf63a1d4914fa513 changed `isStartOfName` to fix 
problems inside macro directives (judging by the added tests), but this 
behavior changed formatting of attribute macros in an undesirable way.
- efeb546865c233dfa7706ee0316c676de9f69897 changed Google format style to fix 
some widely used attributes.

Instead of changing the format style, this commit specializes behavior 
introduced in 199fc973ced20016b04ba540cf63a1d4914fa513 to macro directives. 
This seems to work well in both cases.

Also update the test with two `GUARDED_BY` directives. While the formatting 
after efeb546865c233dfa7706ee0316c676de9f69897 seems better, this case is rare 
enough to not warrant the extra complexity. We are reverting it back to the 
state it had before
efeb546865c233dfa7706ee0316c676de9f69897.

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


2 Files Affected:

- (modified) clang/lib/Format/Format.cpp (-2) 
- (modified) clang/lib/Format/TokenAnnotator.cpp (+2-1) 


``diff
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f798d555bf9929..38974f578fe1d2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1698,8 +1698,6 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind 
Language) {
   /*BasedOnStyle=*/"google",
   },
   };
-  GoogleStyle.AttributeMacros.push_back("GUARDED_BY");
-  GoogleStyle.AttributeMacros.push_back("ABSL_GUARDED_BY");
 
   GoogleStyle.SpacesBeforeTrailingComments = 2;
   GoogleStyle.Standard = FormatStyle::LS_Auto;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3ac3aa3c5e3a22..94fe5b21cfc6e6 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2209,7 +2209,8 @@ class AnnotatingParser {
 (!NextNonComment && !Line.InMacroBody) ||
 (NextNonComment &&
  (NextNonComment->isPointerOrReference() ||
-  NextNonComment->isOneOf(tok::identifier, tok::string_literal {
+  (Line.InPragmaDirective &&
+   NextNonComment->isOneOf(tok::identifier, tok::string_literal) {
   return false;
 }
 

``




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


[clang] [clang-format] Fix more bugs in isStartOfName() (PR #72336)

2024-01-03 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

I have played around with specializing new behavior to macro directives and it 
seems work well, I have sent #76804 for review.

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


[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

2024-01-03 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov updated 
https://github.com/llvm/llvm-project/pull/76804

>From d8598a382fb1496a96d6ff8317c06cf73606ad84 Mon Sep 17 00:00:00 2001
From: Ilya Biryukov 
Date: Wed, 3 Jan 2024 11:07:17 +0100
Subject: [PATCH 1/2] [Format] Fix isStartOfName to recognize attributes

This addresses a problem with formatting attributes in a different way
as before. For some context:
- 199fc973ced20016b04ba540cf63a1d4914fa513 changed `isStartOfName` to
  fix problems inside macro directives (judging by the added tests), but
  this behavior changed formatting of attribute macros in an undesirable
  way.
- efeb546865c233dfa7706ee0316c676de9f69897 changed Google format style
  to fix some widely used attributes.

Instead of changing the format style, this commit specializes behavior
introduced in 199fc973ced20016b04ba540cf63a1d4914fa513 to macro
directives. This seems to work well in both cases.

Also update the test with two `GUARDED_BY` directives. While the
formatting after efeb546865c233dfa7706ee0316c676de9f69897 seems better,
this case is rare enough to not warrant the extra complexity. We are
reverting it back to the state it had before
efeb546865c233dfa7706ee0316c676de9f69897.
---
 clang/lib/Format/Format.cpp | 2 --
 clang/lib/Format/TokenAnnotator.cpp | 3 ++-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f798d555bf9929..38974f578fe1d2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1698,8 +1698,6 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind 
Language) {
   /*BasedOnStyle=*/"google",
   },
   };
-  GoogleStyle.AttributeMacros.push_back("GUARDED_BY");
-  GoogleStyle.AttributeMacros.push_back("ABSL_GUARDED_BY");
 
   GoogleStyle.SpacesBeforeTrailingComments = 2;
   GoogleStyle.Standard = FormatStyle::LS_Auto;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3ac3aa3c5e3a22..94fe5b21cfc6e6 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2209,7 +2209,8 @@ class AnnotatingParser {
 (!NextNonComment && !Line.InMacroBody) ||
 (NextNonComment &&
  (NextNonComment->isPointerOrReference() ||
-  NextNonComment->isOneOf(tok::identifier, tok::string_literal {
+  (Line.InPragmaDirective &&
+   NextNonComment->isOneOf(tok::identifier, tok::string_literal) {
   return false;
 }
 

>From 6ba6f35e97af2299bbd5364fd535f31962a7eb4c Mon Sep 17 00:00:00 2001
From: Ilya Biryukov 
Date: Wed, 3 Jan 2024 11:22:26 +0100
Subject: [PATCH 2/2] Update tests

---
 clang/unittests/Format/FormatTest.cpp | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 881993ede17c3d..fbbeddc29cfb5f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8498,9 +8498,6 @@ TEST_F(FormatTest, 
BreaksFunctionDeclarationsWithTrailingTokens) {
"__attribute__((unused));");
 
   Style = getGoogleStyle();
-  ASSERT_THAT(Style.AttributeMacros,
-  testing::AllOf(testing::Contains("GUARDED_BY"),
- testing::Contains("ABSL_GUARDED_BY")));
 
   verifyFormat(
   "bool 
a\n"
@@ -10093,11 +10090,11 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
getGoogleStyleWithColumns(40));
   verifyFormat("Tttt ppp\n"
"ABSL_GUARDED_BY(mutex1)\n"
-   "ABSL_GUARDED_BY(mutex2);",
+   "ABSL_GUARDED_BY(mutex2);",
getGoogleStyleWithColumns(40));
   verifyFormat("Tt f(int a, int b)\n"
"ABSL_GUARDED_BY(mutex1)\n"
-   "ABSL_GUARDED_BY(mutex2);",
+   "ABSL_GUARDED_BY(mutex2);",
getGoogleStyleWithColumns(40));
   // * typedefs
   verifyGoogleFormat("typedef ATTR(X) char x;");

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


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Ben Shi via cfe-commits

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


[clang] 3db749a - [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (#76671)

2024-01-03 Thread via cfe-commits

Author: Ben Shi
Date: 2024-01-03T18:23:45+08:00
New Revision: 3db749afcb5079dac332942a3e0b258cdb629a02

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

LOG: [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (#76671)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/errno-stdlibraryfunctions.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 6560fd239ce668..20068653d530a3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -2507,10 +2507,13 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 .ArgConstraint(NotNull(ArgNo(0;
 
 // char *mkdtemp(char *template);
-// FIXME: Improve for errno modeling.
 addToFunctionSummaryMap(
 "mkdtemp", Signature(ArgTypes{CharPtrTy}, RetType{CharPtrTy}),
-Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
+Summary(NoEvalCall)
+.Case({ReturnValueCondition(BO_EQ, ArgNo(0))},
+  ErrnoMustNotBeChecked, GenericSuccessMsg)
+.Case({IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg)
+.ArgConstraint(NotNull(ArgNo(0;
 
 // char *getcwd(char *buf, size_t size);
 // FIXME: Improve for errno modeling.

diff  --git a/clang/test/Analysis/errno-stdlibraryfunctions.c 
b/clang/test/Analysis/errno-stdlibraryfunctions.c
index dafda764af9f38..80e14c4e2923ca 100644
--- a/clang/test/Analysis/errno-stdlibraryfunctions.c
+++ b/clang/test/Analysis/errno-stdlibraryfunctions.c
@@ -7,12 +7,9 @@
 // RUN:   -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true
 
 #include "Inputs/errno_var.h"
+#include "Inputs/std-c-library-functions-POSIX.h"
 
-typedef typeof(sizeof(int)) size_t;
-typedef __typeof(sizeof(int)) off_t;
-typedef size_t ssize_t;
-ssize_t send(int sockfd, const void *buf, size_t len, int flags);
-off_t lseek(int fildes, off_t offset, int whence);
+#define NULL ((void *) 0)
 
 void clang_analyzer_warnIfReached();
 void clang_analyzer_eval(int);
@@ -54,3 +51,26 @@ int errno_lseek(int fildes, off_t offset) {
   }
   return 0;
 }
+
+void errno_mkstemp(char *template) {
+  int FD = mkstemp(template);
+  if (FD >= 0) {
+if (errno) {}// expected-warning{{An undefined value 
may be read from 'errno'}}
+close(FD);
+  } else {
+clang_analyzer_eval(FD == -1);   // expected-warning{{TRUE}}
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+if (errno) {}// no warning
+  }
+}
+
+void errno_mkdtemp(char *template) {
+  char *Dir = mkdtemp(template);
+  if (Dir == NULL) {
+clang_analyzer_eval(errno != 0);  // expected-warning{{TRUE}}
+if (errno) {} // no warning
+  } else {
+clang_analyzer_eval(Dir == template); // expected-warning{{TRUE}}
+if (errno) {} // expected-warning{{An undefined 
value may be read from 'errno'}}
+  }
+}



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


[clang-tools-extra] [clang] [coroutines] Do not check coroutine wrappers for skipped function bodies (PR #76729)

2024-01-03 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/76729

>From c0baa45c2541bc688f377a6bd2c9281532b4d541 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Tue, 2 Jan 2024 16:49:28 +0100
Subject: [PATCH 1/2] [coroutines] Do not check coroutine wrappers for skipped
 function bodies

---
 .../clangd/unittests/DiagnosticsTests.cpp | 54 +++
 clang/lib/Sema/SemaDecl.cpp   |  2 +-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 37643e5afa2304..a5744cdd4cbe6f 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -420,6 +420,60 @@ TEST(DiagnosticTest, MakeUnique) {
"no matching constructor for initialization of 'S'")));
 }
 
+TEST(DiagnosticTest, CoroutineInHeader) {
+  StringRef CoroutineH = R"cpp(
+namespace std {
+template 
+struct coroutine_traits { using promise_type = typename Ret::promise_type; };
+
+template 
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(Promise &promise);
+  constexpr void* address() const noexcept;
+};
+template <>
+struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *);
+  constexpr void* address() const noexcept;
+};
+
+struct awaitable {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+} // namespace std
+  )cpp";
+
+  StringRef Header = R"cpp(
+#include "coroutine.h"
+template  struct [[clang::coro_return_type]] Gen {
+  struct promise_type {
+Gen get_return_object() {
+  return {};
+}
+std::awaitable  initial_suspend();
+std::awaitable  final_suspend() noexcept;
+void unhandled_exception();
+void return_value(T t);
+  };
+};
+
+Gen foo_coro(int b) { co_return b; }
+  )cpp";
+  Annotations Main(R"cpp(
+#include "header.hpp"
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["coroutine.h"] = std::string(CoroutineH);
+  TU.AdditionalFiles["header.hpp"] = std::string(Header);
+  TU.ExtraArgs.push_back("--std=c++20");
+  EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+}
+
 TEST(DiagnosticTest, MakeShared) {
   // We usually miss diagnostics from header functions as we don't parse them.
   // std::make_shared is only parsed when --parse-forwarding-functions is set
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ffbe317d559995..8329c00f1d16c1 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15845,7 +15845,7 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
 }
 
 void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
-  if (!FD)
+  if (!FD || FD->hasSkippedBody())
 return;
   RecordDecl *RD = FD->getReturnType()->getAsRecordDecl();
   if (!RD || !RD->getUnderlyingDecl()->hasAttr())

>From a2ac00f74130e0caa47072785fbd650c53a67be6 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 3 Jan 2024 11:25:33 +0100
Subject: [PATCH 2/2] addressed comments and added negative test as well

---
 clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp | 6 --
 clang/lib/Sema/SemaDecl.cpp | 5 ++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index a5744cdd4cbe6f..f302dcf5f09db0 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -465,13 +465,15 @@ template  struct [[clang::coro_return_type]] 
Gen {
 Gen foo_coro(int b) { co_return b; }
   )cpp";
   Annotations Main(R"cpp(
-#include "header.hpp"
+// error-ok
+#include "header.hpp"
+Gen $[[bar_coro]](int b) { return foo_coro(b); }
   )cpp");
   TestTU TU = TestTU::withCode(Main.code());
   TU.AdditionalFiles["coroutine.h"] = std::string(CoroutineH);
   TU.AdditionalFiles["header.hpp"] = std::string(Header);
   TU.ExtraArgs.push_back("--std=c++20");
-  EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
+  EXPECT_THAT(TU.build().getDiagnostics(), 
ElementsAre(hasRange(Main.range(;
 }
 
 TEST(DiagnosticTest, MakeShared) {
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 8329c00f1d16c1..2de631941325fa 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15845,8 +15845,6 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
 }
 
 void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
-  if (!FD || FD->hasSkippedBody())
-return;
   RecordDecl *RD = FD->getReturnType()->getAsRecordDecl();
   if (!RD || !RD->getUnderlyingDecl()->hasAttr())
 return;
@@ -15869,7 +15867,

[clang] [clang][analyzer] Support 'fdopen' in the StreamChecker (PR #76776)

2024-01-03 Thread Balázs Kéri via cfe-commits

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


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


[clang-tools-extra] [clang] [coroutines] Do not check coroutine wrappers for skipped function bodies (PR #76729)

2024-01-03 Thread Utkarsh Saxena via cfe-commits


@@ -15845,7 +15845,7 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
 }
 
 void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
-  if (!FD)
+  if (!FD || FD->hasSkippedBody())

usx95 wrote:

Moved the check to calling code. `CheckCompletedCoroutineBody` suffers from the 
same problem, i.e., use of `FSI->isCoroutine()` is invalid. So both coroutine 
related actions are now behind this check.

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


[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

2024-01-03 Thread kadir çetinkaya via cfe-commits

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

can you also add a test to clang/unittests/Format/TokenAnnotatorTest.cpp that 
ensures trailing attribute-like macros receive `StartOfName` annotation to make 
sure we don't regress the signal in the future?

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


[lldb] [clang-tools-extra] [flang] [clang] [libc] [llvm] [compiler-rt] [libcxx] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via cfe-commits

yi-wu-arm wrote:

Hi @klausler , any thought of this patch? Thank in advance!

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


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Balazs Benics via cfe-commits

steakhal wrote:

No release notes?

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


[clang] [llvm] [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs (PR #76777)

2024-01-03 Thread Alexander Theißen via cfe-commits

athei wrote:

> What was the last bit of discussion on the phabricator review? I can no 
> longer access it.

It was basically just waiting for final approval. The agreement was that it is 
good enough to be merged in as experimental even with unfinalized ABI.

I really hope we can get this in before end of this month to be able to use it 
in rustc.

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


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Ben Shi via cfe-commits

benshi001 wrote:

> No release notes?

Sorry, I forget to pull your modification to my local repo, I will fix this 
soon.

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


[clang-tools-extra] [clangd] Track IWYU pragmas for non-preamble includes (PR #75612)

2024-01-03 Thread Haojian Wu via cfe-commits

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

thanks, looks good.

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


[clang] [clang][analyzer][NFC] Improve release note (PR #76805)

2024-01-03 Thread Ben Shi via cfe-commits

https://github.com/benshi001 created 
https://github.com/llvm/llvm-project/pull/76805

None

>From c037cab9ef925d902a34a173244826e5cf797800 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Wed, 3 Jan 2024 18:50:16 +0800
Subject: [PATCH] [clang][analyzer][NFC] Improve release note

---
 clang/docs/ReleaseNotes.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0c8fec691bf3c9..e00fc5ba791690 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1127,9 +1127,10 @@ Improvements
 
 
 - Improved the ``unix.StdCLibraryFunctions`` checker by modeling more
-  functions like ``send``, ``recv``, ``readlink``, ``fflush`` and
+  functions like ``send``, ``recv``, ``readlink``, ``fflush``, ``mkdtemp`` and
   ``errno`` behavior.
   (`52ac71f92d38 
`_,
+  `#76671 `_,
   `#71373 `_,
   `#76557 `_,
   `#71392 `_)

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


[clang] [clang][analyzer][NFC] Improve release note (PR #76805)

2024-01-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ben Shi (benshi001)


Changes



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


1 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0c8fec691bf3c9..e00fc5ba791690 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1127,9 +1127,10 @@ Improvements
 
 
 - Improved the ``unix.StdCLibraryFunctions`` checker by modeling more
-  functions like ``send``, ``recv``, ``readlink``, ``fflush`` and
+  functions like ``send``, ``recv``, ``readlink``, ``fflush``, ``mkdtemp`` and
   ``errno`` behavior.
   (`52ac71f92d38 
`_,
+  `#76671 `_,
   `#71373 `_,
   `#76557 `_,
   `#71392 `_)

``




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


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Ben Shi via cfe-commits

benshi001 wrote:

> No release notes?

I have created another PR to add the miss release note. 
https://github.com/llvm/llvm-project/pull/76805


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


[clang] [clang][analyzer][NFC] Improve release note (PR #76805)

2024-01-03 Thread Balazs Benics via cfe-commits

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


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


[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)

2024-01-03 Thread Tsarkov Maksim via cfe-commits

s1Sharp wrote:

It seems your changes remain compatible with the old clang-format behavior.
Сode looks quite correct

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


[clang] Add SPIRV support to HIPAMD toolchain (PR #75357)

2024-01-03 Thread Henry Linjamäki via cfe-commits

linehill wrote:

> > Perhaps we should consider prefixing it in some way (e.g. `hip-spirv` or 
> > `amd-spirv`) that leaves the door open for some special handling (enable a 
> > particular set of extensions only for amdgpu targeting SPIRV, try to deal 
> > with missing builtins etc.) / flexibility?
> 
> I think amd-spirv may be a good choice since spirv itself is ambiguous about 
> which HIP toolchain to choose since there are two HIP toolchains that support 
> SPIRV: HIPAMD and HIPSPV.

> > I wonder if `-mcpu` is the correct way to encode this. Targeting SPIR-V is 
> > more like the triple than the architecture as far as I'm aware.
> 
> I will see whether I can use triple instead.

How about using `--offload=` which can take a target triple? E.g.

* `--offload=spirv64-amd` or something like that: pick HIPAMD tool chain.
* `--offload=spirv64`: pick HIPSPV tool chain.

And also remove this 
[limitation](https://github.com/llvm/llvm-project/blob/5fc712c4bbe84e6cbaa1f7d2a0300f613f11b0c3/clang/lib/Driver/Driver.cpp#L3130-L3136)
 if you want `--offload` to work along with `--offload-arch`. 

Or alternatively allow multiple `--offload` options, deprecate `--offload-arch` 
and use `--offload` instead. For convenience and easy transition, options like 
`--offload=` could be allowed where the `` is treated as 
an alias for an offload target (E.g. `--offload=gfx900` could imply 
`--offload=amdgcn-amd-amdhsa:gfx900` or something like that).


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


[clang] [clang-tools-extra] [coroutines] Do not check coroutine wrappers for skipped function bodies (PR #76729)

2024-01-03 Thread Ilya Biryukov via cfe-commits


@@ -15845,7 +15845,7 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
 }
 
 void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
-  if (!FD)
+  if (!FD || FD->hasSkippedBody())

ilya-biryukov wrote:

Nice! Thanks, this definitely looks much better now!

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


[clang] [clang-tools-extra] [coroutines] Do not check coroutine wrappers for skipped function bodies (PR #76729)

2024-01-03 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov approved this pull request.


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


[clang] [C++20] [Modules] Introduce reduced BMI (PR #75894)

2024-01-03 Thread Iain Sandoe via cfe-commits

iains wrote:

@ChuanqiXu9 very sorry for the slow review.  It would help me if the design was 
described in the commit message instead of trying to deduce it from the patch 
(maybe it's in a thread somewhere - so a cross-reference would help).

two immediate questions and one observation:

- I see you are using a multiplex consumer (actually, for some reason, I 
thought you were objecting to that part of my design); does this mean that your 
proposed solution can emit both the object and the reduced BMI from a single 
compilation job?

- I was concerned from earlier conversations that this design might require a 
codegen back end to be instantiated to allow the reduced BMI (which would be 
bad for --precompile/-fmodule-only type jobs). Any comments?

- It would be better to avoid introducing more layering violations but, as we 
discussed in face-to-face meetings, I have less concern on the output side.  It 
still seems to me that the best model is one where we have AST transforms (that 
very likely need Sema to be correct) and then the serializer is a simple as 
possible.

so  something like

raw AST   > codegen (when required)
   +
   + => AST transforms > BMI output.

As I understand the patch you are combining the transform with the output?


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


[clang-tools-extra] aba40fb - [coroutines] Do not check coroutine wrappers for skipped function bodies (#76729)

2024-01-03 Thread via cfe-commits

Author: Utkarsh Saxena
Date: 2024-01-03T12:41:10+01:00
New Revision: aba40fb34a27f1d36b4b541bf04d414dca7d1c4c

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

LOG: [coroutines] Do not check coroutine wrappers for skipped function bodies 
(#76729)

Without function bodies, we cannot tell whether a function is a
coroutine or not.
The analysis of coroutine wrappers is not useful when this information
is not available.

We therefore now skip this analysis for skipped function bodies.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 37643e5afa2304..f302dcf5f09db0 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -420,6 +420,62 @@ TEST(DiagnosticTest, MakeUnique) {
"no matching constructor for initialization of 'S'")));
 }
 
+TEST(DiagnosticTest, CoroutineInHeader) {
+  StringRef CoroutineH = R"cpp(
+namespace std {
+template 
+struct coroutine_traits { using promise_type = typename Ret::promise_type; };
+
+template 
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(Promise &promise);
+  constexpr void* address() const noexcept;
+};
+template <>
+struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *);
+  constexpr void* address() const noexcept;
+};
+
+struct awaitable {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+} // namespace std
+  )cpp";
+
+  StringRef Header = R"cpp(
+#include "coroutine.h"
+template  struct [[clang::coro_return_type]] Gen {
+  struct promise_type {
+Gen get_return_object() {
+  return {};
+}
+std::awaitable  initial_suspend();
+std::awaitable  final_suspend() noexcept;
+void unhandled_exception();
+void return_value(T t);
+  };
+};
+
+Gen foo_coro(int b) { co_return b; }
+  )cpp";
+  Annotations Main(R"cpp(
+// error-ok
+#include "header.hpp"
+Gen $[[bar_coro]](int b) { return foo_coro(b); }
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles["coroutine.h"] = std::string(CoroutineH);
+  TU.AdditionalFiles["header.hpp"] = std::string(Header);
+  TU.ExtraArgs.push_back("--std=c++20");
+  EXPECT_THAT(TU.build().getDiagnostics(), 
ElementsAre(hasRange(Main.range(;
+}
+
 TEST(DiagnosticTest, MakeShared) {
   // We usually miss diagnostics from header functions as we don't parse them.
   // std::make_shared is only parsed when --parse-forwarding-functions is set

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ffbe317d559995..2de631941325fa 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15845,8 +15845,6 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
 }
 
 void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
-  if (!FD)
-return;
   RecordDecl *RD = FD->getReturnType()->getAsRecordDecl();
   if (!RD || !RD->getUnderlyingDecl()->hasAttr())
 return;
@@ -15869,7 +15867,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
   sema::AnalysisBasedWarnings::Policy WP = AnalysisWarnings.getDefaultPolicy();
   sema::AnalysisBasedWarnings::Policy *ActivePolicy = nullptr;
 
-  if (getLangOpts().Coroutines) {
+  // If we skip function body, we can't tell if a function is a coroutine.
+  if (getLangOpts().Coroutines && FD && !FD->hasSkippedBody()) {
 if (FSI->isCoroutine())
   CheckCompletedCoroutineBody(FD, Body);
 else



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


[clang] [clang-tools-extra] [coroutines] Do not check coroutine wrappers for skipped function bodies (PR #76729)

2024-01-03 Thread Utkarsh Saxena via cfe-commits

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


[clang] [X86] Emit Warnings for frontend options to enable knl/knm. (PR #75580)

2024-01-03 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

Making avx512f the only case where avx512vl can be disabled doesn't seem like 
too much of a stretch to me - we'd be merely making all avx512 extension 
features depend on avx512vl.

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


[lldb] [polly] [libcxx] [openmp] [libcxxabi] [mlir] [compiler-rt] [clang] [llvm] [clang-tools-extra] [libc] [flang] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-03 Thread Mehdi Amini via cfe-commits

https://github.com/joker-eph approved this pull request.


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


[clang] [Clang] Correctly construct template arguments for file-scope template template parameters (PR #76811)

2024-01-03 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/76811

This fixes the bug introduced by
https://github.com/llvm/llvm-project/commit/6db007a0654ed7a6ed5c3aa3b61a937c19a6bc6b.

We construct placeholder template arguments for template-template parameters to 
avoid mismatching argument substitution since they have different depths with 
their corresponding template arguments. In this case,

```cpp
template  class T> void foo(T);
```

T lies at the depth 0, and C lies at 1. The corresponding argument, of which 
there is exactly one, int, is at depth 0. If we consider the argument as the 
outermost one, then we would end up substituting 'int' into the wrong parameter 
T.

We used to perform such placeholder construction during the context walk-up. In 
the previous patch, we slipped through that inadvertently because we would walk 
up to the parent, which is precisely a FileContext for template-template 
parameters, after adding innermost arguments.

Besides, this patch moves the sanity check up to the context switch. That way, 
we avoid dereferencing null pointers if ND is unspecified.

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

>From 1164c705a8515d39bc9d4404e8523da8876d81cf Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Wed, 3 Jan 2024 19:33:01 +0800
Subject: [PATCH] [Clang] Correctly construct template arguments for file-scope
 template template parameters

This fixes the bug introduced by
https://github.com/llvm/llvm-project/commit/6db007a0654ed7a6ed5c3aa3b61a937c19a6bc6b.

We construct placeholder template arguments for template-template parameters to
avoid mismatching argument substitution since they have different depths
with their corresponding template arguments. In this case,

```cpp
template  class T> void foo(T);
```

T lies at the depth 0, and C lies at 1. The corresponding argument, of which
there is exactly one, int, is at depth 0. If we consider the
argument as the outermost one, then we would end up substituting 'int'
into the wrong parameter T.

We used to perform such placeholder construction during the context walk-up.
In the previous patch, we slipped through that inadvertently because we would
walk up to the parent, which is precisely a FileContext for template-template
parameters, after adding innermost arguments.

Besides, this patch moves the sanity check up to the context switch.
That way, we avoid dereferencing null pointers if ND is unspecified.

Closes https://github.com/llvm/llvm-project/issues/57410.
---
 clang/docs/ReleaseNotes.rst   |  3 +++
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 12 ++---
 .../temp/temp.arg/temp.arg.template/p3-2a.cpp | 25 +++
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0c8fec691bf3c9..7193d711333780 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -843,6 +843,9 @@ Bug Fixes to C++ Support
 - Fix crash when parsing nested requirement. Fixes:
   (`#73112 `_)
 
+- Fix a regression where clang forgets how to substitute into constraints on 
template-template
+  parameters. Fixes: (`#57410 
`_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index df6b40999e645c..4420280efebb86 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -345,15 +345,19 @@ MultiLevelTemplateArgumentList 
Sema::getTemplateInstantiationArgs(
 
   using namespace TemplateInstArgsHelpers;
   const Decl *CurDecl = ND;
+
+  if (!ND)
+CurDecl = Decl::castFromDeclContext(DC);
+
   if (Innermost) {
 Result.addOuterTemplateArguments(const_cast(ND),
  Innermost->asArray(), Final);
-CurDecl = Response::UseNextDecl(ND).NextDecl;
+if (CurDecl->getDeclContext()->isFileContext())
+  if (const auto *TTP = dyn_cast(CurDecl))
+HandleDefaultTempArgIntoTempTempParam(TTP, Result);
+CurDecl = Response::UseNextDecl(CurDecl).NextDecl;
   }
 
-  if (!ND)
-CurDecl = Decl::castFromDeclContext(DC);
-
   while (!CurDecl->isFileContextDecl()) {
 Response R;
 if (const auto *VarTemplSpec =
diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp 
b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
index 449b6232542e24..277935f6b3b2f0 100644
--- a/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
+++ b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
@@ -59,3 +59,28 @@ struct Nothing {};
 
 // FIXME: Wait the standard to clarify the intent.
 template<> template<> Z S5::V;
+
+namespace GH57410 {
+
+template
+concept True = true;
+
+template
+concept False = false; // #False
+
+templa

[clang] [Clang] Correctly construct template arguments for file-scope template template parameters (PR #76811)

2024-01-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

This fixes the bug introduced by
https://github.com/llvm/llvm-project/commit/6db007a0654ed7a6ed5c3aa3b61a937c19a6bc6b.

We construct placeholder template arguments for template-template parameters to 
avoid mismatching argument substitution since they have different depths with 
their corresponding template arguments. In this case,

```cpp
template