[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-01 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 441610.
kito-cheng marked 24 inline comments as done.
kito-cheng added a comment.

Changes:

- Address @craig.topper's comment
- Address @khchen's comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

Files:
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -110,6 +110,7 @@
 void EmitRVVHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitRVVBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
 void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -88,6 +88,7 @@
   GenRISCVVectorHeader,
   GenRISCVVectorBuiltins,
   GenRISCVVectorBuiltinCG,
+  GenRISCVVectorBuiltinSema,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -243,6 +244,8 @@
"Generate riscv_vector_builtins.inc for clang"),
 clEnumValN(GenRISCVVectorBuiltinCG, "gen-riscv-vector-builtin-codegen",
"Generate riscv_vector_builtin_cg.inc for clang"),
+clEnumValN(GenRISCVVectorBuiltinSema, "gen-riscv-vector-builtin-sema",
+   "Generate riscv_vector_builtin_sema.inc for clang"),
 clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
 clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -458,6 +461,9 @@
   case GenRISCVVectorBuiltinCG:
 EmitRVVBuiltinCG(Records, OS);
 break;
+  case GenRISCVVectorBuiltinSema:
+EmitRVVBuiltinSema(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
@@ -29,6 +30,59 @@
 using namespace clang::RISCV;
 
 namespace {
+struct SemaRecord {
+  // Intrinsic name, e.g. vadd_vv
+  std::string Name;
+
+  // Overloaded intrinsic name, could be empty if can be computed from Name
+  // e.g. vadd
+  std::string OverloadedName;
+
+  // Supported type, mask of BasicType
+  unsigned TypeRangeMask;
+
+  // Supported LMUL.
+  unsigned Log2LMULMask;
+
+  // Required extensions for this intrinsic.
+  unsigned RequiredExtension;
+
+  // Prototype for this intrinsic.
+  SmallVector Prototype;
+
+  // Prototype for masked intrinsic.
+  SmallVector MaskedPrototype;
+
+  // Suffix of intrinsic name.
+  SmallVector Suffix;
+
+  // Suffix of overloaded intrinsic name.
+  SmallVector OverloadedSuffix;
+
+  // Number of field, large than 1 if it's segment load/store.
+  unsigned NF;
+};
+
+// Compressed function signature table.
+class SemaSignatureTable {
+private:
+  std::vector SignatureTable;
+
+  void insert(ArrayRef Signature);
+
+public:
+  static constexpr unsigned INVALID_INDEX = (unsigned)-1;
+
+  // Create compressed signature table from SemaRecords.
+  void init(ArrayRef SemaRecords);
+
+  // Query the Signature, return INVALID_INDEX if not found.
+  unsigned getIndex(ArrayRef Signature);
+
+  /// Print signature table in RVVHeader Record to \p OS
+  void print(raw_ostream &OS);
+};
+
 class RVVEmitter {
 private:
   RecordKeeper &Records;
@@ -45,22 +99,22 @@
   /// Emit all the information needed to map builtin -> LLVM IR intrinsic.
   void createCodeGen(raw_ostream &o);
 
+  /// Emit all the information needed by SemaRISCVVectorLookup.cpp.
+  /// We've large number of intrinsic function for RVV, creating a customized
+  /// could speed up the compilation time.
+  void createSema(raw_ostream &o);
+
 private:
-  /// Create all intrinsics and add them to \p Out
-  void crea

[PATCH] D128807: [clang][transformer] Finish plumbing `Note` all the way to the output.

2022-07-01 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

In D128807#3622779 , @ymandel wrote:

> In D128807#3622727 , @li.zhe.hua 
> wrote:
>
>> - A note being a part of an edit seems weird at best. An `ASTEdit` and 
>> `Edit` are fragments of a greater, logical change. That a note should 
>> semantically be associated with the insertion of an open paren "`(`" but not 
>> the close paren "`)`" seems odd to me.
>> - The note takes the location of the edit it is attached to. Perhaps that 
>> could be of some convenience when those coincide, but I don't believe that 
>> should necessarily be the case. I'm imagining notes could be used to point 
>> out //other// parts of the source that are interesting.
>
> Eric, these are great points. Originally, the idea for note (IIRC) came from 
> the observation that sometimes a single match will generate edits in multiple 
> locations, each which deserve a different diagnostic note (perhaps the same 
> text, but appearing at the respective location). The intent was *not* to 
> allow noting the insertion of paren, for example.  So, I think it was a 
> mistake. Yes, sometimes an ASTEdit is a coherent change, but sometimes (as 
> the paren example demonstrates) its just a fragment.
>
> So, from my original intent, I think that we'd just want to support multiple 
> notes per rule, with each keyed on a source range.
>
> Clement -- what was your intended application? That may help clarify.

Thank for the comments.

For my particular case, I just need multiple notes per rule. I don't need them 
to be associated to a particular edit (and in that very particular case, I 
don't even need a source location).
Right now I have a check that is implemented as a transformer check. I want to 
emit an extra note. However, because `transformer` do not support notes I will 
have to rewrite the check to a traditional non-`transformer` one, which is a 
large change and could be a one-liner if `transformer` supported notes.

In terms of the overall design requirements, non-`transformer` checks can have 
multiple notes per rule, associated to a source location (and multiple checks 
are using the note location to point to somewhere else in the code, so that is 
a required feature if we want to be as powerful as the original clang-tidies, 
which I think we do). Notes cannot be associated to a particular `FixitHint`, 
and I'm not sure whether that's useful.

I  went with the design in this patch (notes associated to edits) because:

- it looked like associating a note with an `ASTEdit` was the original intent, 
given that `ASTEdit` already had a `Note` field.
- we can plumb notes inside `Metadata`, but `Metadata` is already used for the 
warning, so that looks a bit more involved.

No strong opinion on that front though :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128807

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-01 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:114
   bool operator>(const PrototypeDescriptor &PD) const {
-return !(PD.PT <= PT && PD.VTM <= VTM && PD.TM <= TM);
+if (PD.PT != PT)
+  return PD.PT > PT;

craig.topper wrote:
> This can be written as
> 
> `return std::tie(PD.PT, PD.VTM, PD.TM) > std::tie(PT, VTM, TM);`
> 
> Though it's still surprising that PD is on the left. This is operator> but 
> the implementation looks more like operator<.
Rewrite as `operator>` and updated the use site, thank!



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:254
+  if (Signature.empty())
+return 0;
+

khchen wrote:
> Does it mean empty Signature always at 0?
> If yes,  maybe we could check the table from Index = 1 in below loop?
Actually empty signature could be indicate into any index, we have hold length 
when we emit the index. 

Add comment to mention that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[clang] 9ac3864 - [ConstExpr] Don't create insertvalue expressions

2022-07-01 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-07-01T09:23:28+02:00
New Revision: 9ac386495d3c9578e04c9aeb07a3d255b8cc8413

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

LOG: [ConstExpr] Don't create insertvalue expressions

In preparation for the removal in D128719, this stops creating
insertvalue constant expressions (well, unless they are directly
used in LLVM IR).

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

Added: 


Modified: 
clang/lib/CodeGen/ItaniumCXXABI.cpp
llvm/include/llvm/Analysis/TargetFolder.h
llvm/include/llvm/IR/ConstantFolder.h
llvm/lib/Analysis/ConstantFolding.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index c41b4192051a3..f0003c4aab78b 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -962,7 +962,9 @@ ItaniumCXXABI::EmitMemberPointerConversion(const CastExpr 
*E,
   else
 dstAdj = llvm::ConstantExpr::getNSWAdd(srcAdj, adj);
 
-  return llvm::ConstantExpr::getInsertValue(src, dstAdj, 1);
+  llvm::Constant *res = ConstantFoldInsertValueInstruction(src, dstAdj, 1);
+  assert(res != nullptr && "Folding must succeed");
+  return res;
 }
 
 llvm::Constant *

diff  --git a/llvm/include/llvm/Analysis/TargetFolder.h 
b/llvm/include/llvm/Analysis/TargetFolder.h
index a360be5313aec..93ac33ce5effe 100644
--- a/llvm/include/llvm/Analysis/TargetFolder.h
+++ b/llvm/include/llvm/Analysis/TargetFolder.h
@@ -133,7 +133,7 @@ class TargetFolder final : public IRBuilderFolder {
 auto *CAgg = dyn_cast(Agg);
 auto *CVal = dyn_cast(Val);
 if (CAgg && CVal)
-  return Fold(ConstantExpr::getInsertValue(CAgg, CVal, IdxList));
+  return ConstantFoldInsertValueInstruction(CAgg, CVal, IdxList);
 return nullptr;
   }
 

diff  --git a/llvm/include/llvm/IR/ConstantFolder.h 
b/llvm/include/llvm/IR/ConstantFolder.h
index 9cf68dc39a652..1243043a64d64 100644
--- a/llvm/include/llvm/IR/ConstantFolder.h
+++ b/llvm/include/llvm/IR/ConstantFolder.h
@@ -123,7 +123,7 @@ class ConstantFolder final : public IRBuilderFolder {
 auto *CAgg = dyn_cast(Agg);
 auto *CVal = dyn_cast(Val);
 if (CAgg && CVal)
-  return ConstantExpr::getInsertValue(CAgg, CVal, IdxList);
+  return ConstantFoldInsertValueInstruction(CAgg, CVal, IdxList);
 return nullptr;
   }
 

diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp 
b/llvm/lib/Analysis/ConstantFolding.cpp
index 01092b4892f6b..b2b071cc662e0 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1093,7 +1093,7 @@ Constant *ConstantFoldInstOperandsImpl(const Value 
*InstOrCE, unsigned Opcode,
   case Instruction::InsertElement:
 return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]);
   case Instruction::InsertValue:
-return ConstantExpr::getInsertValue(
+return ConstantFoldInsertValueInstruction(
 Ops[0], Ops[1], cast(InstOrCE)->getIndices());
   case Instruction::ShuffleVector:
 return ConstantExpr::getShuffleVector(



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


[PATCH] D128792: [ConstExpr] Don't create insertvalue expressions

2022-07-01 Thread Nikita Popov 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 rG9ac386495d3c: [ConstExpr] Don't create insertvalue 
expressions (authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128792

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/lib/Analysis/ConstantFolding.cpp


Index: llvm/lib/Analysis/ConstantFolding.cpp
===
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -1093,7 +1093,7 @@
   case Instruction::InsertElement:
 return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]);
   case Instruction::InsertValue:
-return ConstantExpr::getInsertValue(
+return ConstantFoldInsertValueInstruction(
 Ops[0], Ops[1], cast(InstOrCE)->getIndices());
   case Instruction::ShuffleVector:
 return ConstantExpr::getShuffleVector(
Index: llvm/include/llvm/IR/ConstantFolder.h
===
--- llvm/include/llvm/IR/ConstantFolder.h
+++ llvm/include/llvm/IR/ConstantFolder.h
@@ -123,7 +123,7 @@
 auto *CAgg = dyn_cast(Agg);
 auto *CVal = dyn_cast(Val);
 if (CAgg && CVal)
-  return ConstantExpr::getInsertValue(CAgg, CVal, IdxList);
+  return ConstantFoldInsertValueInstruction(CAgg, CVal, IdxList);
 return nullptr;
   }
 
Index: llvm/include/llvm/Analysis/TargetFolder.h
===
--- llvm/include/llvm/Analysis/TargetFolder.h
+++ llvm/include/llvm/Analysis/TargetFolder.h
@@ -133,7 +133,7 @@
 auto *CAgg = dyn_cast(Agg);
 auto *CVal = dyn_cast(Val);
 if (CAgg && CVal)
-  return Fold(ConstantExpr::getInsertValue(CAgg, CVal, IdxList));
+  return ConstantFoldInsertValueInstruction(CAgg, CVal, IdxList);
 return nullptr;
   }
 
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -962,7 +962,9 @@
   else
 dstAdj = llvm::ConstantExpr::getNSWAdd(srcAdj, adj);
 
-  return llvm::ConstantExpr::getInsertValue(src, dstAdj, 1);
+  llvm::Constant *res = ConstantFoldInsertValueInstruction(src, dstAdj, 1);
+  assert(res != nullptr && "Folding must succeed");
+  return res;
 }
 
 llvm::Constant *


Index: llvm/lib/Analysis/ConstantFolding.cpp
===
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -1093,7 +1093,7 @@
   case Instruction::InsertElement:
 return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]);
   case Instruction::InsertValue:
-return ConstantExpr::getInsertValue(
+return ConstantFoldInsertValueInstruction(
 Ops[0], Ops[1], cast(InstOrCE)->getIndices());
   case Instruction::ShuffleVector:
 return ConstantExpr::getShuffleVector(
Index: llvm/include/llvm/IR/ConstantFolder.h
===
--- llvm/include/llvm/IR/ConstantFolder.h
+++ llvm/include/llvm/IR/ConstantFolder.h
@@ -123,7 +123,7 @@
 auto *CAgg = dyn_cast(Agg);
 auto *CVal = dyn_cast(Val);
 if (CAgg && CVal)
-  return ConstantExpr::getInsertValue(CAgg, CVal, IdxList);
+  return ConstantFoldInsertValueInstruction(CAgg, CVal, IdxList);
 return nullptr;
   }
 
Index: llvm/include/llvm/Analysis/TargetFolder.h
===
--- llvm/include/llvm/Analysis/TargetFolder.h
+++ llvm/include/llvm/Analysis/TargetFolder.h
@@ -133,7 +133,7 @@
 auto *CAgg = dyn_cast(Agg);
 auto *CVal = dyn_cast(Val);
 if (CAgg && CVal)
-  return Fold(ConstantExpr::getInsertValue(CAgg, CVal, IdxList));
+  return ConstantFoldInsertValueInstruction(CAgg, CVal, IdxList);
 return nullptr;
   }
 
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -962,7 +962,9 @@
   else
 dstAdj = llvm::ConstantExpr::getNSWAdd(srcAdj, adj);
 
-  return llvm::ConstantExpr::getInsertValue(src, dstAdj, 1);
+  llvm::Constant *res = ConstantFoldInsertValueInstruction(src, dstAdj, 1);
+  assert(res != nullptr && "Folding must succeed");
+  return res;
 }
 
 llvm::Constant *
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128783: [test] Check for more -fsanitize=array-bounds regressions

2022-07-01 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.



Comment at: clang/test/CodeGen/bounds-checking-fam.c:59
+  // CXX-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}

Another C++-specific behavior: if the bound results from the substitution of a 
template parameter, event if its value is 1 it's currently not considered a FAM


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

https://reviews.llvm.org/D128783

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


[clang] b822efc - [FPEnv] Allow CompoundStmt to keep FP options

2022-07-01 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2022-07-01T14:32:33+07:00
New Revision: b822efc7404bf09ccfdc1ab7657475026966c3b2

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

LOG: [FPEnv] Allow CompoundStmt to keep FP options

AST does not have special nodes for pragmas. Instead a pragma modifies
some state variables of Sema, which in turn results in modified
attributes of AST nodes. This technique applies to floating point
operations as well. Every AST node that can depend on FP options keeps
current set of them.

This technique works well for options like exception behavior or fast
math options. They represent instructions to the compiler how to modify
code generation for the affected nodes. However treatment of FP control
modes has problems with this technique. Modifying FP control mode
(like rounding direction) usually requires operations on hardware, like
writing to control registers. It must be done prior to the first
operation that depends on the control mode. In particular, such
operations are required for implementation of `pragma STDC FENV_ROUND`,
compiler should set up necessary rounding direction at the beginning of
compound statement where the pragma occurs. As there is no representation
for pragmas in AST, the code generation becomes a complicated task in
this case.

To solve this issue FP options are kept inside CompoundStmt. Unlike to FP
options in expressions, these does not affect any operation on FP values,
but only inform the codegen about the FP options that act in the body of
the statement. As all pragmas that modify FP environment may occurs only
at the start of compound statement or at global level, such solution
works for all relevant pragmas. The options are kept as a difference
from the options in the enclosing compound statement or default options,
it helps codegen to set only changed control modes.

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

Added: 
clang/test/AST/ast-dump-pragma-json.c
clang/test/AST/ast-print-fp-pragmas.c

Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/include/clang/AST/Stmt.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Sema/ScopeInfo.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/Stmt.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/Basic/LangOptions.cpp
clang/lib/CodeGen/CGCoroutine.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/AST/ast-dump-fpfeatures.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 5638df42a1c50..ed49e0007a189 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -160,6 +160,7 @@ class JSONNodeDumper
   std::string createPointerRepresentation(const void *Ptr);
   llvm::json::Object createQualType(QualType QT, bool Desugar = true);
   llvm::json::Object createBareDeclRef(const Decl *D);
+  llvm::json::Object createFPOptions(FPOptionsOverride FPO);
   void writeBareDeclRef(const Decl *D);
   llvm::json::Object createCXXRecordDefinitionData(const CXXRecordDecl *RD);
   llvm::json::Object createCXXBaseSpecifier(const CXXBaseSpecifier &BS);
@@ -317,6 +318,7 @@ class JSONNodeDumper
   void VisitGotoStmt(const GotoStmt *GS);
   void VisitWhileStmt(const WhileStmt *WS);
   void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *OACS);
+  void VisitCompoundStmt(const CompoundStmt *IS);
 
   void VisitNullTemplateArgument(const TemplateArgument &TA);
   void VisitTypeTemplateArgument(const TemplateArgument &TA);

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 653ce4b4b90c5..49a66a1ea5b86 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/CapturedStmt.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -128,6 +129,10 @@ class alignas(void *) Stmt {
 
 unsigned : NumStmtBits;
 
+/// True if the compound statement has one or more pragmas that set some
+/// floating-point features.
+unsigned HasFPFeatures : 1;
+
 unsigned NumStmts;
   };
 
@@ -1398,8 +1403,9 @@ class NullStmt : public Stmt {
 };
 
 /// CompoundStmt - This represents a group of statements like { stmt stmt }.
-class C

[PATCH] D123952: [FPEnv] Allow CompoundStmt to keep FP options

2022-07-01 Thread Serge Pavlov 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 rGb822efc7404b: [FPEnv] Allow CompoundStmt to keep FP options 
(authored by sepavloff).

Changed prior to commit:
  https://reviews.llvm.org/D123952?vs=440644&id=441622#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123952

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/AST/ast-dump-pragma-json.c
  clang/test/AST/ast-print-fp-pragmas.c

Index: clang/test/AST/ast-print-fp-pragmas.c
===
--- /dev/null
+++ clang/test/AST/ast-print-fp-pragmas.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
+
+float func_1(float x, float y) {
+#pragma STDC FENV_ACCESS ON
+  if (x != 0) {
+return y;
+  }
+  return x + y;
+}
+
+// CHECK-LABEL: float func_1(float x, float y) {
+// CHECK-NEXT:  #pragma STDC FENV_ACCESS ON
+// CHECK-NEXT:  if (x != 0) {
+// CHECK-NEXT:  return y;
+// CHECK-NEXT:  }
+// CHECK-NEXT:  return x + y;
+// CHECK-NEXT:  }
+
+float func_2(float x, float y) {
+#pragma STDC FENV_ACCESS ON
+  if (x != 0) {
+  #pragma STDC FENV_ACCESS OFF
+return y;
+  }
+  return x + y;
+}
+
+// CHECK-LABEL: float func_2(float x, float y) {
+// CHECK-NEXT:  #pragma STDC FENV_ACCESS ON
+// CHECK-NEXT:  if (x != 0) {
+// CHECK-NEXT:  #pragma STDC FENV_ACCESS OFF
+// CHECK-NEXT:  return y;
+// CHECK-NEXT:  }
+// CHECK-NEXT:  return x + y;
+// CHECK-NEXT:  }
+
+float func_3(float x, float y) {
+#pragma STDC FENV_ROUND FE_DOWNWARD
+  return x + y;
+}
+
+// CHECK-LABEL: float func_3(float x, float y) {
+// CHECK-NEXT:  #pragma STDC FENV_ROUND FE_UPWARD
+// CHECK-NEXT:  return x + y;
+// CHECK-NEXT:  }
+
+float func_4(float x, float y, float z) {
+#pragma STDC FENV_ACCESS ON
+#pragma clang fp exceptions(maytrap)
+#pragma STDC FENV_ROUND FE_UPWARD
+  if (z != 0) {
+  #pragma STDC FENV_ACCESS OFF
+  #pragma STDC FENV_ROUND FE_TOWARDZERO
+return z + x;
+  }
+  return x + y;
+}
+
+// CHECK-LABEL: float func_4(float x, float y, float z) {
+// CHECK-NEXT:  #pragma STDC FENV_ACCESS ON
+// CHECK-NEXT:  #pragma clang fp exceptions(maytrap)
+// CHECK-NEXT:  #pragma STDC FENV_ROUND FE_DOWNWARD
+// CHECK-NEXT:  if (z != 0) {
+// CHECK-NEXT:  #pragma STDC FENV_ACCESS OFF
+// CHECK-NEXT:  #pragma STDC FENV_ROUND FE_TOWARDZERO
+// CHECK-NEXT:  return z + x;
+// CHECK-NEXT:  }
+// CHECK-NEXT:  return x + y;
+// CHECK-NEXT:  }
Index: clang/test/AST/ast-dump-pragma-json.c
===
--- /dev/null
+++ clang/test/AST/ast-dump-pragma-json.c
@@ -0,0 +1,485 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump=json %s | FileCheck %s
+
+float func_16(float x, float y) {
+  #pragma STDC FENV_ROUND FE_TOWARDZERO
+  if (x < 0) {
+#pragma STDC FENV_ROUND FE_UPWARD
+return x - y;
+  }
+  return x + y;
+}
+
+// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
+// using --filters=CompoundStmt
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "CompoundStmt",
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 116,
+// CHECK-NEXT:"col": 33,
+// CHECK-NEXT:"tokLen": 1
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 249,
+// CHECK-NEXT:"line": 10,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 1
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "fpoptions": {
+// CHECK-NEXT:   "ConstRoundingMode": 0
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "IfStmt",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 160,
+// CHECK-NEXT:  "line": 5,
+// CHECK-NEXT:  "col": 3,
+// CHECK-NEXT:  "tokLen": 2
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 231,
+// CHECK-NEXT:  "line": 8,
+// CHECK-NEXT:  "col": 3,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-01 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng marked an inline comment as done.
kito-cheng added a comment.

Oh, have one comment not address yet


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D30538: Add documentation for -fno-strict-aliasing

2022-07-01 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.
Herald added a subscriber: jeroen.dobbelaere.
Herald added a project: All.

Hi, is this commit still valid? Why hasn't it been pushed?


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

https://reviews.llvm.org/D30538

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


[PATCH] D124159: [SimplifyCFG] Thread branches on same condition in more cases (PR54980)

2022-07-01 Thread Han-Kuan Chen via Phabricator via cfe-commits
HanKuanChen added a comment.

HI, the following code get infinite loop after this commit.

  ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
  ; RUN: opt 
-passes="simplifycfg"
 -S < %s | FileCheck %s
  
  define void @_Z10alignedboxl(i1 %cmp.a, i1 %cmp.b, i1 %cmp.c) {
  ; CHECK-LABEL: @_Z10alignedboxl(
  ; CHECK-NEXT:  entry:
  ; CHECK-NEXT:br label [[WHILE_COND:%.*]]
  ; CHECK:   while.cond:
  ; CHECK-NEXT:br i1 [[CMP_A:%.*]], label [[FOR:%.*]], label 
[[WHILE_BODY_THREAD:%.*]]
  ; CHECK:   for.body:
  ; CHECK-NEXT:br i1 [[CMP_B:%.*]], label [[WHILE_BODY:%.*]], label 
[[FOR_BODY:%.*]]
  ; CHECK:   for:
  ; CHECK-NEXT:tail call void @XXX()
  ; CHECK-NEXT:br label [[FOR_BODY]]
  ; CHECK:   while.body:
  ; CHECK-NEXT:br i1 [[CMP_C:%.*]], label [[C_EXIT:%.*]], label [[LAND:%.*]]
  ; CHECK:   while.body.thread:
  ; CHECK-NEXT:br i1 [[CMP_C]], label [[WHILE_COND]], label [[LAND]]
  ; CHECK:   land:
  ; CHECK-NEXT:tail call void @XXX()
  ; CHECK-NEXT:br label [[WHILE_COND]]
  ; CHECK:   c.exit:
  ; CHECK-NEXT:br i1 [[CMP_A]], label [[FOR_D:%.*]], label 
[[WHILE_BODY_THREAD]]
  ; CHECK:   for.d:
  ; CHECK-NEXT:ret void
  ;
  entry:
br label %while.cond
  
  while.cond:   ; preds = %land, 
%while.body.thread, %entry
br i1 %cmp.a, label %for, label %while.body.thread
  
  for.body: ; preds = %for, %for.body
br i1 %cmp.b, label %while.body, label %for.body
  
  for:  ; preds = %while.cond
tail call void @XXX()
br label %for.body
  
  while.body:   ; preds = %for.body
br i1 %cmp.c, label %c.exit, label %land
  
  while.body.thread:; preds = %c.exit, 
%while.cond
br i1 %cmp.c, label %while.cond, label %land
  
  land: ; preds = 
%while.body.thread, %while.body
tail call void @XXX()
br label %while.cond
  
  c.exit:   ; preds = %while.body
br i1 %cmp.a, label %for.d, label %while.cond
  
  for.d:; preds = %c.exit
ret void
  }
  
  declare void @XXX()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124159

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


[clang] 0401fd1 - Fix warning on unhandled enumeration value

2022-07-01 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2022-07-01T15:17:29+07:00
New Revision: 0401fd12d4aa0553347fe34d666fb236d8719173

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

LOG: Fix warning on unhandled enumeration value

Added: 


Modified: 
clang/lib/AST/StmtPrinter.cpp

Removed: 




diff  --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index f2aa8fb2659d..983fd39874f0 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -198,6 +198,8 @@ void StmtPrinter::PrintFPPragmas(CompoundStmt *S) {
 if (!FEnvAccess || EM != LangOptions::FPE_Strict) {
   Indent() << "#pragma clang fp exceptions(";
   switch (FPO.getSpecifiedExceptionModeOverride()) {
+  default:
+break;
   case LangOptions::FPE_Ignore:
 OS << "ignore";
 break;



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


[PATCH] D128119: [clang] enforce instantiation of constexpr template functions

2022-07-01 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

gentle ping o/


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

https://reviews.llvm.org/D128119

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


[PATCH] D128892: [clangd] Also mark output arguments of array subscript expressions

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

Makes sense. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128892

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


[clang] dc34d8d - Revert "[FPEnv] Allow CompoundStmt to keep FP options"

2022-07-01 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2022-07-01T15:42:39+07:00
New Revision: dc34d8df4c48b3a8f474360970cae8a58e6c84f0

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

LOG: Revert "[FPEnv] Allow CompoundStmt to keep FP options"

On some buildbots test `ast-print-fp-pragmas.c` fails, need to investigate it.

This reverts commit 0401fd12d4aa0553347fe34d666fb236d8719173.
This reverts commit b822efc7404bf09ccfdc1ab7657475026966c3b2.

Added: 


Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/include/clang/AST/Stmt.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Sema/ScopeInfo.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/Stmt.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/Basic/LangOptions.cpp
clang/lib/CodeGen/CGCoroutine.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/AST/ast-dump-fpfeatures.cpp

Removed: 
clang/test/AST/ast-dump-pragma-json.c
clang/test/AST/ast-print-fp-pragmas.c



diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index ed49e0007a189..5638df42a1c50 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -160,7 +160,6 @@ class JSONNodeDumper
   std::string createPointerRepresentation(const void *Ptr);
   llvm::json::Object createQualType(QualType QT, bool Desugar = true);
   llvm::json::Object createBareDeclRef(const Decl *D);
-  llvm::json::Object createFPOptions(FPOptionsOverride FPO);
   void writeBareDeclRef(const Decl *D);
   llvm::json::Object createCXXRecordDefinitionData(const CXXRecordDecl *RD);
   llvm::json::Object createCXXBaseSpecifier(const CXXBaseSpecifier &BS);
@@ -318,7 +317,6 @@ class JSONNodeDumper
   void VisitGotoStmt(const GotoStmt *GS);
   void VisitWhileStmt(const WhileStmt *WS);
   void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *OACS);
-  void VisitCompoundStmt(const CompoundStmt *IS);
 
   void VisitNullTemplateArgument(const TemplateArgument &TA);
   void VisitTypeTemplateArgument(const TemplateArgument &TA);

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 49a66a1ea5b86..653ce4b4b90c5 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -19,7 +19,6 @@
 #include "clang/Basic/CapturedStmt.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -129,10 +128,6 @@ class alignas(void *) Stmt {
 
 unsigned : NumStmtBits;
 
-/// True if the compound statement has one or more pragmas that set some
-/// floating-point features.
-unsigned HasFPFeatures : 1;
-
 unsigned NumStmts;
   };
 
@@ -1403,9 +1398,8 @@ class NullStmt : public Stmt {
 };
 
 /// CompoundStmt - This represents a group of statements like { stmt stmt }.
-class CompoundStmt final
-: public Stmt,
-  private llvm::TrailingObjects {
+class CompoundStmt final : public Stmt,
+   private llvm::TrailingObjects 
{
   friend class ASTStmtReader;
   friend TrailingObjects;
 
@@ -1415,49 +1409,27 @@ class CompoundStmt final
   /// The location of the closing "}".
   SourceLocation RBraceLoc;
 
-  CompoundStmt(ArrayRef Stmts, FPOptionsOverride FPFeatures,
-   SourceLocation LB, SourceLocation RB);
+  CompoundStmt(ArrayRef Stmts, SourceLocation LB, SourceLocation RB);
   explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty) {}
 
   void setStmts(ArrayRef Stmts);
 
-  /// Set FPOptionsOverride in trailing storage. Used only by Serialization.
-  void setStoredFPFeatures(FPOptionsOverride F) {
-assert(hasStoredFPFeatures());
-*getTrailingObjects() = F;
-  }
-
-  size_t numTrailingObjects(OverloadToken) const {
-return CompoundStmtBits.NumStmts;
-  }
-
 public:
   static CompoundStmt *Create(const ASTContext &C, ArrayRef Stmts,
-  FPOptionsOverride FPFeatures, SourceLocation LB,
-  SourceLocation RB);
+  SourceLocation LB, SourceLocation RB);
 
   // Build an empty compound statement with a location.
   explicit CompoundStmt(SourceLocation Loc)
   : Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(Loc) {
 CompoundStmtBits.NumStmts = 0;
-CompoundStmtBits.Has

[clang-tools-extra] ac511fd - [clangd] Also mark output arguments of array subscript expressions

2022-07-01 Thread Nathan Ridge via cfe-commits

Author: Christian Kandeler
Date: 2022-07-01T04:45:20-04:00
New Revision: ac511fd4392d0f1fad3852378adf3c80738016b7

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

LOG: [clangd] Also mark output arguments of array subscript expressions

... with the "usedAsMutableReference" semantic token modifier.
It's quite unusual to declare the index parameter of a subscript
operator as a non-const reference type, but arguably that makes it even
more helpful to be aware of it when working with such code.

Reviewed By: nridge

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

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index aafff0ae285fc..5e0e3b2cc7dc8 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -543,9 +543,14 @@ class CollectExtraHighlightings
 // operators as well
 llvm::ArrayRef Args = {E->getArgs(), E->getNumArgs()};
 if (const auto callOp = dyn_cast(E)) {
-  if (callOp->getOperator() != OO_Call)
+  switch (callOp->getOperator()) {
+  case OO_Call:
+  case OO_Subscript:
+Args = Args.drop_front(); // Drop object parameter
+break;
+  default:
 return true;
-  Args = Args.drop_front(); // Drop object parameter
+  }
 }
 
 highlightMutableReferenceArguments(

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index db183d648b5b5..a40a0f92e4a6f 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -742,6 +742,8 @@ sizeof...($TemplateParameter[[Elements]]);
 void operator()(int);
 void operator()(int, int &);
 void operator()(int, int, const int &);
+int &operator[](int &);
+int operator[](int) const;
 };
 void $Function_decl[[fun]](int, const int,
int*, const int*,
@@ -768,9 +770,12 @@ sizeof...($TemplateParameter[[Elements]]);
   [](int&){}($LocalVariable_usedAsMutableReference[[val]]);
   [](const int&){}($LocalVariable[[val]]);
   $Class[[ClassWithOp]] $LocalVariable_decl[[c]];
+  const $Class[[ClassWithOp]] $LocalVariable_decl_readonly[[c2]];
   $LocalVariable[[c]]($LocalVariable[[val]]);
   $LocalVariable[[c]](0, $LocalVariable_usedAsMutableReference[[val]]);
   $LocalVariable[[c]](0, 0, $LocalVariable[[val]]);
+  $LocalVariable[[c]][$LocalVariable_usedAsMutableReference[[val]]];
+  $LocalVariable_readonly[[c2]][$LocalVariable[[val]]];
 }
 struct $Class_decl[[S]] {
   $Class_decl[[S]](int&) {



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


[PATCH] D128892: [clangd] Also mark output arguments of array subscript expressions

2022-07-01 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac511fd4392d: [clangd] Also mark output arguments of array 
subscript expressions (authored by ckandeler, committed by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128892

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -742,6 +742,8 @@
 void operator()(int);
 void operator()(int, int &);
 void operator()(int, int, const int &);
+int &operator[](int &);
+int operator[](int) const;
 };
 void $Function_decl[[fun]](int, const int,
int*, const int*,
@@ -768,9 +770,12 @@
   [](int&){}($LocalVariable_usedAsMutableReference[[val]]);
   [](const int&){}($LocalVariable[[val]]);
   $Class[[ClassWithOp]] $LocalVariable_decl[[c]];
+  const $Class[[ClassWithOp]] $LocalVariable_decl_readonly[[c2]];
   $LocalVariable[[c]]($LocalVariable[[val]]);
   $LocalVariable[[c]](0, $LocalVariable_usedAsMutableReference[[val]]);
   $LocalVariable[[c]](0, 0, $LocalVariable[[val]]);
+  $LocalVariable[[c]][$LocalVariable_usedAsMutableReference[[val]]];
+  $LocalVariable_readonly[[c2]][$LocalVariable[[val]]];
 }
 struct $Class_decl[[S]] {
   $Class_decl[[S]](int&) {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -543,9 +543,14 @@
 // operators as well
 llvm::ArrayRef Args = {E->getArgs(), E->getNumArgs()};
 if (const auto callOp = dyn_cast(E)) {
-  if (callOp->getOperator() != OO_Call)
+  switch (callOp->getOperator()) {
+  case OO_Call:
+  case OO_Subscript:
+Args = Args.drop_front(); // Drop object parameter
+break;
+  default:
 return true;
-  Args = Args.drop_front(); // Drop object parameter
+  }
 }
 
 highlightMutableReferenceArguments(


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -742,6 +742,8 @@
 void operator()(int);
 void operator()(int, int &);
 void operator()(int, int, const int &);
+int &operator[](int &);
+int operator[](int) const;
 };
 void $Function_decl[[fun]](int, const int,
int*, const int*,
@@ -768,9 +770,12 @@
   [](int&){}($LocalVariable_usedAsMutableReference[[val]]);
   [](const int&){}($LocalVariable[[val]]);
   $Class[[ClassWithOp]] $LocalVariable_decl[[c]];
+  const $Class[[ClassWithOp]] $LocalVariable_decl_readonly[[c2]];
   $LocalVariable[[c]]($LocalVariable[[val]]);
   $LocalVariable[[c]](0, $LocalVariable_usedAsMutableReference[[val]]);
   $LocalVariable[[c]](0, 0, $LocalVariable[[val]]);
+  $LocalVariable[[c]][$LocalVariable_usedAsMutableReference[[val]]];
+  $LocalVariable_readonly[[c2]][$LocalVariable[[val]]];
 }
 struct $Class_decl[[S]] {
   $Class_decl[[S]](int&) {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -543,9 +543,14 @@
 // operators as well
 llvm::ArrayRef Args = {E->getArgs(), E->getNumArgs()};
 if (const auto callOp = dyn_cast(E)) {
-  if (callOp->getOperator() != OO_Call)
+  switch (callOp->getOperator()) {
+  case OO_Call:
+  case OO_Subscript:
+Args = Args.drop_front(); // Drop object parameter
+break;
+  default:
 return true;
-  Args = Args.drop_front(); // Drop object parameter
+  }
 }
 
 highlightMutableReferenceArguments(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128783: [test] Check for more -fsanitize=array-bounds regressions

2022-07-01 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 441640.
sberg added a comment.

added test involving template argument substitution


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

https://reviews.llvm.org/D128783

Files:
  clang/test/CodeGen/bounds-checking-fam.c


Index: clang/test/CodeGen/bounds-checking-fam.c
===
--- clang/test/CodeGen/bounds-checking-fam.c
+++ clang/test/CodeGen/bounds-checking-fam.c
@@ -1,5 +1,6 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=array-bounds %s -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-STRICT-0
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=array-bounds -x c++ %s 
-o - | FileCheck %s --check-prefixes=CHECK,CHECK-STRICT-0,CXX,CXX-STRICT-0
 
 /// Before flexible array member was added to C99, many projects use a
 /// one-element array as the last emember of a structure as an alternative.
@@ -15,20 +16,58 @@
   int a[3];
 };
 
-// CHECK-LABEL: define {{.*}} @test_one(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_one{{.*}}(
 int test_one(struct One *p, int i) {
   // CHECK-STRICT-0-NOT: @__ubsan
   return p->a[i] + (p->a)[i];
 }
 
-// CHECK-LABEL: define {{.*}} @test_two(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_two{{.*}}(
 int test_two(struct Two *p, int i) {
   // CHECK-STRICT-0: call void @__ubsan_handle_out_of_bounds_abort(
   return p->a[i] + (p->a)[i];
 }
 
-// CHECK-LABEL: define {{.*}} @test_three(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_three{{.*}}(
 int test_three(struct Three *p, int i) {
   // CHECK-STRICT-0: call void @__ubsan_handle_out_of_bounds_abort(
   return p->a[i] + (p->a)[i];
 }
+
+#define FLEXIBLE 1
+struct Macro {
+  int a[FLEXIBLE];
+};
+
+// CHECK-LABEL: define {{.*}} @{{.*}}test_macro{{.*}}(
+int test_macro(struct Macro *p, int i) {
+  // CHECK-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}
+
+#if defined __cplusplus
+
+struct Base {
+  int b;
+};
+struct NoStandardLayout : Base {
+  int a[1];
+};
+
+// CXX-LABEL: define {{.*}} @{{.*}}test_nostandardlayout{{.*}}(
+int test_nostandardlayout(NoStandardLayout *p, int i) {
+  // CXX-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}
+
+template struct Template {
+  int a[N];
+};
+
+// CXX-LABEL: define {{.*}} @{{.*}}test_template{{.*}}(
+int test_template(Template<1> *p, int i) {
+  // CXX-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}
+
+#endif


Index: clang/test/CodeGen/bounds-checking-fam.c
===
--- clang/test/CodeGen/bounds-checking-fam.c
+++ clang/test/CodeGen/bounds-checking-fam.c
@@ -1,5 +1,6 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=array-bounds %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-STRICT-0
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=array-bounds -x c++ %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-STRICT-0,CXX,CXX-STRICT-0
 
 /// Before flexible array member was added to C99, many projects use a
 /// one-element array as the last emember of a structure as an alternative.
@@ -15,20 +16,58 @@
   int a[3];
 };
 
-// CHECK-LABEL: define {{.*}} @test_one(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_one{{.*}}(
 int test_one(struct One *p, int i) {
   // CHECK-STRICT-0-NOT: @__ubsan
   return p->a[i] + (p->a)[i];
 }
 
-// CHECK-LABEL: define {{.*}} @test_two(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_two{{.*}}(
 int test_two(struct Two *p, int i) {
   // CHECK-STRICT-0: call void @__ubsan_handle_out_of_bounds_abort(
   return p->a[i] + (p->a)[i];
 }
 
-// CHECK-LABEL: define {{.*}} @test_three(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_three{{.*}}(
 int test_three(struct Three *p, int i) {
   // CHECK-STRICT-0: call void @__ubsan_handle_out_of_bounds_abort(
   return p->a[i] + (p->a)[i];
 }
+
+#define FLEXIBLE 1
+struct Macro {
+  int a[FLEXIBLE];
+};
+
+// CHECK-LABEL: define {{.*}} @{{.*}}test_macro{{.*}}(
+int test_macro(struct Macro *p, int i) {
+  // CHECK-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}
+
+#if defined __cplusplus
+
+struct Base {
+  int b;
+};
+struct NoStandardLayout : Base {
+  int a[1];
+};
+
+// CXX-LABEL: define {{.*}} @{{.*}}test_nostandardlayout{{.*}}(
+int test_nostandardlayout(NoStandardLayout *p, int i) {
+  // CXX-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}
+
+template struct Template {
+  int a[N];
+};
+
+// CXX-LABEL: define {{.*}} @{{.*}}test_template{{.*}}(
+int test_template(Template<1> *p, int i) {
+  // CXX-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128783: [test] Check for more -fsanitize=array-bounds regressions

2022-07-01 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg marked an inline comment as done.
sberg added inline comments.



Comment at: clang/test/CodeGen/bounds-checking-fam.c:59
+  // CXX-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}

serge-sans-paille wrote:
> Another C++-specific behavior: if the bound results from the substitution of 
> a template parameter, event if its value is 1 it's currently not considered a 
> FAM
I hadn't encountered that in the wild, so didn't bother to create a test for 
it; but yes, makes sense to add it too


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

https://reviews.llvm.org/D128783

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


[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-07-01 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 441643.
awarzynski added a comment.

Add a comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/test/Driver/flang/flang.f90
  clang/test/Driver/flang/flang_ucase.F90
  clang/test/Driver/flang/multiple-inputs-mixed.f90
  clang/test/Driver/flang/multiple-inputs.f90
  flang/CMakeLists.txt
  flang/docs/FlangDriver.md
  flang/docs/ImplementingASemanticCheck.md
  flang/docs/Overview.md
  flang/examples/FlangOmpReport/FlangOmpReport.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/CMakeLists.txt
  flang/test/Driver/disable-ext-name-interop.f90
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-version.f90
  flang/test/Driver/escaped-backslash.f90
  flang/test/Driver/fdefault.f90
  flang/test/Driver/flarge-sizes.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/intrinsic-module-path.f90
  flang/test/Driver/macro-def-undef.F90
  flang/test/Driver/missing-input.f90
  flang/test/Driver/predefined-macros-compiler-version.F90
  flang/test/Driver/std2018-wrong.f90
  flang/test/Driver/std2018.f90
  flang/test/Driver/use-module-error.f90
  flang/test/Driver/use-module.f90
  flang/test/Frontend/multiple-input-files.f90
  flang/test/Lower/Intrinsics/command_argument_count.f90
  flang/test/Lower/Intrinsics/exit.f90
  flang/test/Lower/Intrinsics/get_command_argument.f90
  flang/test/Lower/Intrinsics/get_environment_variable.f90
  flang/test/Lower/OpenACC/Todo/acc-declare.f90
  flang/test/Lower/OpenACC/Todo/acc-routine.f90
  flang/test/Lower/OpenMP/Todo/omp-declarative-allocate.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-reduction.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-simd.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-target.f90
  flang/test/lit.cfg.py
  flang/test/lit.site.cfg.py.in
  flang/tools/f18/CMakeLists.txt
  flang/tools/flang-driver/CMakeLists.txt
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -85,14 +85,15 @@
   llvm::InitLLVM x(argc, argv);
   llvm::SmallVector args(argv, argv + argc);
 
-  clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang");
+  clang::driver::ParsedClangName targetandMode =
+  clang::driver::ToolChain::getTargetAndModeFromProgramName(argv[0]);
   std::string driverPath = getExecutablePath(args[0]);
 
   llvm::BumpPtrAllocator a;
   llvm::StringSaver saver(a);
   ExpandResponseFiles(saver, args);
 
-  // Check if flang-new is in the frontend mode
+  // Check if flang is in the frontend mode
   auto firstArg = std::find_if(
   args.begin() + 1, args.end(), [](const char *a) { return a != nullptr; });
   if (firstArg != args.end()) {
@@ -101,7 +102,7 @@
<< "Valid tools include '-fc1'.\n";
   return 1;
 }
-// Call flang-new frontend
+// Call flang frontend
 if (llvm::StringRef(args[1]).startswith("-fc1")) {
   return executeFC1Tool(args);
 }
Index: flang/tools/flang-driver/CMakeLists.txt
===
--- flang/tools/flang-driver/CMakeLists.txt
+++ flang/tools/flang-driver/CMakeLists.txt
@@ -10,7 +10,7 @@
   Support
 )
 
-add_flang_tool(flang-new
+add_flang_tool(flang
   driver.cpp
   fc1_main.cpp
 
@@ -23,23 +23,33 @@
   Fortran_main
 )
 
-target_link_libraries(flang-new
+target_link_libraries(flang
   PRIVATE
   flangFrontend
   flangFrontendTool
 )
 
-clang_target_link_libraries(flang-new
+clang_target_link_libraries(flang
   PRIVATE
   clangDriver
   clangBasic
 )
 
+if(WIN32 AND NOT CYGWIN)
+  # Prevent versioning if the buildhost is targeting for Win32.
+else()
+  set_target_properties(flang PROPERTIES VERSION ${FLANG_EXECUTABLE_VERSION})
+endif()
+
+if (FLANG_USE_LEGACY_NAME)
+  set_target_properties(flang PROPERTIES OUTPUT_NAME flang-new)
+endif()
+
 option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
 
-# Enable support for plugins, which need access to symbols from flang-new
+# Enable support for plugins, which need access to symbols from flang
 if(FLANG_PLUGIN_SUPPORT)
-  export_executable_symbols_for_plugins(flang-new)
+  export_executable_symbols_for_plugins(flang)
 endif()
 
-install(TARGETS flang-new DESTINATION "${CMAKE_INSTALL_BINDIR}")
+install(TARGETS flang DESTINATION "${CMAKE_INSTALL_BINDIR}")
Index: flang/tools/f18/CMakeLists.txt
===
--- flang/tools/f18/CMakeLists.txt
+++ flang/tools/f18/CMakeLists.txt
@@ -35,9 +35,9 @@
   endif()
   add_custom_command(OUTPUT ${base}.mod
 COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
-COMMAND fla

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

2022-07-01 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 441646.
upsj added a comment.

don't add reference hints to unresolved parameter packs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

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

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -174,6 +174,43 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameVariadicDeclaration) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+template 
+void foo(Args&& ...);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicForwarded) {
+  // No hint for anonymous variadic parameter
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicPlain) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
 TEST(ParameterHints, NameInDefinition) {
   // Parameter name picked up from definition if necessary.
   assertParameterHints(R"cpp(
@@ -186,6 +223,36 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, NamePartiallyInDefinition) {
+  // Parameter name picked up from definition if necessary.
+  assertParameterHints(R"cpp(
+void foo(int, int b);
+void bar() {
+  foo($param1[[42]], $param2[[42]]);
+}
+void foo(int a, int) {};
+  )cpp",
+   ExpectedHint{"a: ", "param1"},
+   ExpectedHint{"b: ", "param2"});
+}
+
+TEST(ParameterHints, NameInDefinitionVariadic) {
+  // Parameter name picked up from definition in a resolved forwarded parameter.
+  assertParameterHints(R"cpp(
+void foo(int, int);
+template 
+void bar(Args... args) {
+  foo(args...);
+}
+void baz() {
+  bar($param1[[42]], $param2[[42]]);
+}
+void foo(int a, int b) {};
+  )cpp",
+   ExpectedHint{"a: ", "param1"},
+   ExpectedHint{"b: ", "param2"});
+}
+
 TEST(ParameterHints, NameMismatch) {
   // Prefer name from declaration.
   assertParameterHints(R"cpp(
@@ -258,6 +325,455 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, VariadicForwardedConstructor) {
+  // Name hint for variadic parameter using std::forward in a constructor call
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainConstructor) {
+  // Name hint for variadic parameter in a constructor call
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwardedNewConstructor) {
+  // Name hint for variadic parameter using std::forward in a new expression
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainNewConstructor) {
+  // Name hint for variadic parameter in a new expression
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwarded) {
+  // Name for variadic parameter using std::forward
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+  

[PATCH] D128974: [AST] [Modules] Handle full cases of DefaultArgStorage::setInherited

2022-07-01 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: erichkeane, iains, vsapsai, v.g.vassilev, dblaikie, 
rsmith, jansvoboda11, aaron.ballman.
ChuanqiXu added projects: clang, clang-modules.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a subscriber: cfe-commits.

There were two assertions in DefaultArgStorage::setInherited previously. But 
there are edge cases could hit them actually. One is 
`InheritDefaultArguments.cppm` that I found recently (there is another issue in 
the driver: https://github.com/llvm/llvm-project/issues/56327). Another one is 
pr31469.cpp, which was created fives years ago.

This patch tries to fix the two failures by handling more cases in 
DefaultArgStorage::setInherited. And I added assertions for sameness to keep 
correctness.

This is guaranteed to not introduce any breaking change since it lives in the 
path we wouldn't touch before.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128974

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Modules/InheritDefaultArguments.cppm
  clang/test/Modules/Inputs/PR31469/textual.h

Index: clang/test/Modules/Inputs/PR31469/textual.h
===
--- clang/test/Modules/Inputs/PR31469/textual.h
+++ clang/test/Modules/Inputs/PR31469/textual.h
@@ -4,7 +4,7 @@
   template  class allocator;
   template > class list;
   template  class __list_iterator {
-//template  friend class list; // causes another crash in ASTDeclReader::attachPreviousDecl
+template  friend class list;
 template  friend class list;
   };
   template  class __list_imp {};
Index: clang/test/Modules/InheritDefaultArguments.cppm
===
--- clang/test/Modules/InheritDefaultArguments.cppm
+++ clang/test/Modules/InheritDefaultArguments.cppm
@@ -2,8 +2,8 @@
 // RUN: split-file %s %t
 // RUN: cd %t
 //
-// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
-// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm -verify -fsyntax-only
+// RUN: %clang -std=c++20 %t/A.cppm --precompile -o %t/A.pcm
+// RUN: %clang -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm -Xclang -verify -S -o -
 
 //--- foo.h
 template 
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2643,46 +2643,6 @@
   return false;
 }
 
-static bool hasSameDefaultTemplateArgument(NamedDecl *X, NamedDecl *Y) {
-  ASTContext &C = X->getASTContext();
-  // If the type parameter isn't the same already, we don't need to check the
-  // default argument further.
-  if (!C.isSameTemplateParameter(X, Y))
-return false;
-
-  if (auto *TTPX = dyn_cast(X)) {
-auto *TTPY = cast(Y);
-if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
-  return false;
-
-return C.hasSameType(TTPX->getDefaultArgument(),
- TTPY->getDefaultArgument());
-  }
-
-  if (auto *NTTPX = dyn_cast(X)) {
-auto *NTTPY = cast(Y);
-if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
-  return false;
-
-Expr *DefaultArgumentX = NTTPX->getDefaultArgument()->IgnoreImpCasts();
-Expr *DefaultArgumentY = NTTPY->getDefaultArgument()->IgnoreImpCasts();
-llvm::FoldingSetNodeID XID, YID;
-DefaultArgumentX->Profile(XID, C, /*Canonical=*/true);
-DefaultArgumentY->Profile(YID, C, /*Canonical=*/true);
-return XID == YID;
-  }
-
-  auto *TTPX = cast(X);
-  auto *TTPY = cast(Y);
-
-  if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
-return false;
-
-  const TemplateArgument &TAX = TTPX->getDefaultArgument().getArgument();
-  const TemplateArgument &TAY = TTPY->getDefaultArgument().getArgument();
-  return C.hasSameTemplateName(TAX.getAsTemplate(), TAY.getAsTemplate());
-}
-
 /// Checks the validity of a template parameter list, possibly
 /// considering the template parameter list from a previous
 /// declaration.
@@ -2780,7 +2740,8 @@
 if (!OldTypeParm->getOwningModule() ||
 isModuleUnitOfCurrentTU(OldTypeParm->getOwningModule()))
   RedundantDefaultArg = true;
-else if (!hasSameDefaultTemplateArgument(OldTypeParm, NewTypeParm)) {
+else if (!getASTContext().isSameDefaultTemplateArgument(OldTypeParm,
+NewTypeParm)) {
   InconsistentDefaultArg = true;
   PrevModuleName =
   OldTypeParm->getImportedOwningModule()->getFullModuleName();
@@ -2832,8 +2793,8 @@
 if (!OldNonTypeParm->getOwningModule() ||
 isModuleUnitOfCurrentTU(OldNonTypeParm->getOwningModule()))
   RedundantDefaultArg = true;
-else if (!hasSameDefaultTemp

[PATCH] D128977: [clangd] Support "usedAsMutableReference" in member initializations

2022-07-01 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
ckandeler requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

That is, mark constructor parameters being used to initialize
non-const reference members.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128977

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -745,6 +745,15 @@
 int &operator[](int &);
 int operator[](int) const;
 };
+struct $Class_decl[[ClassWithRefMembers]] {
+  $Class_decl[[ClassWithRefMembers]](int $Parameter_decl[[i]])
+: $Field[[i1]]($Parameter[[i]]),
+  $Field_readonly[[i2]]($Parameter[[i]]),
+  $Field[[i3]]($Parameter_usedAsMutableReference[[i]]) {}
+  int $Field_decl[[i1]];
+  const int &$Field_decl_readonly[[i2]];
+  int &$Field_decl[[i3]];
+};
 void $Function_decl[[fun]](int, const int,
int*, const int*,
int&, const int&,
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -523,6 +523,8 @@
 /// e.g. highlights dependent names and 'auto' as the underlying type.
 class CollectExtraHighlightings
 : public RecursiveASTVisitor {
+  using Base = RecursiveASTVisitor;
+
 public:
   CollectExtraHighlightings(HighlightingsBuilder &H) : H(H) {}
 
@@ -533,6 +535,22 @@
 return true;
   }
 
+  bool TraverseConstructorInitializer(CXXCtorInitializer *Init) {
+if (!Init->isMemberInitializer())
+  return Base::TraverseConstructorInitializer(Init);
+if (const auto Member = Init->getMember()) {
+  const auto MemberType = Member->getType();
+  if (MemberType->isLValueReferenceType() &&
+  !MemberType->getPointeeType().isConstQualified()) {
+if (const auto Param = dyn_cast(Init->getInit())) {
+  H.addExtraModifier(Param->getLocation(),
+ HighlightingModifier::UsedAsMutableReference);
+}
+  }
+}
+return Base::TraverseConstructorInitializer(Init);
+  }
+
   bool VisitCallExpr(CallExpr *E) {
 // Highlighting parameters passed by non-const reference does not really
 // make sense for literals...


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -745,6 +745,15 @@
 int &operator[](int &);
 int operator[](int) const;
 };
+struct $Class_decl[[ClassWithRefMembers]] {
+  $Class_decl[[ClassWithRefMembers]](int $Parameter_decl[[i]])
+: $Field[[i1]]($Parameter[[i]]),
+  $Field_readonly[[i2]]($Parameter[[i]]),
+  $Field[[i3]]($Parameter_usedAsMutableReference[[i]]) {}
+  int $Field_decl[[i1]];
+  const int &$Field_decl_readonly[[i2]];
+  int &$Field_decl[[i3]];
+};
 void $Function_decl[[fun]](int, const int,
int*, const int*,
int&, const int&,
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -523,6 +523,8 @@
 /// e.g. highlights dependent names and 'auto' as the underlying type.
 class CollectExtraHighlightings
 : public RecursiveASTVisitor {
+  using Base = RecursiveASTVisitor;
+
 public:
   CollectExtraHighlightings(HighlightingsBuilder &H) : H(H) {}
 
@@ -533,6 +535,22 @@
 return true;
   }
 
+  bool TraverseConstructorInitializer(CXXCtorInitializer *Init) {
+if (!Init->isMemberInitializer())
+  return Base::TraverseConstructorInitializer(Init);
+if (const auto Member = Init->getMember()) {
+  const auto MemberType = Member->getType();
+  if (MemberType->isLValueReferenceType() &&
+  !MemberType->getPointeeType().isConstQualified()) {
+if (const auto Param = dyn_cast(Init->getInit())) {
+  H.addExtraModifier(Param->getLocation(),
+ HighlightingModifier::UsedAsMutableReference)

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

2022-07-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked 2 inline comments as done.
tbaeder added a comment.

In D128248#3622775 , @shafik wrote:

> LGTM after addressing all of Aaron's comments.

I've already addressed them; did you miss the update or are you saying I 
haven't addressed them properly?


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

https://reviews.llvm.org/D128248

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


[PATCH] D128142: [MemProf] Memprof profile matching and annotation

2022-07-01 Thread Mingjie Xu via Phabricator via cfe-commits
Enna1 added inline comments.



Comment at: llvm/lib/Analysis/MemoryBuiltins.cpp:288-290
+bool llvm::isNewLikeFn(const Value *V, const TargetLibraryInfo *TLI) {
+  return getAllocationData(V, OpNewLike, TLI).hasValue();
+}

nit: place the definition of `llvm::isNewLikeFn` just after 
`llvm::isAllocationFn(const Value *V, function_ref GetTLI)` ? 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128142

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


[PATCH] D127643: [Static Analyzer] Structured bindings to data members

2022-07-01 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I read https://en.cppreference.com/w/cpp/language/structured_binding carefully, 
and there are a number of interesting rules that might deserve their own test 
case, even if this isn't the patch where you solve that issue, or believe that 
the solution handles it without the need for special case handling.

Just to name a few, you seem to not have test cases for when the bindings are 
cv-qualified. If you declare structured bindings like this:

  struct s {
int a;
int b;
  };
  
  void a(void) {
s tst;
  
auto [i, j](tst); // Syntax (3) according to cppreference
  
int x = i; // expected-warning{{Assigned value is garbage or undefined}}
  }

then the bindings are direct initialized, not copy initialized.

I'm not sure that the actual standard 
 has 
anything that cppreference doesn't, but maybe we could give it a glance.




Comment at: clang/test/Analysis/uninit-structured-binding-struct.cpp:10
+
+void a(void) {
+  s tst;

In the long run, it might make your own life easier to create more talkative 
test function names, like `testPODDecomp` or smt like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127643

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


[PATCH] D128981: [C++20][Modules] Implement include translation.

2022-07-01 Thread Iain Sandoe via Phabricator via cfe-commits
iains created this revision.
Herald added a project: All.
iains requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This addresses [cpp.include]/7

(when encountering #include header-name)

If the header identified by the header-name denotes an importable header, it
is implementation-defined whether the #include preprocessing directive is
instead replaced by an import directive.

In this implementation, include translation is performed _only_ for headers
in the Global Module fragment, so:

  module;
   #include "will-be-translated.h" // IFF the header unit is available.
  
  export module M;
   #include "will-not-be-translated.h" // even if the header unit is available

The reasoning is that, in general, includes in the module purview would not
be validly translatable (they would have to immediately follow the module
decl and without any other intervening decls).  Otherwise that would violate
the rules on contiguous import directives.

This would be quite complex to track in the preprocessor, and for relatively
little gain (the user can 'import "will-not-be-translated.h";' instead.)

TODO: This is one area where it becomes increasingly difficult to disambiguate
clang modules in C++ from C++ standard modules.  That needs to be addressed in
both the driver and the FE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128981

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Modules/cxx20-include-translation.cpp

Index: clang/test/Modules/cxx20-include-translation.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-include-translation.cpp
@@ -0,0 +1,58 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 -xc++-user-header h1.h -emit-header-unit -o h1.pcm
+// RUN: %clang_cc1 -std=c++20 -xc++-user-header h2.h -emit-header-unit -o h2.pcm
+
+// RUN: %clang_cc1 -std=c++20 Xlate.cpp -emit-module-interface -o Xlate.pcm \
+// RUN: -fmodule-file=h1.pcm -fmodule-file=h2.pcm \
+// RUN: -fsyntax-only -Wauto-import -verify
+
+// RUN: %clang_cc1 -std=c++20 Xlate.cpp -emit-module-interface \
+// RUN: -fmodule-file=h1.pcm -fmodule-file=h2.pcm \
+// RUN: -E | FileCheck %s
+
+// The content of the headers is not terribly important, we just want to check
+// whether they are textually included or include-translated.
+//--- h1.h
+#ifndef H1_GUARD
+#define H1_GUARD
+
+#define ONE 1
+
+void foo();
+
+#endif // H1_GUARD
+
+//--- h2.h
+#ifndef H2_GUARD
+#define H2_GUARD
+
+#define TWO 2
+
+void bar();
+
+#endif // H2_GUARD
+
+//--- Xlate.cpp
+/* some comment ...
+  ... */
+module /*nothing here*/;
+
+// This should be include-translated, when the header unit for h1 is available.
+#include "h1.h" // expected-warning {{treating #include as an import of module './h1.h'}}
+
+export module Xlate;
+
+// This should *not* be include-translated, even if header unit for h2 is
+// available.
+#include "h2.h"
+export void charlie() {
+  foo();
+  bar();
+}
+
+// CHECK: #pragma clang module import "./h1.h"
+// CHECK-NOT: #pragma clang module import "./h2.h"
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -663,12 +663,23 @@
 return false;
   }
 
-  case tok::annot_module_include:
-Actions.ActOnModuleInclude(Tok.getLocation(),
-   reinterpret_cast(
-   Tok.getAnnotationValue()));
+  case tok::annot_module_include: {
+auto Loc = Tok.getLocation();
+Module *Mod = reinterpret_cast(Tok.getAnnotationValue());
+// FIXME: We need a better way to disambiguate C++ clang modules and
+// standard C++ modules.
+if (!getLangOpts().CPlusPlusModules || !Mod->isHeaderUnit() ||
+getLangOpts().ModulesTS)
+  Actions.ActOnModuleInclude(Loc, Mod);
+else {
+  DeclResult Import =
+  Actions.ActOnModuleImport(Loc, SourceLocation(), Loc, Mod);
+  Decl *ImportDecl = Import.isInvalid() ? nullptr : Import.get();
+  Result = Actions.ConvertDeclToDeclGroup(ImportDecl);
+}
 ConsumeAnnotationToken();
 return false;
+  }
 
   case tok::annot_module_begin:
 Actions.ActOnModuleBegin(Tok.getLocation(), reinterpret_cast(
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -929,6 +929,9 @@
 
   // Update ImportSeqState to track our position within a C++20 import-seq
   // if this token is being produced as a result of phase 4 of translation.
+  // Update TrackGMFState to decide if we are currently in a Global Module
+  // Fragment. GMF state updates should precede ImportSeq ones, since GMF state
+  // de

[clang] 14035d5 - Fix this C99 DR to be more robust

2022-07-01 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-07-01T07:33:37-04:00
New Revision: 14035d5147a2e2e910341556cef3b16b66a2be66

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

LOG: Fix this C99 DR to be more robust

This should fix the following test issue on ARM:
https://lab.llvm.org/buildbot/#/builders/171/builds/16815

Added: 


Modified: 
clang/test/C/drs/dr2xx.c

Removed: 




diff  --git a/clang/test/C/drs/dr2xx.c b/clang/test/C/drs/dr2xx.c
index 0fa0f97858197..7cf692cb1a712 100644
--- a/clang/test/C/drs/dr2xx.c
+++ b/clang/test/C/drs/dr2xx.c
@@ -31,16 +31,23 @@ void dr204(void) {
   /* If the implementation supports a standard integer type larger than signed
* long, it's okay for size_t and ptr
diff _t to have a greater integer
* conversion rank than signed long.
+   *
+   * Note, it's not required that the implementation use that larger conversion
+   * rank; it's acceptable to use an unsigned long or unsigned int for the size
+   * type (those ranks are not greater than that of signed long).
*/
-   (void)_Generic(s + sl, __typeof__(s) : 1);
-   (void)_Generic(p + sl, __typeof__(p) : 1);
+   (void)_Generic(s + sl, __typeof__(s) : 1, unsigned long : 1, unsigned int : 
1);
+   (void)_Generic(p + sl, __typeof__(p) : 1, signed long : 1, signed int : 1);
 #elif __LLONG_WIDTH__ == __LONG_WIDTH__
   /* But if the implementation doesn't support a larger standard integer type
* than signed long, the conversion rank should prefer signed long if the 
type
* is signed (ptr
diff _t) or unsigned long if the type is unsigned (size_t).
+   *
+   * Note, as above, unsigned/signed int is also acceptable due to having a
+   * lesser integer conversion rank.
*/
-   (void)_Generic(s + sl, unsigned long : 1);
-   (void)_Generic(p + sl, signed long : 1);
+   (void)_Generic(s + sl, unsigned long : 1, unsigned int : 1);
+   (void)_Generic(p + sl, signed long : 1, signed int : 1);
 #else
 #error "Something has gone off the rails"
 #endif



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


[PATCH] D128984: [clang-format] Tweak help text a bit

2022-07-01 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added reviewers: curdeius, MyDeveloperDay.
Herald added a project: All.
thakis requested review of this revision.

In particular, make it clear that `--style=file` is the default,
since there's some confusion about this, e.g. here:
https://stackoverflow.com/questions/61455148/


https://reviews.llvm.org/D128984

Files:
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -70,16 +70,18 @@
   cl::desc("The name of the predefined style used as a\n"
"fallback in case clang-format is invoked with\n"
"-style=file, but can not find the .clang-format\n"
-   "file to use.\n"
+   "file to use. Defaults to 'LLVM'.\n"
"Use -fallback-style=none to skip formatting."),
   cl::init(clang::format::DefaultFallbackStyle),
   cl::cat(ClangFormatCategory));
 
 static cl::opt AssumeFileName(
 "assume-filename",
-cl::desc("Override filename used to determine the language.\n"
- "When reading from stdin, clang-format assumes this\n"
- "filename to determine the language.\n"
+cl::desc("Set filename used to determine the language and to find\n"
+ ".clang-format file.\n"
+ "Only used when reading from stdin.\n"
+ "If this is not passed, the .clang-format file is searched\n"
+ "relative to the current working directory when reading stdin.\n"
  "Unrecognized filenames are treated as C++.\n"
  "supported:\n"
  "  CSharp: .cs\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3433,17 +3433,19 @@
 }
 
 const char *StyleOptionHelpDescription =
-"Coding style, currently supports:\n"
-"  LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.\n"
-"Use -style=file to load style configuration from\n"
-".clang-format file located in one of the parent\n"
-"directories of the source file (or current\n"
-"directory for stdin).\n"
-"Use -style=file: to explicitly specify\n"
-"the configuration file.\n"
-"Use -style=\"{key: value, ...}\" to set specific\n"
-"parameters, e.g.:\n"
-"  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
+"Set coding style.  can be:\n"
+"1. A preset: LLVM, GNU, Google, Chromium, Microsoft,\n"
+"   Mozilla, WebKit.\n"
+"2. 'file' to load style configuration from a\n"
+"   .clang-format file in one of the parent directories\n"
+"   of the source file (for stdin, see --assume-filename).\n"
+"   If no .clang-format file is found, falls back to\n"
+"   --fallback-style.\n"
+"   --style=file is the default.\n"
+"3. 'file:' to explicitly specify\n"
+"   the configuration file.\n"
+"4. \"{key: value, ...}\" to set specific parameters, e.g.:\n"
+"   --style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
 
 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
   if (FileName.endswith(".java"))
@@ -3498,6 +3500,7 @@
   return GuessedLanguage;
 }
 
+// Update StyleOptionHelpDescription above when changing this.
 const char *DefaultFormatStyle = "file";
 
 const char *DefaultFallbackStyle = "LLVM";


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -70,16 +70,18 @@
   cl::desc("The name of the predefined style used as a\n"
"fallback in case clang-format is invoked with\n"
"-style=file, but can not find the .clang-format\n"
-   "file to use.\n"
+   "file to use. Defaults to 'LLVM'.\n"
"Use -fallback-style=none to skip formatting."),
   cl::init(clang::format::DefaultFallbackStyle),
   cl::cat(ClangFormatCategory));
 
 static cl::opt AssumeFileName(
 "assume-filename",
-cl::desc("Override filename used to determine the language.\n"
- "When reading from stdin, clang-format assumes this\n"
- "filename to determine the language.\n"
+cl::desc("Set filename used to determine the language and to find\n"
+ ".clang-format file.\n"
+ "Only used when reading from stdin.\n"
+ "If this is not passed, the .clang-format file is searched\n"
+ "relative to the current working directory when reading stdin.\n"
  "Unrecognized filename

[clang] 83fdf0c - Ensure that the generic associations aren't redundant

2022-07-01 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-07-01T07:48:59-04:00
New Revision: 83fdf0c34e60e61849574d30c39cf7f7324c5271

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

LOG: Ensure that the generic associations aren't redundant

This should hopefully address the test failure found in:
https://lab.llvm.org/buildbot/#/builders/171/builds/16833

Added: 


Modified: 
clang/test/C/drs/dr2xx.c

Removed: 




diff  --git a/clang/test/C/drs/dr2xx.c b/clang/test/C/drs/dr2xx.c
index 7cf692cb1a71..aa5fcff18f75 100644
--- a/clang/test/C/drs/dr2xx.c
+++ b/clang/test/C/drs/dr2xx.c
@@ -36,8 +36,8 @@ void dr204(void) {
* rank; it's acceptable to use an unsigned long or unsigned int for the size
* type (those ranks are not greater than that of signed long).
*/
-   (void)_Generic(s + sl, __typeof__(s) : 1, unsigned long : 1, unsigned int : 
1);
-   (void)_Generic(p + sl, __typeof__(p) : 1, signed long : 1, signed int : 1);
+   (void)_Generic(s + sl, unsigned long long : 1, unsigned long : 1, unsigned 
int : 1);
+   (void)_Generic(p + sl, signed long long : 1, signed long : 1, signed int : 
1);
 #elif __LLONG_WIDTH__ == __LONG_WIDTH__
   /* But if the implementation doesn't support a larger standard integer type
* than signed long, the conversion rank should prefer signed long if the 
type



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


[clang] ac8dab8 - Add some more expected warnings to this C99 DR test

2022-07-01 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-07-01T08:11:46-04:00
New Revision: ac8dab8e09d8faee902861343ccb9278982f4306

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

LOG: Add some more expected warnings to this C99 DR test

This should address the issue found by:
https://lab.llvm.org/buildbot/#/builders/171/builds/16835

Added: 


Modified: 
clang/test/C/drs/dr2xx.c

Removed: 




diff  --git a/clang/test/C/drs/dr2xx.c b/clang/test/C/drs/dr2xx.c
index aa5fcff18f75..e4fe3183b02c 100644
--- a/clang/test/C/drs/dr2xx.c
+++ b/clang/test/C/drs/dr2xx.c
@@ -36,8 +36,8 @@ void dr204(void) {
* rank; it's acceptable to use an unsigned long or unsigned int for the size
* type (those ranks are not greater than that of signed long).
*/
-   (void)_Generic(s + sl, unsigned long long : 1, unsigned long : 1, unsigned 
int : 1);
-   (void)_Generic(p + sl, signed long long : 1, signed long : 1, signed int : 
1);
+   (void)_Generic(s + sl, unsigned long long : 1, unsigned long : 1, unsigned 
int : 1); /* c89only-warning {{'long long' is an extension when C99 mode is not 
enabled}} */
+   (void)_Generic(p + sl, signed long long : 1, signed long : 1, signed int : 
1);   /* c89only-warning {{'long long' is an extension when C99 mode is not 
enabled}} */
 #elif __LLONG_WIDTH__ == __LONG_WIDTH__
   /* But if the implementation doesn't support a larger standard integer type
* than signed long, the conversion rank should prefer signed long if the 
type



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


[PATCH] D128715: [clang-tidy] Fix confusable identifiers interaction with DeclContext

2022-07-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from some minor style nits.




Comment at: 
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp:130-132
+if (ND1->getAccess() != AS_private && isMemberOf(ND1, RD0)) {
+  return true;
+}





Comment at: 
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp:135-137
+if (ND0->getAccess() != AS_private && isMemberOf(ND0, RD1)) {
+  return true;
+}





Comment at: 
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp:142-145
+  else if (DC1->Encloses(DC0))
+return mayShadowImpl(ND1, ND0);
+  else
+return false;




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

https://reviews.llvm.org/D128715

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


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

2022-07-01 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 441667.
junaire added a comment.

- Rebase
- turn clang-format off in tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128782

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


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


Index: clang/test/Interpreter/code-undo.cpp
===
--- clang/test/Interpreter/code-undo.cpp
+++ clang/test/Interpreter/code-undo.cpp
@@ -1,3 +1,4 @@
+// clang-format off
 // RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
@@ -20,4 +21,9 @@
 auto r3 = printf("foo() = %d\n", foo());
 // CHECK-NEXT: foo() = 2
 
+inline int bar() { return 42;}
+auto r4 = bar();
+%undo
+auto r5 = bar();
+
 %quit
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -344,6 +344,20 @@
   std::vector DeferredDeclsToEmit;
   void addDeferredDeclToEmit(GlobalDecl GD) {
 DeferredDeclsToEmit.emplace_back(GD);
+addEmittedDeferredDecl(GD);
+  }
+
+  /// Decls that were DeferredDecls and have now been emitted.
+  llvm::DenseMap EmittedDeferredDecls;
+
+  void addEmittedDeferredDecl(GlobalDecl GD) {
+if (!llvm::isa(GD.getDecl()))
+  return;
+llvm::GlobalVariable::LinkageTypes L = getFunctionLinkage(GD);
+if (llvm::GlobalValue::isLinkOnceLinkage(L) ||
+llvm::GlobalValue::isWeakLinkage(L)) {
+  EmittedDeferredDecls[getMangledName(GD)] = GD;
+}
   }
 
   /// List of alias we have emitted. Used to make sure that what they point to
@@ -1516,6 +1530,10 @@
 NewBuilder->WeakRefReferences = std::move(WeakRefReferences);
 
 NewBuilder->TBAA = std::move(TBAA);
+assert(NewBuilder->EmittedDeferredDecls.empty() &&
+   "Still have (unmerged) EmittedDeferredDecls deferred decls");
+
+NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);
   }
 
 private:
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -445,6 +445,7 @@
 
 void CodeGenModule:

[clang] 325e7e8 - [LLVM][LTO][LLD] Enable Profile Guided Layout (--call-graph-profile-sort) for FullLTO

2022-07-01 Thread Ben Dunbobbin via cfe-commits

Author: Ben Dunbobbin
Date: 2022-07-01T13:57:36+01:00
New Revision: 325e7e8b87423f83ba9fc53b9486ce67329d486c

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

LOG: [LLVM][LTO][LLD] Enable Profile Guided Layout (--call-graph-profile-sort) 
for FullLTO

The CGProfilePass needs to be run during FullLTO compilation at link
time to emit the .llvm.call-graph-profile section to the compiled LTO
object file. Currently, it is being run only during the initial
LTO-prelink compilation stage (to produce the bitcode files to be
consumed by the linker) and so the section is not produced.

ThinLTO is not affected because:
- For ThinLTO-prelink compilation the CGProfilePass pass is not run
  because ThinLTO-prelink passes are added via
  buildThinLTOPreLinkDefaultPipeline. Normal and FullLTO-prelink
  passes are both added via buildPerModuleDefaultPipeline which uses
  the LTOPreLink parameter to customize its behavior for the
  FullLTO-prelink pass differences.
- ThinLTO backend compilation phase adds the CGProfilePass (see:
  buildModuleOptimizationPipeline).

Adjust when the pass is run so that the .llvm.call-graph-profile
section is produced correctly for FullLTO.

Fixes #56185 (https://github.com/llvm/llvm-project/issues/56185)

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 6d42e9e744a89..463fc522c6a28 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -105,9 +105,9 @@
 ; CHECK-O: Running pass: InstSimplifyPass on main
 ; CHECK-O: Running pass: DivRemPairsPass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main
-; CHECK-O: Running pass: CGProfilePass
 ; CHECK-O: Running pass: GlobalDCEPass
 ; CHECK-O: Running pass: ConstantMergePass
+; CHECK-O: Running pass: CGProfilePass
 
 target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-grtev4-linux-gnu"

diff  --git a/llvm/lib/Passes/PassBuilderPipelines.cpp 
b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 8e0f0cb3075bf..a5345172aae14 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1278,9 +1278,6 @@ 
PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
   if (PTO.MergeFunctions)
 MPM.addPass(MergeFunctionsPass());
 
-  if (PTO.CallGraphProfile)
-MPM.addPass(CGProfilePass());
-
   // Now we need to do some global optimization transforms.
   // FIXME: It would seem like these should come first in the optimization
   // pipeline and maybe be the bottom of the canonicalization pipeline? Weird
@@ -1288,6 +1285,9 @@ 
PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
   MPM.addPass(GlobalDCEPass());
   MPM.addPass(ConstantMergePass());
 
+  if (PTO.CallGraphProfile && !LTOPreLink)
+MPM.addPass(CGProfilePass());
+
   // TODO: Relative look table converter pass caused an issue when full lto is
   // enabled. See https://reviews.llvm.org/D94355 for more details.
   // Until the issue fixed, disable this pass during pre-linking phase.
@@ -1748,6 +1748,9 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel 
Level,
   if (PTO.MergeFunctions)
 MPM.addPass(MergeFunctionsPass());
 
+  if (PTO.CallGraphProfile)
+MPM.addPass(CGProfilePass());
+
   for (auto &C : FullLinkTimeOptimizationLastEPCallbacks)
 C(MPM, Level);
 

diff  --git a/llvm/test/Other/new-pm-defaults.ll 
b/llvm/test/Other/new-pm-defaults.ll
index 04b57fedc20f1..8dd82c4802830 100644
--- a/llvm/test/Other/new-pm-defaults.ll
+++ b/llvm/test/Other/new-pm-defaults.ll
@@ -265,9 +265,9 @@
 ; CHECK-IR-OUTLINER-NEXT: Running pass: IROutlinerPass
 ; CHECK-IR-OUTLINER-NEXT: Running analysis: IRSimilarityAnalysis
 ; CHECK-MERGE-FUNCS-NEXT: Running pass: MergeFunctionsPass
-; CHECK-O-NEXT: Running pass: CGProfilePass
 ; CHECK-O-NEXT: Running pass: GlobalDCEPass
 ; CHECK-O-NEXT: Running pass: ConstantMergePass
+; CHECK-DEFAULT-NEXT: Running pass: CGProfilePass
 ; CHECK-DEFAULT-NEXT: Running pass: RelLookupTableConverterPass
 ; CHECK-LTO-NOT: Running pass: RelLookupTableConverterPass
 ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo

diff  --git a/llvm/test/Other/new-pm-lto-defaults.ll 
b/llvm/test/Other/new-pm-lto-defaults.ll
index 2e826985fbb45..da66e71a5bf8d 100644
--- a/llvm/test/Other/new-pm-l

[PATCH] D12669: [libcxxabi] Fix alignment of pointers returned by fallback_malloc

2022-07-01 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.
Herald added a project: All.

@EricWF, I have an updated version of this patch that applies against current 
`main`. Do you mind if I commandeer this revision and post my updated patch on 
it?


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

https://reviews.llvm.org/D12669

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


[PATCH] D127448: [wip][pseudo] Implement guard extension.

2022-07-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 441677.
hokein marked 8 inline comments as done.
hokein added a comment.

rebase and address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127448

Files:
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
  clang-tools-extra/pseudo/gen/Main.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/Language.h
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cli/CLI.cpp
  clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf
  clang-tools-extra/pseudo/test/cxx/contextual-keywords.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -81,6 +81,13 @@
 ADD_FAILURE() << "No such symbol found: " << Name;
 return 0;
   }
+  ExtensionID extensionID(llvm::StringRef AttrValueName) const {
+for (unsigned ID = 0; ID < TestLang.G.table().AttributeValues.size(); ++ID)
+  if (TestLang.G.table().AttributeValues[ID] == AttrValueName)
+return static_cast(ID);
+ADD_FAILURE() << "No such attribute value found: " << AttrValueName;
+return 0;
+  }
 
   RuleID ruleFor(llvm::StringRef NonterminalName) const {
 auto RuleRange =
@@ -133,7 +140,7 @@
   ForestNode &SemiTerminal = Arena.createTerminal(tok::semi, 0);
   std::vector NewHeads;
   glrShift({GSSNode1, GSSNode2, GSSNode3}, SemiTerminal,
-   {TestLang.G, TestLang.Table, Arena, GSStack}, NewHeads);
+   {emptyTokenStream(), Arena, GSStack}, TestLang, NewHeads);
 
   EXPECT_THAT(NewHeads,
   UnorderedElementsAre(AllOf(state(4), parsedSymbol(&SemiTerminal),
@@ -171,7 +178,7 @@
 
   std::vector Heads = {GSSNode1};
   glrReduce(Heads, tokenSymbol(tok::eof),
-{TestLang.G, TestLang.Table, Arena, GSStack});
+{emptyTokenStream(), Arena, GSStack}, TestLang);
   EXPECT_THAT(Heads, UnorderedElementsAre(
  GSSNode1,
  AllOf(state(2), parsedSymbolID(id("class-name")),
@@ -212,7 +219,8 @@
   {/*State=*/4, ruleFor("ptr-operator")},
   });
   std::vector Heads = {GSSNode4};
-  glrReduce(Heads, tokenSymbol(tok::eof), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack},
+TestLang);
 
   EXPECT_THAT(Heads, UnorderedElementsAre(
  GSSNode4,
@@ -267,7 +275,8 @@
   {/*State=*/4, /* type-name := enum-name */ 1},
   });
   std::vector Heads = {GSSNode3, GSSNode4};
-  glrReduce(Heads, tokenSymbol(tok::eof), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack},
+TestLang);
 
   // Verify that the stack heads are joint at state 5 after reduces.
   EXPECT_THAT(Heads, UnorderedElementsAre(GSSNode3, GSSNode4,
@@ -325,7 +334,7 @@
  });
   std::vector Heads = {GSSNode3, GSSNode4};
   glrReduce(Heads, tokenSymbol(tok::eof),
-{TestLang.G, TestLang.Table, Arena, GSStack});
+{emptyTokenStream(), Arena, GSStack}, TestLang);
 
   EXPECT_THAT(
   Heads, UnorderedElementsAre(GSSNode3, GSSNode4,
@@ -363,14 +372,16 @@
 
   // When the lookahead is +, reduce is performed.
   std::vector Heads = {GSSNode1};
-  glrReduce(Heads, tokenSymbol(tok::plus), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::plus), {emptyTokenStream(), Arena, GSStack},
+TestLang);
   EXPECT_THAT(Heads,
   ElementsAre(GSSNode1, AllOf(state(2), parsedSymbolID(id("term")),
   parents(Root;
 
   // When the lookahead is -, reduce is not performed.
   Heads = {GSSNode1};
-  glrReduce(Heads, tokenSymbol(tok::minus), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::minus),
+{emptyTokenStream(), Arena, GSStack}, TestLang);
   EXPECT_THAT(Heads, ElementsAre(GSSNode1));
 }
 
@@ -396,7 +407,7 @@
   const TokenStream &Tokens = cook(lex("{ abc", LOptions), LOptions);
 
   const ForestNode &Parsed =
-  glrParse(Tokens, {TestLang.G, TestLang.Table, Arena, GSStack}, id("test"));
+  glrParse({Tokens, Arena, GSStack}, id("test"), TestLang);
   // Verify that there is no duplicated sequence node of `expr := IDENTIFIER`
   // in the forest, see the `#1` and `=#1` in the dump string.
   EXPECT_EQ(Parsed.dumpRecursive(TestLang.G),
@@ -433,7 +444,7 @@
   TestLang.Table = LRTable::buildSLR(TestLang.G);
 
   cons

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

@shafik  was able to help me figure out how to repro, and I think I've about 
fixed this, so I'll try another commit soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D127448: [wip][pseudo] Implement guard extension.

2022-07-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 441680.
hokein marked 5 inline comments as done.
hokein added a comment.

fix format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127448

Files:
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
  clang-tools-extra/pseudo/gen/Main.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/Language.h
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cli/CLI.cpp
  clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf
  clang-tools-extra/pseudo/test/cxx/contextual-keywords.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -81,6 +81,13 @@
 ADD_FAILURE() << "No such symbol found: " << Name;
 return 0;
   }
+  ExtensionID extensionID(llvm::StringRef AttrValueName) const {
+for (unsigned ID = 0; ID < TestLang.G.table().AttributeValues.size(); ++ID)
+  if (TestLang.G.table().AttributeValues[ID] == AttrValueName)
+return static_cast(ID);
+ADD_FAILURE() << "No such attribute value found: " << AttrValueName;
+return 0;
+  }
 
   RuleID ruleFor(llvm::StringRef NonterminalName) const {
 auto RuleRange =
@@ -133,7 +140,7 @@
   ForestNode &SemiTerminal = Arena.createTerminal(tok::semi, 0);
   std::vector NewHeads;
   glrShift({GSSNode1, GSSNode2, GSSNode3}, SemiTerminal,
-   {TestLang.G, TestLang.Table, Arena, GSStack}, NewHeads);
+   {emptyTokenStream(), Arena, GSStack}, TestLang, NewHeads);
 
   EXPECT_THAT(NewHeads,
   UnorderedElementsAre(AllOf(state(4), parsedSymbol(&SemiTerminal),
@@ -171,7 +178,7 @@
 
   std::vector Heads = {GSSNode1};
   glrReduce(Heads, tokenSymbol(tok::eof),
-{TestLang.G, TestLang.Table, Arena, GSStack});
+{emptyTokenStream(), Arena, GSStack}, TestLang);
   EXPECT_THAT(Heads, UnorderedElementsAre(
  GSSNode1,
  AllOf(state(2), parsedSymbolID(id("class-name")),
@@ -212,7 +219,8 @@
   {/*State=*/4, ruleFor("ptr-operator")},
   });
   std::vector Heads = {GSSNode4};
-  glrReduce(Heads, tokenSymbol(tok::eof), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack},
+TestLang);
 
   EXPECT_THAT(Heads, UnorderedElementsAre(
  GSSNode4,
@@ -267,7 +275,8 @@
   {/*State=*/4, /* type-name := enum-name */ 1},
   });
   std::vector Heads = {GSSNode3, GSSNode4};
-  glrReduce(Heads, tokenSymbol(tok::eof), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::eof), {emptyTokenStream(), Arena, GSStack},
+TestLang);
 
   // Verify that the stack heads are joint at state 5 after reduces.
   EXPECT_THAT(Heads, UnorderedElementsAre(GSSNode3, GSSNode4,
@@ -325,7 +334,7 @@
  });
   std::vector Heads = {GSSNode3, GSSNode4};
   glrReduce(Heads, tokenSymbol(tok::eof),
-{TestLang.G, TestLang.Table, Arena, GSStack});
+{emptyTokenStream(), Arena, GSStack}, TestLang);
 
   EXPECT_THAT(
   Heads, UnorderedElementsAre(GSSNode3, GSSNode4,
@@ -363,14 +372,16 @@
 
   // When the lookahead is +, reduce is performed.
   std::vector Heads = {GSSNode1};
-  glrReduce(Heads, tokenSymbol(tok::plus), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::plus), {emptyTokenStream(), Arena, GSStack},
+TestLang);
   EXPECT_THAT(Heads,
   ElementsAre(GSSNode1, AllOf(state(2), parsedSymbolID(id("term")),
   parents(Root;
 
   // When the lookahead is -, reduce is not performed.
   Heads = {GSSNode1};
-  glrReduce(Heads, tokenSymbol(tok::minus), {TestLang.G, TestLang.Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::minus),
+{emptyTokenStream(), Arena, GSStack}, TestLang);
   EXPECT_THAT(Heads, ElementsAre(GSSNode1));
 }
 
@@ -396,7 +407,7 @@
   const TokenStream &Tokens = cook(lex("{ abc", LOptions), LOptions);
 
   const ForestNode &Parsed =
-  glrParse(Tokens, {TestLang.G, TestLang.Table, Arena, GSStack}, id("test"));
+  glrParse({Tokens, Arena, GSStack}, id("test"), TestLang);
   // Verify that there is no duplicated sequence node of `expr := IDENTIFIER`
   // in the forest, see the `#1` and `=#1` in the dump string.
   EXPECT_EQ(Parsed.dumpRecursive(TestLang.G),
@@ -433,7 +444,7 @@
   TestLang.Table = LRTable::buildSLR(TestLang.G);
 
   const ForestNode &Par

[PATCH] D127448: [wip][pseudo] Implement guard extension.

2022-07-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:298
   auto Pop = [&](const GSS::Node *Head, RuleID RID) {
-LLVM_DEBUG(llvm::dbgs() << "  Pop " << Params.G.dumpRule(RID) << "\n");
-const auto &Rule = Params.G.lookupRule(RID);
+LLVM_DEBUG(llvm::dbgs() << "  Pop " << Params.Lang.G.dumpRule(RID) << 
"\n");
+const auto &Rule = Params.Lang.G.lookupRule(RID);

sammccall wrote:
> I'm not sure exactly what the best thing to do about this is, but 
> `Params.Lang.G` is hard to read - it's a long complicated name that doesn't 
> even name the thing.
> 
> I think probably we should split ParseParams up instead of nesting ParseLang 
> in it, e.g.
> 
> ```
> struct GLRStorage { ForestArena&, GSS }
> glrReduce(vector, const ParseLang&, GLStorage&, NewHeadCallback)
> ```
> 
> Or even put a forest pointer in the GSS just for convenience.
Changed the signature of glrShift/Reduce/Parse.





Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:306
+  auto It = Params.Lang.Guards.find(Rule.Guard);
+  assert(It != Params.Lang.Guards.end() && "missing guard!");
+  if (!It->getSecond()(TempSequence, Tokens))

sammccall wrote:
> I think diagnosing missing guards but then treating them as always-passing is 
> less surprising and more ergonomic while modifying a grammar
I wanted to make this as a contract  (guard in each rule must refer to a valid 
extension function) in GLR parser.

I think loosing the restriction is also fine -- the only downside I can see is 
that if we have a typo guard in the grammar file, which we don't have a 
corresponding function, the parser will run and emit confusing results. We can 
fix it by adding "missing guard function" diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127448

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


[PATCH] D128991: [NFC] Add a missing test for for clang-repl

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

This adds a missing test for 0ecbedc0986bd4b7b90a60a5f31d32337160d4c4 

Signed-off-by: Jun Zhang 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128991

Files:
  clang/test/Interpreter/execute.cpp


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -18,4 +18,8 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+int __attribute__((weak)) bar() { return 1; }
+auto r4 = printf("bar() = %d\n", bar());
+// CHECK-NEXT: bar() = 1
+
 %quit


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -18,4 +18,8 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+int __attribute__((weak)) bar() { return 1; }
+auto r4 = printf("bar() = %d\n", bar());
+// CHECK-NEXT: bar() = 1
+
 %quit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] befa8cf - Re-apply "Deferred Concept Instantiation Implementation""

2022-07-01 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-07-01T06:51:38-07:00
New Revision: befa8cf087dbb8159a4d9dc8fa4d6748d6d5049a

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

LOG: Re-apply "Deferred Concept Instantiation Implementation""

This reverts commit d4d47e574ecae562ab32f8ac7fa3f4d424bb6574.

This fixes the lldb crash that was observed by ensuring that our
friend-'template contains reference to' TreeTransform properly handles a
TemplateDecl.

Added: 
clang/test/SemaTemplate/concepts-friends.cpp
clang/test/SemaTemplate/deferred-concept-inst.cpp
clang/test/SemaTemplate/trailing-return-short-circuit.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp

clang/test/CXX/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp

clang/test/CXX/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
clang/test/SemaTemplate/concepts.cpp
clang/test/SemaTemplate/instantiate-requires-clause.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3342f6208c4f8..26d769deee6d4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -451,10 +451,11 @@ C++20 Feature Support
 - No longer attempt to evaluate a consteval UDL function call at runtime when
   it is called through a template instantiation. This fixes
   `Issue 54578 `_.
-
-- Implemented ``__builtin_source_location()``, which enables library support
-  for ``std::source_location``.
-
+- Implemented `__builtin_source_location()` which enables library support for 
std::source_location.
+- Clang now correctly delays the instantiation of function constraints until
+  the time of checking, which should now allow the libstdc++ ranges 
implementation
+  to work for at least trivial examples.  This fixes
+  `Issue 44178 `_.
 - The mangling scheme for C++20 modules has incompatibly changed. The
   initial mangling was discovered not to be reversible, and the weak
   ownership design decision did not give the backwards compatibility

diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 66fab94b45b8a..0a7dc63d1c25d 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1890,7 +1890,9 @@ class FunctionDecl : public DeclaratorDecl,
 TK_FunctionTemplateSpecialization,
 // A function template specialization that hasn't yet been resolved to a
 // particular specialized function template.
-TK_DependentFunctionTemplateSpecialization
+TK_DependentFunctionTemplateSpecialization,
+// A non templated function which is in a dependent scope.
+TK_DependentNonTemplate
   };
 
   /// Stashed information about a defaulted function definition whose body has
@@ -1939,20 +1941,21 @@ class FunctionDecl : public DeclaratorDecl,
   /// The template or declaration that this declaration
   /// describes or was instantiated from, respectively.
   ///
-  /// For non-templates, this value will be NULL. For function
-  /// declarations that describe a function template, this will be a
-  /// pointer to a FunctionTemplateDecl. For member functions
-  /// of class template specializations, this will be a 
MemberSpecializationInfo
-  /// pointer containing information about the specialization.
-  /// For function template specializations, this will be a
-  /// FunctionTemplateSpecializationInfo, which contains information about
-  /// the template being specialized and the template arguments involved in
-  /// that specialization.
-  llvm::PointerUnion
-TemplateOrSpecialization;
+  TemplateOrSpecialization;
 
   /// Provides source/type location info for the declaration name embedded in
   /// the DeclaratorDecl base class.
@@ -2695,6 +2698,11 @@ class FunctionDecl : public DeclaratorDecl,
 setInstantiationOfMemberFunction(getASTContext(), FD, TSK);
   }
 
+  /// Specify that this function declaration was instantiated from FunctionDecl

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Some drive-by comments from the peanut gallery.




Comment at: clang/lib/Parse/ParsePragma.cpp:3963
+<< PP.getSpelling(Tok) << "riscv" << /*Expected=*/true << 
"'intrinsic'";
+return;
+  }

It's fine to warn on this, but then you need to eat tokens until the end of 
directive is found so that parsing recovery is correct. e.g.,
```
#pragma clang riscv int i = 12;
```
See `HandlePragmaAttribute()` for an example (though you'll look for `eod` 
instead of `eof`).



Comment at: clang/lib/Parse/ParsePragma.cpp:3971
+<< PP.getSpelling(Tok) << "riscv" << /*Expected=*/true << "'vector'";
+return;
+  }

Same here.



Comment at: clang/lib/Parse/ParsePragma.cpp:3978
+<< "clang riscv intrinsic";
+return;
+  }

And here as well.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:100
+switch (Type->getElementBitwidth()) {
+case 64:
+  QT = Context.DoubleTy;

I almost hate to ask, but... `long double`? Any of the 16-bit float types?



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:111
+break;
+  default:
+llvm_unreachable("Unhandled type.");

Might as well handle `Invalid` and then drop the `default` entirely so it's a 
fully covered switch.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:121
+  // Transform the type to a pointer as the last step, if necessary.
+  if (Type->isPointer())
+QT = Context.getPointerType(QT);

Double-checking -- do you have to care about references as well?



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:185-186
+   
Record.OverloadedSuffixSize);
+for (int TypeRangeMaskShift = 0;
+ TypeRangeMaskShift <= static_cast(BasicType::MaxOffset);
+ ++TypeRangeMaskShift) {

Given that we're bit twiddling with this, I'd feel more comfortable if this was 
`unsigned int` rather than `int` (same for `BaseTypeI`).



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:223-225
+if (!Types.hasValue()) {
+  continue;
+}





Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:227-229
+auto SuffixStr =
+RVVIntrinsic::getSuffixStr(BaseType, Log2LMUL, SuffixProto);
+auto OverloadedSuffixStr = RVVIntrinsic::getSuffixStr(

You should spell the type explicitly here instead of using `auto`.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:235-237
+bool HasMask = Record.MaskedPrototypeLength != 0;
+
+if (HasMask) {





Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:299-301
+  auto Sigs = IDef.Signature;
+  size_t SigLength = Sigs.size();
+  auto ReturnType = Sigs[0];

Spell out the types instead of using `auto`.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:322
+  SC_Extern, S.getCurFPFeatures().isFPConstrained(), false,
+  BuiltinFuncType->isFunctionProtoType());
+

No need to calculate this, we already know.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:328
+  SmallVector ParmList;
+  for (unsigned IParm = 0, e = FP->getNumParams(); IParm != e; ++IParm) {
+ParmVarDecl *Parm =

Naming style fix.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:342
+  // Setup alias to __builtin_rvv_*
+  auto &IntrinsicII = PP.getIdentifierTable().get(IDef.BuiltinName);
+  RVVIntrinsicDecl->addAttr(

Spell out type name.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:358
+  if (OvIItr != OverloadIntrinsics.end()) {
+auto OvIntrinsicDef = OvIItr->second;
+for (auto Index : OvIntrinsicDef.Indexs)

Spell out the type.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:41
+
+  // Supported type, mask of BasicType
+  unsigned TypeRangeMask;





Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:74
+public:
+  static constexpr unsigned INVALID_INDEX = (unsigned)-1;
+





Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:232-237
+  for (const auto &SemaRecord : SemaRecords) {
+InsertToSignatureSet(SemaRecord.Prototype);
+InsertToSignatureSet(SemaRecord.MaskedPrototype);
+InsertToSignatureSet(SemaRecord.Suffix);
+InsertToSignatureSet(SemaRecord.OverloadedSuffix);
   }





Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:239-240
+
+  for (const auto &Sig : Signatures)
+insert(Sig);
+}

Pretty sure you can go with this instead.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  h

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-01 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 441684.
kito-cheng added a comment.

Changes:

- Address @craig.topper's comment
  - Introduce RISCVIntrinsicManager.h and let it become member of Sema, that 
make sure the it won't outlive than Sema.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

Files:
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/RISCVIntrinsicManager.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -110,6 +110,7 @@
 void EmitRVVHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitRVVBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
 void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -88,6 +88,7 @@
   GenRISCVVectorHeader,
   GenRISCVVectorBuiltins,
   GenRISCVVectorBuiltinCG,
+  GenRISCVVectorBuiltinSema,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -243,6 +244,8 @@
"Generate riscv_vector_builtins.inc for clang"),
 clEnumValN(GenRISCVVectorBuiltinCG, "gen-riscv-vector-builtin-codegen",
"Generate riscv_vector_builtin_cg.inc for clang"),
+clEnumValN(GenRISCVVectorBuiltinSema, "gen-riscv-vector-builtin-sema",
+   "Generate riscv_vector_builtin_sema.inc for clang"),
 clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
 clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -458,6 +461,9 @@
   case GenRISCVVectorBuiltinCG:
 EmitRVVBuiltinCG(Records, OS);
 break;
+  case GenRISCVVectorBuiltinSema:
+EmitRVVBuiltinSema(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
@@ -29,6 +30,59 @@
 using namespace clang::RISCV;
 
 namespace {
+struct SemaRecord {
+  // Intrinsic name, e.g. vadd_vv
+  std::string Name;
+
+  // Overloaded intrinsic name, could be empty if can be computed from Name
+  // e.g. vadd
+  std::string OverloadedName;
+
+  // Supported type, mask of BasicType
+  unsigned TypeRangeMask;
+
+  // Supported LMUL.
+  unsigned Log2LMULMask;
+
+  // Required extensions for this intrinsic.
+  unsigned RequiredExtension;
+
+  // Prototype for this intrinsic.
+  SmallVector Prototype;
+
+  // Prototype for masked intrinsic.
+  SmallVector MaskedPrototype;
+
+  // Suffix of intrinsic name.
+  SmallVector Suffix;
+
+  // Suffix of overloaded intrinsic name.
+  SmallVector OverloadedSuffix;
+
+  // Number of field, large than 1 if it's segment load/store.
+  unsigned NF;
+};
+
+// Compressed function signature table.
+class SemaSignatureTable {
+private:
+  std::vector SignatureTable;
+
+  void insert(ArrayRef Signature);
+
+public:
+  static constexpr unsigned INVALID_INDEX = (unsigned)-1;
+
+  // Create compressed signature table from SemaRecords.
+  void init(ArrayRef SemaRecords);
+
+  // Query the Signature, return INVALID_INDEX if not found.
+  unsigned getIndex(ArrayRef Signature);
+
+  /// Print signature table in RVVHeader Record to \p OS
+  void print(raw_ostream &OS);
+};
+
 class RVVEmitter {
 private:
   RecordKeeper &Records;
@@ -45,22 +99,22 @@
   /// Emit all the information needed to map builtin -> LLVM IR intrinsic.
   void createCodeGen(raw_ostream &o);
 
+  /// Emit all the information needed by SemaRISCVVectorLookup.cpp.
+  /// We've large number of intrinsic function for RVV, creating a customized
+  /// could speed up the compila

[PATCH] D128821: [clangd][ObjC] Fix ObjC method definition completion

2022-07-01 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 441685.
dgoldman added a comment.

- Use codeCompletionString(Result) for RK_Pattern


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128821

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3131,6 +3131,26 @@
   EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
 }
 
+TEST(CompletionTest, ObjectiveCMethodDeclarationFilterOnEntireSelector) {
+  auto Results = completions(R"objc(
+  @interface Foo
+  - (int)valueForCharacter:(char)c secondArgument:(id)object;
+  @end
+  @implementation Foo
+  secondArg^
+  @end
+)objc",
+ /*IndexSymbols=*/{},
+ /*Opts=*/{}, "Foo.m");
+
+  auto C = Results.Completions;
+  EXPECT_THAT(C, ElementsAre(named("valueForCharacter:")));
+  EXPECT_THAT(C, ElementsAre(filterText("valueForCharacter:secondArgument:")));
+  EXPECT_THAT(C, ElementsAre(kind(CompletionItemKind::Method)));
+  EXPECT_THAT(C, ElementsAre(qualifier("- (int)")));
+  EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
+}
+
 TEST(CompletionTest, ObjectiveCMethodDeclarationPrefixTyped) {
   auto Results = completions(R"objc(
   @interface Foo
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -861,7 +861,7 @@
 case CodeCompletionResult::RK_Macro:
   return Result.Macro->getName();
 case CodeCompletionResult::RK_Pattern:
-  return Result.Pattern->getTypedText();
+  break;
 }
 auto *CCS = codeCompletionString(Result);
 const CodeCompletionString::Chunk *OnlyText = nullptr;


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3131,6 +3131,26 @@
   EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
 }
 
+TEST(CompletionTest, ObjectiveCMethodDeclarationFilterOnEntireSelector) {
+  auto Results = completions(R"objc(
+  @interface Foo
+  - (int)valueForCharacter:(char)c secondArgument:(id)object;
+  @end
+  @implementation Foo
+  secondArg^
+  @end
+)objc",
+ /*IndexSymbols=*/{},
+ /*Opts=*/{}, "Foo.m");
+
+  auto C = Results.Completions;
+  EXPECT_THAT(C, ElementsAre(named("valueForCharacter:")));
+  EXPECT_THAT(C, ElementsAre(filterText("valueForCharacter:secondArgument:")));
+  EXPECT_THAT(C, ElementsAre(kind(CompletionItemKind::Method)));
+  EXPECT_THAT(C, ElementsAre(qualifier("- (int)")));
+  EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
+}
+
 TEST(CompletionTest, ObjectiveCMethodDeclarationPrefixTyped) {
   auto Results = completions(R"objc(
   @interface Foo
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -861,7 +861,7 @@
 case CodeCompletionResult::RK_Macro:
   return Result.Macro->getName();
 case CodeCompletionResult::RK_Pattern:
-  return Result.Pattern->getTypedText();
+  break;
 }
 auto *CCS = codeCompletionString(Result);
 const CodeCompletionString::Chunk *OnlyText = nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] dc6c1f1 - [clangd][ObjC] Fix ObjC method definition completion

2022-07-01 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2022-07-01T10:02:47-04:00
New Revision: dc6c1f181b8a95b959f590423ce007b819532290

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

LOG: [clangd][ObjC] Fix ObjC method definition completion

D124637 improved filtering of method expressions, but not method
definitions. With this change, clangd will now filter ObjC method
definition completions based on their entire selector instead of
only the first selector fragment.

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index fbd7488c07d21..2da83c05e9702 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -861,7 +861,7 @@ struct CompletionRecorder : public CodeCompleteConsumer {
 case CodeCompletionResult::RK_Macro:
   return Result.Macro->getName();
 case CodeCompletionResult::RK_Pattern:
-  return Result.Pattern->getTypedText();
+  break;
 }
 auto *CCS = codeCompletionString(Result);
 const CodeCompletionString::Chunk *OnlyText = nullptr;

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index f962c3f4ff336..6084a024bea38 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3131,6 +3131,26 @@ TEST(CompletionTest, ObjectiveCMethodDeclaration) {
   EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
 }
 
+TEST(CompletionTest, ObjectiveCMethodDeclarationFilterOnEntireSelector) {
+  auto Results = completions(R"objc(
+  @interface Foo
+  - (int)valueForCharacter:(char)c secondArgument:(id)object;
+  @end
+  @implementation Foo
+  secondArg^
+  @end
+)objc",
+ /*IndexSymbols=*/{},
+ /*Opts=*/{}, "Foo.m");
+
+  auto C = Results.Completions;
+  EXPECT_THAT(C, ElementsAre(named("valueForCharacter:")));
+  EXPECT_THAT(C, ElementsAre(filterText("valueForCharacter:secondArgument:")));
+  EXPECT_THAT(C, ElementsAre(kind(CompletionItemKind::Method)));
+  EXPECT_THAT(C, ElementsAre(qualifier("- (int)")));
+  EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
+}
+
 TEST(CompletionTest, ObjectiveCMethodDeclarationPrefixTyped) {
   auto Results = completions(R"objc(
   @interface Foo



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


[PATCH] D128821: [clangd][ObjC] Fix ObjC method definition completion

2022-07-01 Thread David Goldman 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 rGdc6c1f181b8a: [clangd][ObjC] Fix ObjC method definition 
completion (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128821

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3131,6 +3131,26 @@
   EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
 }
 
+TEST(CompletionTest, ObjectiveCMethodDeclarationFilterOnEntireSelector) {
+  auto Results = completions(R"objc(
+  @interface Foo
+  - (int)valueForCharacter:(char)c secondArgument:(id)object;
+  @end
+  @implementation Foo
+  secondArg^
+  @end
+)objc",
+ /*IndexSymbols=*/{},
+ /*Opts=*/{}, "Foo.m");
+
+  auto C = Results.Completions;
+  EXPECT_THAT(C, ElementsAre(named("valueForCharacter:")));
+  EXPECT_THAT(C, ElementsAre(filterText("valueForCharacter:secondArgument:")));
+  EXPECT_THAT(C, ElementsAre(kind(CompletionItemKind::Method)));
+  EXPECT_THAT(C, ElementsAre(qualifier("- (int)")));
+  EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
+}
+
 TEST(CompletionTest, ObjectiveCMethodDeclarationPrefixTyped) {
   auto Results = completions(R"objc(
   @interface Foo
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -861,7 +861,7 @@
 case CodeCompletionResult::RK_Macro:
   return Result.Macro->getName();
 case CodeCompletionResult::RK_Pattern:
-  return Result.Pattern->getTypedText();
+  break;
 }
 auto *CCS = codeCompletionString(Result);
 const CodeCompletionString::Chunk *OnlyText = nullptr;


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3131,6 +3131,26 @@
   EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
 }
 
+TEST(CompletionTest, ObjectiveCMethodDeclarationFilterOnEntireSelector) {
+  auto Results = completions(R"objc(
+  @interface Foo
+  - (int)valueForCharacter:(char)c secondArgument:(id)object;
+  @end
+  @implementation Foo
+  secondArg^
+  @end
+)objc",
+ /*IndexSymbols=*/{},
+ /*Opts=*/{}, "Foo.m");
+
+  auto C = Results.Completions;
+  EXPECT_THAT(C, ElementsAre(named("valueForCharacter:")));
+  EXPECT_THAT(C, ElementsAre(filterText("valueForCharacter:secondArgument:")));
+  EXPECT_THAT(C, ElementsAre(kind(CompletionItemKind::Method)));
+  EXPECT_THAT(C, ElementsAre(qualifier("- (int)")));
+  EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
+}
+
 TEST(CompletionTest, ObjectiveCMethodDeclarationPrefixTyped) {
   auto Results = completions(R"objc(
   @interface Foo
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -861,7 +861,7 @@
 case CodeCompletionResult::RK_Macro:
   return Result.Macro->getName();
 case CodeCompletionResult::RK_Pattern:
-  return Result.Pattern->getTypedText();
+  break;
 }
 auto *CCS = codeCompletionString(Result);
 const CodeCompletionString::Chunk *OnlyText = nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75788: [OpenMP] Provide math functions in OpenMP device code via OpenMP variants

2022-07-01 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added inline comments.
Herald added subscribers: kosarev, mattd, asavonic, sstefan1, MaskRay.
Herald added a project: All.



Comment at: clang/lib/Headers/CMakeLists.txt:145
 
 set(openmp_wrapper_files
   openmp_wrappers/math.h

It doesn't contain , intentional?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788

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


[PATCH] D123319: Change how we handle auto return types for lambda operator() to be consistent with gcc

2022-07-01 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Seems like for an "auto"-returning function/lambda with a definition, the 
front-end should have deduced the return type, and so we should emit that in 
the DWARF, even if we end up emitting DWARF with both a declaration and a 
separate definition.

I accept that a member function declaration (no definition) returning "auto" is 
not hugely useful, although I reserve the right to make pedantic grousing 
noises. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123319

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


[PATCH] D119407: [PowerPC] [Clang] Add SSE4 and BMI compatible intrinsics implementation for PowerPC

2022-07-01 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added inline comments.



Comment at: clang/lib/Headers/CMakeLists.txt:170
+  ppc_wrappers/immintrin.h
+  ppc_wrappers/tmmintrin.h
+  ppc_wrappers/x86intrin.h

It doesn't contain , forgot?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119407

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


[PATCH] D128704: [clang-extdef-mapping] Directly process .ast files

2022-07-01 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks, this is a great addition!

- Please use Capitalized names for all the variables (as per the LLVM coding 
standards suggests here 
).
- Could you please update the release notes part of Clang Static Analyzer as 
this is a cool user facing change.

> I tried this on llvm/lib/AsmParser/Parser.cpp and running extdef-mapping on 
> the .cpp file took 5.4s on my machine. While running it on the .ast file it 
> took 2s.

I am wondering if you could have a comparison on more files? I think a 
measurement run on all `clang` source/ast files comparing the overall run-time 
could be even more persuasive.




Comment at: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp:124-129
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  TextDiagnosticPrinter *DiagClient =
+  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  IntrusiveRefCntPtr Diags(
+  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));

Is there a way to reuse the `DiagOpts` (and the other Diag variables) over the 
multiple `HandleAST` calls? If not then we might use smart pointers to avoid 
leaking.



Comment at: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp:142-143
+
+  std::unique_ptr consumer =
+  std::make_unique(unit->getASTContext(), absPath);
+  consumer->HandleTranslationUnit(unit->getASTContext());

Could this be a simple non-pointer variable?



Comment at: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp:151
+   CompilationDatabase &compilations) {
+  std::vector sourceToBeParsed;
+  for (StringRef src : sourceFiles) {

I'd rather use a plural from here, there might be more than one source files.



Comment at: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp:152
+  std::vector sourceToBeParsed;
+  for (StringRef src : sourceFiles) {
+if (src.endswith(".ast")) {

Could you please add a one-liner explanatory comment for this loop?



Comment at: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp:175-177
   const char *Overview = "\nThis tool collects the USR name and location "
  "of external definitions in the source files "
  "(excluding headers).\n";

Could you please extend the documentation of the tool with the new behavior?



Comment at: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp:122
+
+  CompilerInstance CI;
+

thieta wrote:
> Not sure if I can just create a compilerinstance here and if I should feed it 
> anymore data then I already do.
I think it is okay to create the `CI` like you do. However, it would be enough 
to create that only once, not in every `HandleAST` call. Perhaps, it could be 
`static` or you might pass a reference to it from `main`.



Comment at: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp:136
+  FileManager fm(CI.getFileSystemOpts());
+  SmallString<128> absPath(astPath);
+  fm.makeAbsolutePath(absPath);

thieta wrote:
> thieta wrote:
> > Pretty sure 128 is wrong here - but I searched the codebase and that seems 
> > to be the most common size used? I couldn't find anything using PATH_MAX or 
> > something like that.
> Never mind 128 is just the default size not the absolute size. Got it.
128 looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128704

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


RE: [clang] 4821508 - Revert "DebugInfo: Fully integrate ctor type homing into 'limited' debug info"

2022-07-01 Thread Robinson, Paul via cfe-commits
Hi Dave,

The original commit message included
Also fix a bug I found along the way that was causing ctor type homing
to kick in even when something could be vtable homed

Is it reasonable to fix that without removing ctor homing in general?
Or would that cause too much test churn, as you're planning to recommit
this patch anyway?
--paulr

> -Original Message-
> From: cfe-commits  On Behalf Of David
> Blaikie via cfe-commits
> Sent: Friday, June 24, 2022 1:08 PM
> To: cfe-commits@lists.llvm.org
> Subject: [clang] 4821508 - Revert "DebugInfo: Fully integrate ctor type
> homing into 'limited' debug info"
> 
> 
> Author: David Blaikie
> Date: 2022-06-24T17:07:47Z
> New Revision: 4821508d4db75a535d02b8938f81fac6de66cc26
> 
> URL: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> project/commit/4821508d4db75a535d02b8938f81fac6de66cc26__;!!JmoZiZGBv3RvKR
> Sx!7pmjZG0ponrxAVY0dOSOTgWfvxMgERh3TNpn2zRGr7NTuooxwQKHzTroRX39LtKaKCXGoQD
> n3Ri4BOhJymrwDVc8Rzk$
> DIFF: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> project/commit/4821508d4db75a535d02b8938f81fac6de66cc26.diff__;!!JmoZiZGBv
> 3RvKRSx!7pmjZG0ponrxAVY0dOSOTgWfvxMgERh3TNpn2zRGr7NTuooxwQKHzTroRX39LtKaKC
> XGoQDn3Ri4BOhJymrwKAIx5Rg$
> 
> LOG: Revert "DebugInfo: Fully integrate ctor type homing into 'limited'
> debug info"
> 
> Reverting to simplify some Google-internal rollout issues. Will recommit
> in a week or two.
> 
> This reverts commit 517bbc64dbe493644eff8d55fd9566435e930520.
> 
> Added:
> clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
> 
> Modified:
> clang/docs/UsersManual.rst
> clang/include/clang/Basic/CodeGenOptions.h
> clang/include/clang/Basic/DebugInfoOptions.h
> clang/include/clang/Driver/Options.td
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/lib/Frontend/CompilerInvocation.cpp
> clang/test/CodeGen/attr-cpuspecific-renaming.cpp
> clang/test/CodeGen/pr52782-stdcall-func-decl.cpp
> clang/test/CodeGenCXX/debug-info-class.cpp
> clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
> clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
> clang/test/CodeGenCXX/debug-lambda-this.cpp
> clang/test/CodeGenCXX/ibm128-declarations.cpp
> clang/test/CodeGenCXX/standalone-debug-attribute.cpp
> clang/test/Driver/cl-options.c
> clang/test/Driver/clang-g-opts.c
> clang/test/Driver/cuda-dwarf-2.cu
> clang/test/Driver/debug-options-as.c
> clang/test/Driver/debug-options.c
> clang/test/Driver/integrated-as.s
> clang/test/Driver/myriad-toolchain.c
> clang/test/Driver/openmp-offload-gpu.c
> clang/test/Driver/split-debug.c
> clang/test/OpenMP/debug_private.c
> clang/test/OpenMP/debug_task_shared.c
> clang/test/OpenMP/debug_threadprivate_copyin.c
> 
> Removed:
> 
> 
> 
> ##
> ##
> diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
> index ccb5fed1cb370..e12dc72407b13 100644
> --- a/clang/docs/UsersManual.rst
> +++ b/clang/docs/UsersManual.rst
> @@ -2672,6 +2672,19 @@ below. If multiple flags are present, the last one
> is used.
> **-fno-standalone-debug** option can be used to get to turn on the
> vtable-based optimization described above.
> 
> +.. option:: -fuse-ctor-homing
> +
> +   This optimization is similar to the optimizations that are enabled as
> part
> +   of -fno-standalone-debug. Here, Clang only emits type info for a
> +   non-trivial, non-aggregate C++ class in the modules that contain a
> +   definition of one of its constructors. This relies on the additional
> +   assumption that all classes that are not trivially constructible have
> a
> +   non-trivial constructor that is used somewhere. The negation,
> +   -fno-use-ctor-homing, ensures that constructor homing is not used.
> +
> +   This flag is not enabled by default, and needs to be used with -cc1 or
> +   -Xclang.
> +
>  .. option:: -g
> 
>Generate complete debug info.
> 
> diff  --git a/clang/include/clang/Basic/CodeGenOptions.h
> b/clang/include/clang/Basic/CodeGenOptions.h
> index 5f5218c87a605..23d76c308d847 100644
> --- a/clang/include/clang/Basic/CodeGenOptions.h
> +++ b/clang/include/clang/Basic/CodeGenOptions.h
> @@ -468,7 +468,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
> 
>/// Check if type and variable info should be emitted.
>bool hasReducedDebugInfo() const {
> -return getDebugInfo() >= codegenoptions::LimitedDebugInfo;
> +return getDebugInfo() >= codegenoptions::DebugInfoConstructor;
>}
> 
>/// Check if maybe unused type info should be emitted.
> 
> diff  --git a/clang/include/clang/Basic/DebugInfoOptions.h
> b/clang/include/clang/Basic/DebugInfoOptions.h
> index 98210cc3cfa13..a99a2b5903d7e 100644
> --- a/clang/include/clang/Basic/DebugInfoOptions.h
> +++ b/clang/include/clang/Basic/DebugInfoOptions.h
> @@ -34,6 +34,12 @@ enum DebugIn

[PATCH] D128119: [clang] enforce instantiation of constexpr template functions

2022-07-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: rsmith, clang-language-wg.
aaron.ballman added a comment.

It's a bummer that patch application failed on precommit CI for reasons 
unrelated to your patch (as best I can tell, anyway)... Also, please update the 
patch summary to have some more details about what your changing and why.




Comment at: clang/test/SemaCXX/constexpr-late-instantiation.cpp:1
+// Make sure foo is sinstantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s





Comment at: clang/test/SemaCXX/constexpr-late-instantiation.cpp:2
+// Make sure foo is sinstantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+

This test should be in CodeGenCXX, not SemaCXX. But there is a SemaCXX test I'd 
appreciate:
```
template 
constexpr T foo(T a);

int main() {
  int k = foo(5); // Ok
  constexpr int j = foo(5); // Not okay, a definition is needed for this
}

template 
constexpr T foo(T a) {
  return a;
}
```


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

https://reviews.llvm.org/D128119

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


[PATCH] D128119: [clang] enforce instantiation of constexpr template functions

2022-07-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4859
 << Function;
+  } else if (!Recursive) {
+Function->setInstantiationIsPending(true);

This condition seems a little aggressive, and will end up instantiating way 
more than just constexprs here, right?  I guess my real question is what it is 
about the constexpr that makes us decide to skip the instantiation earlier.


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

https://reviews.llvm.org/D128119

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


[PATCH] D128012: [HLSL] Add ExternalSemaSource & vector alias

2022-07-01 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

gentle ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128012

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


[PATCH] D128449: [clang] Introduce -Warray-parameter

2022-07-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:3216
+   (Ty->isVariableArrayType() &&
+cast(Ty)->getSizeModifier() ==
+ArrayType::ArraySizeModifier::Star);

I forgot about this gotcha -- arrays are special in that you shouldn't be using 
`cast<>` and friends on them, you need to ask the `ASTContext` to go from the 
`QualType` to the correct array type. e.g., 
`ASTContext::getAsConstantArrayType()` and 
`ASTContext::getAsVariableArrayType()` -- I think this is the cause of the 
failed assertions we're seeing in precommit CI.


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

https://reviews.llvm.org/D128449

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


[clang-tools-extra] a322c10 - [pseudo] temporary fix for missing generated header after fe66aebd755191fac6

2022-07-01 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-07-01T16:45:22+02:00
New Revision: a322c104cb5987df93be22b09e527a8a0c932af5

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

LOG: [pseudo] temporary fix for missing generated header after 
fe66aebd755191fac6

Better fix to be added by Haojian later!

Added: 


Modified: 
clang-tools-extra/pseudo/lib/cli/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/pseudo/lib/cli/CMakeLists.txt 
b/clang-tools-extra/pseudo/lib/cli/CMakeLists.txt
index 25b3d9e1425c0..68e644f62fded 100644
--- a/clang-tools-extra/pseudo/lib/cli/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/lib/cli/CMakeLists.txt
@@ -5,6 +5,10 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangPseudoCLI
   CLI.cpp
 
+  # FIXME export the headers from clangPseudoCXX instead
+  DEPENDS
+  cxx_gen
+
   LINK_LIBS
   clangPseudoGrammar
   clangPseudoCXX



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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-01 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added a comment.

Just nits from me.




Comment at: clang/include/clang/Sema/RISCVIntrinsicManager.h:9
+//
+// This file defines the RISCVIntrinsicManager, which handle RISC-V vector
+// intrinsic functions.

`handles`



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:49
+  // Index of RISCVIntrinsicManagerImpl::IntrinsicList.
+  SmallVector Indexs;
+};

`Indices` (or `Indexes`)?



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:218
+  for (int Log2LMUL = -3; Log2LMUL <= 3; Log2LMUL++) {
+if (!(Record.Log2LMULMask & (1 << (Log2LMUL + 3 {
+  continue;

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:185-186
+   
Record.OverloadedSuffixSize);
+for (int TypeRangeMaskShift = 0;
+ TypeRangeMaskShift <= static_cast(BasicType::MaxOffset);
+ ++TypeRangeMaskShift) {

aaron.ballman wrote:
> Given that we're bit twiddling with this, I'd feel more comfortable if this 
> was `unsigned int` rather than `int` (same for `BaseTypeI`).
+1



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:47
+
+  // Required extensions for this intrinsic.
+  unsigned RequiredExtension;

Comment is plural, variable is singular.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:111
+   std::vector *SemaRecords = nullptr);
+  /// Create all intrinsics record and SemaSignatureTable from SemaRecords.
+  void createRVVIntrinsicRecord(std::vector &Out,

all records, plural?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:578
+
+if (SemaRecords) {
+  // Create SemaRecord

`if (!SemaRecords) continue;`? Might make things a little more readable.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:637
+Out.emplace_back(Record);
+Out.back().Name = SR.Name.c_str();
+Out.back().OverloadedName = SR.OverloadedName.c_str();

I assume the compiler's able to avoid recomputing `Out.back()` multiple times? 
We could take a reference to `Out.back()` and use that, just in case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-01 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 441692.
kito-cheng marked 18 inline comments as done.
kito-cheng added a comment.

Changes:

- Address @aaron.ballman’s comment
  - Add 2 new testcase:
- riscv-bad-intrnisic-pragma.c
- riscv-intrnisic-pragma.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

Files:
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/RISCVIntrinsicManager.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/test/Sema/riscv-bad-intrnisic-pragma.c
  clang/test/Sema/riscv-intrnisic-pragma.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -110,6 +110,7 @@
 void EmitRVVHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitRVVBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
 void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -88,6 +88,7 @@
   GenRISCVVectorHeader,
   GenRISCVVectorBuiltins,
   GenRISCVVectorBuiltinCG,
+  GenRISCVVectorBuiltinSema,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -243,6 +244,8 @@
"Generate riscv_vector_builtins.inc for clang"),
 clEnumValN(GenRISCVVectorBuiltinCG, "gen-riscv-vector-builtin-codegen",
"Generate riscv_vector_builtin_cg.inc for clang"),
+clEnumValN(GenRISCVVectorBuiltinSema, "gen-riscv-vector-builtin-sema",
+   "Generate riscv_vector_builtin_sema.inc for clang"),
 clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
 clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -458,6 +461,9 @@
   case GenRISCVVectorBuiltinCG:
 EmitRVVBuiltinCG(Records, OS);
 break;
+  case GenRISCVVectorBuiltinSema:
+EmitRVVBuiltinSema(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
@@ -29,6 +30,59 @@
 using namespace clang::RISCV;
 
 namespace {
+struct SemaRecord {
+  // Intrinsic name, e.g. vadd_vv
+  std::string Name;
+
+  // Overloaded intrinsic name, could be empty if can be computed from Name
+  // e.g. vadd
+  std::string OverloadedName;
+
+  // Supported type, mask of BasicType.
+  unsigned TypeRangeMask;
+
+  // Supported LMUL.
+  unsigned Log2LMULMask;
+
+  // Required extensions for this intrinsic.
+  unsigned RequiredExtension;
+
+  // Prototype for this intrinsic.
+  SmallVector Prototype;
+
+  // Prototype for masked intrinsic.
+  SmallVector MaskedPrototype;
+
+  // Suffix of intrinsic name.
+  SmallVector Suffix;
+
+  // Suffix of overloaded intrinsic name.
+  SmallVector OverloadedSuffix;
+
+  // Number of field, large than 1 if it's segment load/store.
+  unsigned NF;
+};
+
+// Compressed function signature table.
+class SemaSignatureTable {
+private:
+  std::vector SignatureTable;
+
+  void insert(ArrayRef Signature);
+
+public:
+  static constexpr unsigned INVALID_INDEX = ~0U;
+
+  // Create compressed signature table from SemaRecords.
+  void init(ArrayRef SemaRecords);
+
+  // Query the Signature, return INVALID_INDEX if not found.
+  unsigned getIndex(ArrayRef Signature);
+
+  /// Print signature table in RVVHeader Record to \p OS
+  void print(raw_ostream &OS);
+};
+
 class RVVEmitter {
 private:
   RecordKeeper &Records;
@@ -45,22 +99,22 @@
   /// Emit all the information needed to map builtin -> LLVM IR intrinsic.
   void createCodeGen(raw_ostream &o);
 
+  /// Emit all the information needed by SemaRISCVVectorLookup.cpp.
+  /// We've 

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-01 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: clang/lib/Parse/ParsePragma.cpp:3963
+<< PP.getSpelling(Tok) << "riscv" << /*Expected=*/true << 
"'intrinsic'";
+return;
+  }

aaron.ballman wrote:
> It's fine to warn on this, but then you need to eat tokens until the end of 
> directive is found so that parsing recovery is correct. e.g.,
> ```
> #pragma clang riscv int i = 12;
> ```
> See `HandlePragmaAttribute()` for an example (though you'll look for `eod` 
> instead of `eof`).
Seems like it already work correctly, and I saw other HandlePragma also just 
return? I add a testcase to make sure it work.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:100
+switch (Type->getElementBitwidth()) {
+case 64:
+  QT = Context.DoubleTy;

aaron.ballman wrote:
> I almost hate to ask, but... `long double`? Any of the 16-bit float types?
Have 16 bit floating below, but we don't support long double in our intrinsic 
for now, add an assertion to make sure.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:121
+  // Transform the type to a pointer as the last step, if necessary.
+  if (Type->isPointer())
+QT = Context.getPointerType(QT);

aaron.ballman wrote:
> Double-checking -- do you have to care about references as well?
We don't have any references type in argument type, so we don't care about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-07-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParsePragma.cpp:3963
+<< PP.getSpelling(Tok) << "riscv" << /*Expected=*/true << 
"'intrinsic'";
+return;
+  }

kito-cheng wrote:
> aaron.ballman wrote:
> > It's fine to warn on this, but then you need to eat tokens until the end of 
> > directive is found so that parsing recovery is correct. e.g.,
> > ```
> > #pragma clang riscv int i = 12;
> > ```
> > See `HandlePragmaAttribute()` for an example (though you'll look for `eod` 
> > instead of `eof`).
> Seems like it already work correctly, and I saw other HandlePragma also just 
> return? I add a testcase to make sure it work.
Ah, you're right, it's the *other* form of pragma handling that needs to do 
that dance, sorry for the noise but thank you for the additional test coverage!



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:100
+switch (Type->getElementBitwidth()) {
+case 64:
+  QT = Context.DoubleTy;

kito-cheng wrote:
> aaron.ballman wrote:
> > I almost hate to ask, but... `long double`? Any of the 16-bit float types?
> Have 16 bit floating below, but we don't support long double in our intrinsic 
> for now, add an assertion to make sure.
Very glad to hear about `long double`, but I was unclear on the 16-bit float, I 
was more wondering if you need to differentiate between `Float16Ty`, 
`BFloat16Ty`, and `HalfTy` since those will all have the same bit widths but be 
different types.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:121
+  // Transform the type to a pointer as the last step, if necessary.
+  if (Type->isPointer())
+QT = Context.getPointerType(QT);

kito-cheng wrote:
> aaron.ballman wrote:
> > Double-checking -- do you have to care about references as well?
> We don't have any references type in argument type, so we don't care about 
> that.
Excellent, thank you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D128706: [Clang] Disable clang-format entirely for clang/test tree.

2022-07-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman commandeered this revision.
aaron.ballman edited reviewers, added: mboehme; removed: aaron.ballman.
aaron.ballman added a comment.

At the off-list request of @mboehme, I'm commandeering this review to take it 
over the finish line whenever the RFC finishes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128706

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


[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-07-01 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi updated this revision to Diff 441700.
akyrtzi added a comment.

Avoid changing the `SourceManager::getFilename()` implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128947

Files:
  clang-tools-extra/test/pp-trace/pp-trace-include.cpp
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Lex/PPLexerChange.cpp

Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -111,6 +111,7 @@
 ///  and start lexing tokens from it instead of the current buffer.
 void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
 ConstSearchDirIterator CurDir) {
+  PreprocessorLexer *PrevPPLexer = CurPPLexer;
 
   // Add the current lexer to the include stack.
   if (CurPPLexer || CurTokenLexer)
@@ -130,8 +131,17 @@
 SrcMgr::CharacteristicKind FileType =
SourceMgr.getFileCharacteristic(CurLexer->getFileLoc());
 
-Callbacks->FileChanged(CurLexer->getFileLoc(),
-   PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;
+if (PrevPPLexer) {
+  PrevFID = PrevPPLexer->getFileID();
+  EnterLoc = PrevPPLexer->getSourceLocation();
+}
+Callbacks->FileChanged(CurLexer->getFileLoc(), PPCallbacks::EnterFile,
+   FileType, PrevFID);
+Callbacks->LexedFileChanged(CurLexer->getFileID(),
+PPCallbacks::LexedFileChangeReason::EnterFile,
+FileType, PrevFID, EnterLoc);
   }
 }
 
@@ -486,10 +496,13 @@
 
 // Notify the client, if desired, that we are in a new source file.
 if (Callbacks && !isEndOfMacro && CurPPLexer) {
+  SourceLocation Loc = CurPPLexer->getSourceLocation();
   SrcMgr::CharacteristicKind FileType =
-SourceMgr.getFileCharacteristic(CurPPLexer->getSourceLocation());
-  Callbacks->FileChanged(CurPPLexer->getSourceLocation(),
- PPCallbacks::ExitFile, FileType, ExitedFID);
+  SourceMgr.getFileCharacteristic(Loc);
+  Callbacks->FileChanged(Loc, PPCallbacks::ExitFile, FileType, ExitedFID);
+  Callbacks->LexedFileChanged(CurPPLexer->getFileID(),
+  PPCallbacks::LexedFileChangeReason::ExitFile,
+  FileType, ExitedFID, Loc);
 }
 
 // Restore conditional stack as well as the recorded
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -31,23 +31,21 @@
 namespace {
 struct DepCollectorPPCallbacks : public PPCallbacks {
   DependencyCollector &DepCollector;
-  SourceManager &SM;
-  DiagnosticsEngine &Diags;
-  DepCollectorPPCallbacks(DependencyCollector &L, SourceManager &SM,
-  DiagnosticsEngine &Diags)
-  : DepCollector(L), SM(SM), Diags(Diags) {}
-
-  void FileChanged(SourceLocation Loc, FileChangeReason Reason,
-   SrcMgr::CharacteristicKind FileType,
-   FileID PrevFID) override {
-if (Reason != PPCallbacks::EnterFile)
+  Preprocessor &PP;
+  DepCollectorPPCallbacks(DependencyCollector &L, Preprocessor &PP)
+  : DepCollector(L), PP(PP) {}
+
+  void LexedFileChanged(FileID FID, LexedFileChangeReason Reason,
+SrcMgr::CharacteristicKind FileType, FileID PrevFID,
+SourceLocation Loc) override {
+if (Reason != PPCallbacks::LexedFileChangeReason::EnterFile)
   return;
 
 // Dependency generation really does want to go all the way to the
 // file entry for a source location to find out what is depended on.
 // We do not want #line markers to affect dependency generation!
-if (Optional Filename = SM.getNonBuiltinFilenameForID(
-SM.getFileID(SM.getExpansionLoc(Loc
+if (Optional Filename =
+PP.getSourceManager().getNonBuiltinFilenameForID(FID))
   DepCollector.maybeAddDependency(
   llvm::sys::path::remove_leading_dotslash(*Filename),
   /*FromModule*/ false, isSystem(FileType), /*IsModuleFile*/ false,
@@ -90,7 +88,9 @@
 /*IsMissing=*/false);
   }
 
-  void EndOfMainFile() override { DepCollector.finishedMainFile(Diags); }
+  void EndOfMainFile() override {
+DepCollector.finishedMainFile(PP.getDiagnostics());
+  }
 };
 
 struct DepCollectorMMCallbacks : public ModuleMapCallbacks {
@@ -175,8 +175,7 @@
 
 DependencyCollector::~DependencyCollector() { }
 void DependencyCollector::attachToPreprocessor(Preprocessor &PP) {
-  PP.addPPCallbacks(std::make_unique(
-  *this, PP.getSourceManager(), PP.getDiagnostics()));
+  PP.addPPCallbacks(std::make_u

[clang] 2750985 - [NFC] Add a missing test for for clang-repl

2022-07-01 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-07-01T23:26:54+08:00
New Revision: 2750985a5ccb97f4630c3443e75d78ed435d2bd0

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

LOG: [NFC] Add a missing test for for clang-repl

This adds a missing test for 0ecbedc0986bd4b7b90a60a5f31d32337160d4c4
Signed-off-by: Jun Zhang 

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

Added: 


Modified: 
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index f5c70c21ac507..8fb528c4750a8 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -18,4 +18,8 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, 
reinterpret_casthttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128991: [NFC] Add a missing test for for clang-repl

2022-07-01 Thread Jun Zhang 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 rG2750985a5ccb: [NFC] Add a missing test for for clang-repl 
(authored by junaire).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128991

Files:
  clang/test/Interpreter/execute.cpp


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -18,4 +18,8 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+int __attribute__((weak)) bar() { return 1; }
+auto r4 = printf("bar() = %d\n", bar());
+// CHECK-NEXT: bar() = 1
+
 %quit


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -18,4 +18,8 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+int __attribute__((weak)) bar() { return 1; }
+auto r4 = printf("bar() = %d\n", bar());
+// CHECK-NEXT: bar() = 1
+
 %quit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-07-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2273-2274
+bool Sema::isOpenMPRebuildMemberExpr(ValueDecl *D) {
+  if (getCurCapturedRegion() &&
+  getCurCapturedRegion()->CapRegionKind == CR_OpenMP) {
+DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA(

What if we have another outer OpenMP region, something like lambda inside 
OpenMP region?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127803

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


[PATCH] D113107: Support of expression granularity for _Float16.

2022-07-01 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 441702.
zahiraam marked 7 inline comments as done.

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

https://reviews.llvm.org/D113107

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/X86/Float16-arithmetic.c
  clang/test/CodeGen/X86/Float16-complex.c
  clang/test/Sema/Float16.c
  clang/test/SemaCXX/Float16.cpp

Index: clang/test/SemaCXX/Float16.cpp
===
--- clang/test/SemaCXX/Float16.cpp
+++ clang/test/SemaCXX/Float16.cpp
@@ -1,20 +1,10 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-pc %s
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-pc -target-feature +sse2 %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s
 
-#ifdef HAVE
 // expected-no-diagnostics
-#endif // HAVE
 
-#ifndef HAVE
-// expected-error@+2{{_Float16 is not supported on this target}}
-#endif // !HAVE
 _Float16 f;
 
-#ifndef HAVE
-// expected-error@+2{{invalid suffix 'F16' on floating constant}}
-#endif // !HAVE
 const auto g = 1.1F16;
Index: clang/test/Sema/Float16.c
===
--- clang/test/Sema/Float16.c
+++ clang/test/Sema/Float16.c
@@ -1,19 +1,15 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-pc %s
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-pc -target-feature +sse2 %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc -target-feature +avx512fp16 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc -target-feature +avx512fp16 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s
 
-#ifndef HAVE
-// expected-error@+2{{_Float16 is not supported on this target}}
-#endif // HAVE
-_Float16 f;
-
-#ifdef HAVE
 _Complex _Float16 a;
 void builtin_complex(void) {
   _Float16 a = 0;
   (void)__builtin_complex(a, a); // expected-error {{'_Complex _Float16' is invalid}}
 }
-#endif
Index: clang/test/CodeGen/X86/Float16-complex.c
===
--- clang/test/CodeGen/X86/Float16-complex.c
+++ clang/test/CodeGen/X86/Float16-complex.c
@@ -1,134 +1,422 @@
-// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -target-feature +avx512fp16 -o - | FileCheck %s --check-prefix=X86
-// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -target-feature +avx512fp16 -o - | FileCheck %s --check-prefixes=CHECK,AVX
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefixes=CHECK,X86
 
 _Float16 _Complex add_half_rr(_Float16 a, _Float16 b) {
-  // X86-LABEL: @add_half_rr(
-  // X86: fadd
-  // X86-NOT: fadd
-  // X86: ret
+  // CHECK-LABEL: @add_half_rr(
+  // CHECK: [[A:%.*]] = alloca half
+  // CHECK-NEXT: [[B:%.*]] = alloca half
+  // CHECK: [[A_LOAD:%.*]] = load half, ptr [[A]]
+
+  // AVX-NEXT: [[B_LOAD:%.*]] = load half, ptr [[B]]
+  // AVX-NEXT: [[AB_ADD:%.*]] = fadd half [[A_LOAD]], [[B_LOAD]]
+  // AVX: store half [[AB_ADD]], {{.*}}
+
+  // X86-NEXT: [[A_EXT:%.*]] = fpext half [[A_LOAD]] to float
+  // X86-NEXT: [[B_LOAD:%.*]] = load half, ptr [[B]]
+  // X86-NEXT: [[B_EXT:%.*]] = fpext half [[B_LOAD]] to float
+  // X86-NEXT: [[AB_ADD:%.*]] = fadd float [[A_EXT]], [[B_EXT]]
+  // X86-NEXT: [[AB_ADD_TRUN

[PATCH] D113107: Support of expression granularity for _Float16.

2022-07-01 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

Refactored the code as requested and fixed the compound operator promotion for 
scalar.
The operators that are left to complete are compound operators for complex type 
and ternary operator for scalar and complex types.
Then we need to add the option -fexcess-precision. I am not sure for now where 
and what values the _FLT_EVAL_METHOD should have when excess  precision is 
enabled/disabled.


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

https://reviews.llvm.org/D113107

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


[PATCH] D128991: [NFC] Add a missing test for for clang-repl

2022-07-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on Windows: http://45.33.8.238/win/61429/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128991

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


[PATCH] D112579: Allow non-variadic functions to be attributed with `__attribute__((format))`

2022-07-01 Thread Félix Cloutier via Phabricator via cfe-commits
fcloutier updated this revision to Diff 441703.
fcloutier set the repository for this revision to rG LLVM Github Monorepo.
fcloutier added a comment.

Thanks, Aaron. I wasn't sure how to follow up given how long it had been since 
the review started. I understand that we're all busy (which explains the week 
delay on my part here as well).

I've addressed all of your comments except the one on this bit 
:

  if (const FunctionType *FnTy = D->getFunctionType())
IsVariadic = cast(FnTy)->isVariadic();

The proposed change isn't identical because `D->getFunctionType()` can return 
nullptr (for instance, if `D` is a `BlockDecl`). However, in the case `FnTy` 
isn't nullptr, then it is guaranteed to be a `FunctionProtoType` as the 
attribute is rejected on functions without a prototype.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112579

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/FormatString.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-format.c
  clang/test/Sema/format-strings.c
  clang/test/SemaCXX/attr-format.cpp

Index: clang/test/SemaCXX/attr-format.cpp
===
--- clang/test/SemaCXX/attr-format.cpp
+++ clang/test/SemaCXX/attr-format.cpp
@@ -1,7 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -Wformat-nonliteral -verify %s
+#include 
+
+int printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
+
 struct S {
-  static void f(const char*, ...) __attribute__((format(printf, 1, 2)));
-  static const char* f2(const char*) __attribute__((format_arg(1)));
+  static void f(const char *, ...) __attribute__((format(printf, 1, 2)));
+  static const char *f2(const char *) __attribute__((format_arg(1)));
 
   // GCC has a hidden 'this' argument in member functions which is why
   // the format argument is argument 2 here.
@@ -38,6 +42,47 @@
 
 // Make sure we interpret member operator calls as having an implicit
 // this argument.
-void test_operator_call(S s, const char* str) {
+void test_operator_call(S s, const char *str) {
   s("%s", str);
 }
+
+template 
+void format(const char *fmt, Args &&...args) // expected-warning{{GCC requires a function with the 'format' attribute to be variadic}}
+__attribute__((format(printf, 1, 2)));
+
+template 
+Arg &expand(Arg &a) { return a; }
+
+struct foo {
+  int big[10];
+  foo();
+  ~foo();
+
+  template 
+  void format(const char *const fmt, Args &&...args) // expected-warning{{GCC requires a function with the 'format' attribute to be variadic}}
+  __attribute__((format(printf, 2, 3))) {
+printf(fmt, expand(args)...);
+  }
+};
+
+void format_invalid_nonpod(const char *fmt, struct foo f) // expected-warning{{GCC requires a function with the 'format' attribute to be variadic}}
+__attribute__((format(printf, 1, 2)));
+
+void do_format() {
+  int x = 123;
+  int &y = x;
+  const char *s = "world";
+  format("bare string");
+  format("%s", 123); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+  format("%s %s %u %d %i %p\n", "hello", s, 10u, x, y, &do_format);
+  format("%s %s %u %d %i %p\n", "hello", s, 10u, x, y, do_format);
+  format("bad format %s"); // expected-warning{{more '%' conversions than data arguments}}
+
+  struct foo f;
+  format_invalid_nonpod("hello %i", f); // expected-warning{{format specifies type 'int' but the argument has type 'struct foo'}}
+
+  f.format("%s", 123); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+  f.format("%s %s %u %d %i %p\n", "hello", s, 10u, x, y, &do_format);
+  f.format("%s %s %u %d %i %p\n", "hello", s, 10u, x, y, do_format);
+  f.format("bad format %s"); // expected-warning{{more '%' conversions than data arguments}}
+}
Index: clang/test/Sema/format-strings.c
===
--- clang/test/Sema/format-strings.c
+++ clang/test/Sema/format-strings.c
@@ -816,6 +816,7 @@
   __attribute__((__format__(__printf__, 2, 3))) {
 va_list ap;
 va_start(ap, fmt);
+vprintf(fmt, ap);
 vprintf(not_fmt, ap); // expected-warning{{format string is not a string literal}}
 va_end(ap);
   };
Index: clang/test/Sema/attr-format.c
===
--- clang/test/Sema/attr-format.c
+++ clang/test/Sema/attr-format.c
@@ -2,18 +2,18 @@
 
 #include 
 
-void a(const char *a, ...) __attribute__((format(printf, 1,2))); // no-error
-void b(const char *a, ...) __attribute__((format(printf, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
-void c(const char *a, ...) __attribute__((format(printf, 0,2))); // expected-error {{'format' at

[PATCH] D128991: [NFC] Add a missing test for for clang-repl

2022-07-01 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

In D128991#3625194 , @thakis wrote:

> Looks like this breaks tests on Windows: 
> http://45.33.8.238/win/61429/step_7.txt
>
> Please take a look and revert for now if it takes a while to fix.

Thanks for the heads up, I'll revert it for now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128991

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


[clang] 3668d12 - Revert "[NFC] Add a missing test for for clang-repl"

2022-07-01 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-07-01T23:55:55+08:00
New Revision: 3668d1264e2d246f7e222338b8a5cab18ce1bdab

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

LOG: Revert "[NFC] Add a missing test for for clang-repl"

This reverts commit 2750985a5ccb97f4630c3443e75d78ed435d2bd0.
This has caused Windows buildbot unhappy :(

Added: 


Modified: 
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index 8fb528c4750a8..f5c70c21ac507 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -18,8 +18,4 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, 
reinterpret_casthttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-07-01 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2273-2274
+bool Sema::isOpenMPRebuildMemberExpr(ValueDecl *D) {
+  if (getCurCapturedRegion() &&
+  getCurCapturedRegion()->CapRegionKind == CR_OpenMP) {
+DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA(

ABataev wrote:
> What if we have another outer OpenMP region, something like lambda inside 
> OpenMP region?
My understanding is that hasDSA will go up to find innermost openmp region 
which has default clause.  Am I right here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127803

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


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-07-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2273-2274
+bool Sema::isOpenMPRebuildMemberExpr(ValueDecl *D) {
+  if (getCurCapturedRegion() &&
+  getCurCapturedRegion()->CapRegionKind == CR_OpenMP) {
+DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA(

jyu2 wrote:
> ABataev wrote:
> > What if we have another outer OpenMP region, something like lambda inside 
> > OpenMP region?
> My understanding is that hasDSA will go up to find innermost openmp region 
> which has default clause.  Am I right here?
Yes, if you're immediate captured region is OpenMP region. But what if you're 
inside lambda, which is inside OpenMP region? In this case 
getCurCapturedRegion()->CapRegionKind != CR_OpenMP. Will it still work, could 
add a test for this situation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127803

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


[PATCH] D128472: [pseudo] Check follow-sets instead of tying reduce actions to lookahead tokens.

2022-07-01 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

Our downstream bots have failed when using `LLVM_ENABLE_EXPENSIVE_CHECKS=ON` , 
and I think (unless my bisecting got screwed up) that it started to happen 
after this patch.

We typically get

  Failed Tests (10):
ClangPseudo :: lr-build-basic.test
ClangPseudo :: lr-build-conflicts.test
clangPseudo Unit Tests :: ./ClangPseudoTests/10/31
clangPseudo Unit Tests :: ./ClangPseudoTests/11/31
clangPseudo Unit Tests :: ./ClangPseudoTests/12/31
clangPseudo Unit Tests :: ./ClangPseudoTests/13/31
clangPseudo Unit Tests :: ./ClangPseudoTests/14/31
clangPseudo Unit Tests :: ./ClangPseudoTests/15/31
clangPseudo Unit Tests :: ./ClangPseudoTests/16/31
clangPseudo Unit Tests :: ./ClangPseudoTests/9/31

And the failing stack traces look like this:

  
/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../include/c++/9.3.0/bits/stl_vector.h:1060:
 std::vector::const_reference std::vector >::operator[](std::vector::size_type) const [_Tp 
= unsigned short, _Alloc = std::allocator]: Assertion 
'__builtin_expect(__n < this->size(), true)' failed.
   #0 0x0047b6b3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/repo/llvm/build-all-expensive/tools/clang/tools/extra/pseudo/unittests/./ClangPseudoTests+0x47b6b3)
   #1 0x004795cc llvm::sys::RunSignalHandlers() 
(/repo/llvm/build-all-expensive/tools/clang/tools/extra/pseudo/unittests/./ClangPseudoTests+0x4795cc)
   #2 0x0047bcc6 SignalHandler(int) 
(/repo/llvm/build-all-expensive/tools/clang/tools/extra/pseudo/unittests/./ClangPseudoTests+0x47bcc6)
   #3 0x7f9ace5af630 __restore_rt (/lib64/libpthread.so.0+0xf630)
   #4 0x7f9acd6ce387 __GI_raise (/lib64/libc.so.6+0x36387)
   #5 0x7f9acd6cfa78 __GI_abort (/lib64/libc.so.6+0x37a78)
   #6 0x0045b988 
(/repo/llvm/build-all-expensive/tools/clang/tools/extra/pseudo/unittests/./ClangPseudoTests+0x45b988)
   #7 0x004e42a6 clang::pseudo::(anonymous 
namespace)::GLRReduce::popPending() 
(/repo/llvm/build-all-expensive/tools/clang/tools/extra/pseudo/unittests/./ClangPseudoTests+0x4e42a6)
   #8 0x004e15f2 clang::pseudo::(anonymous 
namespace)::GLRReduce::operator()(std::vector >&, unsigned short) 
(/repo/llvm/build-all-expensive/tools/clang/tools/extra/pseudo/unittests/./ClangPseudoTests+0x4e15f2)
   #9 0x004e2e15 
clang::pseudo::glrReduce(std::vector >&, unsigned short, 
clang::pseudo::ParseParams const&) 
(/repo/llvm/build-all-expensive/tools/clang/tools/extra/pseudo/unittests/./ClangPseudoTests+0x4e2e15)
  #10 0x00432379 clang::pseudo::(anonymous 
namespace)::GLRTest_ReduceConflictsSplitting_Test::TestBody() 
(/repo/llvm/build-all-expensive/tools/clang/tools/extra/pseudo/unittests/./ClangPseudoTests+0x432379)
  #11 0x004b8b6c testing::Test::Run() 
(/repo/llvm/build-all-expensive/tools/clang/tools/extra/pseudo/unittests/./ClangPseudoTests+0x4b8b6c)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128472

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


[PATCH] D128012: [HLSL] Add ExternalSemaSource & vector alias

2022-07-01 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:52
+
+  llvm::SmallVector TemplateArgs;
+




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128012

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


[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-07-01 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added inline comments.



Comment at: clang/lib/Lex/PPLexerChange.cpp:136
PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;

akyrtzi wrote:
> benlangmuir wrote:
> > Why does `LexedFileChanged` have `PrevFID` set, but `FileChanged` does not 
> > (it has a default argument of `FileID()`?  I would have expected that when 
> > you call both `FileChanged` and `LexedFileChanged` for the same event this 
> > would match.
> I didn't want to change the "contract" of `FileChanged()` as part of these 
> changes but it's probably unlikely that someone depends on `FileID` being 
> invalid, I'll give it a try.
I'm passing a `PrevFID` value for `FileChanged()` as well and I only had to 
update one test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128947

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


[PATCH] D128783: [test] Check for more -fsanitize=array-bounds regressions

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

`clang/test/SemaCXX/array-bounds.cpp` has `tailpad` and `metaprogramming` tests 
which may be added here.

Happy when @serge-sans-paille is happy.


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

https://reviews.llvm.org/D128783

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


[PATCH] D128953: [NFC] refactor compression namespaces making way for a possible introduction of alternatives to zlib compression in the llvm toolchain.

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> [NFC] refactor compression namespaces making way for a possible introduction 
> of alternatives to zlib compression in the llvm toolchain.

I'd use `[NFC] Refactor llvm::zlib namespace` and place supplementary wording 
to the body.

`in the llvm toolchain` is redundant in the sentence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[clang] 6213dba - [CMake][Fuchsia] Use libunwind as the default unwinder

2022-07-01 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-07-01T17:24:00Z
New Revision: 6213dba19fc0d65ab8b366b6d78c56cbd63c9d7d

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

LOG: [CMake][Fuchsia] Use libunwind as the default unwinder

Fuchsia already uses libunwind, but it does so implicitly via libc++.
This change makes the unwinder choice explicit.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 4e3ed6086dec5..3c6cfdaa1c1cc 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@ set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -119,7 +120,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
@@ -130,9 +130,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX "libc++" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
-set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind 
-static-libgcc" CACHE STRING "")
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
@@ -183,13 +180,10 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
-
set(RUNTIMES_${target}_LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")

diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 7b534e61f9520..83232b776ad9e 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@ set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")



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


[PATCH] D127887: [CMake][Fuchsia] Use libunwind as the default unwinder

2022-07-01 Thread Petr Hosek 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 rG6213dba19fc0: [CMake][Fuchsia] Use libunwind as the default 
unwinder (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127887

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -119,7 +120,6 @@
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
@@ -130,9 +130,6 @@
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX "libc++" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
-set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind 
-static-libgcc" CACHE STRING "")
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
@@ -183,13 +180,10 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
-
set(RUNTIMES_${target}_LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALY

[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-01 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@aaron.ballman FYI this is now core-approved


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[PATCH] D125683: [runtimes] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice

2022-07-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM




Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:122
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")

Would it be possible to add `set(RUNTIMES_${target}_LIBCXX_CXX_ABI 
"libcxxabi-objects" CACHE STRING "")` here?



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:189
 
set(RUNTIMES_${target}_LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")

Would it be possible to add `set(RUNTIMES_${target}_LIBCXX_CXX_ABI 
"libcxxabi-objects" CACHE STRING "")` here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125683

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


[PATCH] D129008: [Clang][OpenMP] Fix the issue that globalization doesn't work with byval struct function argument

2022-07-01 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ABataev.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch fixes the issue that the globalized variable is not properly
initialized when it is a byval struct function argument.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129008

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/OpenMP/globalization_byval_struct.c

Index: clang/test/OpenMP/globalization_byval_struct.c
===
--- /dev/null
+++ clang/test/OpenMP/globalization_byval_struct.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+extern int printf(const char *, ...);
+
+struct S {
+  int a;
+  float b;
+};
+
+// CHECK: define{{.*}}void @test(%struct.S* noundef byval(%struct.S) align {{[0-9]+}} [[arg:%[0-9a-zA-Z]+]])
+// CHECK: [[g:%[0-9a-zA-Z]+]] = call align {{[0-9]+}} i8* @__kmpc_alloc_shared
+// CHECK: bitcast i8* [[g]] to %struct.S*
+// CHECK: bitcast %struct.S* [[arg]] to i8**
+// CHECK: call void [[cc:@__copy_constructor[_0-9a-zA-Z]+]]
+// CHECK: void [[cc]]
+void test(struct S s) {
+#pragma omp parallel for
+  for (int i = 0; i < s.a; ++i) {
+printf("%i : %i : %f\n", i, s.a, s.b);
+  }
+}
+
+void foo() {
+  #pragma omp target teams num_teams(1)
+  {
+struct S s;
+s.a = 7;
+s.b = 11;
+test(s);
+  }
+}
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2471,65 +2471,66 @@
   Address DeclPtr = Address::invalid();
   Address AllocaPtr = Address::invalid();
   bool DoStore = false;
+  bool DoCopy = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);
-  // If we already have a pointer to the argument, reuse the input pointer.
-  if (Arg.isIndirect()) {
-// If we have a prettier pointer type at this point, bitcast to that.
-DeclPtr = Arg.getIndirectAddress();
-DeclPtr = Builder.CreateElementBitCast(DeclPtr, ConvertTypeForMem(Ty),
-   D.getName());
-// Indirect argument is in alloca address space, which may be different
-// from the default address space.
-auto AllocaAS = CGM.getASTAllocaAddressSpace();
-auto *V = DeclPtr.getPointer();
-AllocaPtr = DeclPtr;
-auto SrcLangAS = getLangOpts().OpenCL ? LangAS::opencl_private : AllocaAS;
-auto DestLangAS =
-getLangOpts().OpenCL ? LangAS::opencl_private : LangAS::Default;
-if (SrcLangAS != DestLangAS) {
-  assert(getContext().getTargetAddressSpace(SrcLangAS) ==
- CGM.getDataLayout().getAllocaAddrSpace());
-  auto DestAS = getContext().getTargetAddressSpace(DestLangAS);
-  auto *T = DeclPtr.getElementType()->getPointerTo(DestAS);
-  DeclPtr = DeclPtr.withPointer(getTargetHooks().performAddrSpaceCast(
-  *this, V, SrcLangAS, DestLangAS, T, true));
-}
 
-// Push a destructor cleanup for this parameter if the ABI requires it.
-// Don't push a cleanup in a thunk for a method that will also emit a
-// cleanup.
-if (Ty->isRecordType() && !CurFuncIsThunk &&
-Ty->castAs()->getDecl()->isParamDestroyedInCallee()) {
-  if (QualType::DestructionKind DtorKind =
-  D.needsDestruction(getContext())) {
-assert((DtorKind == QualType::DK_cxx_destructor ||
-DtorKind == QualType::DK_nontrivial_c_struct) &&
-   "unexpected destructor type");
-pushDestroy(DtorKind, DeclPtr, Ty);
-CalleeDestructedParamCleanups[cast(&D)] =
-EHStack.stable_begin();
-  }
-}
-  } else {
-// Check if the parameter address is controlled by OpenMP runtime.
-Address OpenMPLocalAddr =
-getLangOpts().OpenMP
-? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D)
-: Address::invalid();
-if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
-  DeclPtr = OpenMPLocalAddr;
+  // We first check if the parameter address is controlled by OpenMP.
+  if (getLangOpts().OpenMP) {
+DeclPtr = CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D);
+if (DeclPtr.isValid()) {
   AllocaPtr = DeclPtr;
-} else {
-  // Otherwise, create a temporary to hold the value.
-  DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(&D),
-  D.getName() + ".addr", &AllocaPtr);
+

[PATCH] D129008: [Clang][OpenMP] Fix the issue that globalization doesn't work with byval struct function argument

2022-07-01 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 441742.
tianshilei1992 added a comment.

fix unused variable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129008

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/OpenMP/globalization_byval_struct.c

Index: clang/test/OpenMP/globalization_byval_struct.c
===
--- /dev/null
+++ clang/test/OpenMP/globalization_byval_struct.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+extern int printf(const char *, ...);
+
+struct S {
+  int a;
+  float b;
+};
+
+// CHECK: define{{.*}}void @test(%struct.S* noundef byval(%struct.S) align {{[0-9]+}} [[arg:%[0-9a-zA-Z]+]])
+// CHECK: [[g:%[0-9a-zA-Z]+]] = call align {{[0-9]+}} i8* @__kmpc_alloc_shared
+// CHECK: bitcast i8* [[g]] to %struct.S*
+// CHECK: bitcast %struct.S* [[arg]] to i8**
+// CHECK: call void [[cc:@__copy_constructor[_0-9a-zA-Z]+]]
+// CHECK: void [[cc]]
+void test(struct S s) {
+#pragma omp parallel for
+  for (int i = 0; i < s.a; ++i) {
+printf("%i : %i : %f\n", i, s.a, s.b);
+  }
+}
+
+void foo() {
+  #pragma omp target teams num_teams(1)
+  {
+struct S s;
+s.a = 7;
+s.b = 11;
+test(s);
+  }
+}
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2470,66 +2470,66 @@
 
   Address DeclPtr = Address::invalid();
   Address AllocaPtr = Address::invalid();
-  bool DoStore = false;
+  bool DoCopy = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);
-  // If we already have a pointer to the argument, reuse the input pointer.
-  if (Arg.isIndirect()) {
-// If we have a prettier pointer type at this point, bitcast to that.
-DeclPtr = Arg.getIndirectAddress();
-DeclPtr = Builder.CreateElementBitCast(DeclPtr, ConvertTypeForMem(Ty),
-   D.getName());
-// Indirect argument is in alloca address space, which may be different
-// from the default address space.
-auto AllocaAS = CGM.getASTAllocaAddressSpace();
-auto *V = DeclPtr.getPointer();
-AllocaPtr = DeclPtr;
-auto SrcLangAS = getLangOpts().OpenCL ? LangAS::opencl_private : AllocaAS;
-auto DestLangAS =
-getLangOpts().OpenCL ? LangAS::opencl_private : LangAS::Default;
-if (SrcLangAS != DestLangAS) {
-  assert(getContext().getTargetAddressSpace(SrcLangAS) ==
- CGM.getDataLayout().getAllocaAddrSpace());
-  auto DestAS = getContext().getTargetAddressSpace(DestLangAS);
-  auto *T = DeclPtr.getElementType()->getPointerTo(DestAS);
-  DeclPtr = DeclPtr.withPointer(getTargetHooks().performAddrSpaceCast(
-  *this, V, SrcLangAS, DestLangAS, T, true));
-}
 
-// Push a destructor cleanup for this parameter if the ABI requires it.
-// Don't push a cleanup in a thunk for a method that will also emit a
-// cleanup.
-if (Ty->isRecordType() && !CurFuncIsThunk &&
-Ty->castAs()->getDecl()->isParamDestroyedInCallee()) {
-  if (QualType::DestructionKind DtorKind =
-  D.needsDestruction(getContext())) {
-assert((DtorKind == QualType::DK_cxx_destructor ||
-DtorKind == QualType::DK_nontrivial_c_struct) &&
-   "unexpected destructor type");
-pushDestroy(DtorKind, DeclPtr, Ty);
-CalleeDestructedParamCleanups[cast(&D)] =
-EHStack.stable_begin();
-  }
-}
-  } else {
-// Check if the parameter address is controlled by OpenMP runtime.
-Address OpenMPLocalAddr =
-getLangOpts().OpenMP
-? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D)
-: Address::invalid();
-if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
-  DeclPtr = OpenMPLocalAddr;
+  // We first check if the parameter address is controlled by OpenMP.
+  if (getLangOpts().OpenMP) {
+DeclPtr = CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D);
+if (DeclPtr.isValid()) {
   AllocaPtr = DeclPtr;
-} else {
-  // Otherwise, create a temporary to hold the value.
-  DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(&D),
-  D.getName() + ".addr", &AllocaPtr);
+  DoCopy = true;
 }
-DoStore = true;
   }
 
-  llvm::Value *ArgVal = (DoStore ? Arg.getDirectValue() : nullptr);
+  // The parameter is not controlled by OpenMP.
+  if (!DeclPtr.isValid()) {
+// If we already have a pointer to the argum

[PATCH] D128953: [NFC] refactor compression namespaces making way for a possible introduction of alternatives to zlib compression in the llvm toolchain.

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/ProfileData/InstrProf.cpp:154
+OS << ("profile uses " + compression::profile::AlgorithmName +
+   " compression but the profile reader was built " + "without " +
+   compression::profile::AlgorithmName + " support");

leonardchan wrote:
> `" compression but the profile reader was built " + "without "` -> `" 
> compression but the profile reader was built without "`
Keep the diagnostic unchanged in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


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

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

I can submit after you address additional comments by Nathan James.


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

https://reviews.llvm.org/D128402

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


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

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

Please provide the name and email address you wish to use on the commit and I 
will submit.


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

https://reviews.llvm.org/D128402

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


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood accepted this revision.
LegalizeAdulthood added a comment.
This revision is now accepted and ready to land.

Thanks for this, like Nathan James this has been pestering me for a while `:)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127807

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


[clang] 6450dad - Test a few more C99 DRs

2022-07-01 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-07-01T13:54:11-04:00
New Revision: 6450daddd20a83327118c0c6fa8f844a99cd1f0f

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

LOG: Test a few more C99 DRs

This updates the status for another 8 DRs.

Added: 


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

Removed: 




diff  --git a/clang/test/C/drs/dr2xx.c b/clang/test/C/drs/dr2xx.c
index e4fe3183b02c9..b34b7ef2cce79 100644
--- a/clang/test/C/drs/dr2xx.c
+++ b/clang/test/C/drs/dr2xx.c
@@ -17,6 +17,21 @@
  *
  * WG14 DR215: yes
  * Equality operators
+ *
+ * WG14 DR218: yes
+ * Signs of non-numeric floating point values
+ *
+ * WG14 DR219: yes
+ * Effective types
+ *
+ * WG14 DR221: yes
+ * Lacuna in pointer arithmetic
+ *
+ * WG14 DR222: yes
+ * Partially initialized structures
+ *
+ * WG14 DR234: yes
+ * Miscellaneous Typos
  */
 
 
@@ -87,3 +102,45 @@ void dr216(void) {
   A('}'); A('~');
 #undef A
 }
+
+/* WG14 DR230: yes
+ * Enumerated type rank
+ */
+void dr230(void) {
+  enum E {
+Value = __INT_MAX__
+  } e;
+  /* The enumeration type has a compatible type that is a signed or unsigned
+   * integer type, or char. But it has to be large enough to hold all of the
+   * values of the enumerators. So it needs to be at least int or unsigned int.
+   *
+   * The integer conversion rank for an enumeration is the same as its
+   * compatible type (C99 6.3.1.1p1), so it's eligible for integer promotions
+   * to either int or unsigned int, depending on the compatible type
+   * (C99 6.3.1.1p2).
+   */
+  (void)_Generic(e, int : 1, unsigned int : 1);
+  (void)_Generic((enum E)Value, int : 1, unsigned int : 1);
+  /* The enumerators themselves have type int (C99 6.7.2.2p3). */
+  (void)_Generic(Value, int : 1);
+}
+
+/* WG14 DR231: no
+ * Semantics of text-line and non-directive
+ *
+ * One of the preprocessing groups to support is # non-directive (C99 6.10p1),
+ * which is defined as pp-tokens followed by a newline. However, we fail to
+ * translate the program if we don't recognize the directive, and we don't take
+ * note when what follows the # is not a valid preprocessing token.
+ */
+
+/* FIXME: this should not fail. */
+# nope /* expected-error {{invalid preprocessing directive}} */
+
+/* FIXME: this should fail, but not because of the unknown directive; it should
+ * fail because of the invalid preprocessing-token.
+ */
+# 'a
+/* expected-error@-1 {{invalid preprocessing directive}} \
+   expected-warning@-1 {{missing terminating ' character}}
+*/

diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index ea604b498a539..239e8e8140ba8 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -1242,13 +1242,13 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_218.htm";>218
 C99
 Signs of non-numeric floating point values
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_219.htm";>219
 NAD
 Effective types
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_220.htm";>220
@@ -1260,13 +1260,13 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_221.htm";>221
 NAD
 Lacuna in pointer arithmetic
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_222.htm";>222
 C99
 Partially initialized structures
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_223.htm";>223
@@ -1290,7 +1290,7 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_226.htm";>226
 NAD
 strftime references
-Yes
+N/A
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_227.htm";>227
@@ -1314,19 +1314,19 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_230.htm";>230
 C99
 Enumerated type rank
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_231.htm";>231
 NAD
 Semantics of text-line and non-directive
-Unknown
+No
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_232.htm";>232
 C99
 Typo in Annex I
-Yes
+N/A
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_233.htm";>233



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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:270
   This fixes `Issue 55962 
`_.
+- Added ``-Winvalid-utf8`` which diagnose invalid UTF-8 code unit sequences in
+  comments.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-01 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 441748.
cor3ntin added a comment.

Fix typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/comment-invalid-utf8.c
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTF.cpp

Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -417,6 +417,16 @@
 return isLegalUTF8(source, length);
 }
 
+/*
+ * Exported function to return the size of the first utf-8 code unit sequence,
+ * Or 0 if the sequence is not valid;
+ */
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
+  int length = trailingBytesForUTF8[*source] + 1;
+  return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+  : 0;
+}
+
 /* - */
 
 static unsigned
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -181,6 +181,8 @@
 
 Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd);
 
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd);
+
 unsigned getNumBytesForUTF8(UTF8 firstByte);
 
 /*/
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2391,13 +2391,37 @@
   //
   // This loop terminates with CurPtr pointing at the newline (or end of buffer)
   // character that ends the line comment.
+
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (C != 0 &&// Potentially EOF.
-   C != '\n' && C != '\r')  // Newline or DOS-style newline.
+while (isASCII(C) && C != 0 &&   // Potentially EOF.
+   C != '\n' && C != '\r') { // Newline or DOS-style newline.
   C = *++CurPtr;
+  UnicodeDecodingAlreadyDiagnosed = false;
+}
+
+if (!isASCII(C)) {
+  unsigned Length = llvm::getUTF8SequenceSize(
+  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
+  if (Length == 0) {
+if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+UnicodeDecodingAlreadyDiagnosed = true;
+++CurPtr;
+  } else {
+UnicodeDecodingAlreadyDiagnosed = false;
+CurPtr += Length;
+  }
+  continue;
+}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2664,6 +2688,12 @@
   if (C == '/')
 C = *CurPtr++;
 
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   while (true) {
 // Skip over all non-interesting characters until we find end of buffer or a
 // (probably ending) '/' character.
@@ -2672,14 +2702,24 @@
 // doesn't check for '\0'.
 !(PP && PP->getCodeCompletionFileLoc() == FileLoc)) {
   // While not aligned to a 16-byte boundary.
-  while (C != '/' && ((intptr_t)CurPtr & 0x0F) != 0)
+  while (C != '/' && (intptr_t)CurPtr % 16 != 0) {
+if (!isASCII(C)) {
+  CurPtr--;
+  goto MultiByteUTF8;
+}
 C = *CurPtr++;
-
+  }
   if (C == '/') goto FoundSlash;
 
 #ifdef __SSE2__
   __m128i Slashes = _mm_set1_epi8('/');
-  while (CurPtr+16 <= BufferEnd) {
+  while (CurPtr + 16 < BufferEnd) {
+int Mask = _mm_movemask_epi8(*(const __m128i *)CurPtr);
+if (LLVM_UNLIKELY(Mask != 0)) {
+  CurPtr += llvm::countTrailingZeros(Mask);
+  goto MultiByteUTF8;
+}
+// look for slashes
 int cmp = _mm_movemask_epi8(_mm_cmpeq_epi8(*(const __m128i*)CurPtr,
 Slashes));
 if (cmp != 0) {
@@ -2692,21 +2732,41 @@
 CurPtr += 16;
   }
 #elif __ALTIVEC__
+  __vector unsigned char LongUTF = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+0

[clang-tools-extra] c998273 - [pseudo] Fix an out-of-bound issue in getReduceRules.

2022-07-01 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-07-01T20:16:06+02:00
New Revision: c99827349927a44334f2b04139168efd0bc87cd3

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

LOG: [pseudo] Fix an out-of-bound issue in getReduceRules.

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
index 70ce52924f110..664a1a3206fe6 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
@@ -140,8 +140,11 @@ class LRTable {
   // // ...apply reduce...
   //   }
   llvm::ArrayRef getReduceRules(StateID State) const {
+if (ReduceOffset[State] >= Reduces.size())
+  return {};
+size_t Length = ReduceOffset[State + 1] - ReduceOffset[State];
 return llvm::makeArrayRef(&Reduces[ReduceOffset[State]],
-  &Reduces[ReduceOffset[State + 1]]);
+  Length);
   }
   // Returns whether Terminal can follow Nonterminal in a valid source file.
   bool canFollow(SymbolID Nonterminal, SymbolID Terminal) const {



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


[PATCH] D128472: [pseudo] Check follow-sets instead of tying reduce actions to lookahead tokens.

2022-07-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the report. There is an out-of-bound issue in 
LRTable::getReduceRules, fixed in c99827349927a44334f2b04139168efd0bc87cd3 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128472

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


[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane added inline comments.



Comment at: llvm/include/llvm/Support/Compression.h:49-51
+namespace profile = llvm::compression::zlib;
+
+namespace serialize = llvm::compression::zlib;

phosek wrote:
> I think we will need to support dynamically selecting (de)compression 
> algorithm for both profile and serialization. For example, we should be able 
> to use read profiles generated by an older version of LLVM that only 
> supported zlib, even if the new one also supports zstd. Given that, I'd omit 
> these and instead use `compression::zlib` everywhere.
Correct, however I think that doing this in the meantime helps make it clear 
semantically for what purpose each compression call is for. It will make 
finding all instances of each time of use much easier in the future, and 
promotes semantically thought out usage.

Therefore I see no reason to not make these explicit aliases as it will only 
ease transition in the future.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[clang] 258c3ae - Revert "Re-apply "Deferred Concept Instantiation Implementation"""

2022-07-01 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-07-01T11:20:16-07:00
New Revision: 258c3aee54e11bc5c5d8ac137eb15e8d5bbcc7e4

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

LOG: Revert "Re-apply "Deferred Concept Instantiation Implementation"""

This reverts commit befa8cf087dbb8159a4d9dc8fa4d6748d6d5049a.

Apparently this breaks some libc++ builds with an apparent assertion,
 so I'm looking into that .

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp

clang/test/CXX/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp

clang/test/CXX/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
clang/test/SemaTemplate/concepts.cpp
clang/test/SemaTemplate/instantiate-requires-clause.cpp

Removed: 
clang/test/SemaTemplate/concepts-friends.cpp
clang/test/SemaTemplate/deferred-concept-inst.cpp
clang/test/SemaTemplate/trailing-return-short-circuit.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 26d769deee6d4..3342f6208c4f8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -451,11 +451,10 @@ C++20 Feature Support
 - No longer attempt to evaluate a consteval UDL function call at runtime when
   it is called through a template instantiation. This fixes
   `Issue 54578 `_.
-- Implemented `__builtin_source_location()` which enables library support for 
std::source_location.
-- Clang now correctly delays the instantiation of function constraints until
-  the time of checking, which should now allow the libstdc++ ranges 
implementation
-  to work for at least trivial examples.  This fixes
-  `Issue 44178 `_.
+
+- Implemented ``__builtin_source_location()``, which enables library support
+  for ``std::source_location``.
+
 - The mangling scheme for C++20 modules has incompatibly changed. The
   initial mangling was discovered not to be reversible, and the weak
   ownership design decision did not give the backwards compatibility

diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 0a7dc63d1c25d..66fab94b45b8a 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1890,9 +1890,7 @@ class FunctionDecl : public DeclaratorDecl,
 TK_FunctionTemplateSpecialization,
 // A function template specialization that hasn't yet been resolved to a
 // particular specialized function template.
-TK_DependentFunctionTemplateSpecialization,
-// A non templated function which is in a dependent scope.
-TK_DependentNonTemplate
+TK_DependentFunctionTemplateSpecialization
   };
 
   /// Stashed information about a defaulted function definition whose body has
@@ -1941,21 +1939,20 @@ class FunctionDecl : public DeclaratorDecl,
   /// The template or declaration that this declaration
   /// describes or was instantiated from, respectively.
   ///
-  /// For non-templates this value will be NULL, unless this non-template
-  /// function declaration was declared directly inside of a function template,
-  /// in which case this will have a pointer to a FunctionDecl, stored in the
-  /// NamedDecl. For function declarations that describe a function template,
-  /// this will be a pointer to a FunctionTemplateDecl, stored in the 
NamedDecl.
-  /// For member functions of class template specializations, this will be a
-  /// MemberSpecializationInfo pointer containing information about the
-  /// specialization. For function template specializations, this will be a
-  /// FunctionTemplateSpecializationInfo, which contains information about the
-  /// template being specialized and the template arguments involved in that
-  /// specialization.
-  llvm::PointerUnion
-  TemplateOrSpecialization;
+TemplateOrSpecialization;
 
   /// Provides source/type location info for the declaration name embedded in
   /// the DeclaratorDecl base class.
@@ -2698,11 +2695,6 @@ class FunctionDecl : p

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

@erichkeane can you please make sure that committed revisions in git have 
"Differential Revision: ". Usually it's added by "arc" when you upload 
review.
Also it would be nice if reapply have the same link.

Regarding reproducer, you can follow 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild
But it's already related, let see if it resolved for our bot as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D126907#3625600 , @vitalybuka 
wrote:

> @erichkeane can you please make sure that committed revisions in git have 
> "Differential Revision: ". Usually it's added by "arc" when you upload 
> review.
> Also it would be nice if reapply have the same link.
>
> Regarding reproducer, you can follow 
> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild
> But it's already related, let see if it resolved for our bot as well.

Yep, I'll make sure to remember that next time.  Corporate IT prevents me from 
using arc, so I am stuck doing it m anually and forget sometimes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane added inline comments.



Comment at: llvm/lib/ProfileData/InstrProf.cpp:154
+OS << ("profile uses " + compression::profile::AlgorithmName +
+   " compression but the profile reader was built " + "without " +
+   compression::profile::AlgorithmName + " support");

MaskRay wrote:
> leonardchan wrote:
> > `" compression but the profile reader was built " + "without "` -> `" 
> > compression but the profile reader was built without "`
> Keep the diagnostic unchanged in this patch.
And the other similar changes?
I will note these are NFC because if zlib is being used (as it currently always 
is), it has the exact same output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[PATCH] D129009: [llvm.analysis] Fix LTO for aliased IFuncs.

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu created this revision.
Herald added subscribers: steakhal, ormris, jeroen.dobbelaere, steven_wu, 
hiraditya, inglorion.
Herald added a project: All.
SchrodingerZhu requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Signed-off-by: SchrodingerZhu 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129009

Files:
  clang/test/Analysis/alias-indirect-function-lto.c
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias &A : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID(&A);
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,23 +646,26 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
-DenseSet &CantBePromoted) {
-  bool NonRenamableLocal = isNonRenamableLocal(A);
-  GlobalValueSummary::GVFlags Flags(
-  A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-  /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-  auto AS = std::make_unique(Flags);
+static void computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias 
&A,
+DenseSet &CantBePromoted) {
   auto *Aliasee = A.getAliaseeObject();
-  auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-  assert(AliaseeVI && "Alias expects aliasee summary to be available");
-  assert(AliaseeVI.getSummaryList().size() == 1 &&
- "Expected a single entry per aliasee in per-module index");
-  AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-  if (NonRenamableLocal)
-CantBePromoted.insert(A.getGUID());
-  Index.addGlobalValueSummary(A, std::move(AS));
+  // Currently, skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
+bool NonRenamableLocal = isNonRenamableLocal(A);
+GlobalValueSummary::GVFlags Flags(
+A.getLinkage(), A.getVisibility(), NonRenamableLocal,
+/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
+auto AS = std::make_unique(Flags);
+auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
+assert(AliaseeVI && "Alias expects aliasee summary to be available");
+assert(AliaseeVI.getSummaryList().size() == 1 &&
+   "Expected a single entry per aliasee in per-module index");
+AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
+if (NonRenamableLocal)
+  CantBePromoted.insert(A.getGUID());
+Index.addGlobalValueSummary(A, std::move(AS));
+  }
 }
 
 // Set LiveRoot flag on entries matching the given value name.
Index: clang/test/Analysis/alias-indirect-function-lto.c
===
--- /dev/null
+++ clang/test/Analysis/alias-indirect-function-lto.c
@@ -0,0 +1,4 @@
+// RUN: %clang_analyze_cc1 -flto -c
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
\ No newline at end of file


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias &A : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID(&A);
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,23 +646,26 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummar

[PATCH] D129009: [llvm.analysis] Fix LTO for aliased IFuncs. As https://github.com/llvm/llvm-project/issues/56290 indicates, when an ifunc is aliased in LTO, clang will attempt to create an alias su

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441756.
SchrodingerZhu retitled this revision from "[llvm.analysis] Fix LTO for aliased 
IFuncs." to "[llvm.analysis] Fix LTO for aliased IFuncs.

As https://github.com/llvm/llvm-project/issues/56290 indicates, 
when an ifunc is aliased in LTO, clang will attempt to create
an alias summary; however, as ifunc is not included in the 
module summary...".
SchrodingerZhu edited the summary of this revision.
SchrodingerZhu added a comment.



Updating D129009: [llvm.analysis] Fix LTO for aliased IFuncs.
=

As https://github.com/llvm/llvm-project/issues/56290 indicates, 
when an ifunc is aliased in LTO, clang will attempt to create
an alias summary; however, as ifunc is not included in the 
module summary...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  clang/test/Analysis/alias-indirect-function-lto.c
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias &A : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID(&A);
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,23 +646,26 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
-DenseSet &CantBePromoted) {
-  bool NonRenamableLocal = isNonRenamableLocal(A);
-  GlobalValueSummary::GVFlags Flags(
-  A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-  /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-  auto AS = std::make_unique(Flags);
+static void computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias 
&A,
+DenseSet &CantBePromoted) {
   auto *Aliasee = A.getAliaseeObject();
-  auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-  assert(AliaseeVI && "Alias expects aliasee summary to be available");
-  assert(AliaseeVI.getSummaryList().size() == 1 &&
- "Expected a single entry per aliasee in per-module index");
-  AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-  if (NonRenamableLocal)
-CantBePromoted.insert(A.getGUID());
-  Index.addGlobalValueSummary(A, std::move(AS));
+  // Currently, skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
+bool NonRenamableLocal = isNonRenamableLocal(A);
+GlobalValueSummary::GVFlags Flags(
+A.getLinkage(), A.getVisibility(), NonRenamableLocal,
+/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
+auto AS = std::make_unique(Flags);
+auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
+assert(AliaseeVI && "Alias expects aliasee summary to be available");
+assert(AliaseeVI.getSummaryList().size() == 1 &&
+   "Expected a single entry per aliasee in per-module index");
+AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
+if (NonRenamableLocal)
+  CantBePromoted.insert(A.getGUID());
+Index.addGlobalValueSummary(A, std::move(AS));
+  }
 }
 
 // Set LiveRoot flag on entries matching the given value name.
Index: clang/test/Analysis/alias-indirect-function-lto.c
===
--- /dev/null
+++ clang/test/Analysis/alias-indirect-function-lto.c
@@ -0,0 +1,4 @@
+// RUN: %clang_analyze_cc1 -flto -c
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
\ No newline at end of file


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias &A : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Alia

  1   2   >