[PATCH] D140803: [clang][Interp] Implement C++ Range-for loops

2023-01-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:418-419
+  this->emitLabel(IncLabel);
+  if (Inc && !this->discard(Inc))
+return false;
+  if (!this->jump(CondLabel))

aaron.ballman wrote:
> Under what circumstances is there not an increment?
The answer to both is that I looked at the code for regular `for` loops and 
assumed that the restrictions are the same.

But looks like there aren't and even `isBody()` always returns non-null.


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

https://reviews.llvm.org/D140803

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


[PATCH] D140250: Define NULL in its own header

2023-01-24 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 491644.
iana added a comment.

Fix the broken tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140250

Files:
  clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/Basic/Module.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__stddef_null.h
  clang/lib/Headers/module.modulemap
  clang/lib/Headers/stddef.h
  compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
  llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
  llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
@@ -88,6 +88,7 @@
 "__clang_hip_runtime_wrapper.h",
 "__clang_hip_stdlib.h",
 "__stddef_max_align_t.h",
+"__stddef_null.h",
 "__wmmintrin_aes.h",
 "__wmmintrin_pclmul.h",
 "adxintrin.h",
Index: llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
===
--- llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
+++ llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll
@@ -10,46 +10,47 @@
 ; CHECK: @llvm.dbg.assign(metadata ptr %0,{{.+}}, metadata !DIExpression(),{{.+}}, metadata ptr undef, {{.+}})
 ;; There should be no new fragment and the value component should remain as %0.
 
-define dso_local void @_Z3funDn(ptr %0) #0 !dbg !14 {
+define dso_local void @_Z3funDn(ptr %0) #0 !dbg !15 {
 entry:
-  %.addr = alloca i8*, align 8, !DIAssignID !22
-  call void @llvm.dbg.assign(metadata i1 undef, metadata !21, metadata !DIExpression(), metadata !22, metadata ptr %.addr, metadata !DIExpression()), !dbg !23
-  store ptr %0, ptr %.addr, align 8, !DIAssignID !28
-  call void @llvm.dbg.assign(metadata ptr %0, metadata !21, metadata !DIExpression(), metadata !28, metadata ptr %.addr, metadata !DIExpression()), !dbg !23
-  ret void, !dbg !29
+  %.addr = alloca i8*, align 8, !DIAssignID !23
+  call void @llvm.dbg.assign(metadata i1 undef, metadata !22, metadata !DIExpression(), metadata !23, metadata ptr %.addr, metadata !DIExpression()), !dbg !24
+  store ptr %0, ptr %.addr, align 8, !DIAssignID !29
+  call void @llvm.dbg.assign(metadata ptr %0, metadata !22, metadata !DIExpression(), metadata !29, metadata ptr %.addr, metadata !DIExpression()), !dbg !24
+  ret void, !dbg !30
 }
 
 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
 declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #1
 
 !llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!10, !11, !12, !1000}
-!llvm.ident = !{!13}
+!llvm.module.flags = !{!11, !12, !13, !1000}
+!llvm.ident = !{!14}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, imports: !3, splitDebugInlining: false, nameTableKind: None)
 !1 = !DIFile(filename: "test.cpp", directory: "/")
 !2 = !{}
 !3 = !{!4}
-!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !6, file: !9, line: 56)
+!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !6, file: !10, line: 56)
 !5 = !DINamespace(name: "std", scope: null)
-!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "max_align_t", file: !7, line: 24, baseType: !8)
+!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "max_align_t", file: !7, line: 24, baseType: !9)
 !7 = !DIFile(filename: "clang/12.0.0/include/__stddef_max_align_t.h", directory: "/")
-!8 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")
-!9 = !DIFile(filename: "include/c++/7.5.0/cstddef", directory: "")
-!10 = !{i32 7, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{!"clang version 12.0.0"}
-!14 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funDn", scope: !1, file: !1, line: 20, type: !15, scopeLine: 20, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20)
-!15 = !DISubroutineType(types: !16)
-!16 = !{null, !17}
-!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "nullptr_t", scope: !5, file: !18, line: 235, baseType: !19)
-!18 = !DIFile(filename: "include/x86_64-linux-gnu/c++/7.5.0/bits/c++config.h", directory: "")
-!19 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
-!20 = !{!21}
-!21 = !DILocalVariable(arg: 1, scope: !14, file: !1, line: 20, type: !17)
-!22 = distinct !DIAssignID(

[clang] 01eb01c - [clang][Lex] Add back PPCallbacks::FileNotFound

2023-01-24 Thread Jonas Hahnfeld via cfe-commits

Author: Jonas Hahnfeld
Date: 2023-01-24T09:52:27+01:00
New Revision: 01eb01c7fd7ad6f569ad4d7bf65b5327ac111955

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

LOG: [clang][Lex] Add back PPCallbacks::FileNotFound

This callback was removed with commit 7a124f4859, but we use it
downstream in ROOT/Cling to implement handling of a special include
syntax. Add back a "safe" version of the callback that only takes
the file name and return a bool to silently skip the file.

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

Added: 


Modified: 
clang/include/clang/Lex/PPCallbacks.h
clang/lib/Lex/PPDirectives.cpp
clang/unittests/Lex/PPCallbacksTest.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/PPCallbacks.h 
b/clang/include/clang/Lex/PPCallbacks.h
index 2e99fd9300362..94f96cf9c5125 100644
--- a/clang/include/clang/Lex/PPCallbacks.h
+++ b/clang/include/clang/Lex/PPCallbacks.h
@@ -83,6 +83,16 @@ class PPCallbacks {
const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) {}
 
+  /// Callback invoked whenever the preprocessor cannot find a file for an
+  /// inclusion directive.
+  ///
+  /// \param FileName The name of the file being included, as written in the
+  /// source code.
+  ///
+  /// \returns true to indicate that the preprocessor should skip this file
+  /// and not issue any diagnostic.
+  virtual bool FileNotFound(StringRef FileName) { return false; }
+
   /// Callback invoked whenever an inclusion directive of
   /// any kind (\c \#include, \c \#import, etc.) has been processed, regardless
   /// of whether the inclusion will actually result in an inclusion.
@@ -451,6 +461,14 @@ class PPChainedCallbacks : public PPCallbacks {
 Second->FileSkipped(SkippedFile, FilenameTok, FileType);
   }
 
+  bool FileNotFound(StringRef FileName) override {
+bool Skip = First->FileNotFound(FileName);
+// Make sure to invoke the second callback, no matter if the first already
+// returned true to skip the file.
+Skip |= Second->FileNotFound(FileName);
+return Skip;
+  }
+
   void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
   StringRef FileName, bool IsAngled,
   CharSourceRange FilenameRange,

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index f08d5fe2747f7..6ae513dea8782 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2000,6 +2000,10 @@ OptionalFileEntryRef 
Preprocessor::LookupHeaderIncludeOrImport(
   if (File)
 return File;
 
+  // Give the clients a chance to silently skip this include.
+  if (Callbacks && Callbacks->FileNotFound(Filename))
+return std::nullopt;
+
   if (SuppressIncludeNotFoundError)
 return std::nullopt;
 

diff  --git a/clang/unittests/Lex/PPCallbacksTest.cpp 
b/clang/unittests/Lex/PPCallbacksTest.cpp
index ec719387fa022..b2be40ef3812e 100644
--- a/clang/unittests/Lex/PPCallbacksTest.cpp
+++ b/clang/unittests/Lex/PPCallbacksTest.cpp
@@ -444,6 +444,50 @@ TEST_F(PPCallbacksTest, TrigraphInMacro) {
   ASSERT_EQ("\"tri\?\?-graph.h\"", GetSourceString(Range));
 }
 
+TEST_F(PPCallbacksTest, FileNotFoundSkipped) {
+  const char *SourceText = "#include \"skipped.h\"\n";
+
+  std::unique_ptr SourceBuf =
+  llvm::MemoryBuffer::getMemBuffer(SourceText);
+  SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
+
+  HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+  Diags, LangOpts, Target.get());
+  TrivialModuleLoader ModLoader;
+
+  DiagnosticConsumer *DiagConsumer = new DiagnosticConsumer;
+  DiagnosticsEngine FileNotFoundDiags(DiagID, DiagOpts.get(), DiagConsumer);
+  Preprocessor PP(std::make_shared(), FileNotFoundDiags,
+  LangOpts, SourceMgr, HeaderInfo, ModLoader,
+  /*IILookup=*/nullptr,
+  /*OwnsHeaderSearch=*/false);
+  PP.Initialize(*Target);
+
+  class FileNotFoundCallbacks : public PPCallbacks {
+  public:
+unsigned int NumCalls = 0;
+bool FileNotFound(StringRef FileName) override {
+  NumCalls++;
+  return FileName == "skipped.h";
+}
+  };
+
+  auto *Callbacks = new FileNotFoundCallbacks;
+  PP.addPPCallbacks(std::unique_ptr(Callbacks));
+
+  // Lex source text.
+  PP.EnterMainSourceFile();
+  while (true) {
+Token Tok;
+PP.Lex(Tok);
+if (Tok.is(tok::eof))
+  break;
+  }
+
+  ASSERT_EQ(1u, Callbacks->NumCalls);
+  ASSERT_EQ(0u, DiagConsumer->getNumErrors());
+}
+
 TEST_F(PPCallbacksTest, OpenCLExtensionPragmaEnabled) {
   const char* Source =
 "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n";



___
cfe-commits ma

[PATCH] D142196: [clang][Lex] Add back PPCallbacks::FileNotFound

2023-01-24 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Hahnfeld marked an inline comment as done.
Closed by commit rG01eb01c7fd7a: [clang][Lex] Add back 
PPCallbacks::FileNotFound (authored by Hahnfeld).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142196

Files:
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Lex/PPDirectives.cpp
  clang/unittests/Lex/PPCallbacksTest.cpp

Index: clang/unittests/Lex/PPCallbacksTest.cpp
===
--- clang/unittests/Lex/PPCallbacksTest.cpp
+++ clang/unittests/Lex/PPCallbacksTest.cpp
@@ -444,6 +444,50 @@
   ASSERT_EQ("\"tri\?\?-graph.h\"", GetSourceString(Range));
 }
 
+TEST_F(PPCallbacksTest, FileNotFoundSkipped) {
+  const char *SourceText = "#include \"skipped.h\"\n";
+
+  std::unique_ptr SourceBuf =
+  llvm::MemoryBuffer::getMemBuffer(SourceText);
+  SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
+
+  HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+  Diags, LangOpts, Target.get());
+  TrivialModuleLoader ModLoader;
+
+  DiagnosticConsumer *DiagConsumer = new DiagnosticConsumer;
+  DiagnosticsEngine FileNotFoundDiags(DiagID, DiagOpts.get(), DiagConsumer);
+  Preprocessor PP(std::make_shared(), FileNotFoundDiags,
+  LangOpts, SourceMgr, HeaderInfo, ModLoader,
+  /*IILookup=*/nullptr,
+  /*OwnsHeaderSearch=*/false);
+  PP.Initialize(*Target);
+
+  class FileNotFoundCallbacks : public PPCallbacks {
+  public:
+unsigned int NumCalls = 0;
+bool FileNotFound(StringRef FileName) override {
+  NumCalls++;
+  return FileName == "skipped.h";
+}
+  };
+
+  auto *Callbacks = new FileNotFoundCallbacks;
+  PP.addPPCallbacks(std::unique_ptr(Callbacks));
+
+  // Lex source text.
+  PP.EnterMainSourceFile();
+  while (true) {
+Token Tok;
+PP.Lex(Tok);
+if (Tok.is(tok::eof))
+  break;
+  }
+
+  ASSERT_EQ(1u, Callbacks->NumCalls);
+  ASSERT_EQ(0u, DiagConsumer->getNumErrors());
+}
+
 TEST_F(PPCallbacksTest, OpenCLExtensionPragmaEnabled) {
   const char* Source =
 "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n";
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2000,6 +2000,10 @@
   if (File)
 return File;
 
+  // Give the clients a chance to silently skip this include.
+  if (Callbacks && Callbacks->FileNotFound(Filename))
+return std::nullopt;
+
   if (SuppressIncludeNotFoundError)
 return std::nullopt;
 
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -83,6 +83,16 @@
const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) {}
 
+  /// Callback invoked whenever the preprocessor cannot find a file for an
+  /// inclusion directive.
+  ///
+  /// \param FileName The name of the file being included, as written in the
+  /// source code.
+  ///
+  /// \returns true to indicate that the preprocessor should skip this file
+  /// and not issue any diagnostic.
+  virtual bool FileNotFound(StringRef FileName) { return false; }
+
   /// Callback invoked whenever an inclusion directive of
   /// any kind (\c \#include, \c \#import, etc.) has been processed, regardless
   /// of whether the inclusion will actually result in an inclusion.
@@ -451,6 +461,14 @@
 Second->FileSkipped(SkippedFile, FilenameTok, FileType);
   }
 
+  bool FileNotFound(StringRef FileName) override {
+bool Skip = First->FileNotFound(FileName);
+// Make sure to invoke the second callback, no matter if the first already
+// returned true to skip the file.
+Skip |= Second->FileNotFound(FileName);
+return Skip;
+  }
+
   void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
   StringRef FileName, bool IsAngled,
   CharSourceRange FilenameRange,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142196: [clang][Lex] Add back PPCallbacks::FileNotFound

2023-01-24 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

I checked a second time and couldn't find other API docs. I've now pushed this 
change for now (also to get it included in `release/16.x`), but please let me 
know for any follow-ups. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142196

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


[PATCH] D140803: [clang][Interp] Implement C++ Range-for loops

2023-01-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/test/AST/Interp/loops.cpp:278
+
+namespace RangeForLoop {
+  constexpr int localArray() {

aaron.ballman wrote:
> You should also add failure tests where the range-based for loop is not valid 
> in a constant expression. Especially interesting cases would be ones 
> involving lifetime problems, such as: https://godbolt.org/z/3EE7f8rdE
Oof, that reproducer doesn't work right now for several reasons :/ Can you come 
up with something simpler?


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

https://reviews.llvm.org/D140803

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


[PATCH] D142437: [clang] Add the check of membership in decltype for the issue #58674

2023-01-24 Thread Liming Liu via Phabricator via cfe-commits
lime created this revision.
lime added reviewers: aaron.ballman, erichkeane, cor3ntin, clang-language-wg.
lime added a project: clang.
Herald added a subscriber: yaxunl.
Herald added a project: All.
lime requested review of this revision.
Herald added a subscriber: cfe-commits.

D137531  had once fixed the issue. However, 
it caused a crash during compiling 
llvm/unittests/IR/PatternMatch.cpp in stage-2. The reason is the predicator 
`isDerivedFrom` does not consider independent types if the derived type is 
dependent.

This patch improves D137531  by adding an 
option to make `isDerivedFrom` consider 
independent types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142437

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2693,20 +2693,34 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember = ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class, true)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/lib/AST/CXXInheritance.cpp
===
--- clang/lib/AST/CXXInheritance.cpp
+++ clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupIndependent) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths);
+  return isDerivedFrom(Base, Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  CXXBasePaths &Paths) const {
+  CXXBasePaths &Paths,
+   

[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-24 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added inline comments.



Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:100
 SYMBOL(atoll, std::, )
+SYMBOL(atomic, std::, )
+SYMBOL(atomic, std::, )

VitaNuo wrote:
> kadircet wrote:
> > hokein wrote:
> > > Conceptually, this (and other `atomic_*` symbols) doesn't feel correct:
> > > - `` provides the generic template `template struct 
> > > atomic;`
> > > -  `` provides partial template specializations for 
> > > `std::shared_ptr` and `std::weak_ptr`  
> > > 
> > > They are variant symbols (ideally, they should be treat as the 
> > > `std::move()`). The issue here is that unlike `std::move` which has two 
> > > individual entries in the index page, we only have one entry for 
> > > `std::atomic` (extending the cppreference_parser.py script to perfectly 
> > > distinguish these two cases in the 
> > > [page](https://en.cppreference.com/w/cpp/atomic/atomic) seems 
> > > non-trivial).  Some options:
> > > 
> > > 1) treat them as multiple-header symbols (like what this patch does now)
> > > 2) special-case these symbols like `std::move()`
> > > 3) always prefer the header providing generic templates
> > > 
> > > @kadircet, what do you think?
> > right, i believe this patch is definitely adding keeping multiple headers 
> > for a symbol around, but mixing it with keeping headers for variants (e.g. 
> > overloads provided by different headers, or specializations as mentioned 
> > here).
> > 
> > we definitely need some more changes in parser to make sure we're only 
> > preserving alternatives for **the same symbol** and not for any other 
> > variants (overloads, specializations). IIRC there are currently 2 places 
> > these variants could come into play:
> > - first is the symbol index page itself, symbols that have ` (foo)` next to 
> > them have variants and should still be ignored (e.g. std::remove variant of 
> > cstdio shouldn't be preserved in the scope of this patch)
> > - second is inside the detail pages for symbols, e.g. 
> > [std::atomic](http://go/std::atomic), we can have headers for different 
> > declarations, they're clearly different variants so we shouldn't add such 
> > symbols into the mapping `_ParseSymbolPage` already does some detection of 
> > declarations in between headers.
> > 
> > in the scope of this patch, we should keep ignoring both.
> I suggest to special-case the overloads for now, just not to solve all the 
> problems in the same patch.
The first group are already ignored. We need to take a lot at how to ignore the 
second one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


[clang] ecbf5db - [6/15][Clang][RISCV][NFC] Instructions with a mask destination register is always tail agnostic

2023-01-24 Thread via cfe-commits

Author: eopXD
Date: 2023-01-24T01:08:58-08:00
New Revision: ecbf5db88d285f72fbd0126be9c20f790d603b23

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

LOG: [6/15][Clang][RISCV][NFC] Instructions with a mask destination register is 
always tail agnostic

The logic under `computeBuiltinTypes` is an amendment to setting Policy as
`Omit`. The tail policy should be set to agnostic for those intrinsics that
has `HasTailPolicy = false`, which are the intrinsics with a mask destination
register.

This is the 6th commit of a patch-set that aims to change the default policy
for RVV intrinsics from TAMU to TAMA.

Please refer to the cover letter in the 1st commit (D141573) for an
overview.

Reviewed By: craig.topper, kito-cheng

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

Added: 


Modified: 
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Support/RISCVVIntrinsicUtils.cpp

Removed: 




diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index dc5323062ed4..e64bab60cad2 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -134,13 +134,9 @@ struct Policy {
 return TailPolicy == Undisturbed && MaskPolicy == Omit;
   }
 
-  bool isMAPolicy() const {
-return MaskPolicy == Agnostic && TailPolicy == Omit;
-  }
+  bool isMAPolicy() const { return MaskPolicy == Agnostic; }
 
-  bool isMUPolicy() const {
-return MaskPolicy == Undisturbed && TailPolicy == Omit;
-  }
+  bool isMUPolicy() const { return MaskPolicy == Undisturbed; }
 
   bool hasTailPolicy() const { return HasTailPolicy; }
 

diff  --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp 
b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index 280fd3f8669a..e93c5533d916 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -915,9 +915,6 @@ llvm::SmallVector 
RVVIntrinsic::computeBuiltinTypes(
 PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
@@ -998,10 +995,11 @@ RVVIntrinsic::getSupportedMaskedPolicies(bool 
HasTailPolicy,
 Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
HasTailPolicy, HasMaskPolicy)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
-return {Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic,
+return {Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
HasTailPolicy, HasMaskPolicy), // MA
-Policy(Policy::PolicyType::Omit, Policy::PolicyType::Undisturbed,
-   HasTailPolicy, HasMaskPolicy)}; // MU
+Policy(Policy::PolicyType::Agnostic,
+   Policy::PolicyType::Undisturbed, HasTailPolicy,
+   HasMaskPolicy)}; // MU
   llvm_unreachable("An RVV instruction should not be without both tail policy "
"and mask policy");
 }
@@ -1040,6 +1038,10 @@ void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, 
bool HasPolicy,
   appendPolicySuffix("_tum");
 else if (PolicyAttrs.isTAMAPolicy() && !PolicyAttrs.hasMaskPolicy())
   appendPolicySuffix("_tam");
+else if (PolicyAttrs.isMUPolicy() && !PolicyAttrs.hasTailPolicy())
+  appendPolicySuffix("_mu");
+else if (PolicyAttrs.isMAPolicy() && !PolicyAttrs.hasTailPolicy())
+  appendPolicySuffix("_ma");
 else if (PolicyAttrs.isTUMUPolicy())
   appendPolicySuffix("_tumu");
 else if (PolicyAttrs.isTAMUPolicy())
@@ -1052,13 +1054,7 @@ void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, 
bool HasPolicy,
   appendPolicySuffix("_tu");
 else if (PolicyAttrs.isTAPolicy() && !IsMasked)
   appendPolicySuffix("_ta");
-else if (PolicyAttrs.isMUPolicy() && !PolicyAttrs.hasTailPolicy()) {
-  appendPolicySuffix("_mu");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else if (PolicyAttrs.isMAPolicy() && !PolicyAttrs.hasTailPolicy()) {
-  appendPolicySuffix("_ma");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else
+else
   llvm_unreachable("Unhandled policy condition");
   }
 }



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

[PATCH] D141756: [6/15][Clang][RISCV][NFC] Instructions with a mask destination register is always tail agnostic

2023-01-24 Thread Yueh-Ting (eop) Chen 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 rGecbf5db88d28: [6/15][Clang][RISCV][NFC] Instructions with a 
mask destination register is… (authored by eopXD).

Changed prior to commit:
  https://reviews.llvm.org/D141756?vs=489301&id=491650#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141756

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -915,9 +915,6 @@
 PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
@@ -998,10 +995,11 @@
 Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
HasTailPolicy, HasMaskPolicy)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
-return {Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic,
+return {Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
HasTailPolicy, HasMaskPolicy), // MA
-Policy(Policy::PolicyType::Omit, Policy::PolicyType::Undisturbed,
-   HasTailPolicy, HasMaskPolicy)}; // MU
+Policy(Policy::PolicyType::Agnostic,
+   Policy::PolicyType::Undisturbed, HasTailPolicy,
+   HasMaskPolicy)}; // MU
   llvm_unreachable("An RVV instruction should not be without both tail policy "
"and mask policy");
 }
@@ -1040,6 +1038,10 @@
   appendPolicySuffix("_tum");
 else if (PolicyAttrs.isTAMAPolicy() && !PolicyAttrs.hasMaskPolicy())
   appendPolicySuffix("_tam");
+else if (PolicyAttrs.isMUPolicy() && !PolicyAttrs.hasTailPolicy())
+  appendPolicySuffix("_mu");
+else if (PolicyAttrs.isMAPolicy() && !PolicyAttrs.hasTailPolicy())
+  appendPolicySuffix("_ma");
 else if (PolicyAttrs.isTUMUPolicy())
   appendPolicySuffix("_tumu");
 else if (PolicyAttrs.isTAMUPolicy())
@@ -1052,13 +1054,7 @@
   appendPolicySuffix("_tu");
 else if (PolicyAttrs.isTAPolicy() && !IsMasked)
   appendPolicySuffix("_ta");
-else if (PolicyAttrs.isMUPolicy() && !PolicyAttrs.hasTailPolicy()) {
-  appendPolicySuffix("_mu");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else if (PolicyAttrs.isMAPolicy() && !PolicyAttrs.hasTailPolicy()) {
-  appendPolicySuffix("_ma");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else
+else
   llvm_unreachable("Unhandled policy condition");
   }
 }
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -134,13 +134,9 @@
 return TailPolicy == Undisturbed && MaskPolicy == Omit;
   }
 
-  bool isMAPolicy() const {
-return MaskPolicy == Agnostic && TailPolicy == Omit;
-  }
+  bool isMAPolicy() const { return MaskPolicy == Agnostic; }
 
-  bool isMUPolicy() const {
-return MaskPolicy == Undisturbed && TailPolicy == Omit;
-  }
+  bool isMUPolicy() const { return MaskPolicy == Undisturbed; }
 
   bool hasTailPolicy() const { return HasTailPolicy; }
 


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -915,9 +915,6 @@
 PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
@@ -998,10 +995,11 @@
 Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
HasTailPolicy, HasMaskPolicy)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
-return {Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic,
+return {Policy(Policy:

[clang] 2a16e1f - [7/15][Clang][RISCV][NFC] Correct the default value for Policy to TAMU

2023-01-24 Thread via cfe-commits

Author: eopXD
Date: 2023-01-24T01:20:55-08:00
New Revision: 2a16e1ff7d2735001dbe40e607823857f4bedd0e

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

LOG: [7/15][Clang][RISCV][NFC] Correct the default value for Policy to TAMU

The default value is set to `Omit`, but in fact the value is then
assigned in `updateNamesAndPolicy`, which is set to TUMU when masked and
TAMU when unmasked. This commit demonstrates so and further remove
another dependency of `Omit`.

This is the 7th commit of a patch-set that aims to change the default policy
for RVV intrinsics from TAMU to TAMA.

Please refer to the cover letter in the 1st commit (D141573) for an
overview.

Reviewed By: craig.topper, kito-cheng

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

Added: 


Modified: 
clang/include/clang/Support/RISCVVIntrinsicUtils.h

Removed: 




diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index e64bab60cad2..57faab0fae59 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@ struct Policy {
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Undisturbed;
   bool HasTailPolicy, HasMaskPolicy;
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),



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


[PATCH] D141759: [7/15][Clang][RISCV][NFC] Correct the default value for Policy to TAMU

2023-01-24 Thread Yueh-Ting (eop) Chen 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 rG2a16e1ff7d27: [7/15][Clang][RISCV][NFC] Correct the default 
value for Policy to TAMU (authored by eopXD).

Changed prior to commit:
  https://reviews.llvm.org/D141759?vs=489302&id=491657#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141759

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Undisturbed;
   bool HasTailPolicy, HasMaskPolicy;
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Undisturbed;
   bool HasTailPolicy, HasMaskPolicy;
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142439: Fix C++11 warnings in RangeSetTest.cpp

2023-01-24 Thread Philipp Tomsich via Phabricator via cfe-commits
philipp.tomsich created this revision.
Herald added a subscriber: steakhal.
Herald added a project: All.
philipp.tomsich requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change fixes the following warnings:

 llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:727:55: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
   727 | TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes);
 |   ^
 llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:728:65: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
   728 | TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes);
 | ^
 llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:729:67: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
   729 | TYPED_TEST_SUITE(RangeSetCastToTruncationTest, 
TruncationCastTypes);
 |   ^
 llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:730:67: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
   730 | TYPED_TEST_SUITE(RangeSetCastToConversionTest, 
ConversionCastTypes);
 |   ^
 llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:732:46: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
   732 |  PromotionConversionCastTypes);
 |  ^
 llvm/clang/unittests/StaticAnalyzer/RangeSetTest.cpp:734:47: warning: ISO 
C++11 requires at least one argument for the "..." in a variadic macro
   734 |  TruncationConversionCastTypes);
 |   ^


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142439

Files:
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp


Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -724,14 +724,14 @@
  CastType, CastType,
  CastType, CastType>;
 
-TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes);
+TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToPromotionConversionTest,
- PromotionConversionCastTypes);
+ PromotionConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToTruncationConversionTest,
- TruncationConversionCastTypes);
+ TruncationConversionCastTypes, );
 
 TYPED_TEST(RangeSetCastToNoopTest, RangeSetCastToNoopTest) {
   // Just to reduce the verbosity.


Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -724,14 +724,14 @@
  CastType, CastType,
  CastType, CastType>;
 
-TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes);
-TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes);
+TYPED_TEST_SUITE(RangeSetCastToNoopTest, NoopCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToPromotionTest, PromotionCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToTruncationTest, TruncationCastTypes, );
+TYPED_TEST_SUITE(RangeSetCastToConversionTest, ConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToPromotionConversionTest,
- PromotionConversionCastTypes);
+ PromotionConversionCastTypes, );
 TYPED_TEST_SUITE(RangeSetCastToTruncationConversionTest,
- TruncationConversionCastTypes);
+ TruncationConversionCastTypes, );
 
 TYPED_TEST(RangeSetCastToNoopTest, RangeSetCastToNoopTest) {
   // Just to reduce the verbosity.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136886: [clang] ASTImporter: Fix importing of va_list types and declarations

2023-01-24 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Hi folks, I'm one of the owners of the AArch64 bot you're seeing the failure 
on. I will try to reproduce it myself and see if I can find what's going on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136886

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


[PATCH] D140619: ExtractFunction: support extracting expressions and selected part of it

2023-01-24 Thread Kacper Kowalski via Phabricator via cfe-commits
KKoovalsky added a comment.

@nridge I have fixed the issues. Thank you for supporting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140619

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


[PATCH] D142384: [C++20] Fix a crash with modules.

2023-01-24 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 491661.
usaxena95 edited the summary of this revision.
usaxena95 added a comment.

Use `getDefinition`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142384

Files:
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -6229,6 +6229,8 @@
 return false;
 
   const CXXRecordDecl *RD = Definition->getParent();
+  assert(RD->hasDefinition());
+  RD->getDefinition();
   if (RD->getNumVBases()) {
 Info.FFDiag(CallLoc, diag::note_constexpr_virtual_base) << RD;
 return false;


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -6229,6 +6229,8 @@
 return false;
 
   const CXXRecordDecl *RD = Definition->getParent();
+  assert(RD->hasDefinition());
+  RD->getDefinition();
   if (RD->getNumVBases()) {
 Info.FFDiag(CallLoc, diag::note_constexpr_virtual_base) << RD;
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141194: [clang][Interp] Implement bitcasts

2023-01-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Note that this "implementation" is based on my knowledge about what bitcasts 
are, so no idea. Is that documented anywhere or should I check 
`ExprConstant.cpp`, //or// is this implementation fine for the time being (IIRC 
this was needed to make a stdlib header work)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141194

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


[PATCH] D138802: [clang][Interp] Implement DecompositionDecls

2023-01-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1417-1418
+  assert(!BD->getHoldingVar()); // FIXME
+  if (!this->allocateVariable(BD, BD->getBinding()))
+return false;
+}

aaron.ballman wrote:
> Is this correct? IIRC, the decomposition declaration is its own 
> object, but the bindings themselves are references back to the decomposition 
> declaration object directly and so they're not distinct objects themselves 
> (they're more like aliases).
Is this not reflected in the individual bindings? What does it mean that the 
bindings aren't "distinct objects themselves"?


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

https://reviews.llvm.org/D138802

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


[PATCH] D142373: [Utils] Add --full-function-signature to update_cc_test_checks.py to match return type as well as args

2023-01-24 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

Do we actually want to include the `dso_local` in the full signature?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142373

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


[PATCH] D142440: [clangd] Don't show 'auto' type hint when type deduction fails

2023-01-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added reviewers: sammccall, kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Fixes https://github.com/clangd/clangd/issues/1475


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142440

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


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1256,6 +1256,13 @@
   )cpp");
 }
 
+TEST(TypeHints, InvalidType) {
+  assertTypeHints(R"cpp(
+auto x = (unknown_type)42; /*error-ok*/
+auto *y = (unknown_ptr)nullptr;
+  )cpp");
+}
+
 TEST(TypeHints, ReturnTypeDeduction) {
   assertTypeHints(
   R"cpp(
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -303,8 +303,8 @@
   return true;
 }
 
-if (D->getType()->getContainedAutoType()) {
-  if (!D->getType()->isDependentType()) {
+if (auto *AT = D->getType()->getContainedAutoType()) {
+  if (!AT->getDeducedType().isNull() && !D->getType()->isDependentType()) {
 // Our current approach is to place the hint on the variable
 // and accordingly print the full type
 // (e.g. for `const auto& x = 42`, print `const int&`).


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1256,6 +1256,13 @@
   )cpp");
 }
 
+TEST(TypeHints, InvalidType) {
+  assertTypeHints(R"cpp(
+auto x = (unknown_type)42; /*error-ok*/
+auto *y = (unknown_ptr)nullptr;
+  )cpp");
+}
+
 TEST(TypeHints, ReturnTypeDeduction) {
   assertTypeHints(
   R"cpp(
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -303,8 +303,8 @@
   return true;
 }
 
-if (D->getType()->getContainedAutoType()) {
-  if (!D->getType()->isDependentType()) {
+if (auto *AT = D->getType()->getContainedAutoType()) {
+  if (!AT->getDeducedType().isNull() && !D->getType()->isDependentType()) {
 // Our current approach is to place the hint on the variable
 // and accordingly print the full type
 // (e.g. for `const auto& x = 42`, print `const int&`).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141765: [FPEnv] Fix complex operations in strictfp mode

2023-01-24 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141765

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


[clang] d595b59 - [FPEnv] Fix complex operations in strictfp mode

2023-01-24 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2023-01-24T16:40:11+07:00
New Revision: d595b59d5c9c8e56c3b3d142912ee16a02071690

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

LOG: [FPEnv] Fix complex operations in strictfp mode

Operations on floating-point complex data had incorrect FP attributes
in strictfp mode, because IRBuilder object was not synchronized with AST
node attributes.

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprComplex.cpp
clang/test/CodeGen/complex-strictfp.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index e65e925a11d48..7a14a418c7b65 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -252,6 +252,7 @@ class ComplexExprEmitter
 ComplexPairTy LHS;
 ComplexPairTy RHS;
 QualType Ty;  // Computation Type.
+FPOptions FPFeatures;
   };
 
   BinOpInfo EmitBinOps(const BinaryOperator *E,
@@ -643,6 +644,7 @@ ComplexPairTy ComplexExprEmitter::EmitBinAdd(const 
BinOpInfo &Op) {
   llvm::Value *ResR, *ResI;
 
   if (Op.LHS.first->getType()->isFloatingPointTy()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, Op.FPFeatures);
 ResR = Builder.CreateFAdd(Op.LHS.first,  Op.RHS.first,  "add.r");
 if (Op.LHS.second && Op.RHS.second)
   ResI = Builder.CreateFAdd(Op.LHS.second, Op.RHS.second, "add.i");
@@ -661,6 +663,7 @@ ComplexPairTy ComplexExprEmitter::EmitBinAdd(const 
BinOpInfo &Op) {
 ComplexPairTy ComplexExprEmitter::EmitBinSub(const BinOpInfo &Op) {
   llvm::Value *ResR, *ResI;
   if (Op.LHS.first->getType()->isFloatingPointTy()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, Op.FPFeatures);
 ResR = Builder.CreateFSub(Op.LHS.first, Op.RHS.first, "sub.r");
 if (Op.LHS.second && Op.RHS.second)
   ResI = Builder.CreateFSub(Op.LHS.second, Op.RHS.second, "sub.i");
@@ -753,6 +756,7 @@ ComplexPairTy ComplexExprEmitter::EmitBinMul(const 
BinOpInfo &Op) {
 // FIXME: C11 also provides for imaginary types which would allow folding
 // still more of this within the type system.
 
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, Op.FPFeatures);
 if (Op.LHS.second && Op.RHS.second) {
   // If both operands are complex, emit the core math directly, and then
   // test for NaNs. If we find NaNs in the result, we delegate to a libcall
@@ -854,6 +858,7 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const 
BinOpInfo &Op) {
 //
 // FIXME: We would be able to avoid the libcall in many places if we
 // supported imaginary types in addition to complex types.
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, Op.FPFeatures);
 if (RHSi && !CGF.getLangOpts().FastMath) {
   BinOpInfo LibCallOp = Op;
   // If LHS was a real, supply a null imaginary part.
@@ -1025,6 +1030,7 @@ ComplexExprEmitter::EmitBinOps(const BinaryOperator *E,
 Ops.Ty = PromotionType;
   else
 Ops.Ty = E->getType();
+  Ops.FPFeatures = E->getFPFeaturesInEffect(CGF.getLangOpts());
   return Ops;
 }
 
@@ -1039,8 +1045,9 @@ EmitCompoundAssignLValue(const CompoundAssignOperator *E,
   if (const AtomicType *AT = LHSTy->getAs())
 LHSTy = AT->getValueType();
 
-  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
   BinOpInfo OpInfo;
+  OpInfo.FPFeatures = E->getFPFeaturesInEffect(CGF.getLangOpts());
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, OpInfo.FPFeatures);
 
   // Load the RHS and LHS operands.
   // __block variables need to have the rhs evaluated first, plus this should

diff  --git a/clang/test/CodeGen/complex-strictfp.c 
b/clang/test/CodeGen/complex-strictfp.c
index 0bffed4ff331d..b0c84d5eebe72 100644
--- a/clang/test/CodeGen/complex-strictfp.c
+++ b/clang/test/CodeGen/complex-strictfp.c
@@ -1,12 +1,12 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown 
-ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown 
-ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck 
--implicit-check-not=fpexcept.maytrap --implicit-check-not=round.tonearest %s
 
 
 // Test that the constrained intrinsics are picking up the exception
 // metadata from the AST instead of the global default from the command line.
 // Include rounding metadata in the testing.
-// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
-// FIXME: All cases of "round.tonearest" in this test are wrong.
+// Any cases of "fpexcept.maytrap" in this test are clang bugs.
+// Any cases of "round.tonearest" in this test are clang bugs.
 
 #pragma float_control(except, on)
 #pragma STDC FENV_ROUND FE_UPWARD
@@ -15,7 +15,7 @@ _Complex double g1,

[PATCH] D141765: [FPEnv] Fix complex operations in strictfp mode

2023-01-24 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 rGd595b59d5c9c: [FPEnv] Fix complex operations in strictfp 
mode (authored by sepavloff).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141765

Files:
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/test/CodeGen/complex-strictfp.c

Index: clang/test/CodeGen/complex-strictfp.c
===
--- clang/test/CodeGen/complex-strictfp.c
+++ clang/test/CodeGen/complex-strictfp.c
@@ -1,12 +1,12 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck --implicit-check-not=fpexcept.maytrap --implicit-check-not=round.tonearest %s
 
 
 // Test that the constrained intrinsics are picking up the exception
 // metadata from the AST instead of the global default from the command line.
 // Include rounding metadata in the testing.
-// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
-// FIXME: All cases of "round.tonearest" in this test are wrong.
+// Any cases of "fpexcept.maytrap" in this test are clang bugs.
+// Any cases of "round.tonearest" in this test are clang bugs.
 
 #pragma float_control(except, on)
 #pragma STDC FENV_ROUND FE_UPWARD
@@ -15,7 +15,7 @@
 _Complex float cf;
 double D;
 
-// CHECK-LABEL: define {{[^@]+}}@test3a(
+// CHECK-LABEL: @test3a(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = load double, ptr @D, align 8
 // CHECK-NEXT:[[CF_REAL:%.*]] = load float, ptr @cf, align 4
@@ -33,7 +33,7 @@
   cf += D;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@test3b(
+// CHECK-LABEL: @test3b(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[CF_REAL:%.*]] = load float, ptr @cf, align 4
 // CHECK-NEXT:[[CF_IMAG:%.*]] = load float, ptr getelementptr inbounds ({ float, float }, ptr @cf, i32 0, i32 1), align 4
@@ -48,7 +48,7 @@
   D += cf;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@test3c(
+// CHECK-LABEL: @test3c(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[G1_REAL:%.*]] = load double, ptr @g1, align 8
 // CHECK-NEXT:[[G1_IMAG:%.*]] = load double, ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
@@ -69,12 +69,12 @@
   cf /= g1;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@test3d(
+// CHECK-LABEL: @test3d(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[G1_REAL:%.*]] = load double, ptr @g1, align 8
 // CHECK-NEXT:[[G1_IMAG:%.*]] = load double, ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load double, ptr @D, align 8
-// CHECK-NEXT:[[ADD_R:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[G1_REAL]], double [[TMP0]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR2]]
+// CHECK-NEXT:[[ADD_R:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[G1_REAL]], double [[TMP0]], metadata !"round.upward", metadata !"fpexcept.strict") #[[ATTR2]]
 // CHECK-NEXT:store double [[ADD_R]], ptr @g1, align 8
 // CHECK-NEXT:store double [[G1_IMAG]], ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
 // CHECK-NEXT:ret void
@@ -83,12 +83,12 @@
   g1 = g1 + D;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@test3e(
+// CHECK-LABEL: @test3e(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = load double, ptr @D, align 8
 // CHECK-NEXT:[[G1_REAL:%.*]] = load double, ptr @g1, align 8
 // CHECK-NEXT:[[G1_IMAG:%.*]] = load double, ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
-// CHECK-NEXT:[[ADD_R:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[TMP0]], double [[G1_REAL]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR2]]
+// CHECK-NEXT:[[ADD_R:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[TMP0]], double [[G1_REAL]], metadata !"round.upward", metadata !"fpexcept.strict") #[[ATTR2]]
 // CHECK-NEXT:store double [[ADD_R]], ptr @g1, align 8
 // CHECK-NEXT:store double [[G1_IMAG]], ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
 // CHECK-NEXT:ret void
@@ -97,7 +97,7 @@
   g1 = D + g1;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@t1(
+// CHECK-LABEL: @t1(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[CONV:%.*]] = call float @llvm.experimental.constrained.fptrunc.f32.f64(double 4.00e+00, metadata !"round.upward", metadata !"fpexcept.strict") #[[ATTR2]]
 // CHECK-NEXT:store float [[CONV]], ptr @cf, align 4
@@ -107,7 +107,7 @@
   (__real__ cf) = 4.0;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@t2(
+// CHECK-LABEL: @t2(
 // CHECK-NEXT:  entry:
 // CHECK-NEX

[PATCH] D142373: [Utils] Add --full-function-signature to update_cc_test_checks.py to match return type as well as args

2023-01-24 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In D142373#4076198 , @luismarques 
wrote:

> Do we actually want to include the `dso_local` in the full signature?

That's a fair question. I could imagine it's useful to include these attributes 
in some test scenarios and not in others. I'm not sure it's worth adding 
another flag and more logic to optionally strip it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142373

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


[PATCH] D142199: [Docs] Replace recommonmark with myst-parser

2023-01-24 Thread Luke Lau via Phabricator via cfe-commits
luke updated this revision to Diff 491667.
luke added a comment.

Update release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142199

Files:
  .github/workflows/release-tasks.yml
  clang/docs/conf.py
  flang/docs/ComplexOperations.md
  flang/docs/DiagnosticsReference.md
  flang/docs/FIRArrayOperations.md
  flang/docs/FlangDriver.md
  flang/docs/HighLevelFIR.md
  flang/docs/OptionComparison.md
  flang/docs/ParameterizedDerivedTypes.md
  flang/docs/PolymorphicEntities.md
  flang/docs/PullRequestChecklist.md
  flang/docs/conf.py
  flang/docs/index.md
  flang/include/flang/Optimizer/Dialect/FIROps.td
  
llvm/docs/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack.md
  llvm/docs/DeveloperPolicy.rst
  llvm/docs/GitRepositoryPolicy.md
  llvm/docs/MarkdownQuickstartTemplate.md
  llvm/docs/PointerAuth.md
  llvm/docs/ReleaseNotes.rst
  llvm/docs/SpeculativeLoadHardening.md
  llvm/docs/SphinxQuickstartTemplate.rst
  llvm/docs/conf.py
  llvm/utils/release/build-docs.sh

Index: llvm/utils/release/build-docs.sh
===
--- llvm/utils/release/build-docs.sh
+++ llvm/utils/release/build-docs.sh
@@ -15,7 +15,7 @@
 # ninja-build gcc-c++
 #   * pip install sphinx-markdown-tables
 # * Ubuntu:
-#   * apt-get install doxygen sphinx-common python3-recommonmark \
+#   * apt-get install doxygen sphinx-common python3-myst-parser \
 # ninja-build graphviz texlive-font-utils
 #   * pip install sphinx-markdown-tables
 #======#
Index: llvm/docs/conf.py
===
--- llvm/docs/conf.py
+++ llvm/docs/conf.py
@@ -37,7 +37,7 @@
 }
 
 try:
-  import recommonmark
+  import myst_parser
 except ImportError:
   # manpages do not use any .md sources
   if not tags.has('builder-man'):
@@ -46,10 +46,11 @@
   import sphinx
   if sphinx.version_info >= (3, 0):
 # This requires 0.5 or later.
-extensions.append('recommonmark')
+extensions.append('myst_parser')
   else:
-source_parsers = {'.md': 'recommonmark.parser.CommonMarkParser'}
+source_parsers = {'.md': 'myst_parser.parsers.sphinx_.MystParser'}
   source_suffix['.md'] = 'markdown'
+  myst_heading_anchors = 7
 
 # The encoding of source files.
 #source_encoding = 'utf-8-sig'
Index: llvm/docs/SphinxQuickstartTemplate.rst
===
--- llvm/docs/SphinxQuickstartTemplate.rst
+++ llvm/docs/SphinxQuickstartTemplate.rst
@@ -164,7 +164,8 @@
  .++:..
   ...
 
-
+.. _generating the documentation:
+			 
 Generating the documentation
 
 
@@ -172,19 +173,19 @@
 see what they would look like. In addition to the normal
 `build tools `_
 you need to install `Sphinx`_ and the
-`recommonmark `_ extension.
+`myst-parser `_ extension.
 
 On Debian you can install these with:
 
 .. code-block:: console
 
-   sudo apt install -y sphinx-doc python-recommonmark-doc
+   sudo apt install -y sphinx-doc python3-myst-parser
 
-On Ubuntu use pip to get an up-to-date version of recommonmark:
+On Ubuntu use pip to get an up-to-date version of myst-parser:
 
 .. code-block:: console
 
-   sudo pip install sphinx recommonmark
+   sudo pip install sphinx myst-parser
 
 Then run cmake to build the documentation inside the ``llvm-project`` checkout:
 
Index: llvm/docs/SpeculativeLoadHardening.md
===
--- llvm/docs/SpeculativeLoadHardening.md
+++ llvm/docs/SpeculativeLoadHardening.md
@@ -1,6 +1,6 @@
 # Speculative Load Hardening
 
-### A Spectre Variant #1 Mitigation Technique
+## A Spectre Variant #1 Mitigation Technique
 
 Author: Chandler Carruth - [chandl...@google.com](mailto:chandl...@google.com)
 
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -316,6 +316,16 @@
   would now be ``UNSUPPORTED: target=arm{{.*}}`` and ``XFAIL: windows``
   would now be ``XFAIL: target={{.*}}-windows{{.*}}``.
 
+* The HTML documentation now uses myst-parser instead of recommonmark, since the
+  `latter has been sunset
+  `_.
+  It can be installed via either apt or pip:
+
+  .. code-block:: bash
+
+ apt install python3-myst-parser
+ pip install myst-parser
+
 External Open Source Projects Using LLVM 15
 ===
 
Index: llvm/docs/PointerAuth.md
===
--- llvm/docs/PointerA

[PATCH] D142199: [Docs] Replace recommonmark with myst-parser

2023-01-24 Thread Luke Lau via Phabricator via cfe-commits
luke added a comment.

In D142199#4073815 , @tstellar wrote:

> LGTM.  Can you add something to the release notes about this.

Done. Do any build machines need to be upgraded before this is landed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142199

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


[PATCH] D142199: [Docs] Replace recommonmark with myst-parser

2023-01-24 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a comment.

The flang website (flang.llvm.org) or flang.llvm.org/docs are built from these. 
Would you know whether there are changes required are there? 
https://github.com/llvm/llvm-zorg/blob/main/zorg/buildbot/builders/SphinxDocsBuilder.py


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142199

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


[PATCH] D142199: [Docs] Replace recommonmark with myst-parser

2023-01-24 Thread Luke Lau via Phabricator via cfe-commits
luke added a comment.

In D142199#4076287 , 
@kiranchandramohan wrote:

> The flang website (flang.llvm.org) or flang.llvm.org/docs are built from 
> these. Would you know whether there are changes required are there? 
> https://github.com/llvm/llvm-zorg/blob/main/zorg/buildbot/builders/SphinxDocsBuilder.py

The `docs-flang-html` target should remain the same, I quickly checked that 
script and it seems fine. The main thing is that the builders would need to 
have `myst-parser` installed on them. Are these python dependencies installed 
via a script or is it done manually?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142199

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


[PATCH] D140803: [clang][Interp] Implement C++ Range-for loops

2023-01-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 491674.

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

https://reviews.llvm.org/D140803

Files:
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.h
  clang/test/AST/Interp/loops.cpp

Index: clang/test/AST/Interp/loops.cpp
===
--- clang/test/AST/Interp/loops.cpp
+++ clang/test/AST/Interp/loops.cpp
@@ -3,10 +3,6 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify=expected-cpp20 %s
 // RUN: %clang_cc1 -std=c++20 -verify=ref %s
 
-// ref-no-diagnostics
-// expected-no-diagnostics
-// expected-cpp20-no-diagnostics
-
 namespace WhileLoop {
   constexpr int f() {
 int i = 0;
@@ -274,3 +270,57 @@
 #endif
 
 };
+
+namespace RangeForLoop {
+  constexpr int localArray() {
+int a[] = {1,2,3,4};
+int s = 0;
+for(int i : a) {
+  s += i;
+}
+return s;
+  }
+  static_assert(localArray() == 10, "");
+
+  constexpr int localArray2() {
+int a[] = {1,2,3,4};
+int s = 0;
+for(const int &i : a) {
+  s += i;
+}
+return s;
+  }
+  static_assert(localArray2() == 10, "");
+
+  constexpr int nested() {
+int s = 0;
+for (const int i : (int[]){1,2,3,4}) {
+  int a[] = {i, i};
+  for(int m : a) {
+s += m;
+  }
+}
+return s;
+  }
+  static_assert(nested() == 20, "");
+
+  constexpr int withBreak() {
+int s = 0;
+for (const int &i: (bool[]){false, true}) {
+  if (i)
+break;
+  s++;
+}
+return s;
+  }
+  static_assert(withBreak() == 1, "");
+
+  constexpr void NoBody() {
+for (const int &i: (bool[]){false, true}); // expected-warning {{empty body}} \
+   // expected-note {{semicolon on a separate line}} \
+   // expected-cpp20-warning {{empty body}} \
+   // expected-cpp20-note {{semicolon on a separate line}} \
+   // ref-warning {{empty body}} \
+   // ref-note {{semicolon on a separate line}}
+  }
+}
Index: clang/lib/AST/Interp/ByteCodeStmtGen.h
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.h
+++ clang/lib/AST/Interp/ByteCodeStmtGen.h
@@ -60,6 +60,7 @@
   bool visitWhileStmt(const WhileStmt *S);
   bool visitDoStmt(const DoStmt *S);
   bool visitForStmt(const ForStmt *S);
+  bool visitCXXForRangeStmt(const CXXForRangeStmt *S);
   bool visitBreakStmt(const BreakStmt *S);
   bool visitContinueStmt(const ContinueStmt *S);
   bool visitSwitchStmt(const SwitchStmt *S);
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -172,6 +172,8 @@
 return visitDoStmt(cast(S));
   case Stmt::ForStmtClass:
 return visitForStmt(cast(S));
+  case Stmt::CXXForRangeStmtClass:
+return visitCXXForRangeStmt(cast(S));
   case Stmt::BreakStmtClass:
 return visitBreakStmt(cast(S));
   case Stmt::ContinueStmtClass:
@@ -369,6 +371,56 @@
   return true;
 }
 
+template 
+bool ByteCodeStmtGen::visitCXXForRangeStmt(const CXXForRangeStmt *S) {
+  const Stmt *Init = S->getInit();
+  const Expr *Cond = S->getCond();
+  const Expr *Inc = S->getInc();
+  const Stmt *Body = S->getBody();
+  const Stmt *BeginStmt = S->getBeginStmt();
+  const Stmt *RangeStmt = S->getRangeStmt();
+  const Stmt *EndStmt = S->getEndStmt();
+  const VarDecl *LoopVar = S->getLoopVariable();
+
+  LabelTy EndLabel = this->getLabel();
+  LabelTy CondLabel = this->getLabel();
+  LabelTy IncLabel = this->getLabel();
+  ExprScope ES(this);
+  LoopScope LS(this, EndLabel, IncLabel);
+
+  // Emit declarations needed in the loop.
+  if (Init && !this->visitStmt(Init))
+return false;
+  if (!this->visitStmt(RangeStmt))
+return false;
+  if (!this->visitStmt(BeginStmt))
+return false;
+  if (!this->visitStmt(EndStmt))
+return false;
+
+  // Now the condition as well as the loop variable assignment.
+  this->emitLabel(CondLabel);
+  if (!this->visitBool(Cond))
+return false;
+  if (!this->jumpFalse(EndLabel))
+return false;
+
+  if (!this->visitVarDecl(LoopVar))
+return false;
+
+  // Body.
+  if (!this->visitStmt(Body))
+return false;
+  this->emitLabel(IncLabel);
+  if (!this->discard(Inc))
+return false;
+  if (!this->jump(CondLabel))
+return false;
+
+  this->emitLabel(EndLabel);
+  return true;
+}
+
 template 
 bool ByteCodeStmtGen::visitBreakStmt(const BreakStmt *S) {
   if (!BreakLabel)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142410: [AArch64] ARMv8.5-A implies both FEAT_SB and FEAT_SSBS

2023-01-24 Thread Dave Green via Phabricator via cfe-commits
dmgreen added reviewers: lenary, tmatheson, pratlucas.
dmgreen added a comment.

I believe this is correct, according to at least one reference I have. 
FEAT_SSBS isn't spelled out very clearly in the reference manual though. Adding 
some more people who might be able to check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142410

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


[PATCH] D142396: [AArch64] Add the Ampere1A core

2023-01-24 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Sounds OK, but do you mind splitting FeatureFuseAddSub2RegAndConstOne into a 
separate patch. They seem to be logically separable, and it can help in case 
there are problems found in one of the patches.




Comment at: llvm/include/llvm/TargetParser/AArch64TargetParser.h:476
+{"ampere1a", ARMV8_6A,
+ (AArch64::AEK_FP16 | AArch64::AEK_RAND | AArch64::AEK_SM4 | 
AArch64::AEK_SHA3 |
+  AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_MTE |

Can you clang-format the patch, otherwise lines get a little longer than they 
should be for llvm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142396

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


[PATCH] D141762: [8/15][Clang][RISCV][NFC] Always emit PolicyAttr in riscv_vector_builtin_cg.inc

2023-01-24 Thread Yueh-Ting (eop) Chen 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 rG5a1c6ec1041f: [8/15][Clang][RISCV][NFC] Always emit 
PolicyAttr in riscv_vector_builtin_cg.inc (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141762

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5a1c6ec - [8/15][Clang][RISCV][NFC] Always emit PolicyAttr in riscv_vector_builtin_cg.inc

2023-01-24 Thread via cfe-commits

Author: eopXD
Date: 2023-01-24T02:25:25-08:00
New Revision: 5a1c6ec1041f19806f3e94c3cb750b9072087c14

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

LOG: [8/15][Clang][RISCV][NFC] Always emit PolicyAttr in 
riscv_vector_builtin_cg.inc

The extra logic here is redundant. Also sneaked in an one-liner for
emitting `IsMasked`.

This is the 8th commit of a patch-set that aims to change the default policy
for RVV intrinsics from TAMU to TAMA.

Please refer to the cover letter in the 1st commit (D141573) for an
overview.

Reviewed By: kito-cheng

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

Added: 


Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 59a250aa29c9..39925cc5c24b 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@ void emitCodeGenSwitchBody(const RVVIntrinsic *RVVI, 
raw_ostream &OS) {
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;



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


[PATCH] D137944: [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH funclet tokens

2023-01-24 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz marked an inline comment as done.
sgraenitz added inline comments.



Comment at: llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp:597
+  assert(CV.size() > 0 && "Uncolored block");
+  for (BasicBlock *EHPadBB : CV)
+if (auto *EHPad = dyn_cast(EHPadBB->getFirstNonPHI())) 
{

ahatanak wrote:
> This piece of code does something similar to `cloneCallInstForBB`, but it's 
> slightly different from it. It iterates over the entries in `CV` whereas the 
> code above just looks at the first entry. 
> 
> Is this a bug that is fixed in https://reviews.llvm.org/D137945?
Yes, D137945 unifies the behavior so that we will always iterate. The unique 
color invariant only holds after WinEHPrepare. So the old assertion in 
`cloneCallInstForBB()` was formally wrong, but I only ever observed cases of 
non-unique coloring in incorrect IR, i.e. dangling funclet tokens before 
D137939. Iteration is the safe solution, especially since we may not be able to 
bail out on dangling funclet tokens in the verifier (see 
https://reviews.llvm.org/D138123#4067201).

FYI: We discussed it this in a previous round of this review 
https://reviews.llvm.org/D137944?id=475132#inline-1334823



Comment at: llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp:751
-const ColorVector &CV = BlockColors.find(&BB)->second;
-assert(CV.size() == 1 && "non-unique color for block!");
-Instruction *EHPad = CV.front()->getFirstNonPHI();

The old code here assumed all EH coloring to be unique.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137944

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


[PATCH] D142410: [AArch64] ARMv8.5-A implies both FEAT_SB and FEAT_SSBS

2023-01-24 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

SSBS is not mandatory from v8.5a onwards. More details/citation inline.

NB: This will need a rebase, because @dmgreen changed how crypto is handled in 
these bitmaps yesterday.




Comment at: llvm/include/llvm/TargetParser/AArch64TargetParser.h:311
 inline constexpr ArchInfo ARMV8_4A  = { VersionTuple{8, 4}, AProfile, 
"armv8.4-a", "+v8.4a", (ARMV8_3A.DefaultExts | AArch64::AEK_DOTPROD)};
-inline constexpr ArchInfo ARMV8_5A  = { VersionTuple{8, 5}, AProfile, 
"armv8.5-a", "+v8.5a", (ARMV8_4A.DefaultExts)};
+inline constexpr ArchInfo ARMV8_5A  = { VersionTuple{8, 5}, AProfile, 
"armv8.5-a", "+v8.5a", (ARMV8_4A.DefaultExts | AArch64::AEK_SB | 
AArch64::AEK_SSBS )};
 constexpr unsigned BaseNoCrypto = ARMV8_5A.DefaultExts ^ AArch64::AEK_CRYPTO; 
// 8.6 onwards has no AEK_CRYPTO

According to the A-profile Arm ARM (version I.a):
- FEAT_SB is mandatory from v8.5 onwards, so thank you for correcting this 
oversight.
- There is no language about the same for FEAT_SSBS/FEAT_SSBS2. It was added to 
v8.0a by v8.5a, but it doesn't seem to have been made mandatory in v8.5a, as 
far as I can see. There is no language in section A2 (Architectural 
Extensions), or in the description of the `ID_AA64PFR1_EL1.SSBS` register about 
being mandatory from certain versions (other fields in this register do have 
this language).



Comment at: llvm/include/llvm/TargetParser/AArch64TargetParser.h:323
 // For v8-R, we do not enable crypto and align with GCC that enables a more 
minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, 
"armv8-r", "+v8r", ((BaseNoCrypto ^ AArch64::AEK_LSE) | AArch64::AEK_SSBS | 
AArch64::AEK_FP16 | AArch64::AEK_FP16FML | AArch64::AEK_SB), };
 // clang-format on

This bitmap is based on the v8.5a bitmap, so would need checking, but it looks 
like it will be correct already because v8r has SB and SSBS marked already 
(which is correct).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142410

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


[PATCH] D142410: [AArch64] ARMv8.5-A implies both FEAT_SB and FEAT_SSBS

2023-01-24 Thread Philipp Tomsich via Phabricator via cfe-commits
philipp.tomsich added a comment.

When looking at "ARM DDI 0487G.a", on page A2-68 under the heading "Additional 
functionality added to Armv8.0 in later releases" in the definition-list item 
"FEAT_SSBS, Speculative Store Bypass Safe":

> This feature is OPTIONAL in Armv8.0 implementations and mandatory in Armv8.5 
> implementations.

There is a to FEAT_SBSS in the backlink in "A2.8 The Armv8.5 architecture 
extension", under the subsection "A2.8.3 Features added to earlier extensions", 
in the bullet-list labeled "The features that have been added to earlier 
architectural extensions are:"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142410

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


[PATCH] D142410: [AArch64] ARMv8.5-A implies both FEAT_SB and FEAT_SSBS

2023-01-24 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

In D142410#4076389 , @philipp.tomsich 
wrote:

> When looking at "ARM DDI 0487G.a", on page A2-68 under the heading 
> "Additional functionality added to Armv8.0 in later releases" in the 
> definition-list item "FEAT_SSBS, Speculative Store Bypass Safe":
>
>> This feature is OPTIONAL in Armv8.0 implementations and mandatory in Armv8.5 
>> implementations.
>
> There is a to FEAT_SBSS in the backlink in "A2.8 The Armv8.5 architecture 
> extension", under the subsection "A2.8.3 Features added to earlier 
> extensions", in the bullet-list labeled "The features that have been added to 
> earlier architectural extensions are:"

I cited version `I.a`, which is later than version `G.a`. Looking at the errata 
for version `G.b`, erratum R18653 (page 93) is where it was relaxed to not be 
mandatory from v8.5a. Errata document link: 
https://developer.arm.com/documentation/102105/gb-05/?lang=en (I'm just happy 
this was in the first errata document I looked for!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142410

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


[PATCH] D142448: [clang][Interp] Handle TypeTraitExprs

2023-01-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, tahonermann, erichkeane, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Only light testing here, since the value we're emitting is something we get 
from sema IIUC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142448

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -749,3 +749,15 @@
   static_assert(get3() == 3, "");
 #endif
 };
+
+namespace TypeTraits {
+  static_assert(__is_trivial(int), "");
+  static_assert(__is_trivial(float), "");
+  static_assert(__is_trivial(E), "");
+  struct S{};
+  static_assert(__is_trivial(S), "");
+  struct S2 {
+S2() {}
+  };
+  static_assert(!__is_trivial(S2), "");
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -91,6 +91,7 @@
   bool VisitExprWithCleanups(const ExprWithCleanups *E);
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
+  bool VisitTypeTraitExpr(const TypeTraitExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -886,6 +886,11 @@
   return false;
 }
 
+template 
+bool ByteCodeExprGen::VisitTypeTraitExpr(const TypeTraitExpr *E) {
+  return this->emitConstBool(E->getValue(), E);
+}
+
 template  bool ByteCodeExprGen::discard(const Expr *E) 
{
   if (E->containsErrors())
 return false;


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -749,3 +749,15 @@
   static_assert(get3() == 3, "");
 #endif
 };
+
+namespace TypeTraits {
+  static_assert(__is_trivial(int), "");
+  static_assert(__is_trivial(float), "");
+  static_assert(__is_trivial(E), "");
+  struct S{};
+  static_assert(__is_trivial(S), "");
+  struct S2 {
+S2() {}
+  };
+  static_assert(!__is_trivial(S2), "");
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -91,6 +91,7 @@
   bool VisitExprWithCleanups(const ExprWithCleanups *E);
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
+  bool VisitTypeTraitExpr(const TypeTraitExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -886,6 +886,11 @@
   return false;
 }
 
+template 
+bool ByteCodeExprGen::VisitTypeTraitExpr(const TypeTraitExpr *E) {
+  return this->emitConstBool(E->getValue(), E);
+}
+
 template  bool ByteCodeExprGen::discard(const Expr *E) {
   if (E->containsErrors())
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140086: [analyzer][solver] Improve reasoning for not equal to operator

2023-01-24 Thread Manas Gupta via Phabricator via cfe-commits
manas added a comment.

Gentle ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140086

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


[PATCH] D142373: [Utils] Add --full-function-signature to update_cc_test_checks.py to match return type as well as args

2023-01-24 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

I'm probably not the best person to review this but, for what it's worth, it 
LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142373

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


[PATCH] D142449: [clang] Fix linking to LLVMTestingAnnotations in standalone build

2023-01-24 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: rupprecht, tstellar, MaskRay, thesamesam.
Herald added a project: All.
mgorny requested review of this revision.

The LLVMTestingAnnotations library that is now used by unittests
is not installed as part of LLVM.  In order to make it possible to build
unittests when performing the standalone build of clang, build
the library from LLVM sources locally.  This mirrors the existing logic
for LLVMTestingSupport.


https://reviews.llvm.org/D142449

Files:
  clang/unittests/CMakeLists.txt


Index: clang/unittests/CMakeLists.txt
===
--- clang/unittests/CMakeLists.txt
+++ clang/unittests/CMakeLists.txt
@@ -2,7 +2,12 @@
 set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
 
 if(CLANG_BUILT_STANDALONE)
-  # LLVMTestingSupport library is needed for some of the unittests.
+  # LLVMTesting* libraries are needed for some of the unittests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  AND NOT TARGET LLVMTestingAnnotations)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  lib/Testing/Annotations)
+  endif()
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
   AND NOT TARGET LLVMTestingSupport)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support


Index: clang/unittests/CMakeLists.txt
===
--- clang/unittests/CMakeLists.txt
+++ clang/unittests/CMakeLists.txt
@@ -2,7 +2,12 @@
 set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
 
 if(CLANG_BUILT_STANDALONE)
-  # LLVMTestingSupport library is needed for some of the unittests.
+  # LLVMTesting* libraries are needed for some of the unittests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  AND NOT TARGET LLVMTestingAnnotations)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  lib/Testing/Annotations)
+  endif()
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
   AND NOT TARGET LLVMTestingSupport)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142449: [clang] Fix linking to LLVMTestingAnnotations in standalone build

2023-01-24 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht accepted this revision.
rupprecht added a comment.
This revision is now accepted and ready to land.

Thanks!


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

https://reviews.llvm.org/D142449

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


[PATCH] D140415: [flang] stack arrays pass

2023-01-24 Thread Tom Eccles via Phabricator via cfe-commits
tblah added a comment.

Ping for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140415

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


[PATCH] D142449: [clang] Fix linking to LLVMTestingAnnotations in standalone build

2023-01-24 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Thanks for the superfast review! I'll push it later today.


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

https://reviews.llvm.org/D142449

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


[PATCH] D142454: [analyzer] Update satest dependencies

2023-01-24 Thread Manas Gupta via Phabricator via cfe-commits
manas created this revision.
manas added a reviewer: steakhal.
Herald added subscribers: ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
manas requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A couple of packages were out-dated while building satest docker image.
This patch updates those.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142454

Files:
  clang/utils/analyzer/Dockerfile


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -31,8 +31,8 @@
 
 # symengine dependencies
 RUN apt-get install -y \
-libgmp10=2:6.1.2+dfsg-2 \
-libgmp-dev=2:6.1.2+dfsg-2
+libgmp10=2:6.1.2+dfsg-2ubuntu0.1 \
+libgmp-dev=2:6.1.2+dfsg-2ubuntu0.1
 
 # simbody dependencies
 RUN apt-get install -y \


Index: clang/utils/analyzer/Dockerfile
===
--- clang/utils/analyzer/Dockerfile
+++ clang/utils/analyzer/Dockerfile
@@ -31,8 +31,8 @@
 
 # symengine dependencies
 RUN apt-get install -y \
-libgmp10=2:6.1.2+dfsg-2 \
-libgmp-dev=2:6.1.2+dfsg-2
+libgmp10=2:6.1.2+dfsg-2ubuntu0.1 \
+libgmp-dev=2:6.1.2+dfsg-2ubuntu0.1
 
 # simbody dependencies
 RUN apt-get install -y \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-01-24 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 491707.
pmatos added a comment.

Further tests for use of tables in conditional branches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/builtins-table.c
  clang/test/CodeGen/WebAssembly/table.c
  clang/test/Sema/builtins-wasm.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs-and-tables.cpp
  clang/test/SemaCXX/wasm-refs.cpp
  llvm/include/llvm/CodeGen/WasmAddressSpaces.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
@@ -62,8 +62,9 @@
   for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
 PtrToIntInst *PTI = dyn_cast(&*I);
 IntToPtrInst *ITP = dyn_cast(&*I);
-if (!(PTI && WebAssembly::isRefType(PTI->getPointerOperand()->getType())) &&
-!(ITP && WebAssembly::isRefType(ITP->getDestTy(
+if (!(PTI &&
+  PTI->getPointerOperand()->getType()->isWebAssemblyReferenceType()) &&
+!(ITP && ITP->getDestTy()->isWebAssemblyReferenceType()))
   continue;
 
 UndefValue *U = UndefValue::get(I->getType());
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1202,7 +1202,7 @@
   // Lastly, if this is a call to a funcref we need to add an instruction
   // table.set to the chain and transform the call.
   if (CLI.CB &&
-  WebAssembly::isFuncrefType(CLI.CB->getCalledOperand()->getType())) {
+  CLI.CB->getCalledOperand()->getType()->isWebAssemblyFuncrefType()) {
 // In the absence of function references proposal where a funcref call is
 // lowered to call_ref, using reference types we generate a table.set to set
 // the funcref to a special table used solely for this purpose, followed by
Index: llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
===
--- llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
+++ llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
@@ -45,43 +45,6 @@
   Multivalue = 0x,
 };
 
-enum WasmAddressSpace : unsigned {
-  // Default address space, for pointers to linear memory (stack, heap, data).
-  WASM_ADDRESS_SPACE_DEFAULT = 0,
-  // A non-integral address space for pointers to named objects outside of
-  // linear memory: WebAssembly globals or WebAssembly locals.  Loads and stores
-  // to these pointers are lowered to global.get / global.set or local.get /
-  // local.set, as appropriate.
-  WASM_ADDRESS_SPACE_VAR = 1,
-  // A non-integral address space for externref values
-  WASM_ADDRESS_SPACE_EXTERNREF = 10,
-  // A non-integral address space for funcref values
-  WASM_ADDRESS_SPACE_FUNCREF = 20,
-};
-
-inline bool isDefaultAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_DEFAULT;
-}
-inline bool isWasmVarAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_VAR;
-}
-inline bool isValidAddressSpace(unsigned AS) {
-  return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);
-}
-inline bool isFuncrefType(const Type *Ty) {
-  return isa(Ty) &&
- Ty->getPointerAddressSpace() ==
- WasmAddressSpace::WASM_ADDRESS_SPACE_FUNCREF;
-}
-inline bool isExternrefType(const Type *Ty) {
-  return isa(Ty) &&
- Ty->getPointerAddressSpace() ==
- WasmAddressSpace::WASM_ADDRESS_SPACE_EXTERNREF;

[PATCH] D142373: [Utils] Add --full-function-signature to update_cc_test_checks.py to match return type as well as args

2023-01-24 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Please give me a day to propose another alternative... Seeing D142452 
 we now have three different patches that 
would like to change UTC output, so I really think we need that `--version` 
flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142373

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


[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2023-01-24 Thread Andrey Butirsky via Phabricator via cfe-commits
bam added a comment.

I'm sorry but I'm not familiar with the codebase, so I can't help, 
unfortunately.


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

https://reviews.llvm.org/D24888

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


[PATCH] D137070: [clang][Interp] Support destructors

2023-01-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked 3 inline comments as done.
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1915-1916
+
+if (const CXXDestructorDecl *Dtor = ElemRecord->getDestructor();
+Dtor && !Dtor->isTrivial()) {
+  for (size_t I = 0, E = Desc->getNumElems(); I != E; ++I) {

aaron.ballman wrote:
> `isTrivial()` only works once the class has been fully built up by Sema IIRC; 
> we should have a test case for that situation.
Are you saying that `isTrivial()` cannot be used like this, or just that it 
can, but needs a test case to ensure that this is true?

Also, how would such a test case look like?



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1917
+Dtor && !Dtor->isTrivial()) {
+  for (size_t I = 0, E = Desc->getNumElems(); I != E; ++I) {
+if (!this->emitConstUint64(I, SourceInfo{}))

aaron.ballman wrote:
> This looks like it will destroy the array elements in order instead of in 
> reverse order -- need test coverage for that. See 
> https://eel.is/c++draft/class.dtor#13.sentence-5
Right, that makes a lot of sense, good catch.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1934
+const Descriptor *D = Field.Desc;
+if (!D->isPrimitive() && !D->isPrimitiveArray()) {
+  if (!this->emitDupPtr(SourceInfo{}))

aaron.ballman wrote:
> Won't this also destroy static data members? (Needs a test case for that.)
> 
> Also, what if the record is a union and not a structure? We only want to 
> destroy the active member in that case, not all of the variant members, 
> right? (Also needs a test case.)
> 
> See http://eel.is/c++draft/class.dtor#13
I saw
```
  // A union destructor does not implicitly destroy its members.
  if (RD->isUnion())
return true;
```
in `ExprConstant.cpp`, but since we don't handle unions at all in the new 
interpreter right now, I didn't add anything for them. I added a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137070

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


[PATCH] D137070: [clang][Interp] Support destructors

2023-01-24 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 491709.

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

https://reviews.llvm.org/D137070

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/test/AST/Interp/cxx20.cpp

Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -217,3 +217,225 @@
// ref-error {{must be initialized by a constant expression}}
 
 };
+
+namespace Destructors {
+
+  class Inc final {
+  public:
+int &I;
+constexpr Inc(int &I) : I(I) {}
+constexpr ~Inc() {
+  I++;
+}
+  };
+
+  class Dec final {
+  public:
+int &I;
+constexpr Dec(int &I) : I(I) {}
+constexpr ~Dec() {
+  I--;
+}
+  };
+
+
+
+  constexpr int m() {
+int i = 0;
+{
+  Inc f1(i);
+  Inc f2(i);
+  Inc f3(i);
+}
+return i;
+  }
+  static_assert(m() == 3, "");
+
+
+  constexpr int C() {
+int i = 0;
+
+while (i < 10) {
+  Inc inc(i);
+  continue;
+  Dec dec(i);
+}
+return i;
+  }
+  static_assert(C() == 10, "");
+
+
+  constexpr int D() {
+int i = 0;
+
+{
+  Inc i1(i);
+  {
+Inc i2(i);
+return i;
+  }
+}
+
+return i;
+  }
+  static_assert(D() == 0, "");
+
+  constexpr int E() {
+int i = 0;
+
+for(;;) {
+  Inc i1(i);
+  break;
+}
+return i;
+  }
+  static_assert(E() == 1, "");
+
+
+  /// FIXME: This should be rejected, since we call the destructor
+  ///   twice. However, GCC doesn't care either.
+  constexpr int ManualDtor() {
+int i = 0;
+{
+  Inc I(i); // ref-note {{destroying object 'I' whose lifetime has already ended}}
+  I.~Inc();
+}
+return i;
+  }
+  static_assert(ManualDtor() == 1, ""); // expected-error {{static assertion failed}} \
+// expected-note {{evaluates to '2 == 1'}} \
+// ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'ManualDtor()'}}
+
+  constexpr void doInc(int &i) {
+Inc I(i);
+return;
+  }
+  constexpr int testInc() {
+int i = 0;
+doInc(i);
+return i;
+  }
+  static_assert(testInc() == 1, "");
+  constexpr void doInc2(int &i) {
+Inc I(i);
+// No return statement.
+  }
+   constexpr int testInc2() {
+int i = 0;
+doInc2(i);
+return i;
+  }
+  static_assert(testInc2() == 1, "");
+
+
+  namespace DtorOrder {
+class A {
+  public:
+  int &I;
+  constexpr A(int &I) : I(I) {}
+  constexpr ~A() {
+I = 1337;
+  }
+};
+
+class B : public A {
+  public:
+  constexpr B(int &I) : A(I) {}
+  constexpr ~B() {
+I = 42;
+  }
+};
+
+constexpr int foo() {
+  int i = 0;
+  {
+B b(i);
+  }
+  return i;
+}
+
+static_assert(foo() == 1337);
+  }
+
+  class FieldDtor1 {
+  public:
+Inc I1;
+Inc I2;
+constexpr FieldDtor1(int &I) : I1(I), I2(I){}
+  };
+
+  constexpr int foo2() {
+int i = 0;
+{
+  FieldDtor1 FD1(i);
+}
+return i;
+  }
+
+  static_assert(foo2() == 2);
+
+  class FieldDtor2 {
+  public:
+Inc Incs[3];
+constexpr FieldDtor2(int &I)  : Incs{Inc(I), Inc(I), Inc(I)} {}
+  };
+
+  constexpr int foo3() {
+int i = 0;
+{
+  FieldDtor2 FD2(i);
+}
+return i;
+  }
+
+  static_assert(foo3() == 3);
+
+  struct ArrD {
+int index;
+int *arr;
+int &p;
+constexpr ~ArrD() {
+  arr[p] = index;
+  ++p;
+}
+  };
+  constexpr bool ArrayOrder() {
+int order[3] = {0, 0, 0};
+int p = 0;
+{
+  ArrD ds[3] = {
+{1, order, p},
+{2, order, p},
+{3, order, p},
+  };
+  // ds will be destroyed.
+}
+return order[0] == 3 && order[1] == 2 && order[2] == 1;
+  }
+  static_assert(ArrayOrder());
+
+
+  // Static members aren't destroyed.
+  class Dec2 {
+  public:
+int A = 0;
+constexpr ~Dec() {
+  A++;
+}
+  };
+  class Foo {
+  public:
+static constexpr Dec2 a;
+  };
+  static_assert(Foo::a.A == 0);
+  constexpr bool f() {
+Foo f;
+return true;
+  }
+  static_assert(Foo::a.A == 0);
+  static_assert(f());
+  static_assert(Foo::a.A == 0);
+
+
+}
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -426,6 +426,7 @@
   if (!BreakLabel)
 return false;
 
+  this->emitCleanup();
   return this->jump(*BreakLabel);
 }
 
@@ -434,6 +435,7 @@
   if (!ContinueLabel)
 return false;
 
+  this->emitCleanup();
   return this->jump(*ContinueLabel);
 }
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
==

[PATCH] D140315: [AMDGCN] Update search path for device libraries

2023-01-24 Thread Michał Górny via Phabricator via cfe-commits
m_resource_dir/include"
 "-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/include" 
"-internal-externc-isystem" "/include" "-internal-externc-isystem" 
"/usr/include" "-fdeprecated-macro" "-fno-autolink" 
"-fdebug-compilation-dir=/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/work/x/y/clang-abi_x86_64.amd64/test/Driver"
 "-ferror-limit" "19" "-fhip-new-launch-api" "-fgnuc-version=4.2.1" 
"-fcxx-exceptions" "-fexceptions" "-cuid=baca1261ad77b3c1" 
"-fcuda-allow-variadic-functions" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" 
"-o" 
"/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/temp/b-aed965/b-gfx803.o" 
"-x" "hip" 
"/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/work/clang/test/Driver/Inputs/hip_multiple_inputs/b.hip"
 
   7:  "/usr/lib/llvm/16/bin/lld" "-flavor" "gnu" "-m" "elf64_amdgpu" 
"--no-undefined" "-shared" "-plugin-opt=-amdgpu-internalize-symbols" 
"-plugin-opt=mcpu=gfx803" "-o" 
"/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/temp/b-8854b0/b-gfx803.out"
 "/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/temp/b-aed965/b-gfx803.o" 
   8:  
"/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/work/x/y/clang-abi_x86_64.amd64/bin/clang-offload-bundler"
 "-type=o" "-bundle-align=4096" 
"-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx803" 
"-input=/dev/null" 
"-input=/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/temp/b-8854b0/b-gfx803.out"
 
"-output=/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/temp/b-54bd59.hipfb"
 
   9:  
"/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/work/x/y/clang-abi_x86_64.amd64/bin/clang-16"
 "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-aux-triple" "amdgcn-amd-amdhsa" 
"-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" 
"-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "b.hip" 
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" 
"-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" 
"-target-cpu" "x86-64" "-tune-cpu" "generic" "-mllvm" 
"-treat-scalable-fixed-error-as-warning" "-debugger-tuning=gdb" 
"-fcoverage-compilation-dir=/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/work/x/y/clang-abi_x86_64.amd64/test/Driver"
 "-resource-dir" 
"/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/work/clang/test/Driver/Inputs/rocm_resource_dir"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/work/clang/test/Driver/Inputs/rocm_resource_dir"
 "-internal-isystem" "/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/x86_64-pc-linux-gnu" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/backward" 
"-internal-isystem" "/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/x86_64-pc-linux-gnu" 
"-internal-isystem" 
"/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/backward" 
"-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/work/clang/test/Driver/Inputs/rocm_resource_dir/include"
 "-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/include" 
"-internal-externc-isystem" "/include" "-internal-externc-isystem" 
"/usr/include" "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-16.0.0_pre20230124/work/clang/test/Driver/Inputs/rocm_resource_dir/include"
 "-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/include" 
"-internal-externc-isystem" "/include" "-internal-externc-isystem" 
"/usr/include" "-fdeprecated-macro" 
"-fde

[clang] 0f8b995 - [clang] Fix linking to LLVMTestingAnnotations in standalone build

2023-01-24 Thread Michał Górny via cfe-commits

Author: Michał Górny
Date: 2023-01-24T13:21:24+01:00
New Revision: 0f8b995b63620c3eb57610f958f66691d38d7185

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

LOG: [clang] Fix linking to LLVMTestingAnnotations in standalone build

The LLVMTestingAnnotations library that is now used by unittests
is not installed as part of LLVM.  In order to make it possible to build
unittests when performing the standalone build of clang, build
the library from LLVM sources locally.  This mirrors the existing logic
for LLVMTestingSupport.

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

Added: 


Modified: 
clang/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index cffd4756616a2..f4e4f585bdd80 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -2,7 +2,12 @@ add_custom_target(ClangUnitTests)
 set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
 
 if(CLANG_BUILT_STANDALONE)
-  # LLVMTestingSupport library is needed for some of the unittests.
+  # LLVMTesting* libraries are needed for some of the unittests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  AND NOT TARGET LLVMTestingAnnotations)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  lib/Testing/Annotations)
+  endif()
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
   AND NOT TARGET LLVMTestingSupport)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support



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


[PATCH] D142449: [clang] Fix linking to LLVMTestingAnnotations in standalone build

2023-01-24 Thread Michał Górny 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 rG0f8b995b6362: [clang] Fix linking to LLVMTestingAnnotations 
in standalone build (authored by mgorny).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142449

Files:
  clang/unittests/CMakeLists.txt


Index: clang/unittests/CMakeLists.txt
===
--- clang/unittests/CMakeLists.txt
+++ clang/unittests/CMakeLists.txt
@@ -2,7 +2,12 @@
 set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
 
 if(CLANG_BUILT_STANDALONE)
-  # LLVMTestingSupport library is needed for some of the unittests.
+  # LLVMTesting* libraries are needed for some of the unittests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  AND NOT TARGET LLVMTestingAnnotations)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  lib/Testing/Annotations)
+  endif()
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
   AND NOT TARGET LLVMTestingSupport)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support


Index: clang/unittests/CMakeLists.txt
===
--- clang/unittests/CMakeLists.txt
+++ clang/unittests/CMakeLists.txt
@@ -2,7 +2,12 @@
 set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
 
 if(CLANG_BUILT_STANDALONE)
-  # LLVMTestingSupport library is needed for some of the unittests.
+  # LLVMTesting* libraries are needed for some of the unittests.
+  if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  AND NOT TARGET LLVMTestingAnnotations)
+add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Annotations
+  lib/Testing/Annotations)
+  endif()
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
   AND NOT TARGET LLVMTestingSupport)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142439: Fix C++11 warnings in RangeSetTest.cpp

2023-01-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

I'm not that confident around gtest macros, but this doesn't look harmful.
Thanks for taking the time and fixing it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142439

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


[PATCH] D140086: [analyzer][solver] Improve reasoning for not equal to operator

2023-01-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Looks good. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140086

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


[PATCH] D142373: [Utils] Add --full-function-signature to update_cc_test_checks.py to match return type as well as args

2023-01-24 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In D142373#4076584 , @nikic wrote:

> Please give me a day to propose another alternative... Seeing D142452 
>  we now have three different patches that 
> would like to change UTC output, so I really think we need that `--version` 
> flag.

Of course, thanks for taking a look. This incarnation of the patch of course is 
explicitly trying to avoid change default UTC output, at the cost of adding yet 
another command line option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142373

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


[PATCH] D139926: [clangd] Add semantic token for angle brackets

2023-01-24 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 491718.
ckandeler marked an inline comment as done.
ckandeler added a comment.

Added test cases from review comment and made them pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  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
@@ -130,17 +130,17 @@
 )cpp",
   R"cpp(
   namespace $Namespace_decl[[abc]] {
-template
+template$Bracket[[<]]typename $TemplateParameter_def[[T]]$Bracket[[>]]
 struct $Class_def[[A]] {
   $TemplateParameter[[T]] $Field_decl[[t]];
 };
   }
-  template
-  struct $Class_def[[C]] : $Namespace[[abc]]::$Class[[A]]<$TemplateParameter[[T]]> {
+  template$Bracket[[<]]typename $TemplateParameter_def[[T]]$Bracket[[>]]
+  struct $Class_def[[C]] : $Namespace[[abc]]::$Class[[A]]$Bracket[[<]]$TemplateParameter[[T]]$Bracket[[>]] {
 typename $TemplateParameter[[T]]::$Type_dependentName[[A]]* $Field_decl[[D]];
   };
-  $Namespace[[abc]]::$Class[[A]] $Variable_def[[AA]];
-  typedef $Namespace[[abc]]::$Class[[A]] $Class_decl[[AAA]];
+  $Namespace[[abc]]::$Class[[A]]$Bracket[[<]]int$Bracket[[>]] $Variable_def[[AA]];
+  typedef $Namespace[[abc]]::$Class[[A]]$Bracket[[<]]int$Bracket[[>]] $Class_decl[[AAA]];
   struct $Class_def[[B]] {
 $Class_decl_constrDestr[[B]]();
 ~$Class_decl_constrDestr[[B]]();
@@ -243,36 +243,36 @@
   typedef float $Primitive_decl[[F]];
 )cpp",
   R"cpp(
-  template
+  template$Bracket[[<]]typename $TemplateParameter_def[[T]], typename = void$Bracket[[>]]
   class $Class_def[[A]] {
 $TemplateParameter[[T]] $Field_decl[[AA]];
 $TemplateParameter[[T]] $Method_decl[[foo]]();
   };
-  template
+  template$Bracket[[<]]class $TemplateParameter_def[[TT]]$Bracket[[>]]
   class $Class_def[[B]] {
-$Class[[A]]<$TemplateParameter[[TT]]> $Field_decl[[AA]];
+$Class[[A]]$Bracket[[<]]$TemplateParameter[[TT]]$Bracket[[>]] $Field_decl[[AA]];
   };
-  template
+  template$Bracket[[<]]class $TemplateParameter_def[[TT]], class $TemplateParameter_def[[GG]]$Bracket[[>]]
   class $Class_def[[BB]] {};
-  template
-  class $Class_def[[BB]]<$TemplateParameter[[T]], int> {};
-  template
-  class $Class_def[[BB]]<$TemplateParameter[[T]], $TemplateParameter[[T]]*> {};
+  template$Bracket[[<]]class $TemplateParameter_def[[T]]$Bracket[[>]]
+  class $Class_def[[BB]]$Bracket[[<]]$TemplateParameter[[T]], int$Bracket[[>]] {};
+  template$Bracket[[<]]class $TemplateParameter_def[[T]]$Bracket[[>]]
+  class $Class_def[[BB]]$Bracket[[<]]$TemplateParameter[[T]], $TemplateParameter[[T]]*$Bracket[[>]] {};
 
-  template class $TemplateParameter_def[[T]], class $TemplateParameter_def[[C]]>
-  $TemplateParameter[[T]]<$TemplateParameter[[C]]> $Function_decl[[f]]();
+  template$Bracket[[<]]template$Bracket[[<]]class$Bracket[[>]] class $TemplateParameter_def[[T]], class $TemplateParameter_def[[C]]$Bracket[[>]]
+  $TemplateParameter[[T]]$Bracket[[<]]$TemplateParameter[[C]]$Bracket[[>]] $Function_decl[[f]]();
 
-  template
+  template$Bracket[[<]]typename$Bracket[[>]]
   class $Class_def[[Foo]] {};
 
-  template
+  template$Bracket[[<]]typename $TemplateParameter_def[[T]]$Bracket[[>]]
   void $Function_decl[[foo]]($TemplateParameter[[T]] ...);
 )cpp",
   R"cpp(
-  template 
+  template $Bracket[[<]]class $TemplateParameter_def[[T]]$Bracket[[>]]
   struct $Class_def[[Tmpl]] {$TemplateParameter[[T]] $Field_decl[[x]] = 0;};
-  extern template struct $Class_def[[Tmpl]];
-  template struct $Class_def[[Tmpl]];
+  extern template struct $Class_def[[Tmpl]]$Bracket[[<]]float$Bracket[[>]];
+  template struct $Class_def[[Tmpl]]$Bracket[[<]]double$Bracket[[>]];
 )cpp",
   // This test is to guard against highlightings disappearing when using
   // conversion operators as their behaviour in the clang AST differ from
@@ -335,17 +335,17 @@
 )cpp",
   R"cpp(
   class $Class_def[[G]] {};
-  template<$Class[[G]] *$TemplateParameter_def_readonly[[U]]>
+  template$Bracket[[<]]$Class[[G]] *$TemplateParameter_def_readonly[[U]]$Bracket[[>]]
   class $Class_def[[GP]] {};
-  template<$Class[[G]] &$TemplateParameter_def_readonly[[U]]>
+  template$Bracket[[<]]$Class[[G]] &$TemplateParameter_def_readonly[[U]]$Bracket[[>]]
   class $Class_def[[GR]] {};
-  templat

[PATCH] D139926: [clangd] Add semantic token for angle brackets

2023-01-24 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

Thanks for the test cases!
All fixed, except:

> // variable template specialization
> // parameter and argument lists are missing semantic tokens
> template <>
> constexpr int V = 5;

Argument list fixed. I didn't manage to make the parameter list work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


[PATCH] D142437: [clang] Add the check of membership in decltype for the issue #58674

2023-01-24 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 491717.

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

https://reviews.llvm.org/D142437

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2693,20 +2693,34 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember = ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class, true)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/lib/AST/CXXInheritance.cpp
===
--- clang/lib/AST/CXXInheritance.cpp
+++ clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupIndependent) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths);
+  return isDerivedFrom(Base, Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  CXXBasePaths &Paths) const {
+  CXXBasePaths &Paths,
+  bool LookupIndependent) const {
   if (getCanonicalDecl() == Base->getCanonicalDecl())
 return false;
 
@@ -80,9 +82,10 @@
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
   return lookupInBases(
   [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
-return FindBaseClass(Specifier, Path, BaseDecl);
+return Specifier->getType()->getAsRecordDecl() &&
+   FindBaseClass(Specifier, Path, BaseDecl);
   },
-  Paths);
+  Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const {
Index: 

[PATCH] D137302: [clang-tidy] Add modernize-type-traits check

2023-01-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

LGTM, really useful check! Would be nice to get some more eyes on the 
implementation, it's fairly advanced for my basic AST knowledge.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137302

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


[PATCH] D142459: [clang] Deprecate uses of GlobalObject::getAlignment

2023-01-24 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added a project: All.
gchatelet requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This remove the last uses of GlobalObject::getAlignment and marks it as 
deprecated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142459

Files:
  clang/include/clang/AST/CharUnits.h
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/IR/GlobalObject.h

Index: llvm/include/llvm/IR/GlobalObject.h
===
--- llvm/include/llvm/IR/GlobalObject.h
+++ llvm/include/llvm/IR/GlobalObject.h
@@ -67,6 +67,7 @@
   GlobalObject(const GlobalObject &) = delete;
 
   /// FIXME: Remove this function once transition to Align is over.
+  LLVM_DEPRECATED("Use getAlign() instead", "getAlign")
   uint64_t getAlignment() const {
 MaybeAlign Align = getAlign();
 return Align ? Align->value() : 0;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2132,7 +2132,7 @@
   // functions. If the current target's C++ ABI requires this and this is a
   // member function, set its alignment accordingly.
   if (getTarget().getCXXABI().areMemberFunctionsAligned()) {
-if (F->getAlignment() < 2 && isa(D))
+if (F->getAlign() < 2 && isa(D))
   F->setAlignment(llvm::Align(2));
   }
 
@@ -5611,8 +5611,8 @@
StringLength);
 
   if (auto *C = Entry.second)
-return ConstantAddress(
-C, C->getValueType(), CharUnits::fromQuantity(C->getAlignment()));
+return ConstantAddress(C, C->getValueType(),
+   CharUnits::fromQuantity(C->getAlign()));
 
   llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
   llvm::Constant *Zeros[] = { Zero, Zero };
@@ -5909,7 +5909,7 @@
   if (!LangOpts.WritableStrings) {
 Entry = &ConstantStringMap[C];
 if (auto GV = *Entry) {
-  if (uint64_t(Alignment.getQuantity()) > GV->getAlignment())
+  if (GV->getAlign() < uint64_t(Alignment.getQuantity()))
 GV->setAlignment(Alignment.getAsAlign());
   return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV),
  GV->getValueType(), Alignment);
@@ -5976,7 +5976,7 @@
   if (!LangOpts.WritableStrings) {
 Entry = &ConstantStringMap[C];
 if (auto GV = *Entry) {
-  if (uint64_t(Alignment.getQuantity()) > GV->getAlignment())
+  if (GV->getAlign() < uint64_t(Alignment.getQuantity()))
 GV->setAlignment(Alignment.getAsAlign());
   return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV),
  GV->getValueType(), Alignment);
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -1987,8 +1987,8 @@
 GetConstantStringEntry(NSConstantStringMap, Literal, StringLength);
 
   if (auto *C = Entry.second)
-return ConstantAddress(
-C, C->getValueType(), CharUnits::fromQuantity(C->getAlignment()));
+return ConstantAddress(C, C->getValueType(),
+   CharUnits::fromQuantity(C->getAlign()));
 
   // If we don't already have it, get _NSConstantStringClassReference.
   llvm::Constant *Class = getNSConstantStringClassRef();
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1157,7 +1157,7 @@
 GV->setAlignment(Align.getAsAlign());
 GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 CacheEntry = GV;
-  } else if (CacheEntry->getAlignment() < uint64_t(Align.getQuantity())) {
+  } else if (CacheEntry->getAlign() < uint64_t(Align.getQuantity())) {
 CacheEntry->setAlignment(Align.getAsAlign());
   }
 
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -488,7 +488,7 @@
   llvm::Value *OldV = Var;
   llvm::Instruction *NewV =
   new llvm::LoadInst(Var->getType(), ManagedVar, "ld.managed", false,
- llvm::Align(Var->getAlignment()), I);
+ Var->getAlign().valueOrOne(), I);
   WorkItem.pop_back();
   // Replace constant expressions directly or indirectly using the managed
   // variable with instructions.
@@ -631,7 +631,7 @@
 Builder.CreateBitCast(Var, VoidPtrTy),
 VarName,
 llvm::ConstantInt::get(VarSizeTy, VarSize),
-llvm::ConstantInt::get(IntTy, Var->getAlignment())}

[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:106
-SYMBOL(atomic_exchange_explicit, std::, )
-SYMBOL(atomic_fetch_add, std::, )
-SYMBOL(atomic_fetch_add_explicit, std::, )

Looks like the regex filters too many symbols -- e.g. atomic_fetch_add is not a 
variant symbol, we should keep it instead. The same to other following symbols 
as well.



Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:100
 SYMBOL(atoll, std::, )
+SYMBOL(atomic, std::, )
+SYMBOL(atomic, std::, )

VitaNuo wrote:
> VitaNuo wrote:
> > kadircet wrote:
> > > hokein wrote:
> > > > Conceptually, this (and other `atomic_*` symbols) doesn't feel correct:
> > > > - `` provides the generic template `template struct 
> > > > atomic;`
> > > > -  `` provides partial template specializations for 
> > > > `std::shared_ptr` and `std::weak_ptr`  
> > > > 
> > > > They are variant symbols (ideally, they should be treat as the 
> > > > `std::move()`). The issue here is that unlike `std::move` which has two 
> > > > individual entries in the index page, we only have one entry for 
> > > > `std::atomic` (extending the cppreference_parser.py script to perfectly 
> > > > distinguish these two cases in the 
> > > > [page](https://en.cppreference.com/w/cpp/atomic/atomic) seems 
> > > > non-trivial).  Some options:
> > > > 
> > > > 1) treat them as multiple-header symbols (like what this patch does now)
> > > > 2) special-case these symbols like `std::move()`
> > > > 3) always prefer the header providing generic templates
> > > > 
> > > > @kadircet, what do you think?
> > > right, i believe this patch is definitely adding keeping multiple headers 
> > > for a symbol around, but mixing it with keeping headers for variants 
> > > (e.g. overloads provided by different headers, or specializations as 
> > > mentioned here).
> > > 
> > > we definitely need some more changes in parser to make sure we're only 
> > > preserving alternatives for **the same symbol** and not for any other 
> > > variants (overloads, specializations). IIRC there are currently 2 places 
> > > these variants could come into play:
> > > - first is the symbol index page itself, symbols that have ` (foo)` next 
> > > to them have variants and should still be ignored (e.g. std::remove 
> > > variant of cstdio shouldn't be preserved in the scope of this patch)
> > > - second is inside the detail pages for symbols, e.g. 
> > > [std::atomic](http://go/std::atomic), we can have headers for different 
> > > declarations, they're clearly different variants so we shouldn't add such 
> > > symbols into the mapping `_ParseSymbolPage` already does some detection 
> > > of declarations in between headers.
> > > 
> > > in the scope of this patch, we should keep ignoring both.
> > I suggest to special-case the overloads for now, just not to solve all the 
> > problems in the same patch.
> The first group are already ignored. We need to take a lot at how to ignore 
> the second one.
Ideally, we should tweak the `_ParseSymbolPage` to handle this case, but I 
don't see a easy way to do it (the `atomic` 
[case](https://en.cppreference.com/w/cpp/atomic/atomic) is quite tricky where 
the symbol name is identical, only the template argument is different, and the 
simple text-match heuristic in `_ParseSymbolPage` fails in this case).

so specialcasing these (there are not too many of them) looks fine to me.



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:58
+int SymIndex = NextAvailSymIndex;
+if (NSSymbolMap *NSSymbols = NamespaceSymbols->lookup(NS)) {
+  auto It = NSSymbols->find(Name);

VitaNuo wrote:
> hokein wrote:
> > Given the fact that multiple-header symbols are grouped in the .inc file, 
> > we could simplify the code of checking a new symbol by looking at the last 
> > available SymIndex:
> > 
> > ```
> > if (NextAvailSymIndex > 0 && SymbolNames[NextAvailSymIndex-1].first == NS 
> > && SymbolNames[NextAvailSymIndex-1].second == Name) {
> >// this is not a new symbol.
> > }
> > ```
> I know this is easier in terms of code, but this heavily relies on the order 
> in the generated files. I would prefer to keep the library and the generator 
> as decoupled as possible, even if it means slightly more complex code here. 
> Overall, it seems more future-proof in case of unrelated generator changes 
> (bugs?) that might change the order.
> but this heavily relies on the order in the generated files.

Yeah, this is true. I actually think we should make it as an invariant 
(multiple-header symbols are grouped) of the generated .inc files. This 
invariant is important and useful, it is much easier for human to read and 
justify. We can probably guarantee it in the generator side.



Comment at: clang/tools/include-mapping/gen_std.py:112
   for symbol in symbols:
-if len(symbol.headers) == 1:

[clang] 16cea04 - Fix the Clang sphinx build

2023-01-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-01-24T08:21:53-05:00
New Revision: 16cea040d032deb1dae5538db0937888c02fc7f4

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

LOG: Fix the Clang sphinx build

This addresses issues found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/39084

Added: 


Modified: 
clang/docs/OffloadingDesign.rst

Removed: 




diff  --git a/clang/docs/OffloadingDesign.rst b/clang/docs/OffloadingDesign.rst
index 5df8a320b4da7..6d2c0da312847 100644
--- a/clang/docs/OffloadingDesign.rst
+++ b/clang/docs/OffloadingDesign.rst
@@ -240,13 +240,13 @@ will use this information when :ref:`Device Linking`.
   .. table:: Offloading Sections
 :name: table-offloading_sections
 
-
+--++
-| Section  | Description   
 |
-
+==++
-| omp_offloading_entries   | Offloading entry information (see 
:ref:`table-tgt_offload_entry`)  |
-
+--++
-| .llvm.offloading | Embedded device object file for the 
target device and architecture |
-
+--++
+
+--+--+
+| Section  | Description   
   |
+
+==+==+
+| omp_offloading_entries   | Offloading entry information (see 
:ref:`table-tgt_offload_entry_structure`)  |
+
+--+--+
+| .llvm.offloading | Embedded device object file for the 
target device and architecture   |
+
+--+--+
 
 .. _Device Linking:
 
@@ -286,7 +286,7 @@ Several 
diff erent structures are used to store offloading information. The
 linked device image and its associated offloading entries. The offloading
 entries are stored using the ``__start_omp_offloading_entries`` and
 ``__stop_omp_offloading_entries`` symbols generated by the linker using the
-:ref:`table-tgt_offload_entry`.
+:ref:`table-tgt_offload_entry_structure`.
 
   .. table:: __tgt_device_image Structure
 :name: table-device_image_structure



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


[PATCH] D141144: [clang-tidy][doc] Improve clang-tidy documentation

2023-01-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 491728.
carlosgalvezp added a comment.

Add HeaderFileExtensions and ImplementationFileExtensions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141144

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -110,6 +110,7 @@
 .. code-block:: console
 
   $ clang-tidy --help
+
   USAGE: clang-tidy [options]  [... ]
 
   OPTIONS:
@@ -122,170 +123,171 @@
 
   clang-tidy options:
 
---checks=  -
- Comma-separated list of globs with optional '-'
- prefix. Globs are processed in order of
- appearance in the list. Globs without '-'
- prefix add checks with matching names to the
- set, globs with the '-' prefix remove checks
- with matching names from the set of enabled
- checks. This option's value is appended to the
- value of the 'Checks' option in .clang-tidy
- file, if any.
---config=  -
- Specifies a configuration in YAML/JSON format:
-   -config="{Checks: '*',
- CheckOptions: {x, y}}"
- When the value is empty, clang-tidy will
- attempt to find a file named .clang-tidy for
- each source file in its parent directories.
---config-file= -
-Specify the path of .clang-tidy or custom config file:
+--checks=  - Comma-separated list of globs with optional '-'
+prefix. Globs are processed in order of
+appearance in the list. Globs without '-'
+prefix add checks with matching names to the
+set, globs with the '-' prefix remove checks
+with matching names from the set of enabled
+checks. This option's value is appended to the
+value of the 'Checks' option in .clang-tidy
+file, if any.
+--config=  - Specifies a configuration in YAML/JSON format:
+  -config="{Checks: '*',
+CheckOptions: {x: y}}"
+When the value is empty, clang-tidy will
+attempt to find a file named .clang-tidy for
+each source file in its parent directories.
+--config-file= - Specify the path of .clang-tidy or custom config file:
   e.g. --config-file=/some/path/myTidyConfigFile
 This option internally works exactly the same way as
   --config option after reading specified config file.
 Use either --config-file or --config, not both.
---dump-config  -
- Dumps configuration in the YAML format to
- stdout. This option can be used along with a
- file name (and '--' if the file is outside of a
- project with configured compilation database).
- The configuration used for this file will be
- printed.
- Use along with -checks=* to include
- configuration of all checks.
---enable-check-profile -
- Enable per-check timing profiles, and print a
- report to stderr.
---explain-config   -
- For each enabled check explains, where it is
- enabled, i.e. in clang-tidy binary, command
- line or a specific configuration file.
---export-fixes=  -
- YAML file to store suggested fixes in. The
- stored fixes can be appli

[PATCH] D141144: [clang-tidy][doc] Improve clang-tidy documentation

2023-01-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 491729.
carlosgalvezp added a comment.

Fix formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141144

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -110,6 +110,7 @@
 .. code-block:: console
 
   $ clang-tidy --help
+
   USAGE: clang-tidy [options]  [... ]
 
   OPTIONS:
@@ -122,8 +123,7 @@
 
   clang-tidy options:
 
---checks=  -
- Comma-separated list of globs with optional '-'
+--checks=  - Comma-separated list of globs with optional '-'
  prefix. Globs are processed in order of
  appearance in the list. Globs without '-'
  prefix add checks with matching names to the
@@ -132,21 +132,18 @@
  checks. This option's value is appended to the
  value of the 'Checks' option in .clang-tidy
  file, if any.
---config=  -
- Specifies a configuration in YAML/JSON format:
+--config=  - Specifies a configuration in YAML/JSON format:
-config="{Checks: '*',
- CheckOptions: {x, y}}"
+ CheckOptions: {x: y}}"
  When the value is empty, clang-tidy will
  attempt to find a file named .clang-tidy for
  each source file in its parent directories.
---config-file= -
-Specify the path of .clang-tidy or custom config file:
+--config-file= - Specify the path of .clang-tidy or custom config file:
   e.g. --config-file=/some/path/myTidyConfigFile
-This option internally works exactly the same way as
+ This option internally works exactly the same way as
   --config option after reading specified config file.
-Use either --config-file or --config, not both.
---dump-config  -
- Dumps configuration in the YAML format to
+ Use either --config-file or --config, not both.
+--dump-config  - Dumps configuration in the YAML format to
  stdout. This option can be used along with a
  file name (and '--' if the file is outside of a
  project with configured compilation database).
@@ -154,38 +151,29 @@
  printed.
  Use along with -checks=* to include
  configuration of all checks.
---enable-check-profile -
- Enable per-check timing profiles, and print a
+--enable-check-profile - Enable per-check timing profiles, and print a
  report to stderr.
---explain-config   -
- For each enabled check explains, where it is
+--explain-config   - For each enabled check explains, where it is
  enabled, i.e. in clang-tidy binary, command
  line or a specific configuration file.
---export-fixes=  -
- YAML file to store suggested fixes in. The
+--export-fixes=  - YAML file to store suggested fixes in. The
  stored fixes can be applied to the input source
  code with clang-apply-replacements.
---extra-arg=   - Additional argument to append to the compiler command line.
- Can be used several times.
---extra-arg-before=- Additional argument to prepend to the compiler command line.
- Can be used several times.
---fix  -
- Apply suggested fixes. Without -fix-errors
+--extra-arg=   - Additional argument to append to the compiler command line
+--extra-arg-before=- Additional argument to prepen

[PATCH] D141144: [clang-tidy][doc] Improve clang-tidy documentation

2023-01-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 491731.
carlosgalvezp edited the summary of this revision.
carlosgalvezp added a comment.

Remove newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141144

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -122,8 +122,7 @@
 
   clang-tidy options:
 
---checks=  -
- Comma-separated list of globs with optional '-'
+--checks=  - Comma-separated list of globs with optional '-'
  prefix. Globs are processed in order of
  appearance in the list. Globs without '-'
  prefix add checks with matching names to the
@@ -132,21 +131,18 @@
  checks. This option's value is appended to the
  value of the 'Checks' option in .clang-tidy
  file, if any.
---config=  -
- Specifies a configuration in YAML/JSON format:
+--config=  - Specifies a configuration in YAML/JSON format:
-config="{Checks: '*',
- CheckOptions: {x, y}}"
+ CheckOptions: {x: y}}"
  When the value is empty, clang-tidy will
  attempt to find a file named .clang-tidy for
  each source file in its parent directories.
---config-file= -
-Specify the path of .clang-tidy or custom config file:
+--config-file= - Specify the path of .clang-tidy or custom config file:
   e.g. --config-file=/some/path/myTidyConfigFile
-This option internally works exactly the same way as
+ This option internally works exactly the same way as
   --config option after reading specified config file.
-Use either --config-file or --config, not both.
---dump-config  -
- Dumps configuration in the YAML format to
+ Use either --config-file or --config, not both.
+--dump-config  - Dumps configuration in the YAML format to
  stdout. This option can be used along with a
  file name (and '--' if the file is outside of a
  project with configured compilation database).
@@ -154,38 +150,29 @@
  printed.
  Use along with -checks=* to include
  configuration of all checks.
---enable-check-profile -
- Enable per-check timing profiles, and print a
+--enable-check-profile - Enable per-check timing profiles, and print a
  report to stderr.
---explain-config   -
- For each enabled check explains, where it is
+--explain-config   - For each enabled check explains, where it is
  enabled, i.e. in clang-tidy binary, command
  line or a specific configuration file.
---export-fixes=  -
- YAML file to store suggested fixes in. The
+--export-fixes=  - YAML file to store suggested fixes in. The
  stored fixes can be applied to the input source
  code with clang-apply-replacements.
---extra-arg=   - Additional argument to append to the compiler command line.
- Can be used several times.
---extra-arg-before=- Additional argument to prepend to the compiler command line.
- Can be used several times.
---fix  -
- Apply suggested fixes. Without -fix-errors
+--extra-arg=   - Additional argument to append to the compiler command line
+--extra-arg-before=- Additional argument to prepend to the compiler command line
+--fix  - Apply

[PATCH] D141144: [clang-tidy][doc] Improve clang-tidy documentation

2023-01-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Friendly ping @njames93 , see my previous comment about `TrimFirstChar`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141144

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp:13
+
+#include 
+

Not sure if this is allowed in the repo or if we should use something 
equivalent from ADT.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h:14-15
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {

Update namespace to C++17



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:1
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- 
-fno-delayed-template-parsing
+

You specified C++11 in the LangOpts, but test against C++14 or later in the 
test, maybe change it here to c++11-or-later?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:45
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: rvalue reference parameter is 
never moved from inside the function body 
[cppcoreguidelines-rvalue-reference-param-not-moved]

Could we add something like this too?

```
template 
struct Foo
{
  void never_moves(T&& t) {}
};
```

Here `t` is not a universal reference so the check should warn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D142016: [Clang][RISCV] Simplify RVV intrinsic policy suffix

2023-01-24 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142016

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


[PATCH] D142437: [clang] Add the check of membership in decltype for the issue #58674

2023-01-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

1 nit, otherwise I don't have concerns.




Comment at: clang/lib/Sema/SemaExpr.cpp:2717
+if ((MightBeImplicitMember = ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class, 
true)))
+  break;




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

https://reviews.llvm.org/D142437

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


[PATCH] D140598: [Clang] Add sanity check in Sema::getDestructorName to prevent nullptr dereference

2023-01-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D140598

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


[PATCH] D142396: [AArch64] Add the Ampere1A core

2023-01-24 Thread Philipp Tomsich via Phabricator via cfe-commits
philipp.tomsich updated this revision to Diff 491738.
philipp.tomsich added a comment.

- Split off new (Ampere1A-specific) fusion case
- Updated the Ampere1A SubtargetFeature list to include (hopefully) all features


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142396

Files:
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/TargetParser/Host.cpp
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/neon-dot-product.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.3a-rcpc.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/TargetParser/Host.cpp
  llvm/unittests/TargetParser/TargetParserTest.cpp

Index: llvm/unittests/TargetParser/TargetParserTest.cpp
===
--- llvm/unittests/TargetParser/TargetParserTest.cpp
+++ llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -1341,6 +1341,15 @@
  AArch64::AEK_AES  | AArch64::AEK_I8MM | AArch64::AEK_SSBS |
  AArch64::AEK_SB   | AArch64::AEK_RAND,
  "8.6-A"),
+ARMCPUTestParams("ampere1a", "armv8.6-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC  | AArch64::AEK_FP   | AArch64::AEK_FP16   |
+ AArch64::AEK_SIMD | AArch64::AEK_RAS  | AArch64::AEK_LSE |
+ AArch64::AEK_RDM  | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+ AArch64::AEK_SM4  | AArch64::AEK_SHA3 | AArch64::AEK_BF16|
+ AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_I8MM|
+ AArch64::AEK_SSBS | AArch64::AEK_SB   | AArch64::AEK_RAND|
+ AArch64::AEK_MTE,
+ "8.6-A"),
 ARMCPUTestParams(
 "neoverse-512tvb", "armv8.4-a", "crypto-neon-fp-armv8",
 AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
@@ -1403,7 +1412,7 @@
  "8.2-A")));
 
 // Note: number of CPUs includes aliases.
-static constexpr unsigned NumAArch64CPUArchs = 61;
+static constexpr unsigned NumAArch64CPUArchs = 62;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/unittests/TargetParser/Host.cpp
===
--- llvm/unittests/TargetParser/Host.cpp
+++ llvm/unittests/TargetParser/Host.cpp
@@ -117,6 +117,9 @@
   EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
   "CPU part: 0xac3"),
 "ampere1");
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
+  "CPU part: 0xac4"),
+"ampere1a");
 
   // MSM8992/4 weirdness
   StringRef MSM8992ProcCpuInfo = R"(
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -13,6 +13,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1a --disassemble < %s | FileCheck %s
 
 # CHECK: ldaprb w0, [x0]
 # CHECK: ldaprh w0, [x0]
Index: llvm/test/MC/AArch64/armv8.3a-rcpc.s
===
--- llvm/test/MC/AArch64/armv8.3a-rcpc.s
+++ llvm/test/MC/AArch64/armv8.3a-rcpc.s
@@ -7,6 +7,7 @@
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=neoverse-n1 < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=neoverse-n2 < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=ampere1 < %s 2>&1 | FileCheck %s
+// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=ampere1a < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+v8.2a -mattr=+rcpc < %s 2>&1 | FileCheck %s
 // RUN: not llvm-mc -triple aarch64-none-linux-gnu -mattr=+v8.2a < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-REQ %s < %t
Index: llvm/test/MC/AArch64/armv8.2a-dotprod.s
===
--- llvm/test/MC/AArch64/armv8.2a-dotprod.s
+++ llvm/test/MC/AArch64/armv8.2a-dotprod.s
@@ -14,6 +14,

[PATCH] D142459: [clang] Deprecate uses of GlobalObject::getAlignment

2023-01-24 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: clang/include/clang/AST/CharUnits.h:73
 
+  /// fromQuantity - Construct a CharUnits quantity from an llvm::Align
+  /// quantity.

`Maybe`*



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:1991
+return ConstantAddress(C, C->getValueType(),
+   CharUnits::fromQuantity(C->getAlign()));
 

I'm wondering whetehr we could just do away with this conversion and store a 
`MaybeAlign` in `GlobalValue` instead. 

The only uses of `Address::getAlign()` is to creata another `Address` or do 
`Address::getAlign()->getAsAlign()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142459

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


[PATCH] D142085: [Clang][RISCV] Add `__riscv_` prefix for all RVV intrinsics

2023-01-24 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

> I don't have a preference here, is any of __riscv_RVV_CSR/ 
> __riscv_rvv_csr_type / __riscv_rvv_csr_t suitable?

Either is fine to me at this stage, I expect they will be drop soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142085

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


[PATCH] D142085: [Clang][RISCV] Add `__riscv_` prefix for all RVV intrinsics

2023-01-24 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Agree with @jrtc27 about the test function name, we could keep the function 
name in the test file, that's also reduce lots of diff which is not really 
necessary.

e.g.
`vint8mf8_t test_vaadd_vv_i8mf8(vint8mf8_t op1, vint8mf8_t op2, size_t vl)` 
keep same name rather than rename to `vint8mf8_t 
test___riscv_vaadd_vv_i8mf8(vint8mf8_t op1, vint8mf8_t op2, size_t vl)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142085

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


[PATCH] D140250: Define NULL in its own header

2023-01-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: echristo, dblaikie, aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

I'd expect there to be a test under `clang/test/Headers/` showing that this new 
header works as expected.




Comment at: 
llvm/test/DebugInfo/Generic/assignment-tracking/sroa/unspecified-var-size.ll:37
 !7 = !DIFile(filename: "clang/12.0.0/include/__stddef_max_align_t.h", 
directory: "/")
-!8 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 
256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")
-!9 = !DIFile(filename: "include/c++/7.5.0/cstddef", directory: "")
-!10 = !{i32 7, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{i32 1, !"wchar_size", i32 4}
-!13 = !{!"clang version 12.0.0"}
-!14 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funDn", scope: !1, 
file: !1, line: 20, type: !15, scopeLine: 20, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !20)
-!15 = !DISubroutineType(types: !16)
-!16 = !{null, !17}
-!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "nullptr_t", scope: !5, file: 
!18, line: 235, baseType: !19)
-!18 = !DIFile(filename: "include/x86_64-linux-gnu/c++/7.5.0/bits/c++config.h", 
directory: "")
-!19 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
-!20 = !{!21}
-!21 = !DILocalVariable(arg: 1, scope: !14, file: !1, line: 20, type: !17)
-!22 = distinct !DIAssignID()
-!23 = !DILocation(line: 0, scope: !14)
-!28 = distinct !DIAssignID()
-!29 = !DILocation(line: 20, column: 27, scope: !14)
+!8 = !DIFile(filename: "clang/12.0.0/include/__stddef_null.h", directory: "/")
+!9 = !DICompositeType(tag: DW_TAG_structure_type, file: !7, line: 19, size: 
256, flags: DIFlagFwdDecl, identifier: "_ZTS11max_align_t")

iana wrote:
> Adding this line is the only reason I changed this file. I'm not familiar at 
> all with how these tests work, so I don't really know if it's necessary. The 
> test passes with and without these changes.
CC @dblaikie and @echristo for questions about whether we should be updating 
this debug info test or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140250

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


[PATCH] D142094: [Clang][Doc] Add release note for changes for the RVV intrinsics

2023-01-24 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

As a RISC-V GCC maintainer: GCC 14 is targeting on RVV intrinsic 1.0, but 
segment load store and rounding mode stuff might not meet the release, so the 
status will be pretty close to clang/LLVM (with @eopXD's changes, `__riscv_` 
prefix and those simplification stuffs).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142094

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


[PATCH] D142454: [analyzer] Update satest dependencies

2023-01-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

I'm not using this docker file, so I don't mind changing it.
It probably won't hurt :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142454

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


[PATCH] D142465: [clang][lex] Consolidate PPCallbacks::PragmaDirective parameters

2023-01-24 Thread Kyle Edwards via Phabricator via cfe-commits
KyleFromKitware created this revision.
KyleFromKitware added a reviewer: clang.
KyleFromKitware created this object with edit policy "Only User: 
KyleFromKitware (Kyle Edwards)".
KyleFromKitware added a project: clang.
Herald added subscribers: carlosgalvezp, shchenz, kbarton, nemanjai.
Herald added a reviewer: njames93.
Herald added a project: All.
KyleFromKitware requested review of this revision.
Herald added a subscriber: cfe-commits.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142465

Files:
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
  clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
  clang-tools-extra/docs/pp-trace.rst
  clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
  clang-tools-extra/pp-trace/PPCallbacksTracker.h
  clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Lex/Pragma.cpp

Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -166,7 +166,7 @@
 /// rest of the pragma, passing it to the registered pragma handlers.
 void Preprocessor::HandlePragmaDirective(PragmaIntroducer Introducer) {
   if (Callbacks)
-Callbacks->PragmaDirective(Introducer.Loc, Introducer.Kind);
+Callbacks->PragmaDirective(Introducer);
 
   if (!PragmasEnabled)
 return;
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -183,9 +183,7 @@
   }
 
   /// Callback invoked when start reading any pragma directive.
-  virtual void PragmaDirective(SourceLocation Loc,
-   PragmaIntroducerKind Introducer) {
-  }
+  virtual void PragmaDirective(PragmaIntroducer Introducer) {}
 
   /// Callback invoked when a \#pragma comment directive is read.
   virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
@@ -493,10 +491,9 @@
 Second->Ident(Loc, str);
   }
 
-  void PragmaDirective(SourceLocation Loc,
-   PragmaIntroducerKind Introducer) override {
-First->PragmaDirective(Loc, Introducer);
-Second->PragmaDirective(Loc, Introducer);
+  void PragmaDirective(PragmaIntroducer Introducer) override {
+First->PragmaDirective(Introducer);
+Second->PragmaDirective(Introducer);
   }
 
   void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
@@ -6,24 +6,21 @@
 
 // CHECK: ---
 // CHECK-NEXT: - Callback: PragmaDirective
-// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:1"
-// CHECK-NEXT:   Introducer: PIK_HashPragma
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:26"
 // CHECK-NEXT:   Name: all
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:32"
 // CHECK-NEXT:   State: 0
 // CHECK-NEXT: - Callback: PragmaDirective
-// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:1"
-// CHECK-NEXT:   Introducer: PIK_HashPragma
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:26"
 // CHECK-NEXT:   Name: cl_khr_int64_base_atomics
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:54"
 // CHECK-NEXT:   State: 0
 // CHECK-NEXT: - Callback: PragmaDirective
-// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:1"
-// CHECK-NEXT:   Introducer: PIK_HashPragma
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:26"
 // CHECK-NEXT:   Name: cl_khr_int64_base_atomics
Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
@@ -18,72 +18,61 @@
 
 // CHECK: ---
 // CHECK-NEXT: - Callback: PragmaDirective
-// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:1"
-// CHECK-NEXT:   Introducer: PIK_HashPragm

[PATCH] D142030: [pp-trace] Print HashLoc/Introducer parameter

2023-01-24 Thread Kyle Edwards via Phabricator via cfe-commits
KyleFromKitware updated this revision to Diff 491747.
KyleFromKitware retitled this revision from "[pp-trace] Print HashLoc 
parameter" to "[pp-trace] Print HashLoc/Introducer parameter".
KyleFromKitware added a comment.

Printed Introducer parameter in Pragma methods.


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

https://reviews.llvm.org/D142030

Files:
  clang-tools-extra/docs/pp-trace.rst
  clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
  clang-tools-extra/test/pp-trace/pp-trace-conditional.cpp
  clang-tools-extra/test/pp-trace/pp-trace-ident.cpp
  clang-tools-extra/test/pp-trace/pp-trace-include.cpp
  clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp

Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
@@ -8,6 +8,7 @@
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:26"
 // CHECK-NEXT:   Name: all
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:32"
@@ -15,6 +16,7 @@
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:26"
 // CHECK-NEXT:   Name: cl_khr_int64_base_atomics
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:54"
@@ -22,6 +24,7 @@
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:26"
 // CHECK-NEXT:   Name: cl_khr_int64_base_atomics
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:54"
Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
@@ -20,36 +20,42 @@
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:9"
 // CHECK-NEXT:   Kind: compiler
 // CHECK-NEXT:   Str: compiler comment
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:4:9"
 // CHECK-NEXT:   Kind: exestr
 // CHECK-NEXT:   Str: exestr comment
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:5:9"
 // CHECK-NEXT:   Kind: lib
 // CHECK-NEXT:   Str: lib comment
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:6:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:6:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:6:9"
 // CHECK-NEXT:   Kind: linker
 // CHECK-NEXT:   Str: linker comment
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:7:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:7:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\

[clang] d9eece9 - [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH funclet tokens

2023-01-24 Thread Stefan Gränitz via cfe-commits

Author: Stefan Gränitz
Date: 2023-01-24T15:17:18+01:00
New Revision: d9eece916a8a9b370e1f90e6461c612d12c55729

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

LOG: [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH 
funclet tokens

When optimizing retain-release-sequences we insert (and delete) ObjC runtime 
calls. These calls need a funclet operand bundle that refers to the enclosing 
funclet pad whenever they are inserted in a WinEH funclet. WinEH funclets can 
contain multiple basic blocks. In order to find the enclosing funclet pad, we 
have to calculate the funclet coloring first.

Reviewed By: ahatanak

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

Added: 
llvm/test/Transforms/ObjCARC/funclet-catchpad.ll

Modified: 
clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp

Removed: 




diff  --git a/clang/test/CodeGenObjCXX/arc-exceptions-seh.mm 
b/clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
index d5daf55db..0b697be54855d 100644
--- a/clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
+++ b/clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc 
-fexceptions -fobjc-exceptions -fobjc-arc-exceptions -fobjc-runtime=gnustep-2.0 
-o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-O0
-// RUN: %clang_cc1 -O2 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc 
-fexceptions -fobjc-exceptions -fobjc-arc-exceptions -fobjc-runtime=gnustep-2.0 
-mllvm -enable-objc-arc-opts=false -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-O2
+// RUN: %clang_cc1 -O0 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc 
-fexceptions -fobjc-exceptions -fobjc-arc-exceptions -fobjc-runtime=gnustep-2.0 
-o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-O0
+// RUN: %clang_cc1 -O2 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc 
-fexceptions -fobjc-exceptions -fobjc-arc-exceptions -fobjc-runtime=gnustep-2.0 
-o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-O2
 
 // WinEH requires funclet tokens on nounwind intrinsics if they can lower to
 // regular function calls in the course of IR transformations.
@@ -24,7 +24,9 @@ void try_catch_with_objc_intrinsic() {
 // CHECK-LABEL:   try_catch_with_objc_intrinsic
 //
 // CHECK: catch.dispatch:
-// CHECK-NEXT:  [[CATCHSWITCH:%[0-9]+]] = catchswitch within none [label 
%catch] unwind label %[[CLEANUP1:.*]]
+// CHECK-NEXT:  [[CATCHSWITCH:%[0-9]+]] = catchswitch within none [label 
%catch]
+// CHECK-O0:  unwind label %[[CLEANUP1:.*]]
+// CHECK-O2:  unwind to caller
 //
 // All calls within a catchpad must have funclet tokens that refer to it:
 // CHECK: catch:
@@ -58,12 +60,12 @@ void try_catch_with_objc_intrinsic() {
 // CHECK-O2:  @llvm.objc.release
 // CHECK: [ "funclet"(token [[CLEANUPPAD2]]) ]
 // CHECK:   cleanupret from [[CLEANUPPAD2]]
-// CHECK: unwind label %[[CLEANUP1]]
+// CHECK-O0:  unwind label %[[CLEANUP1]]
+// CHECK-O2:  unwind to caller
 //
-// CHECK: [[CLEANUP1]]:
-// CHECK-NEXT:  [[CLEANUPPAD1:%[0-9]+]] = cleanuppad within none
-// CHECK:   call
+// CHECK-O0:  [[CLEANUP1]]:
+// CHECK-O0-NEXT:   [[CLEANUPPAD1:%[0-9]+]] = cleanuppad within none
+// CHECK-O0:call
 // CHECK-O0:  @llvm.objc.storeStrong
-// CHECK-O2:  @llvm.objc.release
-// CHECK: [ "funclet"(token [[CLEANUPPAD1]]) ]
-// CHECK:   cleanupret from [[CLEANUPPAD1]] unwind to caller
+// CHECK-O0:  [ "funclet"(token [[CLEANUPPAD1]]) ]
+// CHECK-O0:cleanupret from [[CLEANUPPAD1]] unwind to caller

diff  --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp 
b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 927f3898c9c49..5108598426036 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -501,6 +501,8 @@ class ObjCARCOpt {
   /// is in fact used in the current function.
   unsigned UsedInThisFunction;
 
+  DenseMap BlockEHColors;
+
   bool OptimizeRetainRVCall(Function &F, Instruction *RetainRV);
   void OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV,
  ARCInstKind &Class);
@@ -508,17 +510,16 @@ class ObjCARCOpt {
 
   /// Optimize an individual call, optionally passing the
   /// GetArgRCIdentityRoot if it has already been computed.
-  void OptimizeIndividualCallImpl(
-  Function &F, DenseMap &BlockColors,
-  Instruction *Inst, ARCInstKind Class, const Value *Arg);
+  void OptimizeIndividualCallImpl(Function &F, Instruction *Inst,
+  ARCInstKind Class, const Value *Arg);
 
   /// Try to optimize an Autor

[PATCH] D137944: [ObjC][ARC] Teach the OptimizeSequences step of ObjCARCOpts about WinEH funclet tokens

2023-01-24 Thread Stefan Gränitz via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sgraenitz marked an inline comment as done.
Closed by commit rGd9eece916a8a: [ObjC][ARC] Teach the OptimizeSequences step 
of ObjCARCOpts about WinEH funclet… (authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137944

Files:
  clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/test/Transforms/ObjCARC/funclet-catchpad.ll

Index: llvm/test/Transforms/ObjCARC/funclet-catchpad.ll
===
--- /dev/null
+++ llvm/test/Transforms/ObjCARC/funclet-catchpad.ll
@@ -0,0 +1,40 @@
+; RUN: opt -mtriple=x86_64-windows-msvc -passes=objc-arc -S < %s | FileCheck %s
+
+; Check that funclet tokens are preserved
+;
+; CHECK-LABEL:  catch:
+; CHECK:  %1 = catchpad within %0
+; CHECK:  %2 = tail call ptr @llvm.objc.retain(ptr %exn) #0 [ "funclet"(token %1) ]
+; CHECK:  call void @llvm.objc.release(ptr %exn) #0 [ "funclet"(token %1) ]
+; CHECK:  catchret from %1 to label %eh.cont
+
+define void @try_catch_with_objc_intrinsic() personality ptr @__CxxFrameHandler3 {
+entry:
+  %exn.slot = alloca ptr, align 8
+  invoke void @may_throw(ptr null) to label %eh.cont unwind label %catch.dispatch
+
+catch.dispatch:   ; preds = %entry
+  %0 = catchswitch within none [label %catch] unwind to caller
+
+eh.cont:  ; preds = %catch, %entry
+  ret void
+
+catch:; preds = %catch.dispatch
+  %1 = catchpad within %0 [ptr null, i32 0, ptr %exn.slot]
+  br label %if.then
+
+if.then:  ; preds = %catch
+  %exn = load ptr, ptr null, align 8
+  %2 = call ptr @llvm.objc.retain(ptr %exn) [ "funclet"(token %1) ]
+  call void @may_throw(ptr %exn)
+  call void @llvm.objc.release(ptr %exn) [ "funclet"(token %1) ]
+  catchret from %1 to label %eh.cont
+}
+
+declare void @may_throw(ptr)
+declare i32 @__CxxFrameHandler3(...)
+
+declare ptr @llvm.objc.retain(ptr) #0
+declare void @llvm.objc.release(ptr) #0
+
+attributes #0 = { nounwind }
Index: llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
===
--- llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -501,6 +501,8 @@
   /// is in fact used in the current function.
   unsigned UsedInThisFunction;
 
+  DenseMap BlockEHColors;
+
   bool OptimizeRetainRVCall(Function &F, Instruction *RetainRV);
   void OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV,
  ARCInstKind &Class);
@@ -508,17 +510,16 @@
 
   /// Optimize an individual call, optionally passing the
   /// GetArgRCIdentityRoot if it has already been computed.
-  void OptimizeIndividualCallImpl(
-  Function &F, DenseMap &BlockColors,
-  Instruction *Inst, ARCInstKind Class, const Value *Arg);
+  void OptimizeIndividualCallImpl(Function &F, Instruction *Inst,
+  ARCInstKind Class, const Value *Arg);
 
   /// Try to optimize an AutoreleaseRV with a RetainRV or UnsafeClaimRV.  If the
   /// optimization occurs, returns true to indicate that the caller should
   /// assume the instructions are dead.
-  bool OptimizeInlinedAutoreleaseRVCall(
-  Function &F, DenseMap &BlockColors,
-  Instruction *Inst, const Value *&Arg, ARCInstKind Class,
-  Instruction *AutoreleaseRV, const Value *&AutoreleaseRVArg);
+  bool OptimizeInlinedAutoreleaseRVCall(Function &F, Instruction *Inst,
+const Value *&Arg, ARCInstKind Class,
+Instruction *AutoreleaseRV,
+const Value *&AutoreleaseRVArg);
 
   void CheckForCFGHazards(const BasicBlock *BB,
   DenseMap &BBStates,
@@ -566,12 +567,46 @@
 
   void OptimizeReturns(Function &F);
 
+  Instruction *cloneCallInstForBB(CallInst &CI, BasicBlock &BB) {
+SmallVector OpBundles;
+for (unsigned I = 0, E = CI.getNumOperandBundles(); I != E; ++I) {
+  auto Bundle = CI.getOperandBundleAt(I);
+  // Funclets will be reassociated in the future.
+  if (Bundle.getTagID() == LLVMContext::OB_funclet)
+continue;
+  OpBundles.emplace_back(Bundle);
+}
+
+if (!BlockEHColors.empty()) {
+  const ColorVector &CV = BlockEHColors.find(&BB)->second;
+  assert(CV.size() > 0 && "non-unique color for block!");
+  Instruction *EHPad = CV.front()->getFirstNonPHI();
+  if (EHPad->isEHPad())
+OpBundles.emplace_back("funclet", EHPad);
+}
+
+return CallInst::Create(&CI, OpBundles);
+  }
+
+  void addOpBundleForFunclet(BasicBlock *BB,
+  

[clang] e0a2818 - [clang][RISCV] Fix ABI mismatch between GCC and Clang (extension of integers on stack)

2023-01-24 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-01-24T14:20:28Z
New Revision: e0a28188d2b53427bc90cdf7f7899c64af102489

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

LOG: [clang][RISCV] Fix ABI mismatch between GCC and Clang (extension of 
integers on stack)

See  for full
details. Essentially, a previous version of the psABI indicated (by my
reading) that integer scalars passed on the stack were anyext. A [later
commit](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/cec39a064ee0e5b0129973fffab7e3ad1710498f)
changed this to indicate that they are in fact signext/zeroext just as
if they were passed in registers.

This patch adds the change in the release notes but doesn't add a flag
to retain the old behaviour. The hope is that it's sufficiently hard to
trigger an issue due to this that it isn't worthwhile doing so.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32f-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7d356e53547bf..136f47bd28848 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -879,6 +879,8 @@ RISC-V Support in Clang
 - Fix interaction of ``-mcpu`` and ``-march``, RISC-V backend will take the
   architecture extension union of ``-mcpu`` and ``-march`` before, and now will
   take architecture extensions from ``-march`` if both are given.
+- An ABI mismatch between GCC and Clang that related to the
+  sign/zero-extension of integer scalars was fixed.
 
 X86 Support in Clang
 

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 4c3bdbce9e762..be1dbe8480c6e 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -11008,11 +11008,6 @@ void RISCVABIInfo::computeInfo(CGFunctionInfo &FI) 
const {
 }
   }
 
-  // We must track the number of GPRs used in order to conform to the RISC-V
-  // ABI, as integer scalars passed in registers should have signext/zeroext
-  // when promoted, but are anyext if passed on the stack. As GPR usage is
-  // 
diff erent for variadic arguments, we must also track whether we are
-  // examining a vararg or not.
   int ArgGPRsLeft = IsRetIndirect ? NumArgGPRs - 1 : NumArgGPRs;
   int ArgFPRsLeft = FLen ? NumArgFPRs : 0;
   int NumFixedArgs = FI.getNumRequiredArgs();
@@ -11290,7 +11285,6 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType 
Ty, bool IsFixed,
   }
 
   uint64_t NeededAlign = getContext().getTypeAlign(Ty);
-  bool MustUseStack = false;
   // Determine the number of GPRs needed to pass the current argument
   // according to the ABI. 2*XLen-aligned varargs are passed in "aligned"
   // register pairs, so may consume 3 registers.
@@ -11301,7 +11295,6 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType 
Ty, bool IsFixed,
 NeededArgGPRs = 2;
 
   if (NeededArgGPRs > ArgGPRsLeft) {
-MustUseStack = true;
 NeededArgGPRs = ArgGPRsLeft;
   }
 
@@ -11312,14 +11305,13 @@ ABIArgInfo 
RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
 if (const EnumType *EnumTy = Ty->getAs())
   Ty = EnumTy->getDecl()->getIntegerType();
 
-// All integral types are promoted to XLen width, unless passed on the
-// stack.
-if (Size < XLen && Ty->isIntegralOrEnumerationType() && !MustUseStack) {
+// All integral types are promoted to XLen width
+if (Size < XLen && Ty->isIntegralOrEnumerationType()) {
   return extendType(Ty);
 }
 
 if (const auto *EIT = Ty->getAs()) {
-  if (EIT->getNumBits() < XLen && !MustUseStack)
+  if (EIT->getNumBits() < XLen)
 return extendType(Ty);
   if (EIT->getNumBits() > 128 ||
   (!getContext().getTargetInfo().hasInt128Type() &&

diff  --git a/clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
index e18bd1d7eab3f..9b157ad5c782e 100644
--- a/clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
+++ b/clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
@@ -22,20 +22,16 @@ struct large {
   int32_t a, b, c, d;
 };
 
-// Scalars passed on the stack should not have signext/zeroext attributes
-// (they are anyext).
+// Scalars passed on the stack should have signext/zeroext attributes, just as
+// if they were passed in registers.
 

[PATCH] D140401: [clang][RISCV] Fix ABI mismatch between GCC and Clang (extension of integers on stack)

2023-01-24 Thread Alex Bradbury 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 rGe0a28188d2b5: [clang][RISCV] Fix ABI mismatch between GCC 
and Clang (extension of integers on… (authored by asb).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140401

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c

Index: clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
===
--- clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
+++ clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
@@ -183,16 +183,16 @@
   return (v32i8){1, 2, 3, 4, 5, 6, 7, 8};
 }
 
-// Scalars passed on the stack should not have signext/zeroext attributes
-// (they are anyext).
+// Scalars passed on the stack should have signext/zeroext attributes, just as
+// if they were passed in registers.
 
-// CHECK-LABEL: define{{.*}} signext i32 @f_scalar_stack_1(i64 %a.coerce, [2 x i64] %b.coerce, i128 %c.coerce, ptr noundef %d, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef %g, i8 noundef %h)
+// CHECK-LABEL: define{{.*}} signext i32 @f_scalar_stack_1(i64 %a.coerce, [2 x i64] %b.coerce, i128 %c.coerce, ptr noundef %d, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef zeroext %g, i8 noundef signext %h)
 int f_scalar_stack_1(struct tiny a, struct small b, struct small_aligned c,
  struct large d, uint8_t e, int8_t f, uint8_t g, int8_t h) {
   return g + h;
 }
 
-// CHECK-LABEL: define{{.*}} signext i32 @f_scalar_stack_2(i32 noundef signext %a, i128 noundef %b, i64 noundef %c, fp128 noundef %d, ptr noundef %0, i8 noundef zeroext %f, i8 noundef %g, i8 noundef %h)
+// CHECK-LABEL: define{{.*}} signext i32 @f_scalar_stack_2(i32 noundef signext %a, i128 noundef %b, i64 noundef %c, fp128 noundef %d, ptr noundef %0, i8 noundef zeroext %f, i8 noundef signext %g, i8 noundef zeroext %h)
 int f_scalar_stack_2(int32_t a, __int128_t b, int64_t c, long double d, v32i8 e,
  uint8_t f, int8_t g, uint8_t h) {
   return g + h;
@@ -202,16 +202,13 @@
 // the presence of large return values that consume a register due to the need
 // to pass a pointer.
 
-// CHECK-LABEL: define{{.*}} void @f_scalar_stack_3(ptr noalias sret(%struct.large) align 8 %agg.result, i32 noundef signext %a, i128 noundef %b, fp128 noundef %c, ptr noundef %0, i8 noundef zeroext %e, i8 noundef %f, i8 noundef %g)
+// CHECK-LABEL: define{{.*}} void @f_scalar_stack_3(ptr noalias sret(%struct.large) align 8 %agg.result, i32 noundef signext %a, i128 noundef %b, fp128 noundef %c, ptr noundef %0, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef zeroext %g)
 struct large f_scalar_stack_3(uint32_t a, __int128_t b, long double c, v32i8 d,
   uint8_t e, int8_t f, uint8_t g) {
   return (struct large){a, e, f, g};
 }
 
 // Ensure that ABI lowering happens as expected for vararg calls.
-// Specifically, ensure that signext is emitted for varargs that will be
-// passed in registers but not on the stack. Ensure this takes into account
-// the use of "aligned" register pairs for varargs with 2*xlen alignment.
 
 int f_va_callee(int, ...);
 
@@ -221,23 +218,23 @@
   f_va_callee(1, 2, 3LL, 4.0f, 5.0, (struct tiny){6, 7, 8, 9},
   (struct small){10, NULL}, (struct small_aligned){11},
   (struct large){12, 13, 14, 15});
-  // CHECK: call signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i32 noundef signext 3, i32 noundef signext 4, fp128 noundef 0xL40014000, i32 noundef signext 6, i32 noundef signext 7, i32 noundef 8, i32 noundef 9)
+  // CHECK: call signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i32 noundef signext 3, i32 noundef signext 4, fp128 noundef 0xL40014000, i32 noundef signext 6, i32 noundef signext 7, i32 noundef signext 8, i32 noundef signext 9)
   f_va_callee(1, 2, 3, 4, 5.0L, 6, 7, 8, 9);
-  // CHECK: call signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i32 noundef signext 3, i32 noundef signext 4, i128 {{%.*}}, i32 noundef signext 6, i32 noundef signext 7, i32 noundef 8, i32 noundef 9)
+  // CHECK: call signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i32 noundef signext 3, i32 noundef signext 4, i128 {{%.*}}, i32 noundef signext 6, i32 no

[PATCH] D140972: [flang] Add -fstack-arrays flag

2023-01-24 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.

Thanks for the updates, LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140972

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


[PATCH] D142199: [Docs] Replace recommonmark with myst-parser

2023-01-24 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a subscriber: gkistanova.
tstellar added a comment.

@luke You'll need to contact the bot owners so they can update machine.  The 
workers running the publish-sphinx-docs will need to be updated too.  
@gkistanova should be able to help.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142199

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


[PATCH] D141961: [clang][lex] Pass hash location to more PPCallbacks methods

2023-01-24 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added a comment.

LGTM for the ExtractAPI changes.


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

https://reviews.llvm.org/D141961

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


[PATCH] D142467: [Tooling] Add stdlib::Symbol::all() and stdlib::Symbol::qualified_name()

2023-01-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: VitaNuo.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These address some remaining reasons to #include StdSymbolMap.inc directly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142467

Files:
  clang/include/clang/Tooling/Inclusions/StandardLibrary.h
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/unittests/Tooling/StandardLibraryTest.cpp

Index: clang/unittests/Tooling/StandardLibraryTest.cpp
===
--- clang/unittests/Tooling/StandardLibraryTest.cpp
+++ clang/unittests/Tooling/StandardLibraryTest.cpp
@@ -18,6 +18,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+using ::testing::Contains;
 using ::testing::ElementsAre;
 
 namespace clang {
@@ -35,17 +36,24 @@
 TEST(StdlibTest, All) {
   auto VectorH = stdlib::Header::named("");
   EXPECT_TRUE(VectorH);
+  EXPECT_EQ(VectorH->name(), "");
   EXPECT_EQ(llvm::to_string(*VectorH), "");
   EXPECT_FALSE(stdlib::Header::named("HeadersTests.cpp"));
 
   auto Vector = stdlib::Symbol::named("std::", "vector");
   EXPECT_TRUE(Vector);
+  EXPECT_EQ(Vector->scope(), "std::");
+  EXPECT_EQ(Vector->name(), "vector");
+  EXPECT_EQ(Vector->qualified_name(), "std::vector");
   EXPECT_EQ(llvm::to_string(*Vector), "std::vector");
   EXPECT_FALSE(stdlib::Symbol::named("std::", "dongle"));
   EXPECT_FALSE(stdlib::Symbol::named("clang::", "ASTContext"));
 
   EXPECT_EQ(Vector->header(), *VectorH);
   EXPECT_THAT(Vector->headers(), ElementsAre(*VectorH));
+
+  EXPECT_THAT(stdlib::Header::all(), Contains(VectorH));
+  EXPECT_THAT(stdlib::Symbol::all(), Contains(Vector));
 }
 
 TEST(StdlibTest, Recognizer) {
Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -16,7 +16,12 @@
 namespace stdlib {
 
 static llvm::StringRef *HeaderNames;
-static std::pair *SymbolNames;
+static struct SymbolName {
+  const char *Data;  // std::vector
+  unsigned ScopeLen; // ~
+  unsigned NameLen;  //  ~~
+} *SymbolNames;
+static unsigned SymbolCount = 0;
 static unsigned *SymbolHeaderIDs;
 static llvm::DenseMap *HeaderIDs;
 // Maps symbol name -> Symbol::ID, within a namespace.
@@ -24,14 +29,15 @@
 static llvm::DenseMap *NamespaceSymbols;
 
 static int initialize() {
-  unsigned SymCount = 0;
-#define SYMBOL(Name, NS, Header) ++SymCount;
+  SymbolCount = 0;
+#define SYMBOL(Name, NS, Header) ++SymbolCount;
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
 #include "clang/Tooling/Inclusions/StdSymbolMap.inc"
 #undef SYMBOL
-  SymbolNames = new std::remove_reference_t[SymCount];
+  SymbolNames =
+  new std::remove_reference_t[SymbolCount];
   SymbolHeaderIDs =
-  new std::remove_reference_t[SymCount];
+  new std::remove_reference_t[SymbolCount];
   NamespaceSymbols = new std::remove_reference_t;
   HeaderIDs = new std::remove_reference_t;
 
@@ -46,20 +52,25 @@
 return HeaderIDs->try_emplace(Header, HeaderIDs->size()).first->second;
   };
 
-  auto Add = [&, SymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
+  auto Add = [&, SymIndex(0)](llvm::StringRef QName, unsigned NSLen,
   llvm::StringRef HeaderName) mutable {
-if (NS == "None")
-  NS = "";
+// Correct "Nonefoo" => foo.
+// FIXME: get rid of "None" from the generated mapping files.
+if (QName.take_front(NSLen) == "None") {
+  QName = QName.drop_front(NSLen);
+  NSLen = 0;
+}
 
-SymbolNames[SymIndex] = {NS, Name};
+SymbolNames[SymIndex] = {QName.data(), NSLen,
+ static_cast(QName.size() - NSLen)};
 SymbolHeaderIDs[SymIndex] = AddHeader(HeaderName);
 
-NSSymbolMap &NSSymbols = AddNS(NS);
-NSSymbols.try_emplace(Name, SymIndex);
+NSSymbolMap &NSSymbols = AddNS(QName.take_front(NSLen));
+NSSymbols.try_emplace(QName.drop_front(NSLen), SymIndex);
 
 ++SymIndex;
   };
-#define SYMBOL(Name, NS, Header) Add(#Name, #NS, #Header);
+#define SYMBOL(Name, NS, Header) Add(#NS #Name, strlen(#NS), #Header);
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
 #include "clang/Tooling/Inclusions/StdSymbolMap.inc"
 #undef SYMBOL
@@ -76,6 +87,13 @@
   (void)Dummy;
 }
 
+std::vector Header::all() {
+  std::vector Result;
+  Result.reserve(HeaderIDs->size());
+  for (unsigned I = 0, E = HeaderIDs->size(); I < E; ++I)
+Result.push_back(Header(I));
+  return Result;
+}
 std::optional Header::named(llvm::StringRef Name) {
   ensureInitialized();
   auto It = HeaderIDs->find(Name);
@@ -84,8 +102,26 @@
   return Header(It->second);
 }
 llvm::StringRef Header::name() const { return HeaderNames[ID]; }
-llvm::StringRef Symbol::scope() const { return SymbolName

[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-24 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:1
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- 
-fno-delayed-template-parsing
+

carlosgalvezp wrote:
> You specified C++11 in the LangOpts, but test against C++14 or later in the 
> test, maybe change it here to c++11-or-later?
The test uses generalize lambda capture, so it needs 14. Should I split the 
tests that use C++14 features to a separate file, and update this test file to 
use 11?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D142468: [clang][dataflow] Fix bug in handling of reference-typed fields.

2023-01-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: xazax.hun, sgatev, gribozavr2.
Herald added subscribers: martong, rnkovacs.
Herald added a reviewer: NoQ.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

This patch fixes a subtle bug in how we create lvalues to reference-typed
fields. In the rare case that the field is umodeled because of the depth limit
on field modeling, the lvalue created can be malformed. This patch prevents that
and adds some related assertions to other code dealing with lvalues for
references.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142468

Files:
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -156,6 +156,89 @@
   });
 }
 
+TEST(TransferTest, StructIncomplete) {
+  std::string Code = R"(
+struct A;
+
+void target() {
+  A* Foo;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+auto *FooValue = dyn_cast_or_null(
+Env.getValue(*FooDecl, SkipPast::None));
+ASSERT_THAT(FooValue, NotNull());
+
+EXPECT_TRUE(isa(FooValue->getPointeeLoc()));
+auto *FooPointeeValue = Env.getValue(FooValue->getPointeeLoc());
+ASSERT_THAT(FooPointeeValue, NotNull());
+EXPECT_TRUE(isa(FooPointeeValue));
+  });
+}
+
+// As a memory optimization, we prevent modeling fields nested below a certain
+// level (currently, depth 3). This test verifies this lack of modeling. We also
+// include a regression test for the case that the unmodeled field is a
+// reference to a struct; previously, we crashed when accessing such a field.
+TEST(TransferTest, StructFieldUnmodeled) {
+  std::string Code = R"(
+struct S { int X; };
+S GlobalS;
+struct A { S &Unmodeled = GlobalS; };
+struct B { A F3; };
+struct C { B F2; };
+struct D { C F1; };
+
+void target() {
+  D Bar;
+  A Foo = Bar.F1.F2.F3;
+  int Zab = Foo.Unmodeled.X;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+ASSERT_TRUE(FooDecl->getType()->isStructureType());
+auto FooFields = FooDecl->getType()->getAsRecordDecl()->fields();
+
+FieldDecl *UnmodeledDecl = nullptr;
+for (FieldDecl *Field : FooFields) {
+  if (Field->getNameAsString() == "Unmodeled") {
+UnmodeledDecl = Field;
+  } else {
+FAIL() << "Unexpected field: " << Field->getNameAsString();
+  }
+}
+ASSERT_THAT(UnmodeledDecl, NotNull());
+
+const auto *FooLoc = cast(
+Env.getStorageLocation(*FooDecl, SkipPast::None));
+const auto *UnmodeledLoc = &FooLoc->getChild(*UnmodeledDecl);
+ASSERT_TRUE(isa(UnmodeledLoc));
+ASSERT_THAT(Env.getValue(*UnmodeledLoc), IsNull());
+
+const ValueDecl *ZabDecl = findValueDecl(ASTCtx, "Zab");
+ASSERT_THAT(ZabDecl, NotNull());
+EXPECT_THAT(Env.getValue(*ZabDecl, SkipPast::None), NotNull());
+  });
+}
+
 TEST(TransferTest, StructVarDecl) {
   std::string Code = R"(
 struct A {
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -128,6 +128,15 @@
   return &UnpackedVal;
 }
 
+// `isValidReferenceLoc` is only called inside `assert`, so we wrap it in
+// #ifndef to prevent warnings in opt builds.
+#ifndef NDEBUG
+static bool isValidReferenceLoc(StorageLocation &Loc, Environment &Env) {
+  auto *V = Env.getValue(Loc);
+  return V != nullptr && isa(V);
+}
+#endif
+
 class TransferVisitor : public ConstStmtVisitor {
 public:
   TransferVisitor(const StmtToEnvMap &StmtToEnv, Environment &Env)
@@ -197,6 +206,8 @@
   return;
 
 if (VD->getType()->isReferenceType()) {
+  assert(isValidReferenceLoc(*DeclLoc, Env) &&
+ "reference-typed declarations map to `ReferenceValue`s");
   Env.setStorageLocation(*S, *DeclLoc);
 } else {
   auto &Loc = Env.crea

[PATCH] D142470: [clang][lex] Add PragmaOnce callback to PPCallbacks

2023-01-24 Thread Kyle Edwards via Phabricator via cfe-commits
KyleFromKitware created this revision.
KyleFromKitware added a reviewer: clang.
KyleFromKitware created this object with edit policy "Only User: 
KyleFromKitware (Kyle Edwards)".
KyleFromKitware added a project: clang.
Herald added subscribers: shchenz, kbarton, nemanjai.
Herald added a project: All.
KyleFromKitware requested review of this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142470

Files:
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/Pragma.cpp


Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -403,7 +403,7 @@
 }
 
 /// HandlePragmaOnce - Handle \#pragma once.  OnceTok is the 'once'.
-void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
+void Preprocessor::HandlePragmaOnce(PragmaIntroducer Introducer, Token 
&OnceTok) {
   // Don't honor the 'once' when handling the primary source file, unless
   // this is a prefix to a TU, which indicates we're generating a PCH file, or
   // when the main file is a header (e.g. when -xc-header is provided on the
@@ -416,6 +416,9 @@
   // Get the current file lexer we're looking at.  Ignore _Pragma 'files' etc.
   // Mark the file as a once-only file now.
   HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
+
+  if (Callbacks)
+Callbacks->PragmaOnce(Introducer, OnceTok.getLocation());
 }
 
 void Preprocessor::HandlePragmaMark(PragmaIntroducer Introducer,
@@ -991,7 +994,7 @@
   void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &OnceTok) override {
 PP.CheckEndOfDirective("pragma once");
-PP.HandlePragmaOnce(OnceTok);
+PP.HandlePragmaOnce(Introducer, OnceTok);
   }
 };
 
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -2615,7 +2615,7 @@
   void HandlePragmaDirective(PragmaIntroducer Introducer);
 
 public:
-  void HandlePragmaOnce(Token &OnceTok);
+  void HandlePragmaOnce(PragmaIntroducer Introducer, Token &OnceTok);
   void HandlePragmaMark(PragmaIntroducer Introducer, Token &MarkTok);
   void HandlePragmaPoison();
   void HandlePragmaSystemHeader(Token &SysHeaderTok);
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -295,6 +295,9 @@
   virtual void PragmaAssumeNonNullEnd(PragmaIntroducer Introducer,
   SourceLocation Loc) {}
 
+  /// Callback invoked when a \#pragma once directive is read.
+  virtual void PragmaOnce(PragmaIntroducer Introducer, SourceLocation Loc) {}
+
   /// Called by Preprocessor::HandleMacroExpandedIdentifier when a
   /// macro invocation is found.
   virtual void MacroExpands(const Token &MacroNameTok,
@@ -609,6 +612,11 @@
 Second->PragmaAssumeNonNullEnd(Introducer, Loc);
   }
 
+  void PragmaOnce(PragmaIntroducer Introducer, SourceLocation Loc) override {
+First->PragmaOnce(Introducer, Loc);
+Second->PragmaOnce(Introducer, Loc);
+  }
+
   void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
 SourceRange Range, const MacroArgs *Args) override {
 First->MacroExpands(MacroNameTok, MD, Range, Args);


Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -403,7 +403,7 @@
 }
 
 /// HandlePragmaOnce - Handle \#pragma once.  OnceTok is the 'once'.
-void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
+void Preprocessor::HandlePragmaOnce(PragmaIntroducer Introducer, Token &OnceTok) {
   // Don't honor the 'once' when handling the primary source file, unless
   // this is a prefix to a TU, which indicates we're generating a PCH file, or
   // when the main file is a header (e.g. when -xc-header is provided on the
@@ -416,6 +416,9 @@
   // Get the current file lexer we're looking at.  Ignore _Pragma 'files' etc.
   // Mark the file as a once-only file now.
   HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
+
+  if (Callbacks)
+Callbacks->PragmaOnce(Introducer, OnceTok.getLocation());
 }
 
 void Preprocessor::HandlePragmaMark(PragmaIntroducer Introducer,
@@ -991,7 +994,7 @@
   void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &OnceTok) override {
 PP.CheckEndOfDirective("pragma once");
-PP.HandlePragmaOnce(OnceTok);
+PP.HandlePragmaOnce(Introducer, OnceTok);
   }
 };
 
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h

[PATCH] D142388: [clang] Add builtin_nondet

2023-01-24 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:658
 BUILTIN(__builtin_call_with_static_chain, "v.", "nt")
+BUILTIN(__builtin_nondet, "v.", "nt")
 

erichkeane wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > shafik wrote:
> > > > erichkeane wrote:
> > > > > Not a fan of the name in general, it doesn't really explain what is 
> > > > > happening.  Perhaps `__builtin_nondeterministic_value` or something?  
> > > > > 
> > > > > I also wonder if others might have a better name :) 
> > > > `__builtin_indeterminate_value` wdyt?
> > > I think `__builtin_unspecified_value()` makes sense, as that's what 
> > > you're getting back (there is a valid value, but you may get a different 
> > > value on every call). I don't think `indeterminate` makes sense because 
> > > that implies it may return trap values, and I'm guessing that's not 
> > > behavior we want here (or am I wrong about that)?
> > > 
> > > Also, should this be usable within a constant expression? I would assume 
> > > not; we should have a test case showing you can't use it in such a 
> > > context.
> > Why does this require custom typechecking?
> Our issue last time with "unspecified" value was that this has a distinct 
> meaning in C/C++, so we don't want to use that word.  
> I don't think `indeterminate` makes sense because that implies it may return 
> trap values, and I'm guessing that's not behavior we want here (or am I wrong 
> about that)?

The idea is for it to return some correct value of the same type as the 
argument, so no trap values.

Can we settle on `__builtin_nondeterministic_value`? 



Comment at: clang/include/clang/Basic/Builtins.def:658
 BUILTIN(__builtin_call_with_static_chain, "v.", "nt")
+BUILTIN(__builtin_nondet, "v.", "nt")
 

ManuelJBrito wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > shafik wrote:
> > > > > erichkeane wrote:
> > > > > > Not a fan of the name in general, it doesn't really explain what is 
> > > > > > happening.  Perhaps `__builtin_nondeterministic_value` or 
> > > > > > something?  
> > > > > > 
> > > > > > I also wonder if others might have a better name :) 
> > > > > `__builtin_indeterminate_value` wdyt?
> > > > I think `__builtin_unspecified_value()` makes sense, as that's what 
> > > > you're getting back (there is a valid value, but you may get a 
> > > > different value on every call). I don't think `indeterminate` makes 
> > > > sense because that implies it may return trap values, and I'm guessing 
> > > > that's not behavior we want here (or am I wrong about that)?
> > > > 
> > > > Also, should this be usable within a constant expression? I would 
> > > > assume not; we should have a test case showing you can't use it in such 
> > > > a context.
> > > Why does this require custom typechecking?
> > Our issue last time with "unspecified" value was that this has a distinct 
> > meaning in C/C++, so we don't want to use that word.  
> > I don't think `indeterminate` makes sense because that implies it may 
> > return trap values, and I'm guessing that's not behavior we want here (or 
> > am I wrong about that)?
> 
> The idea is for it to return some correct value of the same type as the 
> argument, so no trap values.
> 
> Can we settle on `__builtin_nondeterministic_value`? 
> Why does this require custom typechecking?

I wasn't sure how to have the builtin take one argument of any type. 



Comment at: clang/include/clang/Basic/Builtins.def:658
 BUILTIN(__builtin_call_with_static_chain, "v.", "nt")
+BUILTIN(__builtin_nondet, "v.", "nt")
 

ManuelJBrito wrote:
> ManuelJBrito wrote:
> > erichkeane wrote:
> > > aaron.ballman wrote:
> > > > aaron.ballman wrote:
> > > > > shafik wrote:
> > > > > > erichkeane wrote:
> > > > > > > Not a fan of the name in general, it doesn't really explain what 
> > > > > > > is happening.  Perhaps `__builtin_nondeterministic_value` or 
> > > > > > > something?  
> > > > > > > 
> > > > > > > I also wonder if others might have a better name :) 
> > > > > > `__builtin_indeterminate_value` wdyt?
> > > > > I think `__builtin_unspecified_value()` makes sense, as that's what 
> > > > > you're getting back (there is a valid value, but you may get a 
> > > > > different value on every call). I don't think `indeterminate` makes 
> > > > > sense because that implies it may return trap values, and I'm 
> > > > > guessing that's not behavior we want here (or am I wrong about that)?
> > > > > 
> > > > > Also, should this be usable within a constant expression? I would 
> > > > > assume not; we should have a test case showing you can't use it in 
> > > > > such a context.
> > > > Why does this require custom typechecking?
> > > Our issue last time with "unspecified" value was that this has a distinct 
> > > meaning in C/C++, so we don't want to use that word.  
> > > I don't think `indeterminate` ma

[PATCH] D142471: [pp-trace] Add PragmaOnce callback

2023-01-24 Thread Kyle Edwards via Phabricator via cfe-commits
KyleFromKitware created this revision.
KyleFromKitware added a reviewer: clang-tools-extra.
KyleFromKitware created this object with edit policy "Only User: 
KyleFromKitware (Kyle Edwards)".
KyleFromKitware added a project: clang-tools-extra.
Herald added subscribers: kbarton, nemanjai.
Herald added a project: All.
KyleFromKitware requested review of this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142471

Files:
  clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
  clang-tools-extra/pp-trace/PPCallbacksTracker.h
  clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp


Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -- | FileCheck 
--strict-whitespace %s
+// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' 
-extra-arg-before=-xc++-header %s -- | FileCheck --strict-whitespace %s
 
 #pragma clang diagnostic push
 #pragma clang diagnostic pop
@@ -19,6 +19,8 @@
 { }
 }
 
+#pragma once
+
 // CHECK: ---
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: 
"{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:3:1", Kind: PIK_HashPragma}
@@ -114,5 +116,10 @@
 // CHECK-NEXT:   Introducer: {Loc: 
"{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:18:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:18:23"
 // CHECK-NEXT:   DebugType: captured
+// CHECK-NEXT: - Callback: PragmaDirective
+// CHECK-NEXT:   Introducer: {Loc: 
"{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:22:1", Kind: PIK_HashPragma}
+// CHECK-NEXT: - Callback: PragmaOnce
+// CHECK-NEXT:   Introducer: {Loc: 
"{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:22:1", Kind: PIK_HashPragma}
+// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:22:9"
 // CHECK-NEXT: - Callback: EndOfMainFile
 // CHECK-NEXT: ...
Index: clang-tools-extra/pp-trace/PPCallbacksTracker.h
===
--- clang-tools-extra/pp-trace/PPCallbacksTracker.h
+++ clang-tools-extra/pp-trace/PPCallbacksTracker.h
@@ -135,6 +135,7 @@
  StringRef Str) override;
   void PragmaExecCharsetPop(PragmaIntroducer Introducer,
 SourceLocation Loc) override;
+  void PragmaOnce(PragmaIntroducer Introducer, SourceLocation Loc) override;
   void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
 SourceRange Range, const MacroArgs *Args) override;
   void MacroDefined(SourceLocation HashLoc, const Token &MacroNameTok,
Index: clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
===
--- clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
+++ clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
@@ -337,6 +337,13 @@
   appendArgument("Loc", Loc);
 }
 
+/// Callback invoked when a \#pragma once directive is read.
+void PPCallbacksTracker::PragmaOnce(PragmaIntroducer Introducer, 
SourceLocation Loc) {
+  beginCallback("PragmaOnce");
+  appendArgument("Introducer", Introducer);
+  appendArgument("Loc", Loc);
+}
+
 // Called by Preprocessor::HandleMacroExpandedIdentifier when a
 // macro invocation is found.
 void PPCallbacksTracker::MacroExpands(const Token &MacroNameTok,


Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -- | FileCheck --strict-whitespace %s
+// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' -extra-arg-before=-xc++-header %s -- | FileCheck --strict-whitespace %s
 
 #pragma clang diagnostic push
 #pragma clang diagnostic pop
@@ -19,6 +19,8 @@
 { }
 }
 
+#pragma once
+
 // CHECK: ---
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:3:1", Kind: PIK_HashPragma}
@@ -114,5 +116,10 @@
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:18:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:18:23"
 // CHECK-NEXT:   DebugType: captured
+// CHECK-NEXT: - Callback: PragmaDirective
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:22:1", Kind: PIK_HashPragma}
+// CHECK-NEXT: - Callback: PragmaOnce
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:22:1", Kind: PIK_HashPragma}
+// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-general.cpp:22:9"
 // CHECK-NEXT: - Callback: EndOfMain

[PATCH] D142388: [clang] Add builtin_nondet

2023-01-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/CodeGen/builtins-nondet.c:3
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+

ManuelJBrito wrote:
> shafik wrote:
> > erichkeane wrote:
> > > Add some examples for 'bool' and vector-bool as well to make sure this is 
> > > doing what you want.
> > Does this also work for structs?
> > Does this also work for structs?
> 
> No, i don't think so. What would be expected IR?
can freeze/posion not be of struct types?  If they don't work, it should be an 
error to try.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142388

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


[PATCH] D142467: [Tooling] Add stdlib::Symbol::all() and stdlib::Symbol::qualified_name()

2023-01-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 491766.
sammccall added a comment.

oops, helps if I run tests on the right branch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142467

Files:
  clang/include/clang/Tooling/Inclusions/StandardLibrary.h
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/unittests/Tooling/StandardLibraryTest.cpp

Index: clang/unittests/Tooling/StandardLibraryTest.cpp
===
--- clang/unittests/Tooling/StandardLibraryTest.cpp
+++ clang/unittests/Tooling/StandardLibraryTest.cpp
@@ -18,6 +18,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+using ::testing::Contains;
 using ::testing::ElementsAre;
 
 namespace clang {
@@ -35,17 +36,24 @@
 TEST(StdlibTest, All) {
   auto VectorH = stdlib::Header::named("");
   EXPECT_TRUE(VectorH);
+  EXPECT_EQ(VectorH->name(), "");
   EXPECT_EQ(llvm::to_string(*VectorH), "");
   EXPECT_FALSE(stdlib::Header::named("HeadersTests.cpp"));
 
   auto Vector = stdlib::Symbol::named("std::", "vector");
   EXPECT_TRUE(Vector);
+  EXPECT_EQ(Vector->scope(), "std::");
+  EXPECT_EQ(Vector->name(), "vector");
+  EXPECT_EQ(Vector->qualified_name(), "std::vector");
   EXPECT_EQ(llvm::to_string(*Vector), "std::vector");
   EXPECT_FALSE(stdlib::Symbol::named("std::", "dongle"));
   EXPECT_FALSE(stdlib::Symbol::named("clang::", "ASTContext"));
 
   EXPECT_EQ(Vector->header(), *VectorH);
   EXPECT_THAT(Vector->headers(), ElementsAre(*VectorH));
+
+  EXPECT_THAT(stdlib::Header::all(), Contains(*VectorH));
+  EXPECT_THAT(stdlib::Symbol::all(), Contains(*Vector));
 }
 
 TEST(StdlibTest, Recognizer) {
Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -16,7 +16,12 @@
 namespace stdlib {
 
 static llvm::StringRef *HeaderNames;
-static std::pair *SymbolNames;
+static struct SymbolName {
+  const char *Data;  // std::vector
+  unsigned ScopeLen; // ~
+  unsigned NameLen;  //  ~~
+} *SymbolNames;
+static unsigned SymbolCount = 0;
 static unsigned *SymbolHeaderIDs;
 static llvm::DenseMap *HeaderIDs;
 // Maps symbol name -> Symbol::ID, within a namespace.
@@ -24,14 +29,15 @@
 static llvm::DenseMap *NamespaceSymbols;
 
 static int initialize() {
-  unsigned SymCount = 0;
-#define SYMBOL(Name, NS, Header) ++SymCount;
+  SymbolCount = 0;
+#define SYMBOL(Name, NS, Header) ++SymbolCount;
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
 #include "clang/Tooling/Inclusions/StdSymbolMap.inc"
 #undef SYMBOL
-  SymbolNames = new std::remove_reference_t[SymCount];
+  SymbolNames =
+  new std::remove_reference_t[SymbolCount];
   SymbolHeaderIDs =
-  new std::remove_reference_t[SymCount];
+  new std::remove_reference_t[SymbolCount];
   NamespaceSymbols = new std::remove_reference_t;
   HeaderIDs = new std::remove_reference_t;
 
@@ -46,20 +52,25 @@
 return HeaderIDs->try_emplace(Header, HeaderIDs->size()).first->second;
   };
 
-  auto Add = [&, SymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
+  auto Add = [&, SymIndex(0)](llvm::StringRef QName, unsigned NSLen,
   llvm::StringRef HeaderName) mutable {
-if (NS == "None")
-  NS = "";
+// Correct "Nonefoo" => foo.
+// FIXME: get rid of "None" from the generated mapping files.
+if (QName.take_front(NSLen) == "None") {
+  QName = QName.drop_front(NSLen);
+  NSLen = 0;
+}
 
-SymbolNames[SymIndex] = {NS, Name};
+SymbolNames[SymIndex] = {QName.data(), NSLen,
+ static_cast(QName.size() - NSLen)};
 SymbolHeaderIDs[SymIndex] = AddHeader(HeaderName);
 
-NSSymbolMap &NSSymbols = AddNS(NS);
-NSSymbols.try_emplace(Name, SymIndex);
+NSSymbolMap &NSSymbols = AddNS(QName.take_front(NSLen));
+NSSymbols.try_emplace(QName.drop_front(NSLen), SymIndex);
 
 ++SymIndex;
   };
-#define SYMBOL(Name, NS, Header) Add(#Name, #NS, #Header);
+#define SYMBOL(Name, NS, Header) Add(#NS #Name, strlen(#NS), #Header);
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
 #include "clang/Tooling/Inclusions/StdSymbolMap.inc"
 #undef SYMBOL
@@ -76,6 +87,13 @@
   (void)Dummy;
 }
 
+std::vector Header::all() {
+  std::vector Result;
+  Result.reserve(HeaderIDs->size());
+  for (unsigned I = 0, E = HeaderIDs->size(); I < E; ++I)
+Result.push_back(Header(I));
+  return Result;
+}
 std::optional Header::named(llvm::StringRef Name) {
   ensureInitialized();
   auto It = HeaderIDs->find(Name);
@@ -84,8 +102,26 @@
   return Header(It->second);
 }
 llvm::StringRef Header::name() const { return HeaderNames[ID]; }
-llvm::StringRef Symbol::scope() const { return SymbolNames[ID].first; }
-llvm::StringRef Symbol::name() const { return SymbolNames[ID].second; }
+
+std::vect

[clang] 1ab7e76 - [9/15][Clang][RISCV][NFC] Use correct type for `RVVTypeCache::computeTypes` under RISCVVEmitter.cpp

2023-01-24 Thread via cfe-commits

Author: eopXD
Date: 2023-01-24T07:03:33-08:00
New Revision: 1ab7e76887e3c6ff1ca82b3970a0aae71895d848

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

LOG: [9/15][Clang][RISCV][NFC] Use correct type for 
`RVVTypeCache::computeTypes` under RISCVVEmitter.cpp

`MaskedPrototype` is initialized and used nowhere, this is a bug. The
existing codebase works correctly upon this bug because the default
policy for unmasked intrinsics is set to TAMU.

This is something to be fixed because when the default policy is
changed to TAMA, clang will generate incorrect result.

This is the 9th commit of a patch-set that aims to change the default policy
for RVV intrinsics from TAMU to TAMA.

Please refer to the cover letter in the 1st commit (D141573) for an
overview.

Reviewed By: kito-cheng

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

Added: 


Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 39925cc5c24b4..668e1072c065f 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -587,7 +587,7 @@ void RVVEmitter::createRVVIntrinsics(
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,



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


[PATCH] D141764: [9/15][Clang][RISCV][NFC] Use correct type for `RVVTypeCache::computeTypes` under RISCVVEmitter.cpp

2023-01-24 Thread Yueh-Ting (eop) Chen 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 rG1ab7e76887e3: [9/15][Clang][RISCV][NFC] Use correct type for 
`RVVTypeCache::computeTypes`… (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141764

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -587,7 +587,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -587,7 +587,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142388: [clang] Add builtin_nondet

2023-01-24 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito updated this revision to Diff 491767.
ManuelJBrito added a comment.

Add tests with bool and bool-vector


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142388

Files:
  clang/test/CodeGen/builtins-nondet.c


Index: clang/test/CodeGen/builtins-nondet.c
===
--- clang/test/CodeGen/builtins-nondet.c
+++ clang/test/CodeGen/builtins-nondet.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
 
 typedef float float4 __attribute__((ext_vector_type(4)));
+typedef _Bool bool4 __attribute__((ext_vector_type(4)));
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
@@ -29,7 +30,17 @@
   return __builtin_nondet(x);
 } 
 
-float4 clang_nondet_v( float4 x ) {
+_Bool clang_nondet_b( _Bool x) {
+// CHECK-LABEL: entry
+// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[B:%.*]] = zext i1 %x to i8
+// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: [[R:%.*]] = freeze i1 poison
+// CHECK: ret i1 [[R]]
+  return __builtin_nondet(x);
+} 
+
+float4 clang_nondet_fv( float4 x ) {
 // CHECK-LABEL: entry
 // CHECK: [[A:%.*]] = alloca <4 x float>, align 16
 // CHECK: store <4 x float> [[X:%.*]], ptr [[A]], align 16
@@ -38,3 +49,14 @@
   return __builtin_nondet(x);
 } 
 
+bool4 clang_nondet_bv( bool4 x ) {
+// CHECK-LABEL: entry
+// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[V:%.*]] = shufflevector <4 x i1> [[X:%.*]], <4 x i1> poison, <8 x 
i32> 
+// CHECK: [[B:%.*]] = bitcast <8 x i1> [[V]] to i8
+// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: [[R:%.*]] = freeze <4 x i1> poison
+// CHECK: ret <4 x i1> [[R]]
+  return __builtin_nondet(x);
+} 
+


Index: clang/test/CodeGen/builtins-nondet.c
===
--- clang/test/CodeGen/builtins-nondet.c
+++ clang/test/CodeGen/builtins-nondet.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
 
 typedef float float4 __attribute__((ext_vector_type(4)));
+typedef _Bool bool4 __attribute__((ext_vector_type(4)));
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
@@ -29,7 +30,17 @@
   return __builtin_nondet(x);
 } 
 
-float4 clang_nondet_v( float4 x ) {
+_Bool clang_nondet_b( _Bool x) {
+// CHECK-LABEL: entry
+// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[B:%.*]] = zext i1 %x to i8
+// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: [[R:%.*]] = freeze i1 poison
+// CHECK: ret i1 [[R]]
+  return __builtin_nondet(x);
+} 
+
+float4 clang_nondet_fv( float4 x ) {
 // CHECK-LABEL: entry
 // CHECK: [[A:%.*]] = alloca <4 x float>, align 16
 // CHECK: store <4 x float> [[X:%.*]], ptr [[A]], align 16
@@ -38,3 +49,14 @@
   return __builtin_nondet(x);
 } 
 
+bool4 clang_nondet_bv( bool4 x ) {
+// CHECK-LABEL: entry
+// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[V:%.*]] = shufflevector <4 x i1> [[X:%.*]], <4 x i1> poison, <8 x i32> 
+// CHECK: [[B:%.*]] = bitcast <8 x i1> [[V]] to i8
+// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: [[R:%.*]] = freeze <4 x i1> poison
+// CHECK: ret <4 x i1> [[R]]
+  return __builtin_nondet(x);
+} 
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142465: [clang][lex] Consolidate PPCallbacks::PragmaDirective parameters

2023-01-24 Thread Kyle Edwards via Phabricator via cfe-commits
KyleFromKitware updated this revision to Diff 491772.
KyleFromKitware added a comment.

Rebased onto `main` for D141000 .


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

https://reviews.llvm.org/D142465

Files:
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
  clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
  clang-tools-extra/docs/pp-trace.rst
  clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
  clang-tools-extra/pp-trace/PPCallbacksTracker.h
  clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Lex/Pragma.cpp

Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -166,7 +166,7 @@
 /// rest of the pragma, passing it to the registered pragma handlers.
 void Preprocessor::HandlePragmaDirective(PragmaIntroducer Introducer) {
   if (Callbacks)
-Callbacks->PragmaDirective(Introducer.Loc, Introducer.Kind);
+Callbacks->PragmaDirective(Introducer);
 
   if (!PragmasEnabled)
 return;
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -193,9 +193,7 @@
   }
 
   /// Callback invoked when start reading any pragma directive.
-  virtual void PragmaDirective(SourceLocation Loc,
-   PragmaIntroducerKind Introducer) {
-  }
+  virtual void PragmaDirective(PragmaIntroducer Introducer) {}
 
   /// Callback invoked when a \#pragma comment directive is read.
   virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
@@ -511,10 +509,9 @@
 Second->Ident(Loc, str);
   }
 
-  void PragmaDirective(SourceLocation Loc,
-   PragmaIntroducerKind Introducer) override {
-First->PragmaDirective(Loc, Introducer);
-Second->PragmaDirective(Loc, Introducer);
+  void PragmaDirective(PragmaIntroducer Introducer) override {
+First->PragmaDirective(Introducer);
+Second->PragmaDirective(Introducer);
   }
 
   void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
@@ -6,24 +6,21 @@
 
 // CHECK: ---
 // CHECK-NEXT: - Callback: PragmaDirective
-// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:1"
-// CHECK-NEXT:   Introducer: PIK_HashPragma
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:26"
 // CHECK-NEXT:   Name: all
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:32"
 // CHECK-NEXT:   State: 0
 // CHECK-NEXT: - Callback: PragmaDirective
-// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:1"
-// CHECK-NEXT:   Introducer: PIK_HashPragma
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:26"
 // CHECK-NEXT:   Name: cl_khr_int64_base_atomics
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:54"
 // CHECK-NEXT:   State: 0
 // CHECK-NEXT: - Callback: PragmaDirective
-// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:1"
-// CHECK-NEXT:   Introducer: PIK_HashPragma
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:26"
 // CHECK-NEXT:   Name: cl_khr_int64_base_atomics
Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
@@ -18,72 +18,61 @@
 
 // CHECK: ---
 // CHECK-NEXT: - Callback: PragmaDirective
-// CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:1"
-// CHECK-NEXT:   Introducer: PIK_HashPragma
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:9"
 // CHECK-NEXT:   Kind: compiler
 // CHECK-NEXT:   Str: compiler comment
 // CHECK-NEXT

[PATCH] D142030: [pp-trace] Print HashLoc/Introducer parameter

2023-01-24 Thread Kyle Edwards via Phabricator via cfe-commits
KyleFromKitware updated this revision to Diff 491774.
KyleFromKitware added a comment.

Rebased onto `main` for D141000 .


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

https://reviews.llvm.org/D142030

Files:
  clang-tools-extra/docs/pp-trace.rst
  clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
  clang-tools-extra/test/pp-trace/pp-trace-conditional.cpp
  clang-tools-extra/test/pp-trace/pp-trace-ident.cpp
  clang-tools-extra/test/pp-trace/pp-trace-include.cpp
  clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-general.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
  clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp

Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-opencl.cpp
@@ -8,6 +8,7 @@
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:26"
 // CHECK-NEXT:   Name: all
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:3:32"
@@ -15,6 +16,7 @@
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:26"
 // CHECK-NEXT:   Name: cl_khr_int64_base_atomics
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:4:54"
@@ -22,6 +24,7 @@
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaOpenCLExtension
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   NameLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:26"
 // CHECK-NEXT:   Name: cl_khr_int64_base_atomics
 // CHECK-NEXT:   StateLoc: "{{.*}}{{[/\\]}}pp-trace-pragma-opencl.cpp:5:54"
Index: clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
===
--- clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
+++ clang-tools-extra/test/pp-trace/pp-trace-pragma-ms.cpp
@@ -20,36 +20,42 @@
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:3:9"
 // CHECK-NEXT:   Kind: compiler
 // CHECK-NEXT:   Str: compiler comment
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:4:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:4:9"
 // CHECK-NEXT:   Kind: exestr
 // CHECK-NEXT:   Str: exestr comment
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:5:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:5:9"
 // CHECK-NEXT:   Kind: lib
 // CHECK-NEXT:   Str: lib comment
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:6:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:6:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:6:9"
 // CHECK-NEXT:   Kind: linker
 // CHECK-NEXT:   Str: linker comment
 // CHECK-NEXT: - Callback: PragmaDirective
 // CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:7:1", Kind: PIK_HashPragma}
 // CHECK-NEXT: - Callback: PragmaComment
+// CHECK-NEXT:   Introducer: {Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:7:1", Kind: PIK_HashPragma}
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-pragma-ms.cpp:7:9"
 // CHECK-NEXT:   Kind: user
 // CHECK-NEXT:   Str: user comment
 // CHECK-NEXT: -

  1   2   3   4   >