[PATCH] D142014: [clangd] fix wrong CalleeArgInfo in the hover

2023-01-26 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry added a comment.

I just came up with a case where the original implementation and this patch 
behave differently.

  void foobar(const float &);
  int main() {
foobar(0);
   ^
  }

Used to `Passed by value`, now it is `Passed by const reference`. I think the 
former one is apparently better.

This case can be fixed by getting the `PassType.PassBy = 
HoverInfo::PassType::Value;` back to the `ImplicitCastExpr` case, but hmm...It 
does make me hesitate to insist on the current code change. Maybe we should 
switch to @kadircet's idea if I understand him correctly. WDYT, @nridge, 
@tom-anders and @adamcz?

But the `isLiteral()` and `ImplicitCastExpr` cases in the original 
implementation bring enough mystery and risks to me. For me this is a hard 
decision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142014

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


[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-01-26 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

Small suggestion




Comment at: flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp:41-45
+  std::string newName{result.second.name};
+  if (appendUnderscore)
+newName = newName + "_";
+
+  return newName;

To avoid new copy


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

https://reviews.llvm.org/D140795

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


[PATCH] D142606: Lazyly initialize uncommon toolchain detector

2023-01-26 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
Herald added subscribers: kosarev, kerbowa, jvesely, emaste.
Herald added a project: All.
serge-sans-paille requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Cuda and rocm toolchain detectors are currently run unconditionally, while 
their result may not be used at all. Make their initialization lazy so that the 
discovery code is not run in common cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142606

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/lib/Driver/ToolChains/LazyDetector.h
  clang/lib/Driver/ToolChains/Linux.cpp

Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -681,23 +681,23 @@
 
 void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
-  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
+  CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
 }
 
 void Linux::AddHIPIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
-  RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
+  RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
 }
 
 void Linux::AddHIPRuntimeLibArgs(const ArgList &Args,
  ArgStringList &CmdArgs) const {
   CmdArgs.push_back(
-  Args.MakeArgString(StringRef("-L") + RocmInstallation.getLibPath()));
+  Args.MakeArgString(StringRef("-L") + RocmInstallation->getLibPath()));
 
   if (Args.hasFlag(options::OPT_offload_add_rpath,
options::OPT_no_offload_add_rpath, false))
 CmdArgs.append(
-{"-rpath", Args.MakeArgString(RocmInstallation.getLibPath())});
+{"-rpath", Args.MakeArgString(RocmInstallation->getLibPath())});
 
   CmdArgs.push_back("-lamdhip64");
 }
Index: clang/lib/Driver/ToolChains/LazyDetector.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/LazyDetector.h
@@ -0,0 +1,46 @@
+//===--- LazyDetector.h - Lazy ToolChain Detection --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_LAZYDETECTOR_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_LAZYDETECTOR_H
+
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+#include 
+
+namespace clang {
+
+/// Simple wrapper for toolchain detector with costly initialization. This
+/// delays the creation of the actual detector until its first usage.
+
+template  class LazyDetector {
+  const driver::Driver &D;
+  const llvm::Triple &Triple;
+  const llvm::opt::ArgList &Args;
+
+  mutable std::optional Detector;
+
+public:
+  LazyDetector(const driver::Driver &D, const llvm::Triple &Triple,
+   const llvm::opt::ArgList &Args)
+  : D(D), Triple(Triple), Args(Args) {}
+  T *operator->() {
+if (!Detector) {
+  Detector.emplace(D, Triple, Args);
+}
+return &Detector.value();
+  }
+  T const *operator->() const {
+return const_cast(
+const_cast(*this).operator->());
+  }
+};
+
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_LAZYDETECTOR_H
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -315,7 +315,7 @@
 
 void HIPAMDToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
 ArgStringList &CC1Args) const {
-  RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
+  RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
 }
 
 SanitizerMask HIPAMDToolChain::getSupportedSanitizers() const {
@@ -344,7 +344,7 @@
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
-  for (StringRef Path : RocmInstallation.getRocmDeviceLibPathArg())
+  for (StringRef Path : RocmInstallation->getRocmDeviceLibPathArg())
 LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
 
   addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
@@ -366,7 +366,7 @@
   getDriver().Diag(diag::err_drv_no_such_file) << BCName;
 });
   } else {
-if (!RocmInstallation.hasDeviceLibrary()) {
+if (!RocmInstallation->hasDeviceLibrary()) {
   getDriver().Diag(diag::er

[PATCH] D142607: [clang][ASTImporter] Handle UsingType in friend declarations.

2023-01-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, martong, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

ASTImporterLookupTable did not handle correctly friend declarations
where the friend type is an UsingType (type of a declaration that
comes from an using-declaration). The problem is fixed by handling
it in the same way as a friend with TypedefType.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142607

Files:
  clang/lib/AST/ASTImporterLookupTable.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5160,6 +5160,39 @@
   EXPECT_EQ(Res.count(Alias), 1u);
 }
 
+TEST_P(ASTImporterLookupTableTest,
+   LookupFindsFriendClassDeclWithUsingTypeDoesNotAssert) {
+  TranslationUnitDecl *ToTU = getToTuDecl(
+  R"(
+  namespace a {
+namespace b { class InnerClass; }
+using b::InnerClass;
+  }
+  class B {
+friend a::InnerClass;
+  };
+  )",
+  Lang_CXX11);
+
+  // ASTImporterLookupTable constructor handles friend with using-type without
+  // asserts.
+  ASTImporterLookupTable LT(*ToTU);
+
+  auto *Using = FirstDeclMatcher().match(
+  ToTU, usingDecl(hasName("InnerClass")));
+  DeclarationName Name = Using->getDeclName();
+  auto Res = LT.lookup(ToTU, Name);
+  EXPECT_EQ(Res.size(), 0u);
+  auto *NsA = FirstDeclMatcher().match(
+  ToTU, namespaceDecl(hasName("a")));
+  auto *RecordB = FirstDeclMatcher().match(
+  ToTU, cxxRecordDecl(hasName("B")));
+  auto Res1 = LT.lookup(NsA, Name);
+  EXPECT_EQ(Res1.count(Using), 1u);
+  auto Res2 = LT.lookup(RecordB, Name);
+  EXPECT_EQ(Res2.size(), 0u);
+}
+
 TEST_P(ASTImporterLookupTableTest, LookupFindsFwdFriendClassTemplateDecl) {
   TranslationUnitDecl *ToTU = getToTuDecl(
   R"(
Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -67,6 +67,8 @@
 } else if (isa(Ty)) {
   // We do not put friend typedefs to the lookup table because
   // ASTImporter does not organize typedefs into redecl chains.
+} else if (isa(Ty)) {
+  // Similar to TypedefType, not putting into lookup table.
 } else {
   llvm_unreachable("Unhandled type of friend class");
 }


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5160,6 +5160,39 @@
   EXPECT_EQ(Res.count(Alias), 1u);
 }
 
+TEST_P(ASTImporterLookupTableTest,
+   LookupFindsFriendClassDeclWithUsingTypeDoesNotAssert) {
+  TranslationUnitDecl *ToTU = getToTuDecl(
+  R"(
+  namespace a {
+namespace b { class InnerClass; }
+using b::InnerClass;
+  }
+  class B {
+friend a::InnerClass;
+  };
+  )",
+  Lang_CXX11);
+
+  // ASTImporterLookupTable constructor handles friend with using-type without
+  // asserts.
+  ASTImporterLookupTable LT(*ToTU);
+
+  auto *Using = FirstDeclMatcher().match(
+  ToTU, usingDecl(hasName("InnerClass")));
+  DeclarationName Name = Using->getDeclName();
+  auto Res = LT.lookup(ToTU, Name);
+  EXPECT_EQ(Res.size(), 0u);
+  auto *NsA = FirstDeclMatcher().match(
+  ToTU, namespaceDecl(hasName("a")));
+  auto *RecordB = FirstDeclMatcher().match(
+  ToTU, cxxRecordDecl(hasName("B")));
+  auto Res1 = LT.lookup(NsA, Name);
+  EXPECT_EQ(Res1.count(Using), 1u);
+  auto Res2 = LT.lookup(RecordB, Name);
+  EXPECT_EQ(Res2.size(), 0u);
+}
+
 TEST_P(ASTImporterLookupTableTest, LookupFindsFwdFriendClassTemplateDecl) {
   TranslationUnitDecl *ToTU = getToTuDecl(
   R"(
Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -67,6 +67,8 @@
 } else if (isa(Ty)) {
   // We do not put friend typedefs to the lookup table because
   // ASTImporter does not organize typedefs into redecl chains.
+} else if (isa(Ty)) {
+  // Similar to TypedefType, not putting into lookup table.
 } else {
   llvm_unreachable("Unhandled type of friend class");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-01-26 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 492352.
VitaNuo added a comment.

Sort the C symbol map.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -41,6 +38,7 @@
 import datetime
 import os
 import sys
+import re
 
 CODE_PREFIX = """\
 //===-- gen_std.py generated file ---*- C++ -*-===//
@@ -109,18 +107,17 @@
   cppreference_modified_date = datetime.datetime.fromtimestamp(
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
+  # FIXME: take care of overloads
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if re.match("^remove$|^swap$", symbol.name) and symbol.namespace == "std::":
+  continue
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  symbol.headers = sorted(symbol.headers)
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -47,7 +47,7 @@
 
   Returns a list of headers.
   """
-  headers = set()
+  symbol_headers = set()
   all_headers = set()
 
   soup = BeautifulSoup(symbol_page_html, "html.parser")
@@ -58,32 +58,45 @@
   #   Defined in header   .t-dsc-header
   #   decl2.t-dcl
   for table in soup.select('table.t-dcl-begin, table.t-dsc-begin'):
-current_headers = []
-was_decl = False
-for row in table.select('tr'):
-  if _HasClass(row, 't-dcl', 't-dsc'):
-was_decl = True
-# Symbols are in the first cell.
-found_symbols = row.find('td').stripped_strings
-if not symbol_name in found_symbols:
-  continue
-headers.update(current_headers)
-  elif _HasClass(row, 't-dsc-header'):
-# If we saw a decl since the last header, this is a new block of headers
-# for a new block of decls.
-if was_decl:
-  current_headers = []
-was_decl = False
+rows = table.select('tr')
+i = 0
+while i < len(rows):
+  start = i
+  current_headers = set()
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-header'):
+row = rows[i]
 # There are also .t-dsc-header for "defined in namespace".
 if not "Defined in header " in row.text:
+  i = i + 1
   continue
 # The interesting header content (e.g. ) is wrapped in .
 for header_code in row.find_all("code"):
-  current_headers.append(header_code.text)
   all_headers.add(header_code.text)
+  current_headers.add(header_code.text)
+i = i + 1
+  # some tables have header rows, skip them  
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-hitem'):
+i = i + 1
+  while i < len(rows) and (_HasClass(rows[i], 't-dcl', 't-dsc') or not rows[i].has_attr("class")):
+row = rows[i]
+# Symbols are in the first cell.
+raw_symbols = row.find('td').stripped_strings
+found_symbols = []
+# Finding all text in  is not enough, some strings contain more than one symbol (e.g., "div_t div" is parsed as single symbol).
+for raw_symbol

[PATCH] D142607: [clang][ASTImporter] Handle UsingType in friend declarations.

2023-01-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The test causes this assert if the fix is not applied:

  Unhandled type of friend class
  UNREACHABLE executed at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTImporterLookupTable.cpp:71!
   #0 0x7f4380b90e0a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/local/clang/llvm2/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11
   #1 0x7f4380b90fdb PrintStackTraceSignalHandler(void*) 
/local/clang/llvm2/llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1
   #2 0x7f4380b8f58b llvm::sys::RunSignalHandlers() 
/local/clang/llvm2/llvm-project/llvm/lib/Support/Signals.cpp:103:5
   #3 0x7f4380b91751 SignalHandler(int) 
/local/clang/llvm2/llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1
   #4 0x7f43840b1980 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
   #5 0x7f437fa40e87 raise 
/build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
   #6 0x7f437fa427f1 abort 
/build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
   #7 0x7f4380a132c4 
/local/clang/llvm2/llvm-project/llvm/lib/Support/ErrorHandling.cpp:212:3
   #8 0x7f438265cc05 clang::(anonymous 
namespace)::Builder::VisitFriendDecl(clang::FriendDecl*) 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTImporterLookupTable.cpp:0:11
   #9 0x7f438265ca40 clang::RecursiveASTVisitor::WalkUpFromFriendDecl(clang::FriendDecl*) 
/local/clang/llvm2/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:71:1
  #10 0x7f43825e2505 clang::RecursiveASTVisitor::TraverseFriendDecl(clang::FriendDecl*) 
/local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1550:1
  #11 0x7f43825dfa49 clang::RecursiveASTVisitor::TraverseDecl(clang::Decl*) 
/local/clang/llvm2/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:71:1
  #12 0x7f4382648488 clang::RecursiveASTVisitor::TraverseDeclContextHelper(clang::DeclContext*) 
/local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1489:7
  #13 0x7f43825e7038 clang::RecursiveASTVisitor::TraverseCXXRecordDecl(clang::CXXRecordDecl*) 
/local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:2015:1
  #14 0x7f43825dff7f clang::RecursiveASTVisitor::TraverseDecl(clang::Decl*) 
/local/clang/llvm2/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:295:1
  #15 0x7f4382648488 clang::RecursiveASTVisitor::TraverseDeclContextHelper(clang::DeclContext*) 
/local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1489:7
  #16 0x7f43825ee041 clang::RecursiveASTVisitor::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) 
/local/clang/llvm2/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1599:1
  #17 0x7f43825e084d clang::RecursiveASTVisitor::TraverseDecl(clang::Decl*) 
/local/clang/llvm2/build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:645:1
  #18 0x7f43825df7d4 
clang::ASTImporterLookupTable::ASTImporterLookupTable(clang::TranslationUnitDecl&)
 /local/clang/llvm2/llvm-project/clang/lib/AST/ASTImporterLookupTable.cpp:88:1
  #19 0x00655a44 
std::_MakeUniq::__single_object 
std::make_unique(clang::TranslationUnitDecl&) 
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/unique_ptr.h:821:34
  #20 0x00655933 
clang::ASTImporterSharedState::ASTImporterSharedState(clang::TranslationUnitDecl&)
 
/local/clang/llvm2/llvm-project/clang/include/clang/AST/ASTImporterSharedState.h:52:19
  #21 0x006558d1 void 
__gnu_cxx::new_allocator::construct(clang::ASTImporterSharedState*, 
clang::TranslationUnitDecl&) 
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/ext/new_allocator.h:136:60
  #22 0x006555ed void 
std::allocator_traits>::construct(std::allocator&, 
clang::ASTImporterSharedState*, clang::TranslationUnitDecl&) 
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/alloc_traits.h:475:56
  #23 0x0065544b std::__shared_ptr::__shared_ptr,
 clang::TranslationUnitDecl&>(std::_Sp_make_shared_tag, 
std::allocator const&, 
clang::TranslationUnitDecl&) 
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/shared_ptr_base.h:1327:4
  #24 0x006553ad 
std::shared_ptr::shared_ptr,
 clang::TranslationUnitDecl&>(std::_Sp_make_shared_tag, 
std::allocator const&, 
clang::TranslationUnitDecl&) 
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/shared_ptr.h:345:4
  #25 0x00655316 std::shared_ptr 
std::allocate_shared, 
clang::TranslationUnitDecl&>(std::allocator 
const&, clang::TranslationUnitDecl&) 
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/shared_ptr.h:690:14
  #26 0x0064e6f3 std::shared_ptr 
std::make_shared(clang::TranslationUnitDecl&) 
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/shared_ptr.h:706:7
  #27 0x0064bd3e 
clang::ast_matchers::ASTImporterTestBase::lazy

[clang] 8bb54da - Allow getRawCommentForDecl to find comments in macros

2023-01-26 Thread Dmitri Gribenko via cfe-commits

Author: Dana Jansens
Date: 2023-01-26T10:12:57+01:00
New Revision: 8bb54da5da3194b71b54f70c6cc55485cf2623b0

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

LOG: Allow getRawCommentForDecl to find comments in macros

The key part of getRawCommentForDecl() required to find a comment
is determining where to look for it. The location of the decl
itself is usually right, except when macros get involved. The
comment in the macro is stored in RawCommentList at the spelling
location of the decl, not at the place where the decl comes into
being as the macro is instantiated.

getDeclLocForCommentSearch() already contained to branches to try
handle comments inside macros, and we are able to replace them
and handle more cases as well, by returning the spelling location
of the decl's begin location. That is:
  SourceMgr.getSpellingLoc(D->getBeginLoc())

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/test/Index/annotate-comments-objc.m

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 3ba8b90898b30..18a041d7a72ab 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -181,22 +181,96 @@ static SourceLocation getDeclLocForCommentSearch(const 
Decl *D,
 
   const SourceLocation DeclLoc = D->getLocation();
   if (DeclLoc.isMacroID()) {
-if (isa(D)) {
-  // If location of the typedef name is in a macro, it is because being
-  // declared via a macro. Try using declaration's starting location as
-  // the "declaration location".
-  return D->getBeginLoc();
-}
-
-if (const auto *TD = dyn_cast(D)) {
-  // If location of the tag decl is inside a macro, but the spelling of
-  // the tag name comes from a macro argument, it looks like a special
-  // macro like NS_ENUM is being used to define the tag decl.  In that
-  // case, adjust the source location to the expansion loc so that we can
-  // attach the comment to the tag decl.
-  if (SourceMgr.isMacroArgExpansion(DeclLoc) && TD->isCompleteDefinition())
-return SourceMgr.getExpansionLoc(DeclLoc);
+// There are (at least) three types of macros we care about here.
+//
+// 1. Macros that are used in the definition of a type outside the macro,
+//with a comment attached at the macro call site.
+//```
+//#define MAKE_NAME(Foo) Name##Foo
+//
+///// Comment is here, where we use the macro.
+//struct MAKE_NAME(Foo) {
+//int a;
+//int b;
+//};
+//```
+// 2. Macros that define whole things along with the comment.
+//```
+//#define MAKE_METHOD(name) \
+//  /** Comment is here, inside the macro. */ \
+//  void name() {}
+//
+//struct S {
+//  MAKE_METHOD(f)
+//}
+//```
+// 3. Macros that both declare a type and name a decl outside the macro.
+//```
+///// Comment is here, where we use the macro.
+//typedef NS_ENUM(NSInteger, Size) {
+//SizeWidth,
+//SizeHeight
+//};
+//```
+//In this case NS_ENUM declares am enum type, and uses the same name 
for
+//the typedef declaration that appears outside the macro. The comment
+//here should be applied to both declarations inside and outside the
+//macro.
+//
+// We have found a Decl name that comes from inside a macro, but
+// Decl::getLocation() returns the place where the macro is being called.
+// If the declaration (and not just the name) resides inside the macro,
+// then we want to map Decl::getLocation() into the macro to where the
+// declaration and its attached comment (if any) were written.
+//
+// This mapping into the macro is done by mapping the location to its
+// spelling location, however even if the declaration is inside a macro,
+// the name's spelling can come from a macro argument (case 2 above). In
+// this case mapping the location to the spelling location finds the
+// argument's position (at `f` in MAKE_METHOD(`f`) above), which is not
+// where the declaration and its comment are located.
+//
+// To avoid this issue, we make use of Decl::getBeginLocation() instead.
+// While the declaration's position is where the name is written, the
+// comment is always attached to the begining of the declaration, not to
+// the name.
+//
+// In the first case, the begin location of the decl is outside the macro,
+// at the location of `typedef`. This is where the comment is found as
+// well. The begin location is not inside a macro, so 

[PATCH] D142560: Allow getRawCommentForDecl to find comments in macros

2023-01-26 Thread Dmitri Gribenko 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 rG8bb54da5da31: Allow getRawCommentForDecl to find comments in 
macros (authored by danakj, committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142560

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Index/annotate-comments-objc.m

Index: clang/test/Index/annotate-comments-objc.m
===
--- clang/test/Index/annotate-comments-objc.m
+++ clang/test/Index/annotate-comments-objc.m
@@ -48,17 +48,31 @@
 // attach unrelated comments in the following cases where tag decls are
 // embedded in declarators.
 
-#define DECLARE_FUNCTION() \
+#define DECLARE_FUNCTIONS(suffix) \
+/** functionFromMacro IS_DOXYGEN_SINGLE */ \
 void functionFromMacro(void) { \
   typedef struct Struct_notdoxy Struct_notdoxy; \
+} \
+/** functionFromMacroWithSuffix IS_DOXYGEN_SINGLE */ \
+void functionFromMacro##suffix(void) { \
+  typedef struct Struct_notdoxy Struct_notdoxy; \
 }
 
 /// IS_DOXYGEN_NOT_ATTACHED
-DECLARE_FUNCTION()
+DECLARE_FUNCTIONS(WithSuffix)
 
 /// typedef_isdoxy1 IS_DOXYGEN_SINGLE
 typedef struct Struct_notdoxy *typedef_isdoxy1;
 
+#define DECLARE_ENUMS(name) \
+  /** enumFromMacro IS_DOXYGEN_SINGLE */ \
+  enum enumFromMacro { A }; \
+  /** namedEnumFromMacro IS_DOXYGEN_SINGLE */ \
+  enum name { B };
+
+/// IS_DOXYGEN_NOT_ATTACHED
+DECLARE_ENUMS(namedEnumFromMacro)
+
 #endif
 
 // RUN: rm -rf %t
@@ -121,5 +135,8 @@
 // CHECK: annotate-comments-objc.m:43:22: EnumDecl=An_NS_ENUM_isdoxy1:{{.*}} An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE
 // CHECK: annotate-comments-objc.m:43:22: TypedefDecl=An_NS_ENUM_isdoxy1:{{.*}} An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE
 // CHECK: annotate-comments-objc.m:43:22: EnumDecl=An_NS_ENUM_isdoxy1:{{.*}} An_NS_ENUM_isdoxy1 IS_DOXYGEN_SINGLE
-// CHECK: annotate-comments-objc.m:60:32: TypedefDecl=typedef_isdoxy1:{{.*}} typedef_isdoxy1 IS_DOXYGEN_SINGLE
-
+// CHECK: annotate-comments-objc.m:62:1: FunctionDecl=functionFromMacro:{{.*}} BriefComment=[functionFromMacro IS_DOXYGEN_SINGLE]
+// CHECK: annotate-comments-objc.m:62:1: FunctionDecl=functionFromMacroWithSuffix:{{.*}} BriefComment=[functionFromMacroWithSuffix IS_DOXYGEN_SINGLE]
+// CHECK: annotate-comments-objc.m:65:32: TypedefDecl=typedef_isdoxy1:{{.*}} typedef_isdoxy1 IS_DOXYGEN_SINGLE
+// CHECK: annotate-comments-objc.m:74:1: EnumDecl=enumFromMacro:{{.*}} BriefComment=[enumFromMacro IS_DOXYGEN_SINGLE]
+// CHECK: annotate-comments-objc.m:74:15: EnumDecl=namedEnumFromMacro:{{.*}} BriefComment=[namedEnumFromMacro IS_DOXYGEN_SINGLE]
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -181,22 +181,96 @@
 
   const SourceLocation DeclLoc = D->getLocation();
   if (DeclLoc.isMacroID()) {
-if (isa(D)) {
-  // If location of the typedef name is in a macro, it is because being
-  // declared via a macro. Try using declaration's starting location as
-  // the "declaration location".
-  return D->getBeginLoc();
-}
-
-if (const auto *TD = dyn_cast(D)) {
-  // If location of the tag decl is inside a macro, but the spelling of
-  // the tag name comes from a macro argument, it looks like a special
-  // macro like NS_ENUM is being used to define the tag decl.  In that
-  // case, adjust the source location to the expansion loc so that we can
-  // attach the comment to the tag decl.
-  if (SourceMgr.isMacroArgExpansion(DeclLoc) && TD->isCompleteDefinition())
-return SourceMgr.getExpansionLoc(DeclLoc);
+// There are (at least) three types of macros we care about here.
+//
+// 1. Macros that are used in the definition of a type outside the macro,
+//with a comment attached at the macro call site.
+//```
+//#define MAKE_NAME(Foo) Name##Foo
+//
+///// Comment is here, where we use the macro.
+//struct MAKE_NAME(Foo) {
+//int a;
+//int b;
+//};
+//```
+// 2. Macros that define whole things along with the comment.
+//```
+//#define MAKE_METHOD(name) \
+//  /** Comment is here, inside the macro. */ \
+//  void name() {}
+//
+//struct S {
+//  MAKE_METHOD(f)
+//}
+//```
+// 3. Macros that both declare a type and name a decl outside the macro.
+//```
+///// Comment is here, where we use the macro.
+//typedef NS_ENUM(NSInteger, Size) {
+//SizeWidth,
+//SizeHeight
+//};
+//```
+//In this case NS_ENUM declares am enum type, and uses the same name for
+//the typedef declaration that appears outside the macro.

[PATCH] D139454: [CMake] Replace clang binary if using clang-bolt target

2023-01-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/CMakeLists.txt:959
   )
   add_custom_command(OUTPUT ${CLANG_OPTIMIZED}
 DEPENDS clang-bolt-profile

We should consider placing this and all other intermediate outputs in 
`${CMAKE_CURRENT_BINARY_DIR}`.



Comment at: clang/CMakeLists.txt:966
   -split-all-cold -split-eh -dyno-stats -icf=1 -use-gnu-stack
+COMMAND ${CMAKE_COMMAND} -E rename ${CLANG_OPTIMIZED} 
${CLANG_PATH}-${CLANG_VERSION_MAJOR}
 COMMENT "Optimizing Clang with BOLT"

This makes assumptions about the name of the binary which is chosen by CMake 
and can in theory change. Can you try to use generator expression instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139454

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


[PATCH] D140565: [Clang][CMake] Set up distribution target for Clang-BOLT

2023-01-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140565

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


[PATCH] D142014: [clangd] fix wrong CalleeArgInfo in the hover

2023-01-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:994
   HI.CalleeArgInfo.emplace(toHoverInfoParam(PVD, PP));
+  PassType.PassBy = getPassMode(PVD->getType());
+}

v1nh1shungry wrote:
> kadircet wrote:
> > sorry for showing up late to the party but instead of changing rest of the 
> > code, can we apply this logic only when there are no implicit 
> > casts/conversions between the arg and callexpr (i.e `N == &OuterNode`)?
> To make sure I understand it correctly, do you mean I should give up any 
> other code changes I made but keep this logic, and put this logic into the `N 
> == &OuterNode` branch?
> 
> Sorry if I misunderstood anything! Shame for not being a good reader :(
> To make sure I understand it correctly, do you mean I should give up any 
> other code changes I made but keep this logic, and put this logic into the N 
> == &OuterNode branch?

Somewhat.

Basically this code had the assumption that if we don't see any 
casts/conversions between the expression creating the argument and the 
expression getting passed to the callexpr, it must be passed by reference, and 
this was wrong. Even before the patch that added handling for literals.

The rest of the handling for casts/conversions/constructors in between have 
been working so far and was constructed based on what each particular cast 
does, not for specific cases hence they're easier (for the lack of a better 
word) to reason about. Hence I'd rather keep them as is, especially the changes 
in handling `MaterializeTemporaryExpr` don't sound right. I can see the example 
you've at hand, but we shouldn't be producing "converted" results for it anyway 
(the AST should have a NoOp implicit cast to `const int` and then a 
`MaterializeTemporaryExpr`, which shouldn't generated any converted signals 
with the existing code already).

Hence the my proposal is getting rid of the assumption around "if we don't see 
any casts/conversions between the expression creating the argument and the 
expression getting passed to the callexpr, it must be passed by reference", and 
use the type information in `ParmVarDecl` directly when we don't have any 
implicit nodes in between to infer `PassBy`.
This should imply also getting rid of the special case for literals (`if 
(isLiteral(E) && N->Parent == OuterNode.Parent)`).

Does that make sense?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142014

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


[PATCH] D142592: [clang-tidy][libc] Add an inline function checker for the libc project.

2023-01-26 Thread Piotr Zegar via Phabricator via cfe-commits
ClockMan added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp:31
+  // Consider functions only in header files.
+  if (!Result.SourceManager->getFilename(SrcBegin).ends_with(".h"))
+return;

Probably better would be to check if this isn't main source 
Result.SourceManager->isInMainFile(SrcBegin)



Comment at: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp:35
+  auto Loc = FullSourceLoc(SrcBegin, *Result.SourceManager);
+  if (Loc.getBufferData().starts_with("LIBC_INLINE"))
+return;

Maybe put this LIBC_INLINE into some configuration, so check could be used by 
someone else also for other macros.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142592

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


[PATCH] D142592: [clang-tidy][libc] Add an inline function checker for the libc project.

2023-01-26 Thread Piotr Zegar via Phabricator via cfe-commits
ClockMan added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp:20
+void InlineFunctionDeclCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(decl(functionDecl()).bind("func_decl"), this);
+}

or maybe even better:
Finder->addMatcher(functionDecl(unless(isExpansionInMainFile()), 
isInline()).bind("func_decl"), this);
Instead of line 26 and 32.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142592

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


[PATCH] D142550: Fix sizeof of boolean vector

2023-01-26 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 492362.
Fznamznon added a comment.

Add more sizes to test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142550

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/SemaCXX/vector-bool.cpp


Index: clang/test/SemaCXX/vector-bool.cpp
===
--- clang/test/SemaCXX/vector-bool.cpp
+++ clang/test/SemaCXX/vector-bool.cpp
@@ -90,3 +90,25 @@
   foo(eight_bools.w);// expected-error@90 {{illegal vector component name 
''w''}}
   foo(eight_bools.wyx);  // expected-error@91 {{illegal vector component name 
''wyx''}}
 }
+
+void Sizeof() {
+  using FourBools = bool __attribute__((ext_vector_type(4)));
+  using NineBools = bool __attribute__((ext_vector_type(9)));
+  using TwentyEightBools = bool __attribute__((ext_vector_type(28)));
+  using ThirtyThreeBools = bool __attribute__((ext_vector_type(33)));
+  using SixtyFiveBools = bool __attribute__((ext_vector_type(65)));
+  using Bool129 = bool __attribute__((ext_vector_type(129)));
+  using Bool150 = bool __attribute__((ext_vector_type(150)));
+  using Bool195 = bool __attribute__((ext_vector_type(195)));
+  using Bool257 = bool __attribute__((ext_vector_type(257)));
+  static_assert(sizeof(FourBools) == 1);
+  static_assert(sizeof(EightBools) == 1);
+  static_assert(sizeof(NineBools) == 2);
+  static_assert(sizeof(TwentyEightBools) == 4);
+  static_assert(sizeof(ThirtyThreeBools) == 8);
+  static_assert(sizeof(SixtyFiveBools) == 16);
+  static_assert(sizeof(Bool129) == 32);
+  static_assert(sizeof(Bool150) == 32);
+  static_assert(sizeof(Bool195) == 32);
+  static_assert(sizeof(Bool257) == 64);
+}
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2002,7 +2002,8 @@
 TypeInfo EltInfo = getTypeInfo(VT->getElementType());
 Width = VT->isExtVectorBoolType() ? VT->getNumElements()
   : EltInfo.Width * VT->getNumElements();
-// Enforce at least byte alignment.
+// Enforce at least byte size and alignment.
+Width = std::max(8, Width);
 Align = std::max(8, Width);
 
 // If the alignment is not a power of 2, round up to the next power of 2.


Index: clang/test/SemaCXX/vector-bool.cpp
===
--- clang/test/SemaCXX/vector-bool.cpp
+++ clang/test/SemaCXX/vector-bool.cpp
@@ -90,3 +90,25 @@
   foo(eight_bools.w);// expected-error@90 {{illegal vector component name ''w''}}
   foo(eight_bools.wyx);  // expected-error@91 {{illegal vector component name ''wyx''}}
 }
+
+void Sizeof() {
+  using FourBools = bool __attribute__((ext_vector_type(4)));
+  using NineBools = bool __attribute__((ext_vector_type(9)));
+  using TwentyEightBools = bool __attribute__((ext_vector_type(28)));
+  using ThirtyThreeBools = bool __attribute__((ext_vector_type(33)));
+  using SixtyFiveBools = bool __attribute__((ext_vector_type(65)));
+  using Bool129 = bool __attribute__((ext_vector_type(129)));
+  using Bool150 = bool __attribute__((ext_vector_type(150)));
+  using Bool195 = bool __attribute__((ext_vector_type(195)));
+  using Bool257 = bool __attribute__((ext_vector_type(257)));
+  static_assert(sizeof(FourBools) == 1);
+  static_assert(sizeof(EightBools) == 1);
+  static_assert(sizeof(NineBools) == 2);
+  static_assert(sizeof(TwentyEightBools) == 4);
+  static_assert(sizeof(ThirtyThreeBools) == 8);
+  static_assert(sizeof(SixtyFiveBools) == 16);
+  static_assert(sizeof(Bool129) == 32);
+  static_assert(sizeof(Bool150) == 32);
+  static_assert(sizeof(Bool195) == 32);
+  static_assert(sizeof(Bool257) == 64);
+}
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2002,7 +2002,8 @@
 TypeInfo EltInfo = getTypeInfo(VT->getElementType());
 Width = VT->isExtVectorBoolType() ? VT->getNumElements()
   : EltInfo.Width * VT->getNumElements();
-// Enforce at least byte alignment.
+// Enforce at least byte size and alignment.
+Width = std::max(8, Width);
 Align = std::max(8, Width);
 
 // If the alignment is not a power of 2, round up to the next power of 2.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142550: Fix sizeof of boolean vector

2023-01-26 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/test/SemaCXX/vector-bool.cpp:97
+  using NineBools = bool __attribute__((ext_vector_type(9)));
+  using ABunchOfBools = bool __attribute__((ext_vector_type(28)));
   static_assert(sizeof(FourBools) == 1);

erichkeane wrote:
> Fznamznon wrote:
> > erichkeane wrote:
> > > How about 33?  Does it grow appropriately with alignment?
> > Its sizeof evaluates to 8. Looking at the code in ASTContext that seems to 
> > be appropriate result since 8 is a next power of 2 after 4.
> Yep, that makes sense to me!  Can you do 1 more group for me?  
> 
> 65, 129, 150, 195, 257?
> 
> 
Sure, done. Seems to be working in the same way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142550

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


cfe-commits@lists.llvm.org

2023-01-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.



> Good to know it worked as expected on your project as well.

I have some concerns (mainly because it feels like it could be quite invasive), 
hence I'm delaying on the LGTM, I really want to run this on a large code base, 
which I think if we commit post the branch (which is now branched) we would 
probably see more easily. Historically in the past I think the firefox team 
have kindly picked up recent builds (no obligations) and catch any regressions.




Comment at: clang/lib/Format/TokenAnnotator.cpp:2766
 
-void TokenAnnotator::annotate(AnnotatedLine &Line) const {
   for (auto &Child : Line.Children)

was there a reason it could no longer be const?


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

https://reviews.llvm.org/D141959

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


[PATCH] D140059: [APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues/59515

2023-01-26 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

Thanks @Peter, I will try that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140059

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


cfe-commits@lists.llvm.org

2023-01-26 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:116-117
+   SmallVector &TrackedScopes)
+  : Scopes(TrackedScopes), Style(Style), Line(Line),
+CurrentToken(Line.First), AutoFound(false), Keywords(Keywords) {
 Contexts.push_back(Context(tok::unknown, 1, /*IsExpression=*/false));

Please keep them in the same order as that of the parameters above.



Comment at: clang/lib/Format/TokenAnnotator.cpp:852
+assert(Scopes.size() > 1);
+Scopes.pop_back();
 assert(OpeningBrace.Optional == CurrentToken->Optional);

Should we assert that the token type of `OpeningBrace` matches the `ScopeType` 
before popping?



Comment at: clang/lib/Format/TokenAnnotator.cpp:1162-1169
+  case TT_EnumLBrace:
+  case TT_ControlStatementLBrace:
+  case TT_ElseLBrace:
+  case TT_BracedListLBrace:
+  case TT_CompoundRequirementLBrace:
+  case TT_ObjCBlockLBrace:
+  case TT_RecordLBrace:

Do we really need these? If we add other special `l_brace` token types, we will 
have to update this list.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1207
+  }
   // Lines can start with '}'.
   if (Tok->Previous)

Can you leave the comment at the top of the `case`? If we get rid of `None` for 
`ScopeType`, we don't need to pop here. (See below.)



Comment at: clang/lib/Format/TokenAnnotator.cpp:2485-2487
+ PrevToken->getPreviousNonComment()->isOneOf(tok::amp, tok::period,
+ tok::arrow, 
tok::arrowstar,
+ tok::periodstar)) &&

Can you add a lambda for this so that it can be used below?



Comment at: clang/lib/Format/TokenAnnotator.cpp:2488-2490
+(NextToken && NextToken->Tok.isAnyIdentifier()) &&
+(NextToken->getNextNonComment() &&
+ (NextToken->getNextNonComment()->isOneOf(

`NextToken` is guarded against null on line 2488 but not on lines 2489-2490.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2491-2492
+ (NextToken->getNextNonComment()->isOneOf(
+ tok::amp, tok::semi, tok::period, tok::arrow, tok::arrowstar,
+ tok::periodstar {
+  return TT_BinaryOperator;

Here we can use the lambda suggested above.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2778
+: Style(Style), Keywords(Keywords) {
+  Scopes.push_back(ScopeType::None);
+}

Instead of pushing `None`, would it better to leave `Scopes` empty? Then we 
would not need `None` for the `ScopeType`, and instead of checking for 
`Scopes.size() > 1`, we could check if it's empty().



Comment at: clang/lib/Format/TokenAnnotator.h:183
 
+  enum class ScopeType : std::int8_t {
+// Not contained within scope block.

Drop `std::`.



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:192-194
+  Tokens = annotate("val1 & val2.member;");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::amp, TT_BinaryOperator);

Can you add a case for `periodstar`?



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:207-213
+  Tokens =
+  annotate("val1 & val2.member & val3.member() & val4 & val5->member;");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::amp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[5], tok::amp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[11], tok::amp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[13], tok::amp, TT_BinaryOperator);

Can you add a case for `arrowstar`?


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

https://reviews.llvm.org/D141959

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


[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2023-01-26 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan requested changes to this revision.
kiranchandramohan added a comment.
This revision now requires changes to proceed.

Use `omp.canonical_loop` once it is in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

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


[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-01-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: nickdesaulniers, aaron.ballman.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fix PR37919

The below code produces -Wconstant-logical-operand for the first statement,
but not the second.

void foo(int x) {
if (x && 5) {}
if (5 && x) {}
}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142609

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13593,18 +13593,21 @@
 Diag(Loc, diag::warn_enum_constant_in_bool_context);
 
   // Diagnose cases where the user write a logical and/or but probably meant a
-  // bitwise one.  We do this when the LHS is a non-bool integer and the RHS
-  // is a constant.
-  if (!EnumConstantInBoolContext && LHS.get()->getType()->isIntegerType() &&
-  !LHS.get()->getType()->isBooleanType() &&
-  RHS.get()->getType()->isIntegerType() && !RHS.get()->isValueDependent() 
&&
+  // bitwise one.  We do this when one of the operand is a non-bool integer and
+  // the other is a constant.
+  if (!EnumConstantInBoolContext &&
+  ((RHS.get()->getType()->isIntegerType() && 
!RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent()) 
||
+  ( RHS.get()->getType()->isIntegerType() && 
!RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && 
!LHS.get()->isValueDependent())) &&
   // Don't warn in macros or template instantiations.
   !Loc.isMacroID() && !inTemplateInstantiation()) {
-// If the RHS can be constant folded, and if it constant folds to something
+// If the operand can be constant folded, and if it constant folds to 
something
 // that isn't 0 or 1 (which indicate a potential logical operation that
 // happened to fold to true/false) then warn.
-// Parens on the RHS are ignored.
+// Parens on the operand are ignored.
 Expr::EvalResult EVResult;
+
 if (RHS.get()->EvaluateAsInt(EVResult, Context)) {
   llvm::APSInt Result = EVResult.Val.getInt();
   if ((getLangOpts().Bool && !RHS.get()->getType()->isBooleanType() &&
@@ -13626,6 +13629,28 @@
  RHS.get()->getEndLoc()));
   }
 }
+
+if (LHS.get()->EvaluateAsInt(EVResult, Context)) {
+  llvm::APSInt Result = EVResult.Val.getInt();
+  if ((getLangOpts().Bool && !LHS.get()->getType()->isBooleanType() &&
+   !LHS.get()->getExprLoc().isMacroID()) ||
+  (Result != 0 && Result != 1)) {
+Diag(Loc, diag::warn_logical_instead_of_bitwise)
+<< LHS.get()->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");
+// Suggest replacing the logical operator with the bitwise version
+Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
+<< (Opc == BO_LAnd ? "&" : "|")
+<< FixItHint::CreateReplacement(
+   SourceRange(Loc, getLocForEndOfToken(Loc)),
+   Opc == BO_LAnd ? "&" : "|");
+if (Opc == BO_LAnd)
+  // Suggest replacing "kNonZero && foo() " with "Foo()"
+  Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
+  << FixItHint::CreateRemoval(
+ SourceRange(getLocForEndOfToken(RHS.get()->getEndLoc()),
+ LHS.get()->getEndLoc()));
+  }
+}
   }
 
   if (!Context.getLangOpts().CPlusPlus) {


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13593,18 +13593,21 @@
 Diag(Loc, diag::warn_enum_constant_in_bool_context);
 
   // Diagnose cases where the user write a logical and/or but probably meant a
-  // bitwise one.  We do this when the LHS is a non-bool integer and the RHS
-  // is a constant.
-  if (!EnumConstantInBoolContext && LHS.get()->getType()->isIntegerType() &&
-  !LHS.get()->getType()->isBooleanType() &&
-  RHS.get()->getType()->isIntegerType() && !RHS.get()->isValueDependent() &&
+  // bitwise one.  We do this when one of the operand is a non-bool integer and
+  // the other is a constant.
+  if (!EnumConstantInBoolContext &&
+  ((RHS.get()->getType()->isIntegerType() && !RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent()) ||
+  ( RHS.get()->getType()->isIntegerType() && !RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent())) &&
   // Don't warn in macros or template instantiations.
   !Loc.isMacroID() && !inTemplateInstantiation()) {
-// If the RHS can be constant folded, and if it constant folds to something

[clang] e400c63 - Revert "[clang] Build UsingType for elaborated type specifiers."

2023-01-26 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-01-26T11:37:41+01:00
New Revision: e400c63cc39680538a3726a7736baf6b7844c3a8

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

LOG: Revert "[clang] Build UsingType for elaborated type specifiers."

This reverts commit e70ca7b35319a3621f9d9c6475926428f8c5c000 and the
followup patch "[clang] Fix the location of UsingTypeLoc"
(ebbeb164c25a40cb6ba9c6b18dce5dcd06c0bb07).

The patch causes an incorrect lookup result:

```
namespace ns { struct Foo { };}

using ns::Foo;
void test() {
  struct Foo {
  } k; // the type of k refers to ns::Foo, rather than the local Foo!
}
```

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CXX/drs/dr2xx.cpp
clang/test/CXX/drs/dr4xx.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SelectionTests.cpp 
b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
index 4e5c3774c1655..d7ea34c3c7054 100644
--- a/clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -520,13 +520,6 @@ TEST(SelectionTest, CommonAncestor) {
   )cpp",
"TypedefTypeLoc"},
 
-  {R"cpp(
-namespace ns { class Foo {}; }
-using ns::Foo;
-class [[^Foo]] foo;
-  )cpp",
-   "UsingTypeLoc"},
-
   // lambda captured var-decl
   {R"cpp(
 void test(int bar) {

diff  --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
index e5b99ef9a3a00..3b97cc8cdfd55 100644
--- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -150,9 +150,6 @@ TEST(WalkAST, Using) {
 }
 using ns::$explicit^Y;)cpp",
"^Y x;");
-  testWalk(R"cpp(
-namespace ns { class Foo {}; }
-  )cpp", "using ns::$explicit^Foo; class ^Foo foo;");
 }
 
 TEST(WalkAST, Namespaces) {

diff  --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index a95fe5686009b..69fe2c541607b 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -506,16 +506,8 @@ class DeclSpec {
 assert(isTypeRep((TST) TypeSpecType) && "DeclSpec does not store a type");
 return TypeRep;
   }
-  // Returns the underlying decl, if any.
   Decl *getRepAsDecl() const {
-auto *D = getRepAsFoundDecl();
-if (const auto *Using = dyn_cast_or_null(D))
-  return Using->getTargetDecl();
-return D;
-  }
-  // Returns the originally found decl, if any.
-  Decl *getRepAsFoundDecl() const {
-assert(isDeclRep((TST)TypeSpecType) && "DeclSpec does not store a decl");
+assert(isDeclRep((TST) TypeSpecType) && "DeclSpec does not store a decl");
 return DeclRep;
   }
   Expr *getRepAsExpr() const {

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3e3fb2b0cc56d..e52e853e1df86 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3327,9 +3327,7 @@ class Sema final {
   SourceLocation ScopedEnumKWLoc,
   bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
   bool IsTypeSpecifier, bool IsTemplateParamOrArg,
-  OffsetOfKind OOK,
-  UsingShadowDecl*& FoundUsingShadow,
-  SkipBodyInfo *SkipBody = nullptr);
+  OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
 
   DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc,
  unsigned TagSpec, SourceLocation TagLoc,

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index c7fd1156928ca..e6812ac72c885 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4965,7 +4965,6 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
   bool IsDependent = false;
   const char *PrevSpec = nullptr;
   unsigned DiagID;
-  UsingShadowDecl* FoundUsing = nullptr;
   Decl *TagDecl =
   Actions.ActOnTag(getCurScope(), DeclSpec::TST_enum, TUK, StartLoc, SS,
 Name, NameLoc, attrs, AS, DS.getModulePrivateSpecLoc(),
@@ -4974,7 +4973,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 BaseType, DSC == DeclSpecContext::DSC_type_specifier,
  

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

2023-01-26 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 492366.
VitaNuo added a comment.

Fix "atomic" and "div" overloads programmatically. Add a FIXME for future 
proper handling of overloads.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -41,6 +38,7 @@
 import datetime
 import os
 import sys
+import re
 
 CODE_PREFIX = """\
 //===-- gen_std.py generated file ---*- C++ -*-===//
@@ -109,18 +107,17 @@
   cppreference_modified_date = datetime.datetime.fromtimestamp(
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
+  # FIXME: take care of overloads
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if re.match("^remove$|^swap$", symbol.name) and symbol.namespace == "std::":
+  continue
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  symbol.headers = sorted(symbol.headers)
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -47,7 +47,7 @@
 
   Returns a list of headers.
   """
-  headers = set()
+  symbol_headers = set()
   all_headers = set()
 
   soup = BeautifulSoup(symbol_page_html, "html.parser")
@@ -58,32 +58,54 @@
   #   Defined in header   .t-dsc-header
   #   decl2.t-dcl
   for table in soup.select('table.t-dcl-begin, table.t-dsc-begin'):
-current_headers = []
-was_decl = False
-for row in table.select('tr'):
-  if _HasClass(row, 't-dcl', 't-dsc'):
-was_decl = True
-# Symbols are in the first cell.
-found_symbols = row.find('td').stripped_strings
-if not symbol_name in found_symbols:
-  continue
-headers.update(current_headers)
-  elif _HasClass(row, 't-dsc-header'):
-# If we saw a decl since the last header, this is a new block of headers
-# for a new block of decls.
-if was_decl:
-  current_headers = []
-was_decl = False
+rows = table.select('tr')
+i = 0
+while i < len(rows):
+  start = i
+  current_headers = set()
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-header'):
+row = rows[i]
 # There are also .t-dsc-header for "defined in namespace".
 if not "Defined in header " in row.text:
+  i = i + 1
   continue
 # The interesting header content (e.g. ) is wrapped in .
 for header_code in row.find_all("code"):
-  current_headers.append(header_code.text)
   all_headers.add(header_code.text)
-  # If the symbol was never named, consider all named headers.
-  return headers or all_headers
-
+  current_headers.add(header_code.text)
+i = i + 1
+  # Some tables have header rows, skip them.  
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-hitem'):
+i = i + 1
+  while i < len(rows) and (_HasClass(rows[i], 't-dcl', 't-dsc')
+   or not rows[i].has_attr("class")):
+row = rows[i]
+# Symbols are in the first cell.
+raw_symbols = row.find('td').stripped_strings
+ 

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

2023-01-26 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo marked 2 inline comments as done.
VitaNuo 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::, )

hokein wrote:
> 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.
They're all back now.



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

kadircet wrote:
> hokein wrote:
> > 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.
> I don't follow why we can't perform this detection directly, haven't been 
> taking a look at the details but the page looks like:
> ```
> Defined in header 
> template< class T > struct atomic;
> template< class U > struct atomic;
> Defined in header 
> template< class U > struct atomic>;
> template< class U > struct atomic>;
> Defined in header 
> #define _Atomic(T) /* see below */
> ```
> 
> So `_ParseSymbolPage`, first sees  then a bunch of decls, then 
>  then a bunch more decls and so on, and in the end it returns all the 
> headers it has found.
> 
> Why can't we change the logic here to return `nothing` when there are 
> different decls && headers? i.e. return empty if we see a new header after 
> seeing some declarations.
> does this result in undesired behaviour elsewhere?
Ok, I've fixed (or hacked :) this programmatically.
The parsing of constants in 
https://en.cppreference.com/w/cpp/locale/codecvt_mode is not complete now, 
everything is attributed to the "codecvt" header, the "locale" header is 
ignored. Hope it's OK.
If not, then I'm afraid I can only special-case the "atomic.*" symbols.


===

[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-01-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 492374.
xgupta added a comment.

add test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/exprs.c
  clang/test/SemaCXX/expressions.cpp

Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,6 +44,9 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+   // expected-note {{use '&' for a bitwise operation}} \
+   // expected-note {{remove constant to silence this warning}}
 
   return x && sizeof(int) == 4;  // no warning, RHS is logical op.
   return x && true;
@@ -66,6 +69,8 @@
// expected-note {{use '|' for a bitwise operation}}
   return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
// expected-note {{use '|' for a bitwise operation}}
+  return 5 || x; // expected-warning {{use of logical '||' with constant operand}} \
+   // expected-note {{use '|' for a bitwise operation}}
   return x && 0; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -212,6 +212,10 @@
  // expected-note {{use '&' for a bitwise operation}} \
  // expected-note {{remove constant to silence this warning}}
 
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+
   return x && sizeof(int) == 4;  // no warning, RHS is logical op.
   
   // no warning, this is an idiom for "true" in old C style.
@@ -223,6 +227,9 @@
   // expected-note {{use '|' for a bitwise operation}}
   return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
  // expected-note {{use '|' for a bitwise operation}}
+  return 5 || x; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+
   return x && 0;
   return x && 1;
   return x && -1; // expected-warning {{use of logical '&&' with constant operand}} \
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13593,18 +13593,21 @@
 Diag(Loc, diag::warn_enum_constant_in_bool_context);
 
   // Diagnose cases where the user write a logical and/or but probably meant a
-  // bitwise one.  We do this when the LHS is a non-bool integer and the RHS
-  // is a constant.
-  if (!EnumConstantInBoolContext && LHS.get()->getType()->isIntegerType() &&
-  !LHS.get()->getType()->isBooleanType() &&
-  RHS.get()->getType()->isIntegerType() && !RHS.get()->isValueDependent() &&
+  // bitwise one.  We do this when one of the operand is a non-bool integer and
+  // the other is a constant.
+  if (!EnumConstantInBoolContext &&
+  ((RHS.get()->getType()->isIntegerType() && !RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent()) ||
+  ( RHS.get()->getType()->isIntegerType() && !RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent())) &&
   // Don't warn in macros or template instantiations.
   !Loc.isMacroID() && !inTemplateInstantiation()) {
-// If the RHS can be constant folded, and if it constant folds to something
+// If the operand can be constant folded, and if it constant folds to something
 // that isn't 0 or 1 (which indicate a potential logical operation that
 // happened to fold to true/false) then warn.
-// Parens on the RHS are ignored.
+// Parens on the operand are ignored.
 Expr::EvalResult EVResult;
+
 if (RHS.get()->EvaluateAsInt(EVResult, Context)) {
   llvm::APSInt Result = EVResult.Val.getInt();
   if ((getLangOpts().Bool && !RHS.get()->getType()->isBooleanType() &&
@@ -13626,6 +13629,28 @@
  RHS.get()->getEndLoc()));
   }
 }
+
+if (LHS.get()->EvaluateAsInt(EVResult, Contex

[clang] 55c9ad9 - [clang] Add test for CWG1960

2023-01-26 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-01-26T14:31:24+03:00
New Revision: 55c9ad99d12d18ee91a4c3e3609a0aacbaa5174e

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

LOG: [clang] Add test for CWG1960

P1787: "CWG1960 (currently closed as NAD) is resolved by removing the rule in 
question (which is widely ignored by implementations and gives subtle 
interactions between using-declarations)."
Wording: "In a using-declarator that does not name a constructor, every 
declaration named shall be accessible."

Reviewed By: #clang-language-wg, erichkeane, shafik

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

Added: 


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

Removed: 




diff  --git a/clang/test/CXX/drs/dr19xx.cpp b/clang/test/CXX/drs/dr19xx.cpp
index 08ee2ee77a84f..65a14da66f974 100644
--- a/clang/test/CXX/drs/dr19xx.cpp
+++ b/clang/test/CXX/drs/dr19xx.cpp
@@ -167,6 +167,27 @@ namespace dr1959 { // dr1959: 3.9
 #endif
 }
 
+namespace dr1960 { // dr1960: no
+struct A {
+void f() {}
+protected:
+void g() {}
+};
+
+struct B: A {
+private:
+using A::f;
+using A::g;
+};
+
+struct C : B {
+// FIXME: both declarations are ill-formed, because A::f and A::g
+// are not accessible.
+using A::f;
+using A::g;
+};
+}
+
 namespace dr1966 { // dr1966: 11
 #if __cplusplus >= 201103L
   struct A {

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 0c621a7894340..b54c65e034066 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -11567,7 +11567,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg1960";>1960
 NAD
 Visibility of entity named in class-scope using-declaration
-Unknown
+No
   
   
 https://wg21.link/cwg1961";>1961



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


[PATCH] D142297: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This change broke the `parallel/bug54082.c` testcase in the OpenMP runtime test 
set, when running on Windows (both mingw and MSVC configurations, and happening 
both in i386 and x86_64 builds), see e.g. 
https://github.com/mstorsjo/llvm-mingw/actions/runs/4011290068/jobs/6891673869. 
It's failing with error code `0xC0FD`, which means `STATUS_STACK_OVERFLOW`. 
Is this change missing some aspect that differs between the unix and Windows 
ABIs?

So please don't backport this to the release branch right now. And I'd 
appreciate if you would consider to revert it if there's no immediately obvious 
fix in sight.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142297

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


[clang] 839eae3 - [clang] Add test for CWG1960

2023-01-26 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-01-26T14:40:47+03:00
New Revision: 839eae38a4e4064568e1b3b0ee9538958ead8a40

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

LOG: [clang] Add test for CWG1960

P1787: "CWG1960 (currently closed as NAD) is resolved by removing the rule in 
question (which is widely ignored by implementations and gives subtle 
interactions between using-declarations)."
Wording: "In a using-declarator that does not name a constructor, every 
declaration named shall be accessible."

Reviewed By: #clang-language-wg, erichkeane, shafik

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

Added: 


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

Removed: 




diff  --git a/clang/test/CXX/drs/dr19xx.cpp b/clang/test/CXX/drs/dr19xx.cpp
index 08ee2ee77a84f..65a14da66f974 100644
--- a/clang/test/CXX/drs/dr19xx.cpp
+++ b/clang/test/CXX/drs/dr19xx.cpp
@@ -167,6 +167,27 @@ namespace dr1959 { // dr1959: 3.9
 #endif
 }
 
+namespace dr1960 { // dr1960: no
+struct A {
+void f() {}
+protected:
+void g() {}
+};
+
+struct B: A {
+private:
+using A::f;
+using A::g;
+};
+
+struct C : B {
+// FIXME: both declarations are ill-formed, because A::f and A::g
+// are not accessible.
+using A::f;
+using A::g;
+};
+}
+
 namespace dr1966 { // dr1966: 11
 #if __cplusplus >= 201103L
   struct A {

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 0c621a7894340..b54c65e034066 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -11567,7 +11567,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg1960";>1960
 NAD
 Visibility of entity named in class-scope using-declaration
-Unknown
+No
   
   
 https://wg21.link/cwg1961";>1961



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


[PATCH] D142381: [clang] Add test for CWG1960

2023-01-26 Thread Vlad Serebrennikov 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 rG839eae38a4e4: [clang] Add test for CWG1960 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142381

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


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -11567,7 +11567,7 @@
 https://wg21.link/cwg1960";>1960
 NAD
 Visibility of entity named in class-scope using-declaration
-Unknown
+No
   
   
 https://wg21.link/cwg1961";>1961
Index: clang/test/CXX/drs/dr19xx.cpp
===
--- clang/test/CXX/drs/dr19xx.cpp
+++ clang/test/CXX/drs/dr19xx.cpp
@@ -167,6 +167,27 @@
 #endif
 }
 
+namespace dr1960 { // dr1960: no
+struct A {
+void f() {}
+protected:
+void g() {}
+};
+
+struct B: A {
+private:
+using A::f;
+using A::g;
+};
+
+struct C : B {
+// FIXME: both declarations are ill-formed, because A::f and A::g
+// are not accessible.
+using A::f;
+using A::g;
+};
+}
+
 namespace dr1966 { // dr1966: 11
 #if __cplusplus >= 201103L
   struct A {


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -11567,7 +11567,7 @@
 https://wg21.link/cwg1960";>1960
 NAD
 Visibility of entity named in class-scope using-declaration
-Unknown
+No
   
   
 https://wg21.link/cwg1961";>1961
Index: clang/test/CXX/drs/dr19xx.cpp
===
--- clang/test/CXX/drs/dr19xx.cpp
+++ clang/test/CXX/drs/dr19xx.cpp
@@ -167,6 +167,27 @@
 #endif
 }
 
+namespace dr1960 { // dr1960: no
+struct A {
+void f() {}
+protected:
+void g() {}
+};
+
+struct B: A {
+private:
+using A::f;
+using A::g;
+};
+
+struct C : B {
+// FIXME: both declarations are ill-formed, because A::f and A::g
+// are not accessible.
+using A::f;
+using A::g;
+};
+}
+
 namespace dr1966 { // dr1966: 11
 #if __cplusplus >= 201103L
   struct A {
___
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-26 Thread Tom Eccles via Phabricator via cfe-commits
tblah added a comment.

In D140415#4080080 , @jdoerfert wrote:

> Did you check LLVM's heap2stack and the corresponding tests?
> https://github.com/llvm/llvm-project/blob/c68af565ff0c2fdc5537e9ac0c2d7c75df44b035/llvm/lib/Transforms/IPO/AttributorAttributes.cpp#L6480
> https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/Attributor/heap_to_stack.ll
> https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll

The LLVM pass seems to make quite different design decisions to this pass. The 
LLVM pass does limit the maximum size of allocations moved to the stack, but 
does not attempt to avoid placing allocations inside of loops (and does not 
seem to attempt to move allocations to the entry block). The LLVM pass also 
supports exceptions, which this pass does not (as there are no exceptions in 
Fortran).

There is also a similar MLIR pass (promote buffers to stack). The MLIR pass 
operates on the memref dialect, which is a slightly different problem space 
because there are no explicit free() instructions to detect. Furthermore, the 
MLIR pass does not attempt to hoist allocations outside of loops and only 
detects structured loop operations (LoopLikeOpInterface) not loops formed from 
branch operations in the control flow graph.


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] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-01-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

WIP && TODO- Fixed test

Failed Tests (7):

  Clang :: C/drs/dr4xx.c
  Clang :: Modules/explicit-build-extra-files.cpp
  Clang :: Parser/cxx2a-concept-declaration.cpp
  Clang :: SemaCXX/expressions.cpp
  Clang :: SemaCXX/warn-unsequenced.cpp
  Clang :: SemaObjC/unguarded-availability.m
  Clang :: SemaTemplate/dependent-expr.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

___
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-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

At least a part of the failures is reproducible with `-target aarch64` option. 
I try to fix the failures.


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] D142065: [SVE] Fix incorrect lowering of predicate permute builtins.

2023-01-26 Thread Paul Walker 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 rG26b79ca3fafc: [SVE] Fix incorrect lowering of predicate 
permute builtins. (authored by paulwalker-arm).

Changed prior to commit:
  https://reviews.llvm.org/D142065?vs=490332&id=492387#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142065

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -942,8 +942,8 @@
 ; REV
 ;
 
-define  @rev_b8(  %a) {
-; CHECK-LABEL: rev_b8:
+define  @rev_nxv16i1( %a) {
+; CHECK-LABEL: rev_nxv16i1:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:rev p0.b, p0.b
 ; CHECK-NEXT:ret
@@ -951,8 +951,8 @@
   ret  %res
 }
 
-define  @rev_b16( %a) {
-; CHECK-LABEL: rev_b16:
+define  @rev_nxv8i1( %a) {
+; CHECK-LABEL: rev_nxv8i1:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:rev p0.h, p0.h
 ; CHECK-NEXT:ret
@@ -960,8 +960,8 @@
   ret  %res
 }
 
-define  @rev_b32( %a) {
-; CHECK-LABEL: rev_b32:
+define  @rev_nxv4i1( %a) {
+; CHECK-LABEL: rev_nxv4i1:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:rev p0.s, p0.s
 ; CHECK-NEXT:ret
@@ -969,8 +969,8 @@
   ret  %res
 }
 
-define  @rev_b64( %a) {
-; CHECK-LABEL: rev_b64:
+define  @rev_nxv2i1( %a) {
+; CHECK-LABEL: rev_nxv2i1:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:rev p0.d, p0.d
 ; CHECK-NEXT:ret
@@ -978,7 +978,34 @@
   ret  %res
 }
 
-define  @rev_i8(  %a) {
+define  @rev_b16( %a) {
+; CHECK-LABEL: rev_b16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rev p0.h, p0.h
+; CHECK-NEXT:ret
+  %res = call  @llvm.aarch64.sve.rev.b16( %a)
+  ret  %res
+}
+
+define  @rev_b32( %a) {
+; CHECK-LABEL: rev_b32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rev p0.s, p0.s
+; CHECK-NEXT:ret
+  %res = call  @llvm.aarch64.sve.rev.b32( %a)
+  ret  %res
+}
+
+define  @rev_b64( %a) {
+; CHECK-LABEL: rev_b64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:rev p0.d, p0.d
+; CHECK-NEXT:ret
+  %res = call  @llvm.aarch64.sve.rev.b64( %a)
+  ret  %res
+}
+
+define  @rev_i8( %a) {
 ; CHECK-LABEL: rev_i8:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:rev z0.b, z0.b
@@ -1354,8 +1381,8 @@
 ; TRN1
 ;
 
-define  @trn1_b8( %a,  %b) {
-; CHECK-LABEL: trn1_b8:
+define  @trn1_nxv16i1( %a,  %b) {
+; CHECK-LABEL: trn1_nxv16i1:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:trn1 p0.b, p0.b, p1.b
 ; CHECK-NEXT:ret
@@ -1364,8 +1391,8 @@
   ret  %out
 }
 
-define  @trn1_b16( %a,  %b) {
-; CHECK-LABEL: trn1_b16:
+define  @trn1_nxv8i1( %a,  %b) {
+; CHECK-LABEL: trn1_nxv8i1:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:trn1 p0.h, p0.h, p1.h
 ; CHECK-NEXT:ret
@@ -1374,8 +1401,8 @@
   ret  %out
 }
 
-define  @trn1_b32( %a,  %b) {
-; CHECK-LABEL: trn1_b32:
+define  @trn1_nxv4i1( %a,  %b) {
+; CHECK-LABEL: trn1_nxv4i1:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:trn1 p0.s, p0.s, p1.s
 ; CHECK-NEXT:ret
@@ -1384,8 +1411,8 @@
   ret  %out
 }
 
-define  @trn1_b64( %a,  %b) {
-; CHECK-LABEL: trn1_b64:
+define  @trn1_nxv2i1( %a,  %b) {
+; CHECK-LABEL: trn1_nxv2i1:
 ; CHECK:   // %bb.0:
 ; CHECK-NEXT:trn1 p0.d, p0.d, p1.d
 ; CHECK-NEXT:ret
@@ -1394,6 +1421,36 @@
   ret  %out
 }
 
+define  @trn1_b16( %a,  %b) {
+; CHECK-LABEL: trn1_b16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:trn1 p0.h, p0.h, p1.h
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.trn1.b16( %a,
+ %b)
+  ret  %out
+}
+
+define  @trn1_b32( %a,  %b) {
+; CHECK-LABEL: trn1_b32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:trn1 p0.s, p0.s, p1.s
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.trn1.b32( %a,
+ %b)
+  ret  %out
+}
+
+define  @trn1_b64( %a,  %b) {
+; CHECK-LABEL: trn1_b64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:trn1 p0.d, p0.d, p1.d
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.trn1.b64( %a,
+ %b)
+  ret  %out
+}
+
 define  @trn1_i8( %a,  %b) {
 ; CHECK-LABEL: trn1_i8:
 ; CHECK:   // %bb.0:
@@ -1508,8 +

[clang] 26b79ca - [SVE] Fix incorrect lowering of predicate permute builtins.

2023-01-26 Thread Paul Walker via cfe-commits

Author: Paul Walker
Date: 2023-01-26T12:10:39Z
New Revision: 26b79ca3fafc525225090646d42837368b3763c3

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

LOG: [SVE] Fix incorrect lowering of predicate permute builtins.

When lowering predicate permute builtins we incorrectly assume only
the typically "active" bits for the specified element type play a
role with all other bits zero'd.  This is not the case because all
bits are significant, with the element type specifying how they
are grouped:

  b8  - permute using a block size of 1 bit
  b16 - permute using a block size of 2 bits
  b32 - permute using a block size of 4 bits
  b64 - permute using a block size of 8 bits

The affected builtins are svrev, svtrn1, svtrn2, svuzp1, svuzp2,
svzip1 and svzip2.

This patch adds new intrinsics to support these operations and
changes the builtin lowering code to emit them.  The b8 case remains
unchanged because for that operation the existing intrinsics work
as required and their support for other predicate types has been
maintained as useful if only as a way to test the correctness of
their matching ISD nodes that code generation relies on.

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

Added: 


Modified: 
clang/include/clang/Basic/arm_sve.td
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2.c
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index e910036117b7c..e547bbd34b5e9 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1249,16 +1249,37 @@ def SVZIP1_BF16   : SInst<"svzip1[_{d}]",   "ddd",  
"b", MergeNone, "aarch64_sve
 def SVZIP2_BF16   : SInst<"svzip2[_{d}]",   "ddd",  "b", MergeNone, 
"aarch64_sve_zip2">;
 }
 
-def SVREV_B   : SInst<"svrev_{d}",  "PP",   "PcPsPiPl", MergeNone, 
"aarch64_sve_rev">;
-def SVSEL_B   : SInst<"svsel[_b]",  "", "Pc",   MergeNone, 
"aarch64_sve_sel">;
-def SVTRN1_B  : SInst<"svtrn1_{d}", "PPP",  "PcPsPiPl", MergeNone, 
"aarch64_sve_trn1">;
-def SVTRN2_B  : SInst<"svtrn2_{d}", "PPP",  "PcPsPiPl", MergeNone, 
"aarch64_sve_trn2">;
-def SVPUNPKHI : SInst<"svunpkhi[_b]",   "PP",   "Pc",   MergeNone, 
"aarch64_sve_punpkhi">;
-def SVPUNPKLO : SInst<"svunpklo[_b]",   "PP",   "Pc",   MergeNone, 
"aarch64_sve_punpklo">;
-def SVUZP1_B  : SInst<"svuzp1_{d}", "PPP",  "PcPsPiPl", MergeNone, 
"aarch64_sve_uzp1">;
-def SVUZP2_B  : SInst<"svuzp2_{d}", "PPP",  "PcPsPiPl", MergeNone, 
"aarch64_sve_uzp2">;
-def SVZIP1_B  : SInst<"svzip1_{d}", "PPP",  "PcPsPiPl", MergeNone, 
"aarch64_sve_zip1">;
-def SVZIP2_B  : SInst<"svzip2_{d}", "PPP",  "PcPsPiPl", MergeNone, 
"aarch64_sve_zip2">;
+def SVREV_B8   : SInst<"svrev_b8", "PP",   "Pc", MergeNone, 
"aarch64_sve_rev">;
+def SVREV_B16  : SInst<"svrev_b16","PP",   "Pc", MergeNone, 
"aarch64_sve_rev_b16",  [IsOverloadNone]>;
+def SVREV_B32  : SInst<"svrev_b32","PP",   "Pc", MergeNone, 
"aarch64_sve_rev_b32",  [IsOverloadNone]>;
+def SVREV_B64  : SInst<"svrev_b64","PP",   "Pc", MergeNone, 
"aarch64_sve_rev_b64",  [IsOverloadNone]>;
+def SVSEL_B: SInst<"svsel[_b]","", "Pc", MergeNone, 
"aarch64_sve_sel">;
+def SVTRN1_B8  : SInst<"svtrn1_b8","PPP",  "Pc", MergeNone, 
"aarch64_sve_trn1">;
+def SVTRN1_B16 : SInst<"svtrn1_b16",   "PPP",  "Pc", MergeNone, 
"aarch64_sve_trn1_b16", [IsOverloadNone]>;
+def SVTRN1_B32 : SInst<"svtrn1_b32",   "PPP",  "Pc", MergeNone, 
"aarch64_sve_trn1_b32", [IsOverloadNone]>;
+def SVTRN1_B64 : SInst<"svtrn1_b64",   "PPP",  "Pc", MergeNone, 
"aarch64_sve_trn1_b64", [IsOverloadNone]>;
+def SVTRN2_B8  : SInst<"svtrn2_b8","PPP",  "Pc", MergeNone, 
"aarch64_sve_trn2">;
+def SVTRN2_B16 : SInst<"svtrn2_b16",   "PPP",  "Pc", MergeNone, 
"aarch64_sve_trn2_b16", [IsOverloadNone]>;
+def SVTRN2_B32 : SInst<"svtrn2_b32",   "PPP",  "Pc", MergeNone, 
"aarch64_sve_trn2_b32", [IsOverloadNone]>;
+def SVTRN2_B64 : SInst<"svtrn2_b64",   "PPP",  "Pc", MergeNone, 
"aarch64_sve_trn2_b64", [IsOverloadNone]>;
+def SVPUNPKHI  : SInst<"svunpkhi[_b]", "PP",   "Pc", MergeNone, 
"aarch64_sve_punpkhi">;
+def SVPUNPKLO  : SInst<"svunpklo[_b]", "PP",   "Pc", MergeNone, 
"aa

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

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

I am attempting to reduce the compiler crash on 32 bit, it's a slow process.


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] D142401: [Clang] Fix a crash when recursively callig a default member initializer.

2023-01-26 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D142401#4074959 , @shafik wrote:

> I could not find any tests that test for this warning.

I'm unable to trigger the warning at all. I feel i should but just using that 
function resolves the crash, probably because it allocates more stack in a 
separate thread, and there is actually some code that avoids marking the same 
object used twice.
But the warning might still trigger on some platform, so i suspect the test i 
added might, sometimes, trigger a warning. I'm not exactly sure how to handle 
that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142401

___
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-26 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added a comment.

Thx @efriedma for reminding me of this.
I'll update the documentation and try to give a shot at removing `MaybeAlign` 
from `GlobalObject`.


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] D142315: [clang] Add test for CWG1111

2023-01-26 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill updated this revision to Diff 492395.
Endill added a comment.

Change status from "6" to "yes" since "ambiguous-member-template" warning is a 
false-positive now.

- Disable "ambiguous-member-template" diagnostic in 98 and 03 modes
- Add an example (`struct A`)
- Apply clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142315

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


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -6473,7 +6473,7 @@
 https://wg21.link/cwg";>
 C++11
 Remove dual-scope lookup of member template names
-Unknown
+Yes
   
   
 https://wg21.link/cwg1112";>1112
Index: clang/test/CXX/drs/dr11xx.cpp
===
--- clang/test/CXX/drs/dr11xx.cpp
+++ clang/test/CXX/drs/dr11xx.cpp
@@ -4,6 +4,46 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
+namespace dr { // dr: yes
+namespace example1 {
+template  struct set;
+
+struct X {
+  template  void set(const T &value);
+};
+void foo() {
+  X x;
+#pragma clang diagnostic push
+#if __cplusplus < 201103L
+#pragma clang diagnostic ignored "-Wambiguous-member-template"
+#endif
+  x.set(3.2);
+#pragma clang diagnostic pop
+}
+
+struct Y {};
+void bar() {
+  Y y;
+  y.set(3.2); // expected-error {{no member named 'set' in 
'dr::example1::Y'}}
+}
+} // namespace example1
+
+namespace example2 {
+struct A {};
+namespace N {
+struct A {
+  void g() {}
+  template  operator T();
+};
+} // namespace N
+
+void baz() {
+  N::A a;
+  a.operator A();
+}
+} // namespace example2
+} // namespace dr
+
 namespace dr1113 { // dr1113: partial
   namespace named {
 extern int a; // expected-note {{previous}}


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -6473,7 +6473,7 @@
 https://wg21.link/cwg";>
 C++11
 Remove dual-scope lookup of member template names
-Unknown
+Yes
   
   
 https://wg21.link/cwg1112";>1112
Index: clang/test/CXX/drs/dr11xx.cpp
===
--- clang/test/CXX/drs/dr11xx.cpp
+++ clang/test/CXX/drs/dr11xx.cpp
@@ -4,6 +4,46 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
+namespace dr { // dr: yes
+namespace example1 {
+template  struct set;
+
+struct X {
+  template  void set(const T &value);
+};
+void foo() {
+  X x;
+#pragma clang diagnostic push
+#if __cplusplus < 201103L
+#pragma clang diagnostic ignored "-Wambiguous-member-template"
+#endif
+  x.set(3.2);
+#pragma clang diagnostic pop
+}
+
+struct Y {};
+void bar() {
+  Y y;
+  y.set(3.2); // expected-error {{no member named 'set' in 'dr::example1::Y'}}
+}
+} // namespace example1
+
+namespace example2 {
+struct A {};
+namespace N {
+struct A {
+  void g() {}
+  template  operator T();
+};
+} // namespace N
+
+void baz() {
+  N::A a;
+  a.operator A();
+}
+} // namespace example2
+} // namespace dr
+
 namespace dr1113 { // dr1113: partial
   namespace named {
 extern int a; // expected-note {{previous}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142315: [clang] Add test for CWG1111

2023-01-26 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added inline comments.



Comment at: clang/test/CXX/drs/dr11xx.cpp:1
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98 -fexceptions 
-fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors

erichkeane wrote:
> I see what happened now: Add `-Wno-error=ambiguous-member-template` to this 
> line.
Thank you for suggestion, but I'd like to avoid making changes that could 
affect other tests (now and in the future), so I went pragma way.



Comment at: clang/test/CXX/drs/dr11xx.cpp:31
+  }
+}
+

Endill wrote:
> erichkeane wrote:
> > Can you also add the last example (with struct A) from the issue, and find 
> > a way to confirm that it is calling the right version?
> Nice catch, thank you. Long exposure to P1787 makes one pay less attention to 
> resolutions in CWG issues, it seems :)
Done!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142315

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


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

2023-01-26 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 492396.
VitaNuo marked an inline comment as done.
VitaNuo added a comment.

Remove special casing from gen_std.py. Re-introduce special handling for 
std::remove.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -41,6 +38,7 @@
 import datetime
 import os
 import sys
+import re
 
 CODE_PREFIX = """\
 //===-- gen_std.py generated file ---*- C++ -*-===//
@@ -109,18 +107,15 @@
   cppreference_modified_date = datetime.datetime.fromtimestamp(
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
+  # FIXME: take care of overloads
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  symbol.headers = sorted(symbol.headers)
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -36,7 +36,7 @@
   return False
 
 
-def _ParseSymbolPage(symbol_page_html, symbol_name):
+def _ParseSymbolPage(symbol_page_html, symbol_name, header_to_accept):
   """Parse symbol page and retrieve the include header defined in this page.
   The symbol page provides header for the symbol, specifically in
   "Defined in header " section. An example:
@@ -47,7 +47,7 @@
 
   Returns a list of headers.
   """
-  headers = set()
+  symbol_headers = set()
   all_headers = set()
 
   soup = BeautifulSoup(symbol_page_html, "html.parser")
@@ -58,32 +58,57 @@
   #   Defined in header   .t-dsc-header
   #   decl2.t-dcl
   for table in soup.select('table.t-dcl-begin, table.t-dsc-begin'):
-current_headers = []
-was_decl = False
-for row in table.select('tr'):
-  if _HasClass(row, 't-dcl', 't-dsc'):
-was_decl = True
-# Symbols are in the first cell.
-found_symbols = row.find('td').stripped_strings
-if not symbol_name in found_symbols:
-  continue
-headers.update(current_headers)
-  elif _HasClass(row, 't-dsc-header'):
-# If we saw a decl since the last header, this is a new block of headers
-# for a new block of decls.
-if was_decl:
-  current_headers = []
-was_decl = False
+rows = table.select('tr')
+i = 0
+while i < len(rows):
+  start = i
+  current_headers = set()
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-header'):
+row = rows[i]
 # There are also .t-dsc-header for "defined in namespace".
 if not "Defined in header " in row.text:
+  i = i + 1
   continue
 # The interesting header content (e.g. ) is wrapped in .
 for header_code in row.find_all("code"):
-  current_headers.append(header_code.text)
+  # FIXME: replace with proper handling of overloads
+  if header_to_accept != "" and header_code.text.strip("<>") != header_to_accept:
+continue
   all_headers.add(header_code.text)
-  # If the symbol was never named, consider all named headers.
-  return headers o

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

2023-01-26 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 492398.
VitaNuo added a comment.

Formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -41,6 +38,7 @@
 import datetime
 import os
 import sys
+import re
 
 CODE_PREFIX = """\
 //===-- gen_std.py generated file ---*- C++ -*-===//
@@ -109,18 +107,15 @@
   cppreference_modified_date = datetime.datetime.fromtimestamp(
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
+  # FIXME: take care of overloads
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  symbol.headers = sorted(symbol.headers)
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -36,7 +36,7 @@
   return False
 
 
-def _ParseSymbolPage(symbol_page_html, symbol_name):
+def _ParseSymbolPage(symbol_page_html, symbol_name, header_to_accept):
   """Parse symbol page and retrieve the include header defined in this page.
   The symbol page provides header for the symbol, specifically in
   "Defined in header " section. An example:
@@ -47,7 +47,7 @@
 
   Returns a list of headers.
   """
-  headers = set()
+  symbol_headers = set()
   all_headers = set()
 
   soup = BeautifulSoup(symbol_page_html, "html.parser")
@@ -58,32 +58,57 @@
   #   Defined in header   .t-dsc-header
   #   decl2.t-dcl
   for table in soup.select('table.t-dcl-begin, table.t-dsc-begin'):
-current_headers = []
-was_decl = False
-for row in table.select('tr'):
-  if _HasClass(row, 't-dcl', 't-dsc'):
-was_decl = True
-# Symbols are in the first cell.
-found_symbols = row.find('td').stripped_strings
-if not symbol_name in found_symbols:
-  continue
-headers.update(current_headers)
-  elif _HasClass(row, 't-dsc-header'):
-# If we saw a decl since the last header, this is a new block of headers
-# for a new block of decls.
-if was_decl:
-  current_headers = []
-was_decl = False
+rows = table.select('tr')
+i = 0
+while i < len(rows):
+  start = i
+  current_headers = set()
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-header'):
+row = rows[i]
 # There are also .t-dsc-header for "defined in namespace".
 if not "Defined in header " in row.text:
+  i = i + 1
   continue
 # The interesting header content (e.g. ) is wrapped in .
 for header_code in row.find_all("code"):
-  current_headers.append(header_code.text)
+  # FIXME: replace with proper handling of overloads
+  if header_to_accept != "" and header_code.text.strip("<>") != header_to_accept:
+continue
   all_headers.add(header_code.text)
-  # If the symbol was never named, consider all named headers.
-  return headers or all_headers
-
+  current_headers.add(header_code.text)
+i = i + 1
+  # Some tables have header 

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

2023-01-26 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 492400.
VitaNuo added a comment.

Formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -41,6 +38,7 @@
 import datetime
 import os
 import sys
+import re
 
 CODE_PREFIX = """\
 //===-- gen_std.py generated file ---*- C++ -*-===//
@@ -109,18 +107,15 @@
   cppreference_modified_date = datetime.datetime.fromtimestamp(
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
+  # FIXME: take care of overloads
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  symbol.headers = sorted(symbol.headers)
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -36,7 +36,7 @@
   return False
 
 
-def _ParseSymbolPage(symbol_page_html, symbol_name):
+def _ParseSymbolPage(symbol_page_html, symbol_name, header_to_accept):
   """Parse symbol page and retrieve the include header defined in this page.
   The symbol page provides header for the symbol, specifically in
   "Defined in header " section. An example:
@@ -47,7 +47,7 @@
 
   Returns a list of headers.
   """
-  headers = set()
+  symbol_headers = set()
   all_headers = set()
 
   soup = BeautifulSoup(symbol_page_html, "html.parser")
@@ -58,32 +58,57 @@
   #   Defined in header   .t-dsc-header
   #   decl2.t-dcl
   for table in soup.select('table.t-dcl-begin, table.t-dsc-begin'):
-current_headers = []
-was_decl = False
-for row in table.select('tr'):
-  if _HasClass(row, 't-dcl', 't-dsc'):
-was_decl = True
-# Symbols are in the first cell.
-found_symbols = row.find('td').stripped_strings
-if not symbol_name in found_symbols:
-  continue
-headers.update(current_headers)
-  elif _HasClass(row, 't-dsc-header'):
-# If we saw a decl since the last header, this is a new block of headers
-# for a new block of decls.
-if was_decl:
-  current_headers = []
-was_decl = False
+rows = table.select('tr')
+i = 0
+while i < len(rows):
+  start = i
+  current_headers = set()
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-header'):
+row = rows[i]
 # There are also .t-dsc-header for "defined in namespace".
 if not "Defined in header " in row.text:
+  i = i + 1
   continue
 # The interesting header content (e.g. ) is wrapped in .
 for header_code in row.find_all("code"):
-  current_headers.append(header_code.text)
+  # FIXME: replace with proper handling of overloads
+  if header_to_accept != "" and header_code.text.strip("<>") != header_to_accept:
+continue
   all_headers.add(header_code.text)
-  # If the symbol was never named, consider all named headers.
-  return headers or all_headers
-
+  current_headers.add(header_code.text)
+i = i + 1
+  # Some tables have header 

[PATCH] D142617: [clang][Interp] Check This pointer without creating InterpFrame

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

  The InterpFrame was only created so early so we could use getThis().
  However, we need to know the Function when creating the InterpFrame and
  in the case of virtual functions, we need to determine what function to
  call at interpretation time.
  
  Get the This pointer ourselves and just create the InterpFrame later.

This is of course in preparation for virtual function calls.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142617

Files:
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpStack.h


Index: clang/lib/AST/Interp/InterpStack.h
===
--- clang/lib/AST/Interp/InterpStack.h
+++ clang/lib/AST/Interp/InterpStack.h
@@ -67,6 +67,10 @@
 return *reinterpret_cast(peek(aligned_size()));
   }
 
+  template  T &peek(size_t Offset) const {
+return *reinterpret_cast(peek(Offset));
+  }
+
   /// Returns a pointer to the top object.
   void *top() const { return Chunk ? peek(0) : nullptr; }
 
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -1499,10 +1499,11 @@
 }
 
 inline bool Call(InterpState &S, CodePtr &PC, const Function *Func) {
-  auto NewFrame = std::make_unique(S, Func, PC);
-  Pointer ThisPtr;
   if (Func->hasThisPointer()) {
-ThisPtr = NewFrame->getThis();
+size_t ThisOffset =
+Func->getArgSize() + (Func->hasRVO() ? primSize(PT_Ptr) : 0);
+const Pointer &ThisPtr = S.Stk.peek(ThisOffset);
+
 if (!CheckInvoke(S, PC, ThisPtr))
   return false;
 
@@ -1513,6 +1514,7 @@
   if (!CheckCallable(S, PC, Func))
 return false;
 
+  auto NewFrame = std::make_unique(S, Func, PC);
   InterpFrame *FrameBefore = S.Current;
   S.Current = NewFrame.get();
 


Index: clang/lib/AST/Interp/InterpStack.h
===
--- clang/lib/AST/Interp/InterpStack.h
+++ clang/lib/AST/Interp/InterpStack.h
@@ -67,6 +67,10 @@
 return *reinterpret_cast(peek(aligned_size()));
   }
 
+  template  T &peek(size_t Offset) const {
+return *reinterpret_cast(peek(Offset));
+  }
+
   /// Returns a pointer to the top object.
   void *top() const { return Chunk ? peek(0) : nullptr; }
 
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -1499,10 +1499,11 @@
 }
 
 inline bool Call(InterpState &S, CodePtr &PC, const Function *Func) {
-  auto NewFrame = std::make_unique(S, Func, PC);
-  Pointer ThisPtr;
   if (Func->hasThisPointer()) {
-ThisPtr = NewFrame->getThis();
+size_t ThisOffset =
+Func->getArgSize() + (Func->hasRVO() ? primSize(PT_Ptr) : 0);
+const Pointer &ThisPtr = S.Stk.peek(ThisOffset);
+
 if (!CheckInvoke(S, PC, ThisPtr))
   return false;
 
@@ -1513,6 +1514,7 @@
   if (!CheckCallable(S, PC, Func))
 return false;
 
+  auto NewFrame = std::make_unique(S, Func, PC);
   InterpFrame *FrameBefore = S.Current;
   S.Current = NewFrame.get();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ecec44f - AArch64: remove SM4 support from Apple CPUs.

2023-01-26 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2023-01-26T13:00:36Z
New Revision: ecec44f2ae733b3848d4dd71324f5fdc33adc62e

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

LOG: AArch64: remove SM4 support from Apple CPUs.

The CPUs never supported SM4 instructions, but until recently I think crypto
was folded into the baseline architecture as a monolithic feature so it was
difficult to represent that. Now it's split we can, and the CPUs that support
v8.4 onwards only handle AES, SHA2, SHA3 by way of crypto instructions.

Added: 


Modified: 
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index ba1b56c492067..9c03ae09cb79c 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -312,7 +312,7 @@
 // CHECK-MCPU-APPLE-A11: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.2a" "-target-feature" "+crc" "-target-feature" "+crypto" 
"-target-feature" "+fp-armv8" "-target-feature" "+fullfp16" "-target-feature" 
"+lse" "-target-feature" "+ras" "-target-feature" "+rdm" "-target-feature" 
"+neon" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" 
"+sha2" "-target-feature" "+aes"
 // CHECK-MCPU-APPLE-A12: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.3a" "-target-feature" "+crc" "-target-feature" "+crypto" 
"-target-feature" "+fp-armv8" "-target-feature" "+fullfp16" "-target-feature" 
"+lse" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" 
"+rdm" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" 
"+zcz" "-target-feature" "+sha2" "-target-feature" "+aes"
 // CHECK-MCPU-A34: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+fp-armv8" 
"-target-feature" "+neon"
-// CHECK-MCPU-APPLE-A13: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.4a" "-target-feature" "+crc" "-target-feature" "+crypto" 
"-target-feature" "+dotprod" "-target-feature" "+fp-armv8" "-target-feature" 
"+fp16fml" "-target-feature" "+lse" "-target-feature" "+ras" "-target-feature" 
"+rcpc" "-target-feature" "+rdm" "-target-feature" "+neon" "-target-feature" 
"+zcm" "-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" 
"+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" 
"+aes"
+// CHECK-MCPU-APPLE-A13: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.4a"  "-target-feature" "+aes" "-target-feature" "+crc" 
"-target-feature" "+dotprod" "-target-feature" "+fp-armv8" "-target-feature" 
"+fp16fml" "-target-feature" "+lse" "-target-feature" "+ras" "-target-feature" 
"+rcpc" "-target-feature" "+rdm" "-target-feature" "+sha2" "-target-feature" 
"+sha3" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" 
"+zcz" "-target-feature" "+fullfp16"
 // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fp-armv8" "-target-feature" "+neon"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fp-armv8" "-target-feature" "+neon"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fp-armv8" "-target-feature" "+neon"
@@ -327,7 +327,7 @@
 // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.2a" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fp-armv8" "-target-feature" "+fullfp16" "-target-feature" "+lse" 
"-target-feature" "+ras" "-target-feature" "+rdm" "-target-feature" "+neon" 
"-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fp-armv8" "-target-feature" "+fp16fml" 
"-target-feature" "+lse" "-target-feature" "+ras" "-target-feature" "+rcpc" 
"-target-feature" "+rdm" "-target-feature" "+neon" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-featur

[PATCH] D117087: [C++20] [Coroutines] Implement return value optimization for get_return_object

2023-01-26 Thread Alkis Evlogimenos via Phabricator via cfe-commits
alkis added a comment.
Herald added a project: All.

Does this change the semantics of `get_return_value()` such that it is eagerly 
converted to R the return value of the coro? AFAIU before this change one could 
return T convertible to R and the conversion would happen late - after 
`final_suspend`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117087

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


[PATCH] D131141: [RISCV] Add MC support of RISCV Zcb Extension

2023-01-26 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu added a comment.

In D131141#4081778 , @craig.topper 
wrote:

> @VincentWu are you ok with the changes I made?

sure, thank you for your work )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131141

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


[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

2023-01-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

Hi @dyung and @DavidSpickett,

Thank you for checking this out and sorry for the late reply (holiday zone 
right now in Taiwan). Let me look into it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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


[PATCH] D131141: [RISCV] Add MC support of RISCV Zcb Extension

2023-01-26 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu added a comment.

should I update zcb to v1.0 in this patch?
or create a new one


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131141

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


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

2023-01-26 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 492408.
VitaNuo marked an inline comment as done.
VitaNuo added a comment.

Rely on alphabetic ordering to determine whether the symbol is new.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -41,6 +38,7 @@
 import datetime
 import os
 import sys
+import re
 
 CODE_PREFIX = """\
 //===-- gen_std.py generated file ---*- C++ -*-===//
@@ -109,18 +107,15 @@
   cppreference_modified_date = datetime.datetime.fromtimestamp(
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
+  # FIXME: take care of overloads
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  symbol.headers = sorted(symbol.headers)
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -36,7 +36,7 @@
   return False
 
 
-def _ParseSymbolPage(symbol_page_html, symbol_name):
+def _ParseSymbolPage(symbol_page_html, symbol_name, header_to_accept):
   """Parse symbol page and retrieve the include header defined in this page.
   The symbol page provides header for the symbol, specifically in
   "Defined in header " section. An example:
@@ -47,7 +47,7 @@
 
   Returns a list of headers.
   """
-  headers = set()
+  symbol_headers = set()
   all_headers = set()
 
   soup = BeautifulSoup(symbol_page_html, "html.parser")
@@ -58,32 +58,57 @@
   #   Defined in header   .t-dsc-header
   #   decl2.t-dcl
   for table in soup.select('table.t-dcl-begin, table.t-dsc-begin'):
-current_headers = []
-was_decl = False
-for row in table.select('tr'):
-  if _HasClass(row, 't-dcl', 't-dsc'):
-was_decl = True
-# Symbols are in the first cell.
-found_symbols = row.find('td').stripped_strings
-if not symbol_name in found_symbols:
-  continue
-headers.update(current_headers)
-  elif _HasClass(row, 't-dsc-header'):
-# If we saw a decl since the last header, this is a new block of headers
-# for a new block of decls.
-if was_decl:
-  current_headers = []
-was_decl = False
+rows = table.select('tr')
+i = 0
+while i < len(rows):
+  start = i
+  current_headers = set()
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-header'):
+row = rows[i]
 # There are also .t-dsc-header for "defined in namespace".
 if not "Defined in header " in row.text:
+  i = i + 1
   continue
 # The interesting header content (e.g. ) is wrapped in .
 for header_code in row.find_all("code"):
-  current_headers.append(header_code.text)
+  # FIXME: replace with proper handling of overloads
+  if header_to_accept != "" and header_code.text.strip("<>") != header_to_accept:
+continue
   all_headers.add(header_code.text)
-  # If the symbol was never named, consider all named headers.
-  return headers or all_headers
-
+  

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

2023-01-26 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Thank you all for comments! The patch should be ready for the next review now.




Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:1053
 SYMBOL(remainder, std::, )
+SYMBOL(remove, std::, )
 SYMBOL(remove_all_extents, std::, )

VitaNuo wrote:
> hokein wrote:
> > I think `std::remove` should not be in the scope of the patch, it has two 
> > variants:
> > - std::remove from ``
> > - and std::remove from ``.
> Yes, agreed. Let's take care of the overloads going forward.
The latest version keeps the `std::remove` overload from ``.



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

hokein wrote:
> 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.
Ok, sure. Sorted the symbols in the generator now and also applied the snippet 
from above. I'm not 100% sure the code became much simpler but this version 
seems fine too :)



Comment at: clang/tools/include-mapping/cppreference_parser.py:174
-  # std::remove<> has variant algorithm.
-  "std::remove": ("algorithm"),
-  }

kadircet wrote:
> VitaNuo wrote:
> > VitaNuo wrote:
> > > kadircet wrote:
> > > > VitaNuo wrote:
> > > > > kadircet wrote:
> > > > > > this is actually checking for something else (sorry for the 
> > > > > > confusing naming).
> > > > > > 
> > > > > > the `variant` here refers to library name mentioned in parentheses 
> > > > > > (this is same problem as `std::move`) on the std symbol index page 
> > > > > > https://en.cppreference.com/w/cpp/symbol_index (e.g. `remove<>() 
> > > > > > (algorithm)`). by getting rid of this we're introducing a 
> > > > > > regression, as previously `std::remove` wouldn't be recognized by 
> > > > > > the library, but now it'll be recognized and we'll keep suggesting 
> > > > > > `` for it.
> > > > > > 
> > > > > > so we should actually keep this around.
> > > > > Ok, I can keep this out of this patch, but we'll have to remove this 
> > > > > logic evetually when we deal with overloads.
> > > > > 
> > > > > I have a slight suspicion that this code might be buggy, because it 
> > > > > suggests that one _of_ the variants should be accepted. What is does 
> > > > > in reality, though, is it keeps `algorithm` in the list of headers 
> > > > > suitable for `std::remove` alongside `cstdio`, and then in the last 
> > > > > step `std::remove` is ignored by the generator because of being 
> > > > > defined in two headers.
> > > > > 
> > > > > With this patch, the result will be both `{cstdio, algorithm}`. Is 
> > > > > this (more) satisfactory for now compared to skipping `algorithm` due 
> > > > > to being an overload?
> > > > > 
> > > > > Ok, I can keep this out of this patch, but we'll have to remove this 
> > > > > logic evetually when we deal with overloads.
> > > > 
> > > > Surely, I wasn't saying this should stay here forever, i am just saying 
> > > > that what's done in the scope of this patch doesn't really address the 
> > > > issues "worked around" by this piece.
> > > > 
> > > > > I have a slight suspicion that this code might be buggy, because it 
> > > > > suggests that one _of_ the variants should be accepted. What is does 
> > > > > in reality, though, is it keeps algorithm in the list of headers 
> > > > > suitable for std::remove alongside cstdio, and then in the last step 
> > > > > std::remove is ignored by the generator because of being defined in 
> > > > > two headers.
> > > > 
> > > > right, it's because we have logic to prefer "non-variant" versions of 
> > > > symbols when available (i.e. in the absence of this logic, we'd prefer 
> > > > std::remove from cstdio). this logic enables us to preserve ce

[PATCH] D142583: [SPIR] Add support for __arithmetic_fence builtin for SPIR target.

2023-01-26 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 492410.
zahiraam marked 3 inline comments as done.
zahiraam edited the summary of this revision.

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

https://reviews.llvm.org/D142583

Files:
  clang/lib/Basic/Targets/SPIR.h
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Sema/arithmetic-fence-builtin.c


Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- clang/test/Sema/arithmetic-fence-builtin.c
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
 // RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
 // RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+// RUN: %clang_cc1 -triple spir64 -emit-llvm -o - -verify -x c++ %s
 #ifndef PPC
 int v;
 template  T addT(T a, T b) {
Index: clang/test/CodeGen/arithmetic-fence-builtin.c
===
--- clang/test/CodeGen/arithmetic-fence-builtin.c
+++ clang/test/CodeGen/arithmetic-fence-builtin.c
@@ -1,17 +1,22 @@
 // Test with fast math
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -DFAST \
-// RUN: -mreassociate \
-// RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s
+// RUN: -mreassociate -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPRECISE,CHECKNP %s
 //
 // Test with fast math and fprotect-parens
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -DFAST \
-// RUN: -mreassociate -fprotect-parens -ffp-contract=on\
-// RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPP %s
+// RUN: -mreassociate -fprotect-parens -ffp-contract=on -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPRECISE,CHECKPP %s
 //
 // Test without fast math: llvm intrinsic not created
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -fprotect-parens\
 // RUN: -o - %s | FileCheck --implicit-check-not="llvm.arithmetic.fence" %s
 //
+// Test with fast math on spir target
+// RUN: %clang_cc1 -triple spir64  -emit-llvm -mreassociate -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s
+//
+
 int v;
 int addit(float a, float b) {
   // CHECK: define {{.*}}@addit(float noundef %a, float noundef %b) #0 {
@@ -65,7 +70,7 @@
 #ifdef FAST
 #pragma float_control(precise, on)
 int subit(float a, float b, float *fp) {
-  // CHECKFAST: define {{.*}}@subit(float noundef %a, float noundef %b{{.*}}
+  // CHECKPRECISE: define {{.*}}@subit(float noundef %a, float noundef %b{{.*}}
   *fp = __arithmetic_fence(a - b);
   *fp = (a + b);
   // CHECK-NOT: call{{.*}} float @llvm.arithmetic.fence.f32(float noundef %add)
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -191,6 +191,8 @@
   bool hasFeature(StringRef Feature) const override {
 return Feature == "spir";
   }
+
+  bool checkArithmeticFenceSupported() const override { return true; }
 };
 
 class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {


Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- clang/test/Sema/arithmetic-fence-builtin.c
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
 // RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
 // RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+// RUN: %clang_cc1 -triple spir64 -emit-llvm -o - -verify -x c++ %s
 #ifndef PPC
 int v;
 template  T addT(T a, T b) {
Index: clang/test/CodeGen/arithmetic-fence-builtin.c
===
--- clang/test/CodeGen/arithmetic-fence-builtin.c
+++ clang/test/CodeGen/arithmetic-fence-builtin.c
@@ -1,17 +1,22 @@
 // Test with fast math
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -DFAST \
-// RUN: -mreassociate \
-// RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s
+// RUN: -mreassociate -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPRECISE,CHECKNP %s
 //
 // Test with fast math and fprotect-parens
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -DFAST \
-// RUN: -mreassociate -fprotect-parens -ffp-contract=on\
-// RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPP %s
+// RUN: -mreassociate -fprotect-parens -ffp-contract=on -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPRECISE,CHECKPP %s
 //
 // Test without fast math: llvm intrinsic not created
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -fprotect-parens\
 // RUN: -o - %s | FileCheck --implicit-check-not="llvm.arithmetic.fence" %s
 //
+// Test with fast math on spir target

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

2023-01-26 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 492413.
VitaNuo added a comment.

Remove extra import.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py

Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -14,10 +14,7 @@
 The generated files are located in clang/include/Tooling/Inclusions.
 
 Caveats and FIXMEs:
-  - only symbols directly in "std" namespace are added, we should also add std's
-subnamespace symbols (e.g. chrono).
-  - symbols with multiple variants or defined in multiple headers aren't added,
-e.g. std::move, std::swap
+  - symbols with multiple variants aren't added, e.g., std::move
 
 Usage:
   1. Install BeautifulSoup dependency, see instruction:
@@ -109,18 +106,15 @@
   cppreference_modified_date = datetime.datetime.fromtimestamp(
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
   print(CODE_PREFIX % (args.symbols.upper(), cppreference_modified_date))
+  # FIXME: take care of overloads
   for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
+if len(symbol.headers) == 0:
   sys.stderr.write("No header found for symbol %s\n" % symbol.name)
 else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
-
-
+  symbol.headers = sorted(symbol.headers)
+  for header in symbol.headers:
+# SYMBOL(unqualified_name, namespace, header)
+print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
+  header))
 if __name__ == '__main__':
   main()
Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -36,7 +36,7 @@
   return False
 
 
-def _ParseSymbolPage(symbol_page_html, symbol_name):
+def _ParseSymbolPage(symbol_page_html, symbol_name, header_to_accept):
   """Parse symbol page and retrieve the include header defined in this page.
   The symbol page provides header for the symbol, specifically in
   "Defined in header " section. An example:
@@ -47,7 +47,7 @@
 
   Returns a list of headers.
   """
-  headers = set()
+  symbol_headers = set()
   all_headers = set()
 
   soup = BeautifulSoup(symbol_page_html, "html.parser")
@@ -58,32 +58,57 @@
   #   Defined in header   .t-dsc-header
   #   decl2.t-dcl
   for table in soup.select('table.t-dcl-begin, table.t-dsc-begin'):
-current_headers = []
-was_decl = False
-for row in table.select('tr'):
-  if _HasClass(row, 't-dcl', 't-dsc'):
-was_decl = True
-# Symbols are in the first cell.
-found_symbols = row.find('td').stripped_strings
-if not symbol_name in found_symbols:
-  continue
-headers.update(current_headers)
-  elif _HasClass(row, 't-dsc-header'):
-# If we saw a decl since the last header, this is a new block of headers
-# for a new block of decls.
-if was_decl:
-  current_headers = []
-was_decl = False
+rows = table.select('tr')
+i = 0
+while i < len(rows):
+  start = i
+  current_headers = set()
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-header'):
+row = rows[i]
 # There are also .t-dsc-header for "defined in namespace".
 if not "Defined in header " in row.text:
+  i = i + 1
   continue
 # The interesting header content (e.g. ) is wrapped in .
 for header_code in row.find_all("code"):
-  current_headers.append(header_code.text)
+  # FIXME: replace with proper handling of overloads
+  if header_to_accept != "" and header_code.text.strip("<>") != header_to_accept:
+continue
   all_headers.add(header_code.text)
-  # If the symbol was never named, consider all named headers.
-  return headers or all_headers
-
+  current_headers.add(header_code.text)
+i = i + 1
+  # Some tables have header rows, skip them.  
+  while i < len(rows) and _HasClass(rows[i], 't-dsc-hitem'):
+i = i + 1
+  while i < len(rows) and (_HasClass(rows[i], 't-dcl', 

[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

2023-01-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD reopened this revision.
eopXD added a comment.
This revision is now accepted and ready to land.

Reopening the revision to try land this correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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


[PATCH] D142539: [NFC][AArch64] Use optional returns in target parser instead of 'invalid' objects

2023-01-26 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added inline comments.



Comment at: llvm/unittests/TargetParser/TargetParserTest.cpp:1456
+  std::optional Extension =
+  AArch64::parseArchExtension(ArchExt);
+  if (!Extension)

I think we still need to test getDefaultExtensions, unless we're deleting it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142539

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


[PATCH] D142550: Fix sizeof of boolean vector

2023-01-26 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.

Ok, thank you!  This looks right to me :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142550

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


[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

2023-01-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 492420.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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
@@ -1017,7 +1017,6 @@
   };
 
   if (PolicyAttrs.isUnspecified()) {
-PolicyAttrs.IsUnspecified = false;
 if (IsMasked) {
   Name += "_m";
   if (HasPolicy)
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -92,15 +92,22 @@
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-struct Policy {
-  bool IsUnspecified = false;
+class Policy {
+public:
   enum PolicyType {
 Undisturbed,
 Agnostic,
   };
-  PolicyType TailPolicy = Agnostic;
-  PolicyType MaskPolicy = Agnostic;
+
+private:
+  const bool IsUnspecified = false;
+  // The default assumption for an RVV instruction is TAMA, as an undisturbed
+  // policy generally will affect the performance of an out-of-order core.
+  const PolicyType TailPolicy = Agnostic;
+  const PolicyType MaskPolicy = Agnostic;
   bool HasTailPolicy, HasMaskPolicy;
+
+public:
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
 HasMaskPolicy(HasMaskPolicy) {}
@@ -422,7 +429,6 @@
 return IntrinsicTypes;
   }
   Policy getPolicyAttrs() const {
-assert(PolicyAttrs.IsUnspecified == false);
 return PolicyAttrs;
   }
   unsigned getPolicyAttrsBits() const {
@@ -431,8 +437,6 @@
 // The 1st bit simulates the `vma` of RVV
 // int PolicyAttrs = 0;
 
-assert(PolicyAttrs.IsUnspecified == false);
-
 if (PolicyAttrs.isTUMAPolicy())
   return 2;
 if (PolicyAttrs.isTAMAPolicy())


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -1017,7 +1017,6 @@
   };
 
   if (PolicyAttrs.isUnspecified()) {
-PolicyAttrs.IsUnspecified = false;
 if (IsMasked) {
   Name += "_m";
   if (HasPolicy)
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -92,15 +92,22 @@
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-struct Policy {
-  bool IsUnspecified = false;
+class Policy {
+public:
   enum PolicyType {
 Undisturbed,
 Agnostic,
   };
-  PolicyType TailPolicy = Agnostic;
-  PolicyType MaskPolicy = Agnostic;
+
+private:
+  const bool IsUnspecified = false;
+  // The default assumption for an RVV instruction is TAMA, as an undisturbed
+  // policy generally will affect the performance of an out-of-order core.
+  const PolicyType TailPolicy = Agnostic;
+  const PolicyType MaskPolicy = Agnostic;
   bool HasTailPolicy, HasMaskPolicy;
+
+public:
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
 HasMaskPolicy(HasMaskPolicy) {}
@@ -422,7 +429,6 @@
 return IntrinsicTypes;
   }
   Policy getPolicyAttrs() const {
-assert(PolicyAttrs.IsUnspecified == false);
 return PolicyAttrs;
   }
   unsigned getPolicyAttrsBits() const {
@@ -431,8 +437,6 @@
 // The 1st bit simulates the `vma` of RVV
 // int PolicyAttrs = 0;
 
-assert(PolicyAttrs.IsUnspecified == false);
-
 if (PolicyAttrs.isTUMAPolicy())
   return 2;
 if (PolicyAttrs.isTAMAPolicy())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140756: Add clang_CXXMethod_isExplicit to libclang

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

The fixes LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140756

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


[PATCH] D142539: [NFC][AArch64] Use optional returns in target parser instead of 'invalid' objects

2023-01-26 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas marked an inline comment as done.
pratlucas added inline comments.



Comment at: llvm/unittests/TargetParser/TargetParserTest.cpp:1456
+  std::optional Extension =
+  AArch64::parseArchExtension(ArchExt);
+  if (!Extension)

tmatheson wrote:
> I think we still need to test getDefaultExtensions, unless we're deleting it.
D142540 deletes it in favor of using the information in `CpuInfo` and 
`ArchInfo`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142539

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


[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

2023-01-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

This commit seems to cause `riscv_vector_builtin_cg.inc` to explode into a 630K 
file, which causes the out-of-memory build fail. Confirmed that this is the 
commit that is causing the error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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


[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

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

Nice!

Glad you spotted that, I have had creduce running and getting nowhere fast for 
a day or so. Sounds like it would never have found anything minimal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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


[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

2023-01-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

In D141796#4082665 , @DavidSpickett 
wrote:

> Nice!
>
> Glad you spotted that, I have had creduce running and getting nowhere fast 
> for a day or so. Sounds like it would never have found anything minimal.

Indeed! Thank you for your time again :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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


[PATCH] D142592: [clang-tidy][libc] Add an inline function checker for the libc project.

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



Comment at: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp:20
+void InlineFunctionDeclCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(decl(functionDecl()).bind("func_decl"), this);
+}

ClockMan wrote:
> or maybe even better:
> Finder->addMatcher(functionDecl(unless(isExpansionInMainFile()), 
> isInline()).bind("func_decl"), this);
> Instead of line 26 and 32.
I'm not sure that works - if we pass a header directly to clang-tidy, it will 
consider it as the "main file", right? That's why the established pattern is 
based on `HeaderFileExtensions`, please check out other checks.



Comment at: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp:29
+
+  auto SrcBegin = FuncDecl->getSourceRange().getBegin();
+  // Consider functions only in header files.

Eugene.Zelenko wrote:
> Please don't use `auto` unless type is explicitly stated in same statement or 
> iterator.
We have a well-established pattern for detecting code in headers, grep for 
`HeaderFileExtensions` in existing checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142592

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


[PATCH] D142627: [analyzer] Fix crash exposed by D140059

2023-01-26 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
Herald added subscribers: manas, steakhal, ASDenysPetrov, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, hiraditya, 
xazax.hun.
Herald added a project: All.
vabridgers requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Change https://reviews.llvm.org/D140059 exposed the following crash in
Z3Solver, where bit widths were not checked consistently with that
change. This change makes the check consistent, and fixes the crash.

clang: /llvm/include/llvm/ADT/APSInt.h:99:

  int64_t llvm::APSInt::getExtValue() const: Assertion
  `isRepresentableByInt64() && "Too many bits for int64_t"' failed.

...
Stack dump:
0. Program arguments: clang -cc1 -internal-isystem /lib/clang/16/include

  -nostdsysteminc -analyze 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection
  -analyzer-config crosscheck-with-z3=true -verify reproducer.c

#0 0x045b3476 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)

  /llvm/lib/Support/Unix/Signals.inc:567:22

#1 0x045b3862 PrintStackTraceSignalHandler(void*)

  /llvm/lib/Support/Unix/Signals.inc:641:1

#2 0x045b14a5 llvm::sys::RunSignalHandlers()

  /llvm/lib/Support/Signals.cpp:104:20

#3 0x045b2eb4 SignalHandler(int)

  /llvm/lib/Support/Unix/Signals.inc:412:1

...
 #9 0x04be2eb3 llvm::APSInt::getExtValue() const

  /llvm/include/llvm/ADT/APSInt.h:99:5
  /llvm/lib/Support/Z3Solver.cpp:740:53
  clang::ASTContext&, clang::ento::SymExpr const*, llvm::APSInt const&, 
llvm::APSInt const&, bool)
  /clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:552:61


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142627

Files:
  clang/test/Analysis/z3-crosscheck.c
  llvm/lib/Support/Z3Solver.cpp


Index: llvm/lib/Support/Z3Solver.cpp
===
--- llvm/lib/Support/Z3Solver.cpp
+++ llvm/lib/Support/Z3Solver.cpp
@@ -729,7 +729,7 @@
 const Z3_sort Z3Sort = toZ3Sort(*getBitvectorSort(BitWidth)).Sort;
 
 // Slow path, when 64 bits are not enough.
-if (LLVM_UNLIKELY(Int.getBitWidth() > 64u)) {
+if (LLVM_UNLIKELY(!Int.isRepresentableByInt64())) {
   SmallString<40> Buffer;
   Int.toString(Buffer, 10);
   return newExprRef(Z3Expr(
Index: clang/test/Analysis/z3-crosscheck.c
===
--- clang/test/Analysis/z3-crosscheck.c
+++ clang/test/Analysis/z3-crosscheck.c
@@ -55,3 +55,15 @@
 h(2);
   }
 }
+
+// don't crash, and also produce a core.CallAndMessage finding
+void a(int);
+typedef struct {
+  int b;
+} c;
+c *d;
+void e() {
+  (void)d->b;
+  int f;
+  a(f); // expected-warning {{1st function call argument is an uninitialized 
value [core.CallAndMessage]}}
+}


Index: llvm/lib/Support/Z3Solver.cpp
===
--- llvm/lib/Support/Z3Solver.cpp
+++ llvm/lib/Support/Z3Solver.cpp
@@ -729,7 +729,7 @@
 const Z3_sort Z3Sort = toZ3Sort(*getBitvectorSort(BitWidth)).Sort;
 
 // Slow path, when 64 bits are not enough.
-if (LLVM_UNLIKELY(Int.getBitWidth() > 64u)) {
+if (LLVM_UNLIKELY(!Int.isRepresentableByInt64())) {
   SmallString<40> Buffer;
   Int.toString(Buffer, 10);
   return newExprRef(Z3Expr(
Index: clang/test/Analysis/z3-crosscheck.c
===
--- clang/test/Analysis/z3-crosscheck.c
+++ clang/test/Analysis/z3-crosscheck.c
@@ -55,3 +55,15 @@
 h(2);
   }
 }
+
+// don't crash, and also produce a core.CallAndMessage finding
+void a(int);
+typedef struct {
+  int b;
+} c;
+c *d;
+void e() {
+  (void)d->b;
+  int f;
+  a(f); // expected-warning {{1st function call argument is an uninitialized value [core.CallAndMessage]}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142315: [clang] Add test for CWG1111

2023-01-26 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill updated this revision to Diff 492430.
Endill edited the summary of this revision.
Endill added a comment.

Move CWG2385 ("na") from D142316  into this 
patch. It makes more sense to put it here, because it fixes inconsistent 
wording introduced by CWG resolution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142315

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


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -6473,7 +6473,7 @@
 https://wg21.link/cwg";>
 C++11
 Remove dual-scope lookup of member template names
-Unknown
+Yes
   
   
 https://wg21.link/cwg1112";>1112
@@ -14117,7 +14117,7 @@
 https://wg21.link/cwg2385";>2385
 CD5
 Lookup for conversion-function-ids
-Unknown
+N/A
   
   
 https://wg21.link/cwg2386";>2386
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -169,6 +169,8 @@
 } //namespace dr2303
 #endif
 
+// dr2385: na
+
 namespace dr2394 { // dr2394: 15
 
 struct A {};
Index: clang/test/CXX/drs/dr11xx.cpp
===
--- clang/test/CXX/drs/dr11xx.cpp
+++ clang/test/CXX/drs/dr11xx.cpp
@@ -4,6 +4,46 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
+namespace dr { // dr: yes
+namespace example1 {
+template  struct set;
+
+struct X {
+  template  void set(const T &value);
+};
+void foo() {
+  X x;
+#pragma clang diagnostic push
+#if __cplusplus < 201103L
+#pragma clang diagnostic ignored "-Wambiguous-member-template"
+#endif
+  x.set(3.2);
+#pragma clang diagnostic pop
+}
+
+struct Y {};
+void bar() {
+  Y y;
+  y.set(3.2); // expected-error {{no member named 'set' in 
'dr::example1::Y'}}
+}
+} // namespace example1
+
+namespace example2 {
+struct A {};
+namespace N {
+struct A {
+  void g() {}
+  template  operator T();
+};
+} // namespace N
+
+void baz() {
+  N::A a;
+  a.operator A();
+}
+} // namespace example2
+} // namespace dr
+
 namespace dr1113 { // dr1113: partial
   namespace named {
 extern int a; // expected-note {{previous}}


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -6473,7 +6473,7 @@
 https://wg21.link/cwg";>
 C++11
 Remove dual-scope lookup of member template names
-Unknown
+Yes
   
   
 https://wg21.link/cwg1112";>1112
@@ -14117,7 +14117,7 @@
 https://wg21.link/cwg2385";>2385
 CD5
 Lookup for conversion-function-ids
-Unknown
+N/A
   
   
 https://wg21.link/cwg2386";>2386
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -169,6 +169,8 @@
 } //namespace dr2303
 #endif
 
+// dr2385: na
+
 namespace dr2394 { // dr2394: 15
 
 struct A {};
Index: clang/test/CXX/drs/dr11xx.cpp
===
--- clang/test/CXX/drs/dr11xx.cpp
+++ clang/test/CXX/drs/dr11xx.cpp
@@ -4,6 +4,46 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
+namespace dr { // dr: yes
+namespace example1 {
+template  struct set;
+
+struct X {
+  template  void set(const T &value);
+};
+void foo() {
+  X x;
+#pragma clang diagnostic push
+#if __cplusplus < 201103L
+#pragma clang diagnostic ignored "-Wambiguous-member-template"
+#endif
+  x.set(3.2);
+#pragma clang diagnostic pop
+}
+
+struct Y {};
+void bar() {
+  Y y;
+  y.set(3.2); // expected-error {{no member named 'set' in 'dr::example1::Y'}}
+}
+} // namespace example1
+
+namespace example2 {
+struct A {};
+namespace N {
+struct A {
+  void g() {}
+  template  operator T();
+};
+} // namespace N
+
+void baz() {
+  N::A a;
+  a.operator A();
+}
+} // namespace example2
+} // namespace dr
+
 namespace dr1113 { // dr1113: partial
   namespace named {
 extern int a; // expected-note {{previous}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142316: [clang] Add test for CWG2396

2023-01-26 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill updated this revision to Diff 492433.
Endill edited the summary of this revision.
Endill added a comment.

Move CWG2385 out to D142315 , because it's 
been resolved prior to P1787 , and it's easier 
to explain it there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142316

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


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -7553,7 +7553,7 @@
 https://wg21.link/cwg1291";>1291
 CD6
 Looking up a conversion-type-id
-Unknown
+N/A
   
   
 https://wg21.link/cwg1292";>1292
@@ -14183,7 +14183,7 @@
 https://wg21.link/cwg2396";>2396
 CD6
 Lookup of names in complex conversion-type-ids
-Unknown
+No
   
   
 https://wg21.link/cwg2397";>2397
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -179,3 +179,26 @@
 B b;
 
 }
+
+namespace dr2396 { // dr2396: no
+  template
+  struct identity {
+typedef T type;
+  };
+
+  struct A {
+struct B;
+operator B B::*();
+  };
+  struct B;
+
+  // FIXME: per P1787 "Calling a conversion function" example, all of the
+  // examples below are well-formed, with B resolving to A::B, but currently
+  // it's been resolved to dr2396::B. 
+
+  // void f(A a) { a.operator B B::*(); }
+  // void g(A a) { a.operator decltype(B()) B::*(); }
+  // void g2(A a) { a.operator B decltype(B())::*(); }
+  // void h(A a) { a.operator identity::type B::*(); }  
+  // void h2(A a) { a.operator B identity::type::*(); } 
+}
Index: clang/test/CXX/drs/dr12xx.cpp
===
--- clang/test/CXX/drs/dr12xx.cpp
+++ clang/test/CXX/drs/dr12xx.cpp
@@ -68,6 +68,8 @@
 #endif
 }
 
+// dr1291: na
+
 namespace dr1295 { // dr1295: 4
   struct X {
 unsigned bitfield : 4;


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -7553,7 +7553,7 @@
 https://wg21.link/cwg1291";>1291
 CD6
 Looking up a conversion-type-id
-Unknown
+N/A
   
   
 https://wg21.link/cwg1292";>1292
@@ -14183,7 +14183,7 @@
 https://wg21.link/cwg2396";>2396
 CD6
 Lookup of names in complex conversion-type-ids
-Unknown
+No
   
   
 https://wg21.link/cwg2397";>2397
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -179,3 +179,26 @@
 B b;
 
 }
+
+namespace dr2396 { // dr2396: no
+  template
+  struct identity {
+typedef T type;
+  };
+
+  struct A {
+struct B;
+operator B B::*();
+  };
+  struct B;
+
+  // FIXME: per P1787 "Calling a conversion function" example, all of the
+  // examples below are well-formed, with B resolving to A::B, but currently
+  // it's been resolved to dr2396::B. 
+
+  // void f(A a) { a.operator B B::*(); }
+  // void g(A a) { a.operator decltype(B()) B::*(); }
+  // void g2(A a) { a.operator B decltype(B())::*(); }
+  // void h(A a) { a.operator identity::type B::*(); }  
+  // void h2(A a) { a.operator B identity::type::*(); } 
+}
Index: clang/test/CXX/drs/dr12xx.cpp
===
--- clang/test/CXX/drs/dr12xx.cpp
+++ clang/test/CXX/drs/dr12xx.cpp
@@ -68,6 +68,8 @@
 #endif
 }
 
+// dr1291: na
+
 namespace dr1295 { // dr1295: 4
   struct X {
 unsigned bitfield : 4;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142297: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-26 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D142297#4082242 , @mstorsjo wrote:

> This change broke the `parallel/bug54082.c` testcase in the OpenMP runtime 
> test set, when running on Windows (both mingw and MSVC configurations, and 
> happening both in i386 and x86_64 builds), see e.g. 
> https://github.com/mstorsjo/llvm-mingw/actions/runs/4011290068/jobs/6891673869.
>  It's failing with error code `0xC0FD`, which means 
> `STATUS_STACK_OVERFLOW`. Is this change missing some aspect that differs 
> between the unix and Windows ABIs?
>
> So please don't backport this to the release branch right now. And I'd 
> appreciate if you would consider to revert it if there's no immediately 
> obvious fix in sight.

Thanks for the information. I'll install a Windows VM and try to fix it and get 
the back ported to the release branch as this patch has already been included.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142297

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


[PATCH] D142540: [NFC][AArch64] Get default features directly from ArchInfo and CpuInfo objects

2023-01-26 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson accepted this revision.
tmatheson added a comment.
This revision is now accepted and ready to land.

Looks great, thanks




Comment at: llvm/include/llvm/TargetParser/AArch64TargetParser.h:338
+
+  uint64_t getDefaultExtensions() const {
+return DefaultExtensions | Arch.DefaultExts;

nit: I would expect `getDefaultExtensions()` to return the value of 
`DefaultExtensions`. Is there a better naming combo we could use?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142540

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


[PATCH] D142606: Lazyly initialize uncommon toolchain detector

2023-01-26 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Does this mean that clang will no longer search for the ROCM and CUDA library 
paths for every C compile?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142606

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


[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

2023-01-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 492437.
eopXD added a comment.

Update code. The removal of `PolicyAttrs.IsUnspecified = false;` under

  void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,
  std::string &Name,
  std::string &BuiltinName,
  std::string &OverloadedName,
  Policy &PolicyAttrs) {
  
  /* ... */
if (PolicyAttrs.isUnspecified()) {
}

is incorrect becasue the `==` operator of the `Policy` object still uses it.
So repeating builtin-s were created (becasue repeating ones are not recognized
as duplicates), causing `riscv_vector_builtin_cg.inc` to explode.

The updated patch now only adds `const` qualifier to `TailPolicy` and
`MaskPolicy`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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
@@ -92,15 +92,22 @@
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-struct Policy {
-  bool IsUnspecified = false;
+class Policy {
+public:
   enum PolicyType {
 Undisturbed,
 Agnostic,
   };
-  PolicyType TailPolicy = Agnostic;
-  PolicyType MaskPolicy = Agnostic;
+  bool IsUnspecified = false;
+
+private:
+  // The default assumption for an RVV instruction is TAMA, as an undisturbed
+  // policy generally will affect the performance of an out-of-order core.
+  const PolicyType TailPolicy = Agnostic;
+  const PolicyType MaskPolicy = Agnostic;
   bool HasTailPolicy, HasMaskPolicy;
+
+public:
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
 HasMaskPolicy(HasMaskPolicy) {}


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -92,15 +92,22 @@
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-struct Policy {
-  bool IsUnspecified = false;
+class Policy {
+public:
   enum PolicyType {
 Undisturbed,
 Agnostic,
   };
-  PolicyType TailPolicy = Agnostic;
-  PolicyType MaskPolicy = Agnostic;
+  bool IsUnspecified = false;
+
+private:
+  // The default assumption for an RVV instruction is TAMA, as an undisturbed
+  // policy generally will affect the performance of an out-of-order core.
+  const PolicyType TailPolicy = Agnostic;
+  const PolicyType MaskPolicy = Agnostic;
   bool HasTailPolicy, HasMaskPolicy;
+
+public:
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
 HasMaskPolicy(HasMaskPolicy) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

2023-01-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

Re-commiting this now that the problem is resolved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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


[PATCH] D142578: [Clang][Doc] Edit the Clang release notes

2023-01-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

A handful of suggestions as I spot-checked.  This looks great, thank you for 
doing this!  I'd like Aaron to take a look though.




Comment at: clang/docs/ReleaseNotes.rst:51
+- The ``-fexperimental-new-pass-manager`` and ``-fno-legacy-pass-manager``
+  flags have been removed. These have been no-ops since 15.0.0.
 

`no-ops` read awkwardly to me, so I'm hopeful that 'silently ignored' is a 
little more descriptive.

Perhaps, "deprecated and ignored" if that isn't accurate?



Comment at: clang/docs/ReleaseNotes.rst:53
 
-  Due to the extended period of time this bug was present in major C++
-  implementations (including Clang), this error has the ability to be
-  downgraded into a warning (via: ``-Wno-error=enum-constexpr-conversion``) to
-  provide a transition period for users. This diagnostic is expected to turn
-  into an error-only diagnostic in the next Clang release. Fixes
-  `Issue 50055 `_.
+- Clang's resource dir used to include the full clang version. It will now
+  include only the major version. The new resource directory is





Comment at: clang/docs/ReleaseNotes.rst:54
+- Clang's resource dir used to include the full clang version. It will now
+  include only the major version. The new resource directory is
+  ``$prefix/lib/clang/$CLANG_MAJOR_VERSION`` and can be queried using





Comment at: clang/docs/ReleaseNotes.rst:170
+- Clang now diagnoses non-inline externally-visible definitions in C++
+  standard header units as per ``[module.import/6]``.  Previously, in Clang-15,
+  these definitions were allowed.  Note that such definitions are ODR




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142578

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


[clang] 719a728 - [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

2023-01-26 Thread via cfe-commits

Author: eopXD
Date: 2023-01-26T07:06:33-08:00
New Revision: 719a728b86a1ce6b7bcf1eb9fd6860c4a88391bd

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

LOG: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

The object is now correct by construction.

This is the 15th 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.

Depends on D141793.

Reviewed By: craig.topper

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

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 fc53d70019c55..415179a6f441a 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -92,15 +92,22 @@ enum class TypeModifier : uint8_t {
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-struct Policy {
-  bool IsUnspecified = false;
+class Policy {
+public:
   enum PolicyType {
 Undisturbed,
 Agnostic,
   };
-  PolicyType TailPolicy = Agnostic;
-  PolicyType MaskPolicy = Agnostic;
+  bool IsUnspecified = false;
+
+private:
+  // The default assumption for an RVV instruction is TAMA, as an undisturbed
+  // policy generally will affect the performance of an out-of-order core.
+  const PolicyType TailPolicy = Agnostic;
+  const PolicyType MaskPolicy = Agnostic;
   bool HasTailPolicy, HasMaskPolicy;
+
+public:
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
 HasMaskPolicy(HasMaskPolicy) {}



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


[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

2023-01-26 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 rG719a728b86a1: [15/15][Clang][RISCV][NFC] Set data member 
under Policy as constants (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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
@@ -92,15 +92,22 @@
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-struct Policy {
-  bool IsUnspecified = false;
+class Policy {
+public:
   enum PolicyType {
 Undisturbed,
 Agnostic,
   };
-  PolicyType TailPolicy = Agnostic;
-  PolicyType MaskPolicy = Agnostic;
+  bool IsUnspecified = false;
+
+private:
+  // The default assumption for an RVV instruction is TAMA, as an undisturbed
+  // policy generally will affect the performance of an out-of-order core.
+  const PolicyType TailPolicy = Agnostic;
+  const PolicyType MaskPolicy = Agnostic;
   bool HasTailPolicy, HasMaskPolicy;
+
+public:
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
 HasMaskPolicy(HasMaskPolicy) {}


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -92,15 +92,22 @@
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-struct Policy {
-  bool IsUnspecified = false;
+class Policy {
+public:
   enum PolicyType {
 Undisturbed,
 Agnostic,
   };
-  PolicyType TailPolicy = Agnostic;
-  PolicyType MaskPolicy = Agnostic;
+  bool IsUnspecified = false;
+
+private:
+  // The default assumption for an RVV instruction is TAMA, as an undisturbed
+  // policy generally will affect the performance of an out-of-order core.
+  const PolicyType TailPolicy = Agnostic;
+  const PolicyType MaskPolicy = Agnostic;
   bool HasTailPolicy, HasMaskPolicy;
+
+public:
   Policy(bool HasTailPolicy, bool HasMaskPolicy)
   : IsUnspecified(true), HasTailPolicy(HasTailPolicy),
 HasMaskPolicy(HasMaskPolicy) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142606: Lazyly initialize uncommon toolchain detector

2023-01-26 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D142606#4082753 , @tstellar wrote:

> Does this mean that clang will no longer search for the ROCM and CUDA library 
> paths for every C compile?

That's the goal, yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142606

___
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-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 492441.
eopXD added a comment.

Update code upon re-commit of D141796 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142016

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vadc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vand.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vcompress.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vdivu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfabs.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfclass.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmerge.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfncvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfneg.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrec7.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrsqrt7.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsgnj.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsgnjn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsgnjx.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfslide1down.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfslide1up.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsqrt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/

[PATCH] D141796: [15/15][Clang][RISCV][NFC] Set data member under Policy as constants

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

Looks good to me - https://lab.llvm.org/buildbot/#/builders/245/builds/3919


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141796

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


[PATCH] D140158: [CUDA] Allow targeting NVPTX directly without a host toolchain

2023-01-26 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

This patch breaks our cuda compilations. The output file isn't created after it:

  $ echo 'extern "C" __attribute__((global)) void q() {}' >q.cc
  $ good-clang \
  -nocudainc -x cuda \
  --cuda-path=somepath/cuda/ \
  -Wno-unknown-cuda-version --cuda-device-only \
  -c q.cc -o qqq-good.o \
&& bad-clang \
  -nocudainc -x cuda \
  --cuda-path=somepath/cuda/ \
  -Wno-unknown-cuda-version --cuda-device-only \
  -c q.cc -o qqq-bad.o \
&& ls qqq*.o
  qqq-good.o


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140158

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


[PATCH] D142592: [clang-tidy][libc] Add an inline function checker for the libc project.

2023-01-26 Thread Piotr Zegar via Phabricator via cfe-commits
ClockMan added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp:20
+void InlineFunctionDeclCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(decl(functionDecl()).bind("func_decl"), this);
+}

carlosgalvezp wrote:
> ClockMan wrote:
> > or maybe even better:
> > Finder->addMatcher(functionDecl(unless(isExpansionInMainFile()), 
> > isInline()).bind("func_decl"), this);
> > Instead of line 26 and 32.
> I'm not sure that works - if we pass a header directly to clang-tidy, it will 
> consider it as the "main file", right? That's why the established pattern is 
> based on `HeaderFileExtensions`, please check out other checks.
Yes you right, but isInline still can be checked here.
As for HeaderFileExtensions never used it from both developer and user point of 
view.
When running clang-tidy on headers is still better simply create file with 
single include.
Maybe if there would be AST_MATCHER for HeaderFileExtensions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142592

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


[PATCH] D140158: [CUDA] Allow targeting NVPTX directly without a host toolchain

2023-01-26 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D140158#4082789 , @alexfh wrote:

> This patch breaks our cuda compilations. The output file isn't created after 
> it:
>
>   $ echo 'extern "C" __attribute__((global)) void q() {}' >q.cc
>   $ good-clang \
>   -nocudainc -x cuda \
>   --cuda-path=somepath/cuda/ \
>   -Wno-unknown-cuda-version --cuda-device-only \
>   -c q.cc -o qqq-good.o \
> && bad-clang \
>   -nocudainc -x cuda \
>   --cuda-path=somepath/cuda/ \
>   -Wno-unknown-cuda-version --cuda-device-only \
>   -c q.cc -o qqq-bad.o \
> && ls qqq*.o
>   qqq-good.o

https://github.com/llvm/llvm-project/issues/60301 Still broken after this fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140158

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


[PATCH] D142630: [clang][Interp] Implement virtual function calls

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

@aaron.ballman Not sure if this (the added early return) is all you meant when 
you talked about virtual destructors.

I also wasn't sure about the added `getOverridingFunction()` - I think 
`isDerivedFrom(..., paths)` is what I should be using, but that seemed 
excessively hard to use.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142630

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Context.h
  clang/lib/AST/Interp/Function.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpState.h
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++14 -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify %s
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple i686 -verify %s
 // RUN: %clang_cc1 -verify=ref %s
 // RUN: %clang_cc1 -verify=ref -std=c++14 %s
+// RUN: %clang_cc1 -verify=ref -std=c++20 %s
 // RUN: %clang_cc1 -verify=ref -triple i686 %s
 
 struct BoolPair {
@@ -286,6 +288,7 @@
 };
 
 namespace DeriveFailures {
+#if __cplusplus < 202002L
   struct Base { // ref-note 2{{declared here}}
 int Val;
   };
@@ -301,10 +304,12 @@
// ref-note {{in call to 'Derived(12)'}} \
// ref-note {{declared here}} \
// expected-error {{must be initialized by a constant expression}}
+
   static_assert(D.Val == 0, ""); // ref-error {{not an integral constant expression}} \
  // ref-note {{initializer of 'D' is not a constant expression}} \
  // expected-error {{not an integral constant expression}} \
  // expected-note {{read of object outside its lifetime}}
+#endif
 
   struct AnotherBase {
 int Val;
@@ -354,3 +359,82 @@
   static_assert(getS(true).a == 12, "");
   static_assert(getS(false).a == 13, "");
 };
+
+#if __cplusplus >= 202002L
+namespace VirtualCalls {
+namespace Obvious {
+
+  class A {
+  public:
+constexpr A(){}
+constexpr virtual int foo() {
+  return 3;
+}
+  };
+  class B : public A {
+  public:
+constexpr int foo() override {
+  return 6;
+}
+  };
+
+  constexpr int getFooB(bool b) {
+A *a;
+A myA;
+B myB;
+
+if (b)
+  a = &myA;
+else
+  a = &myB;
+
+return a->foo();
+  }
+  static_assert(getFooB(true) == 3, "");
+  static_assert(getFooB(false) == 6, "");
+}
+
+namespace MultipleBases {
+  class A {
+  public:
+constexpr virtual int getInt() const { return 10; }
+  };
+  class B {
+  public:
+  };
+  class C : public A, public B {
+  public:
+constexpr int getInt() const override { return 20; }
+  };
+
+  constexpr int callGetInt(const A& a) { return a.getInt(); }
+  static_assert(callGetInt(C()) == 20, "");
+  static_assert(callGetInt(A()) == 10, "");
+}
+
+namespace Destructors {
+  class Base {
+  public:
+int i;
+constexpr Base(int &i) : i(i) {i++;}
+constexpr virtual ~Base() {i--;}
+  };
+
+  class Derived : public Base {
+  public:
+constexpr Derived(int &i) : Base(i) {}
+constexpr virtual ~Derived() {i--;}
+  };
+
+  constexpr int test() {
+int i = 0;
+Derived d(i);
+return i;
+  }
+  static_assert(test() == 1);
+}
+
+
+
+};
+#endif
Index: clang/lib/AST/Interp/InterpState.h
===
--- clang/lib/AST/Interp/InterpState.h
+++ clang/lib/AST/Interp/InterpState.h
@@ -86,6 +86,8 @@
 return M ? M->getSource(F, PC) : F->getSource(PC);
   }
 
+  Context &getContext() const { return Ctx; }
+
 private:
   /// AST Walker state.
   State &Parent;
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -1509,6 +1509,22 @@
 
 if (S.checkingPotentialConstantExpression())
   return false;
+
+// For a virtual call, we need to get the right function here.
+if (Func->isVirtual()) {
+  // Our ThisPtr has the decl of the right type at this point,
+  // so we just need to find the function to call.
+  const CXXRecordDecl *DynamicDecl =
+  ThisPtr.getDeclDesc()->getType()->getAsCXXRecordDecl();
+  const CXXRecordDecl *StaticDecl =
+  cast(Func->getParentDecl());
+  const CXXMethodDecl *InitialFunction =
+   

[PATCH] D142632: [clang][TypePrinter] Support expression template arguments when checking defaultedness

2023-01-26 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: erichkeane, aaron.ballman, aprantl, dblaikie.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds support for `TemplateArgument`s of kind
`TemplateArgument::Expression` to `clang::isSubstitutedDefaultArgument`.
We do so by evaluating both the `Pattern` and `Arg` expression to an
`APInt`, if we can, and comparing the results.

This will be useful in an upcoming change where
`clang::isSubstitutedDefaultArgument` gets called from `clang::Sema`
where the `TemplateArgument`s are instantiated as expressions (without
being evaluted to `APInt` beforehand).

**Testing**

- Added unit-tests


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142632

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/unittests/AST/TypePrinterTest.cpp

Index: clang/unittests/AST/TypePrinterTest.cpp
===
--- clang/unittests/AST/TypePrinterTest.cpp
+++ clang/unittests/AST/TypePrinterTest.cpp
@@ -127,3 +127,131 @@
 Policy.EntireContentsOfLargeArray = true;
   }));
 }
+
+TEST(TypePrinter, TemplateArgumentsSubstitution_Expressions) {
+  /// Tests clang::isSubstitutedDefaultArgument on TemplateArguments
+  /// that are of kind TemplateArgument::Expression
+  constexpr char Code[] = R"cpp(
+constexpr bool func() { return true; }
+
+template 
+struct Foo {
+};
+
+Foo X;
+  )cpp";
+
+  auto AST = tooling::buildASTFromCodeWithArgs(Code, /*Args=*/{"-std=c++20"});
+  ASTContext &Ctx = AST->getASTContext();
+
+  auto const *CTD = selectFirst(
+  "id", match(classTemplateDecl(hasName("Foo")).bind("id"), Ctx));
+  ASSERT_NE(CTD, nullptr);
+  auto const *CTSD = *CTD->specializations().begin();
+  ASSERT_NE(CTSD, nullptr);
+  auto const *Params = CTD->getTemplateParameters();
+  ASSERT_NE(Params, nullptr);
+  auto const &ArgList = CTSD->getTemplateArgs();
+
+  auto createBinOpExpr = [&](uint32_t LHS, uint32_t RHS,
+ uint32_t Result) -> ConstantExpr * {
+const int numBits = 32;
+clang::APValue ResultVal{llvm::APSInt(llvm::APInt(numBits, Result))};
+auto *LHSInt = IntegerLiteral::Create(Ctx, llvm::APInt(numBits, LHS),
+  Ctx.UnsignedIntTy, {});
+auto *RHSInt = IntegerLiteral::Create(Ctx, llvm::APInt(numBits, RHS),
+  Ctx.UnsignedIntTy, {});
+auto *BinOp = BinaryOperator::Create(
+Ctx, LHSInt, RHSInt, BinaryOperatorKind::BO_Add, Ctx.UnsignedIntTy,
+ExprValueKind::VK_PRValue, ExprObjectKind::OK_Ordinary, {}, {});
+return ConstantExpr::Create(Ctx, dyn_cast(BinOp), ResultVal);
+  };
+
+  {
+// Arg is an integral '42'
+auto const &Arg = ArgList.get(1);
+ASSERT_EQ(Arg.getKind(), TemplateArgument::Integral);
+
+// Param has default expr which evaluates to '42'
+auto const *Param = Params->getParam(1);
+
+EXPECT_TRUE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+// Arg is an integral '41'
+llvm::APInt Int(32, 41);
+TemplateArgument Arg(Ctx, llvm::APSInt(Int), Ctx.UnsignedIntTy);
+
+// Param has default expr which evaluates to '42'
+auto const *Param = Params->getParam(1);
+
+EXPECT_FALSE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+// Arg is an integral '4'
+llvm::APInt Int(32, 4);
+TemplateArgument Arg(Ctx, llvm::APSInt(Int), Ctx.UnsignedIntTy);
+
+// Param has is value-dependent expression (i.e., sizeof(T))
+auto const *Param = Params->getParam(3);
+
+EXPECT_FALSE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+const int LHS = 40;
+const int RHS = 2;
+const int Result = 42;
+auto *ConstExpr = createBinOpExpr(LHS, RHS, Result);
+// Arg is instantiated with '40 + 2'
+TemplateArgument Arg(ConstExpr);
+
+// Param has default expr of '42'
+auto const *Param = Params->getParam(1);
+
+EXPECT_TRUE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+const int LHS = 40;
+const int RHS = 1;
+const int Result = 41;
+auto *ConstExpr = createBinOpExpr(LHS, RHS, Result);
+
+// Arg is instantiated with '40 + 1'
+TemplateArgument Arg(ConstExpr);
+
+// Param has default expr of '42'
+auto const *Param = Params->getParam(1);
+
+EXPECT_FALSE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+const int LHS = 4;
+const int RHS = 0;
+const int Result = 4;
+auto *ConstExpr = createBinOpExpr(LHS, RHS, Result);
+
+// Arg is instantiated with '4 + 0'
+TemplateAr

[PATCH] D140423: [WIP][clang] Add PrintingPolicy callback for identifying default template arguments

2023-01-26 Thread Michael Buch via Phabricator via cfe-commits
Michael137 abandoned this revision.
Michael137 added a comment.

Abandoning in favour of https://reviews.llvm.org/D141826


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140423

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


[PATCH] D142627: [analyzer] Fix crash exposed by D140059

2023-01-26 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 would not mind less artificial-looking test code, but I'll let you decide if 
you want to make action about it.

Have you thought about the rest of the callsites of `getBitWidth()`? Are they 
also vulnerable to similar bugs?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142627

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


[PATCH] D140158: [CUDA] Allow targeting NVPTX directly without a host toolchain

2023-01-26 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D140158#4082804 , @jhuber6 wrote:

> In D140158#4082789 , @alexfh wrote:
>
>> This patch breaks our cuda compilations. The output file isn't created after 
>> it:
>>
>>   $ echo 'extern "C" __attribute__((global)) void q() {}' >q.cc
>>   $ good-clang \
>>   -nocudainc -x cuda \
>>   --cuda-path=somepath/cuda/ \
>>   -Wno-unknown-cuda-version --cuda-device-only \
>>   -c q.cc -o qqq-good.o \
>> && bad-clang \
>>   -nocudainc -x cuda \
>>   --cuda-path=somepath/cuda/ \
>>   -Wno-unknown-cuda-version --cuda-device-only \
>>   -c q.cc -o qqq-bad.o \
>> && ls qqq*.o
>>   qqq-good.o
>
> https://github.com/llvm/llvm-project/issues/60301 Still broken after this fix?

That works. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140158

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-26 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

I'm not overly familiar with HLSL or DirectX here. Most of the changes are 
purely mechanical, but I don't see anywhere we create the tool. Does that come 
later? Normally you'd test these with `-ccc-print-bindings`, 
`-ccc-print-bindings`, and `-###`.




Comment at: clang/lib/Driver/ToolChains/HLSL.cpp:146-147
+// Not find dxv.
+C.getDriver().Diag(diag::warn_drv_dxc_missing_dxv);
+return;
+  }

Can we really just ignore this if we don't find the path? Normally this is a 
hard error. If this is purely optional I would probably suggest not creating 
the job in the first place.



Comment at: clang/lib/Driver/ToolChains/HLSL.cpp:174
+// Lookup binaries into the driver directory, this is used to
+// discover the clang-offload-bundler executable.
+getProgramPaths().push_back(getDriver().Dir);

Copy paste.



Comment at: clang/test/Misc/warning-flags.c:19
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 

This comment looks relevant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D142637: A more concise AST dump If the modifiedType and the minimally desugared type of an AttributedType are the same, then we do not need to visit both (or show both in an AST dump). Here

2023-01-26 Thread Dani Ferreira Franco Moura via Phabricator via cfe-commits
merrymeerkat created this revision.
Herald added a project: All.
merrymeerkat requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

...when it is different from the equivalentType (the minimally desugared type), 
because the latter is already visited by default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142637

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/test/AST/ast-dump-attr-type.cpp
  clang/test/AST/ast-dump-types-json.cpp


Index: clang/test/AST/ast-dump-types-json.cpp
===
--- clang/test/AST/ast-dump-types-json.cpp
+++ clang/test/AST/ast-dump-types-json.cpp
@@ -203,32 +203,6 @@
 // CHECK-NEXT:]
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "ParenType",
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "void ()"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "inner": [
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "FunctionProtoType",
-// CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": "void ()"
-// CHECK-NEXT:},
-// CHECK-NEXT:"cc": "cdecl",
-// CHECK-NEXT:"inner": [
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "BuiltinType",
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "void"
-// CHECK-NEXT:  }
-// CHECK-NEXT: }
-// CHECK-NEXT:]
-// CHECK-NEXT:   }
-// CHECK-NEXT:  ]
 // CHECK-NEXT: }
 // CHECK-NEXT:]
 // CHECK-NEXT:   }
Index: clang/test/AST/ast-dump-attr-type.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-attr-type.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump %s | 
FileCheck %s
+
+int * _Nonnull x;
+using Ty = decltype(x);
+
+// CHECK:`-TypeAliasDecl 0x{{[^ ]*}}   col:7 Ty 
'decltype(x)':'int *'
+// CHECK-NEXT:  `-DecltypeType 0x{{[^ ]*}} 'decltype(x)' sugar
+// CHECK-NEXT: |-DeclRefExpr 0x{{[^ ]*}}  'int * _Nonnull':'int *' 
lvalue Var 0x{{[^ ]*}} 'x' 'int * _Nonnull':'int *' non_odr_use_unevaluated
+// CHECK-NEXT:`-AttributedType 0x{{[^ ]*}} 'int * _Nonnull' sugar
+// CHECK-NEXT:  `-PointerType 0x{{[^ ]*}} 'int *'
+// CHECK-NEXT:`-BuiltinType 0x{{[^ ]*}} 'int'
+// CHECK-NOT:   `-PointerType 0x564c31a07520 'int *'
Index: clang/include/clang/AST/ASTNodeTraverser.h
===
--- clang/include/clang/AST/ASTNodeTraverser.h
+++ clang/include/clang/AST/ASTNodeTraverser.h
@@ -384,7 +384,8 @@
   }
   void VisitAttributedType(const AttributedType *T) {
 // FIXME: AttrKind
-Visit(T->getModifiedType());
+if (T->getModifiedType() != T->getEquivalentType())
+  Visit(T->getModifiedType());
   }
   void VisitBTFTagAttributedType(const BTFTagAttributedType *T) {
 Visit(T->getWrappedType());


Index: clang/test/AST/ast-dump-types-json.cpp
===
--- clang/test/AST/ast-dump-types-json.cpp
+++ clang/test/AST/ast-dump-types-json.cpp
@@ -203,32 +203,6 @@
 // CHECK-NEXT:]
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "ParenType",
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "void ()"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "inner": [
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "FunctionProtoType",
-// CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": "void ()"
-// CHECK-NEXT:},
-// CHECK-NEXT:"cc": "cdecl",
-// CHECK-NEXT:"inner": [
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "BuiltinType",
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "void"
-// CHECK-NEXT:  }
-// CHECK-NEXT: }
-// CHECK-NEXT:]
-// CHECK-NEXT:   }
-// CHECK-NEXT:  ]
 // CHECK-NEXT: }
 // CHECK-NEXT:]
 // CHECK-NEXT:   }
Index: clang/test/AST/ast-dump-attr-type.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-attr-type.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump %s | FileCheck %s
+
+int * _Nonnull x;
+using Ty = decltype(x);
+
+// CHECK:`-TypeAliasDecl 0x{{

[clang] d4f4b2f - [clang] Fix sizeof of boolean vector

2023-01-26 Thread Mariya Podchishchaeva via cfe-commits

Author: Mariya Podchishchaeva
Date: 2023-01-26T10:44:15-05:00
New Revision: d4f4b2fe21dddff023aeab775dd63b321e23f918

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

LOG: [clang] Fix sizeof of boolean vector

Ensure it is at least 8 bits.

Fixes #59801

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/test/SemaCXX/vector-bool.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 18a041d7a72ab..bdbf1891190e4 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2076,7 +2076,8 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const 
{
 TypeInfo EltInfo = getTypeInfo(VT->getElementType());
 Width = VT->isExtVectorBoolType() ? VT->getNumElements()
   : EltInfo.Width * VT->getNumElements();
-// Enforce at least byte alignment.
+// Enforce at least byte size and alignment.
+Width = std::max(8, Width);
 Align = std::max(8, Width);
 
 // If the alignment is not a power of 2, round up to the next power of 2.

diff  --git a/clang/test/SemaCXX/vector-bool.cpp 
b/clang/test/SemaCXX/vector-bool.cpp
index 1b83a20999cb2..e99d420e73fab 100644
--- a/clang/test/SemaCXX/vector-bool.cpp
+++ b/clang/test/SemaCXX/vector-bool.cpp
@@ -90,3 +90,25 @@ bool* ElementRefs() {
   foo(eight_bools.w);// expected-error@90 {{illegal vector component name 
''w''}}
   foo(eight_bools.wyx);  // expected-error@91 {{illegal vector component name 
''wyx''}}
 }
+
+void Sizeof() {
+  using FourBools = bool __attribute__((ext_vector_type(4)));
+  using NineBools = bool __attribute__((ext_vector_type(9)));
+  using TwentyEightBools = bool __attribute__((ext_vector_type(28)));
+  using ThirtyThreeBools = bool __attribute__((ext_vector_type(33)));
+  using SixtyFiveBools = bool __attribute__((ext_vector_type(65)));
+  using Bool129 = bool __attribute__((ext_vector_type(129)));
+  using Bool150 = bool __attribute__((ext_vector_type(150)));
+  using Bool195 = bool __attribute__((ext_vector_type(195)));
+  using Bool257 = bool __attribute__((ext_vector_type(257)));
+  static_assert(sizeof(FourBools) == 1);
+  static_assert(sizeof(EightBools) == 1);
+  static_assert(sizeof(NineBools) == 2);
+  static_assert(sizeof(TwentyEightBools) == 4);
+  static_assert(sizeof(ThirtyThreeBools) == 8);
+  static_assert(sizeof(SixtyFiveBools) == 16);
+  static_assert(sizeof(Bool129) == 32);
+  static_assert(sizeof(Bool150) == 32);
+  static_assert(sizeof(Bool195) == 32);
+  static_assert(sizeof(Bool257) == 64);
+}



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


[PATCH] D142550: Fix sizeof of boolean vector

2023-01-26 Thread Mariya Podchishchaeva 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 rGd4f4b2fe21dd: [clang] Fix sizeof of boolean vector (authored 
by Fznamznon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142550

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/SemaCXX/vector-bool.cpp


Index: clang/test/SemaCXX/vector-bool.cpp
===
--- clang/test/SemaCXX/vector-bool.cpp
+++ clang/test/SemaCXX/vector-bool.cpp
@@ -90,3 +90,25 @@
   foo(eight_bools.w);// expected-error@90 {{illegal vector component name 
''w''}}
   foo(eight_bools.wyx);  // expected-error@91 {{illegal vector component name 
''wyx''}}
 }
+
+void Sizeof() {
+  using FourBools = bool __attribute__((ext_vector_type(4)));
+  using NineBools = bool __attribute__((ext_vector_type(9)));
+  using TwentyEightBools = bool __attribute__((ext_vector_type(28)));
+  using ThirtyThreeBools = bool __attribute__((ext_vector_type(33)));
+  using SixtyFiveBools = bool __attribute__((ext_vector_type(65)));
+  using Bool129 = bool __attribute__((ext_vector_type(129)));
+  using Bool150 = bool __attribute__((ext_vector_type(150)));
+  using Bool195 = bool __attribute__((ext_vector_type(195)));
+  using Bool257 = bool __attribute__((ext_vector_type(257)));
+  static_assert(sizeof(FourBools) == 1);
+  static_assert(sizeof(EightBools) == 1);
+  static_assert(sizeof(NineBools) == 2);
+  static_assert(sizeof(TwentyEightBools) == 4);
+  static_assert(sizeof(ThirtyThreeBools) == 8);
+  static_assert(sizeof(SixtyFiveBools) == 16);
+  static_assert(sizeof(Bool129) == 32);
+  static_assert(sizeof(Bool150) == 32);
+  static_assert(sizeof(Bool195) == 32);
+  static_assert(sizeof(Bool257) == 64);
+}
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2076,7 +2076,8 @@
 TypeInfo EltInfo = getTypeInfo(VT->getElementType());
 Width = VT->isExtVectorBoolType() ? VT->getNumElements()
   : EltInfo.Width * VT->getNumElements();
-// Enforce at least byte alignment.
+// Enforce at least byte size and alignment.
+Width = std::max(8, Width);
 Align = std::max(8, Width);
 
 // If the alignment is not a power of 2, round up to the next power of 2.


Index: clang/test/SemaCXX/vector-bool.cpp
===
--- clang/test/SemaCXX/vector-bool.cpp
+++ clang/test/SemaCXX/vector-bool.cpp
@@ -90,3 +90,25 @@
   foo(eight_bools.w);// expected-error@90 {{illegal vector component name ''w''}}
   foo(eight_bools.wyx);  // expected-error@91 {{illegal vector component name ''wyx''}}
 }
+
+void Sizeof() {
+  using FourBools = bool __attribute__((ext_vector_type(4)));
+  using NineBools = bool __attribute__((ext_vector_type(9)));
+  using TwentyEightBools = bool __attribute__((ext_vector_type(28)));
+  using ThirtyThreeBools = bool __attribute__((ext_vector_type(33)));
+  using SixtyFiveBools = bool __attribute__((ext_vector_type(65)));
+  using Bool129 = bool __attribute__((ext_vector_type(129)));
+  using Bool150 = bool __attribute__((ext_vector_type(150)));
+  using Bool195 = bool __attribute__((ext_vector_type(195)));
+  using Bool257 = bool __attribute__((ext_vector_type(257)));
+  static_assert(sizeof(FourBools) == 1);
+  static_assert(sizeof(EightBools) == 1);
+  static_assert(sizeof(NineBools) == 2);
+  static_assert(sizeof(TwentyEightBools) == 4);
+  static_assert(sizeof(ThirtyThreeBools) == 8);
+  static_assert(sizeof(SixtyFiveBools) == 16);
+  static_assert(sizeof(Bool129) == 32);
+  static_assert(sizeof(Bool150) == 32);
+  static_assert(sizeof(Bool195) == 32);
+  static_assert(sizeof(Bool257) == 64);
+}
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2076,7 +2076,8 @@
 TypeInfo EltInfo = getTypeInfo(VT->getElementType());
 Width = VT->isExtVectorBoolType() ? VT->getNumElements()
   : EltInfo.Width * VT->getNumElements();
-// Enforce at least byte alignment.
+// Enforce at least byte size and alignment.
+Width = std::max(8, Width);
 Align = std::max(8, Width);
 
 // If the alignment is not a power of 2, round up to the next power of 2.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142639: [clang] Warn by default that implicit capture of 'this' is deprecated in C++20 and later.

2023-01-26 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann created this revision.
tahonermann added reviewers: aaron.ballman, erichkeane, rsmith, shafik.
Herald added a project: All.
tahonermann requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously, a warning that C++20 deprecated implicit capture of 'this' for 
lambda captures specified with a capture default of '=' was only issued when 
'-Wdeprecated' or '-Wdeprecated-this-capture' was specified. This change 
enables the warning by default (it is still only issued when compiling for 
C++20 or later). This is consistent with gcc which warns by default (MSVC 
requires '/Wall').


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142639

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
  clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp
  clang/test/SemaCXX/lambda-implicit-this-capture.cpp


Index: clang/test/SemaCXX/lambda-implicit-this-capture.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-implicit-this-capture.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -verify=cxx11 %s
+// RUN: %clang_cc1 -std=c++2a -verify=cxx2a %s
+// RUN: %clang_cc1 -std=c++2a -verify=cxx2a-no-deprecated %s -Wno-deprecated
+// cxx11-no-diagnostics
+// cxx2a-no-deprecated-no-diagnostics
+
+struct A {
+  int i;
+  void f() {
+(void) [=] { // cxx2a-note {{add an explicit capture of 'this'}}
+  return i; // cxx2a-warning {{implicit capture of 'this' with a capture 
default of '=' is deprecated}}
+};
+  }
+};
Index: clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp
===
--- clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp
+++ clang/test/SemaCXX/cxx2a-lambda-equals-this.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++2a -verify %s -Wdeprecated
+// RUN: %clang_cc1 -std=c++2a -verify %s
+// expected-no-diagnostics
 
 // This test does two things.
 // Deleting the copy constructor ensures that an [=, this] capture doesn't 
copy the object.
@@ -12,12 +13,3 @@
 L();
   }
 };
-
-struct B {
-  int i;
-  void f() {
-(void) [=] { // expected-note {{add an explicit capture of 'this'}}
-  return i; // expected-warning {{implicit capture of 'this' with a 
capture default of '=' is deprecated}}
-};
-  }
-};
Index: clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
===
--- clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
+++ clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -emit-llvm-only %s
-// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only 
-fblocks -emit-llvm-only %s
+// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only 
-fblocks -emit-llvm-only -Wno-deprecated-this-capture %s
 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -emit-llvm-only 
-triple i386-windows-pc %s
-// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only 
-fblocks -emit-llvm-only -triple i386-windows-pc %s
+// RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fsyntax-only 
-fblocks -emit-llvm-only -triple i386-windows-pc -Wno-deprecated-this-capture %s
 // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks 
-fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING
 // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks 
-fms-extensions %s -DMS_EXTENSIONS
 // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks 
-fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS 
-DDELAYED_TEMPLATE_PARSING
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7906,7 +7906,7 @@
 "is a C++20 extension">, InGroup;
   def warn_deprecated_this_capture : Warning<
 "implicit capture of 'this' with a capture default of '=' is deprecated">,
-InGroup, DefaultIgnore;
+InGroup;
   def note_deprecated_this_capture : Note<
 "add an explicit capture of 'this' to capture '*this' by reference">;
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -466,6 +466,9 @@
 - Clang now automatically adds ``[[clang::lifetimebound]]`` to the parameters 
of
   ``std::move, std::forward`` et al, this enables Clang to diagnose more cases
   where the returned reference outlives the object.
+- Clang now warns by default for C++20 and later about deprecated capture of
+  ``this`` with a capture default of ``=``. This warning can be disabled with
+  ``-Wno-deprecated-this-capture``.
 
 Non-comp

[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-26 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:687
+def warn_drv_dxc_missing_dxv : Warning<"dxv not found."
+" Resulting DXIL will not be signed for use in release environments.">;
 

Not all `dxv` binaries can sign… some just validate. Only the “official” 
releases support signing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D142639: [clang] Warn by default that implicit capture of 'this' is deprecated in C++20 and later.

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

You'll need a rebase to get the pre-commit CI to work.  Else, looks fine to me. 
 Make sure @royjacobson knows of the change for this 
(https://reviews.llvm.org/D142578).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142639

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


[PATCH] D142632: [clang][TypePrinter] Support expression template arguments when checking defaultedness

2023-01-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I think this looks correct, but 1 thing I found.




Comment at: clang/lib/AST/TypePrinter.cpp:2020
+  Expr const *pattern_expr = Pattern.getAsExpr();
+  pattern_expr->dump();
+  if (pattern_expr->isValueDependent() ||

this left over from debugging?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142632

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


[PATCH] D142632: [clang][TypePrinter] Support expression template arguments when checking defaultedness

2023-01-26 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added inline comments.



Comment at: clang/lib/AST/TypePrinter.cpp:2020
+  Expr const *pattern_expr = Pattern.getAsExpr();
+  pattern_expr->dump();
+  if (pattern_expr->isValueDependent() ||

erichkeane wrote:
> this left over from debugging?
Yes! Good catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142632

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


[PATCH] D142632: [clang][TypePrinter] Support expression template arguments when checking defaultedness

2023-01-26 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 492458.
Michael137 added a comment.

- Remove `dump()` leftover from debugging


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142632

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/unittests/AST/TypePrinterTest.cpp

Index: clang/unittests/AST/TypePrinterTest.cpp
===
--- clang/unittests/AST/TypePrinterTest.cpp
+++ clang/unittests/AST/TypePrinterTest.cpp
@@ -127,3 +127,131 @@
 Policy.EntireContentsOfLargeArray = true;
   }));
 }
+
+TEST(TypePrinter, TemplateArgumentsSubstitution_Expressions) {
+  /// Tests clang::isSubstitutedDefaultArgument on TemplateArguments
+  /// that are of kind TemplateArgument::Expression
+  constexpr char Code[] = R"cpp(
+constexpr bool func() { return true; }
+
+template 
+struct Foo {
+};
+
+Foo X;
+  )cpp";
+
+  auto AST = tooling::buildASTFromCodeWithArgs(Code, /*Args=*/{"-std=c++20"});
+  ASTContext &Ctx = AST->getASTContext();
+
+  auto const *CTD = selectFirst(
+  "id", match(classTemplateDecl(hasName("Foo")).bind("id"), Ctx));
+  ASSERT_NE(CTD, nullptr);
+  auto const *CTSD = *CTD->specializations().begin();
+  ASSERT_NE(CTSD, nullptr);
+  auto const *Params = CTD->getTemplateParameters();
+  ASSERT_NE(Params, nullptr);
+  auto const &ArgList = CTSD->getTemplateArgs();
+
+  auto createBinOpExpr = [&](uint32_t LHS, uint32_t RHS,
+ uint32_t Result) -> ConstantExpr * {
+const int numBits = 32;
+clang::APValue ResultVal{llvm::APSInt(llvm::APInt(numBits, Result))};
+auto *LHSInt = IntegerLiteral::Create(Ctx, llvm::APInt(numBits, LHS),
+  Ctx.UnsignedIntTy, {});
+auto *RHSInt = IntegerLiteral::Create(Ctx, llvm::APInt(numBits, RHS),
+  Ctx.UnsignedIntTy, {});
+auto *BinOp = BinaryOperator::Create(
+Ctx, LHSInt, RHSInt, BinaryOperatorKind::BO_Add, Ctx.UnsignedIntTy,
+ExprValueKind::VK_PRValue, ExprObjectKind::OK_Ordinary, {}, {});
+return ConstantExpr::Create(Ctx, dyn_cast(BinOp), ResultVal);
+  };
+
+  {
+// Arg is an integral '42'
+auto const &Arg = ArgList.get(1);
+ASSERT_EQ(Arg.getKind(), TemplateArgument::Integral);
+
+// Param has default expr which evaluates to '42'
+auto const *Param = Params->getParam(1);
+
+EXPECT_TRUE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+// Arg is an integral '41'
+llvm::APInt Int(32, 41);
+TemplateArgument Arg(Ctx, llvm::APSInt(Int), Ctx.UnsignedIntTy);
+
+// Param has default expr which evaluates to '42'
+auto const *Param = Params->getParam(1);
+
+EXPECT_FALSE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+// Arg is an integral '4'
+llvm::APInt Int(32, 4);
+TemplateArgument Arg(Ctx, llvm::APSInt(Int), Ctx.UnsignedIntTy);
+
+// Param has is value-dependent expression (i.e., sizeof(T))
+auto const *Param = Params->getParam(3);
+
+EXPECT_FALSE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+const int LHS = 40;
+const int RHS = 2;
+const int Result = 42;
+auto *ConstExpr = createBinOpExpr(LHS, RHS, Result);
+// Arg is instantiated with '40 + 2'
+TemplateArgument Arg(ConstExpr);
+
+// Param has default expr of '42'
+auto const *Param = Params->getParam(1);
+
+EXPECT_TRUE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+const int LHS = 40;
+const int RHS = 1;
+const int Result = 41;
+auto *ConstExpr = createBinOpExpr(LHS, RHS, Result);
+
+// Arg is instantiated with '40 + 1'
+TemplateArgument Arg(ConstExpr);
+
+// Param has default expr of '42'
+auto const *Param = Params->getParam(1);
+
+EXPECT_FALSE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+
+  {
+const int LHS = 4;
+const int RHS = 0;
+const int Result = 4;
+auto *ConstExpr = createBinOpExpr(LHS, RHS, Result);
+
+// Arg is instantiated with '4 + 0'
+TemplateArgument Arg(ConstExpr);
+
+// Param has is value-dependent expression (i.e., sizeof(T))
+auto const *Param = Params->getParam(3);
+
+EXPECT_FALSE(clang::isSubstitutedDefaultArgument(
+Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
+  }
+}
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -2007,6 +2007,36 @@
   return false;
 }
 
+/// Evaluates the expression template argument 'Pattern' and returns true
+/// if 'Arg

[PATCH] D142592: [clang-tidy][libc] Add an inline function checker for the libc project.

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



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.cpp:18-19
+
+// CHECK-MESSAGES: warning: 'addll' must be tagged with the LIBC_INLINE macro
+// CHECK-MESSAGES: warning: 'addul' must be tagged with the LIBC_INLINE macro
+// CHECK-MESSAGES: warning: 'MyClass' must be tagged with the LIBC_INLINE macro

These should specify which line they apply to, as done in all other checks. 

In particular, to get the unit test to work, you will not be able to use a .cpp 
that includes a header. The test file must be a .hpp file (for which you need 
`HeaderFileExtensions` as I said above).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142592

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


[PATCH] D142583: [SPIR] Add support for __arithmetic_fence builtin for SPIR target.

2023-01-26 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/test/CodeGen/arithmetic-fence-builtin.c:73
 int subit(float a, float b, float *fp) {
-  // CHECKFAST: define {{.*}}@subit(float noundef %a, float noundef %b{{.*}}
+  // CHECKPRECISE: define {{.*}}@subit(float noundef %a, float noundef %b{{.*}}
   *fp = __arithmetic_fence(a - b);

Why is this check removed for SPIR target?


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

https://reviews.llvm.org/D142583

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


[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-01-26 Thread Mark Danial via Phabricator via cfe-commits
madanial updated this revision to Diff 492463.
madanial added a comment.

Addressing review comment


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

https://reviews.llvm.org/D140795

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Optimizer/Transforms/Passes.h
  flang/include/flang/Optimizer/Transforms/Passes.td
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/underscoring.f90

Index: flang/test/Driver/underscoring.f90
===
--- /dev/null
+++ flang/test/Driver/underscoring.f90
@@ -0,0 +1,24 @@
+! Test the -funderscoring flag
+
+! RUN: %flang_fc1 -S %s -o - 2>&1 | FileCheck %s --check-prefix=UNDERSCORING
+! RUN: %flang_fc1 -S -fno-underscoring %s -o - 2>&1 | FileCheck %s --check-prefix=NO-UNDERSCORING
+
+subroutine test()
+  common /comblk/ a, b
+  external :: ext_sub
+  call ext_sub()
+end
+
+! UNDERSCORING: test_
+! UNDERSCORING: ext_sub_
+! UNDERSCORING: comblk_
+
+! NO-UNDERSCORING-NOT: test_
+! NO-UNDERSCORING-NOT: _QPtest
+! NO-UNDERSCORING: test
+! NO-UNDERSCORING-NOT: ext_sub_
+! NO-UNDERSCORING-NOT: _QPext_sub
+! NO-UNDERSCORING: ext_sub
+! NO-UNDERSCORING-NOT: comblk_
+! NO-UNDERSCORING-NOT: _QBcomblk
+! NO-UNDERSCORING: comblk
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -50,6 +50,7 @@
 ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
+! HELP-NEXT: -funderscoring Appends one trailing underscore to external names
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
@@ -135,6 +136,7 @@
 ! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
+! HELP-FC1-NEXT: -funderscoring Appends one trailing underscore to external names
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-FC1-NEXT: -help  Display available options
 ! HELP-FC1-NEXT: -init-only Only execute frontend initialization
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -52,6 +52,7 @@
 ! CHECK-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
 ! CHECK-NEXT: -freciprocal-math  Allow division operations to be reassociated
 ! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
+! CHECK-NEXT: -funderscoring Appends one trailing underscore to external names
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
Index: flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
===
--- flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -32,11 +32,16 @@
 std::string
 mangleExternalName(const std::pair
-   result) {
+   result,
+   bool appendUnderscore) {
   if (result.first == fir::NameUniquer::NameKind::COMMON &&
   result.second.name.empty())
 return "__BLNK__";
-  return result.second.name + "_";
+
+  if (appendUnderscore)
+return result.second.name + "_";
+
+  return result.second.name;
 }
 
 //===--===//
@@ -49,6 +54,10 @@
 public:
   using OpRewritePattern::OpRewritePattern;
 
+  MangleNameOnCallOp(mlir::MLIRContext *ctx, bool appendUnderscore)
+  : mlir::OpRewritePattern(ctx),
+appendUnderscore(appendUnderscore) {}
+
   mlir::LogicalResult
   matchAndRewrite(fir::CallOp op,
   mlir::PatternRewriter &rewriter) const override {
@@ -58,34 +67,49 @@

[PATCH] D142085: [WIP][1/N][Clang][RISCV] Add `__riscv_` prefix for vread, vwrite, vsetvl, and vsetvlmax

2023-01-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 492464.
eopXD added a comment.

Update code. Split the single patch into a patch-set of smaller steps.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142085

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsetvl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsetvlmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsetvl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsetvlmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vread-csr.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vwrite-csr.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vwrite-csr.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vwrite-csr.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vwrite-csr.c
@@ -11,7 +11,7 @@
 // CHECK-NEXT:ret void
 //
 void vwrite_csr_vstart(unsigned long value) {
-  vwrite_csr(RVV_VSTART, value);
+  __riscv_vwrite_csr(RVV_VSTART, value);
 }
 
 // CHECK-LABEL: @vwrite_csr_vxsat(
@@ -20,7 +20,7 @@
 // CHECK-NEXT:ret void
 //
 void vwrite_csr_vxsat(unsigned long value) {
-  vwrite_csr(RVV_VXSAT, value);
+  __riscv_vwrite_csr(RVV_VXSAT, value);
 }
 
 // CHECK-LABEL: @vwrite_csr_vxrm(
@@ -29,7 +29,7 @@
 // CHECK-NEXT:ret void
 //
 void vwrite_csr_vxrm(unsigned long value) {
-  vwrite_csr(RVV_VXRM, value);
+  __riscv_vwrite_csr(RVV_VXRM, value);
 }
 
 // CHECK-LABEL: @vwrite_csr_vcsr(
@@ -38,5 +38,5 @@
 // CHECK-NEXT:ret void
 //
 void vwrite_csr_vcsr(unsigned long value) {
-  vwrite_csr(RVV_VCSR, value);
+  __riscv_vwrite_csr(RVV_VCSR, value);
 }
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vread-csr.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vread-csr.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vread-csr.c
@@ -11,7 +11,7 @@
 // CHECK-NEXT:ret i64 [[TMP0]]
 //
 unsigned long vread_csr_vstart(void) {
-  return vread_csr(RVV_VSTART);
+  return __riscv_vread_csr(RVV_VSTART);
 }
 
 // CHECK-LABEL: @vread_csr_vxsat(
@@ -20,7 +20,7 @@
 // CHECK-NEXT:ret i64 [[TMP0]]
 //
 unsigned long vread_csr_vxsat(void) {
-  return vread_csr(RVV_VXSAT);
+  return __riscv_vread_csr(RVV_VXSAT);
 }
 
 // CHECK-LABEL: @vread_csr_vxrm(
@@ -29,7 +29,7 @@
 // CHECK-NEXT:ret i64 [[TMP0]]
 //
 unsigned long vread_csr_vxrm(void) {
-  return vread_csr(RVV_VXRM);
+  return __riscv_vread_csr(RVV_VXRM);
 }
 
 // CHECK-LABEL: @vread_csr_vcsr(
@@ -38,5 +38,5 @@
 // CHECK-NEXT:ret i64 [[TMP0]]
 //
 unsigned long vread_csr_vcsr(void) {
-  return vread_csr(RVV_VCSR);
+  return __riscv_vread_csr(RVV_VCSR);
 }
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsetvlmax.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsetvlmax.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsetvlmax.c
@@ -12,7 +12,7 @@
 // CHECK-RV64-NEXT:ret i64 [[TMP0]]
 //
 size_t test_vsetvlmax_e8mf8() {
-  return vsetvlmax_e8mf8();
+  return __riscv_vsetvlmax_e8mf8();
 }
 
 // CHECK-RV64-LABEL: @test_vsetvlmax_e8mf4(
@@ -21,7 +21,7 @@
 // CHECK-RV64-NEXT:ret i64 [[TMP0]]
 //
 size_t test_vsetvlmax_e8mf4() {
-  return vsetvlmax_e8mf4();
+  return __riscv_vsetvlmax_e8mf4();
 }
 
 // CHECK-RV64-LABEL: @test_vsetvlmax_e8mf2(
@@ -30,7 +30,7 @@
 // CHECK-RV64-NEXT:ret i64 [[TMP0]]
 //
 size_t test_vsetvlmax_e8mf2() {
-  return vsetvlmax_e8mf2();
+  return __riscv_vsetvlmax_e8mf2();
 }
 
 // CHECK-RV64-LABEL: @test_vsetvlmax_e8m1(
@@ -39,7 +39,7 @@
 // CHECK-RV64-NEXT:ret i64 [[TMP0]]
 //
 size_t test_vsetvlmax_e8m1() {
-  return vsetvlmax_e8m1();
+  return __riscv_vsetvlmax_e8m1();
 }
 
 // CHECK-RV64-LABEL: @test_vsetvlmax_e8m2(
@@ -48,7 +48,7 @@
 // CHECK-RV64-NEXT:ret i64 [[TMP0]]
 //
 size_t test_vsetvlmax_e8m2() {
-  return vsetvlmax_e8m2();
+  return __riscv_vsetvlmax_e8m2();
 }
 
 // CHECK-RV64-LABEL: @test_vsetvlmax_e8m4(
@@ -57,7 +57,7 @@
 // CHECK-RV64-NEXT:ret i64 [[TMP0]]
 //
 size_t test_vsetvlmax_e8m4() {
-  return vsetvlmax_e8m4();
+  return __riscv_vsetvlmax_e8m4();
 }
 
 // CHECK-RV64-LABEL: @test_vsetvlmax_e8m8(
@@ -66,7 +66,7 @@
 // CHECK-RV64-NEXT:ret i64 [[TMP0]]
 //
 size_t test_vsetvlmax_e8m8() {
-  return vsetvlmax_e8m8();
+  return __riscv_vsetvlmax_e8m8();
 }
 
 // CHECK-RV64-LABEL: @test_vsetvlmax_e16mf4(
@@ -75,7 +75,7 @@
 // CHECK-RV64-NEXT:ret i64 [[TMP0]]
 //
 size_t test_vsetvlmax_e16mf4() {
-  return vsetvlmax_e16mf4();
+  return __riscv_vsetvlmax_e16mf4();
 }
 
 // CHECK-RV64-LABEL: @test_vsetv

[clang] 98d5509 - Fix assertion failure "PathDiagnosticSpotPiece's must have a valid location." in ReturnPtrRange checker on builtin functions

2023-01-26 Thread Balazs Benics via cfe-commits

Author: Arseniy Zaostrovnykh
Date: 2023-01-26T17:26:05+01:00
New Revision: 98d55095d85129c2776a9d7a227c5f88e3ce2e01

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

LOG: Fix assertion failure "PathDiagnosticSpotPiece's must have a valid 
location." in ReturnPtrRange checker on builtin functions

Builtin functions (such as `std::move`, `std::forward`, `std::as_const`)
have a body generated during the analysis not related to any source file
so their statements have no valid source locations.
`ReturnPtrRange` checker should not report issues for these builtin
functions because they only forward its parameter and do not create any
new pointers.

Fixes #55347

Patch by Arseniy Zaostrovnykh.

Reviewed By: NoQ

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
clang/test/Analysis/return-ptr-range.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
index b35ab1fe23ce3..b85d0adb8eafb 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
@@ -41,6 +41,10 @@ void ReturnPointerRangeChecker::checkPreStmt(const 
ReturnStmt *RS,
   if (!RetE)
 return;
 
+  // Skip "body farmed" functions.
+  if (RetE->getSourceRange().isInvalid())
+return;
+
   SVal V = C.getSVal(RetE);
   const MemRegion *R = V.getAsRegion();
 

diff  --git a/clang/test/Analysis/return-ptr-range.cpp 
b/clang/test/Analysis/return-ptr-range.cpp
index 34c953ee213b7..507720a47ea7d 100644
--- a/clang/test/Analysis/return-ptr-range.cpp
+++ b/clang/test/Analysis/return-ptr-range.cpp
@@ -115,3 +115,14 @@ Data *test_struct_array() {
 
 }
 
+namespace std {
+// A builtin function with the body generated on the fly.
+template  T&& move(T &&) noexcept;
+} // namespace std
+
+char buf[2];
+
+void top() {
+  // see https://github.com/llvm/llvm-project/issues/55347
+  (void)std::move(*(buf + 3)); // no-crash
+}



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


[clang] 3674421 - [analyzer] Fix assertion failure in SMT conversion for unary operator on floats

2023-01-26 Thread Balazs Benics via cfe-commits

Author: Tomasz Kamiński
Date: 2023-01-26T17:33:48+01:00
New Revision: 3674421c4bc0cd3b65b8f1feaaf7038ac2d47ca8

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

LOG: [analyzer] Fix assertion failure in SMT conversion for unary operator on 
floats

In the handling of the Symbols from the RangExpr, the code assumed that
the operands of the unary operators need to have integral type.
However, the CSA can create SymExpr with a floating point operand, when
the integer value is cast into it, like `(float)h == (float)l` where
both of `h` and `l` are integers.

This patch handles such situations, by using `fromFloatUnOp()` instead
of `fromUnOp()`, when the operand have a floating point type.

I have investigated all other calls of `fromUnOp()`, and for one in:

 - `getZeroExpr()` is applied only on boolean types, so it correct
 - `fromBinOp()` is not invoked for floating points
 - `fromFloatUnOp()` I am uncertain about this case and I was not able
   to produce a test that would reach this point, as a negation of
   floating points numbers seem to produce `Unknown` symbols.

This issue exists since the introduction of `UnarySymExpr` in D125318
and their handling for Z3 in D125547.

Patch by Tomasz Kamiński.

Reviewed By: mikhail.ramalho

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
clang/test/Analysis/z3-crosscheck.c

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
index ea05b9f8ee3fe..fcc9c02999b3b 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
@@ -454,7 +454,9 @@ class SMTConv {
   llvm::SMTExprRef OperandExp =
   getSymExpr(Solver, Ctx, USE->getOperand(), &OperandTy, 
hasComparison);
   llvm::SMTExprRef UnaryExp =
-  fromUnOp(Solver, USE->getOpcode(), OperandExp);
+  OperandTy->isRealFloatingType()
+  ? fromFloatUnOp(Solver, USE->getOpcode(), OperandExp)
+  : fromUnOp(Solver, USE->getOpcode(), OperandExp);
 
   // Currently, without the `support-symbolic-integer-casts=true` option,
   // we do not emit `SymbolCast`s for implicit casts.

diff  --git a/clang/test/Analysis/z3-crosscheck.c 
b/clang/test/Analysis/z3-crosscheck.c
index 7711597eb9ec8..e0ec028c518d3 100644
--- a/clang/test/Analysis/z3-crosscheck.c
+++ b/clang/test/Analysis/z3-crosscheck.c
@@ -1,7 +1,9 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -DNO_CROSSCHECK -verify 
%s
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config 
crosscheck-with-z3=true -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -DNO_CROSSCHECK -verify 
%s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config 
crosscheck-with-z3=true -verify %s
 // REQUIRES: z3
 
+void clang_analyzer_dump(float);
+
 int foo(int x) 
 {
   int *z = 0;
@@ -55,3 +57,23 @@ void i() {
 h(2);
   }
 }
+
+void floatUnaryNegInEq(int h, int l) {
+  int j;
+  clang_analyzer_dump(-(float)h); // expected-warning-re{{-(float) 
(reg_${{[0-9]+}})}}
+  clang_analyzer_dump((float)l); // expected-warning-re {{(float) 
(reg_${{[0-9]+}})}}
+  if (-(float)h != (float)l) {  // should not crash
+j += 10;
+// expected-warning@-1{{garbage}}
+  }
+}
+
+void floatUnaryLNotInEq(int h, int l) {
+  int j;
+  clang_analyzer_dump(!(float)h); // expected-warning{{Unknown}}
+  clang_analyzer_dump((float)l); // expected-warning-re {{(float) 
(reg_${{[0-9]+}})}}
+  if ((!(float)h) != (float)l) {  // should not crash
+j += 10;
+// expected-warning@-1{{garbage}}
+  }
+}



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


[PATCH] D142085: [WIP][1/N][Clang][RISCV] Add `__riscv_` prefix for vread, vwrite, vsetvl, and vsetvlmax

2023-01-26 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

As requested, @jrtc27 @kito-cheng, the patch does not alter the function name 
now.


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


  1   2   3   >