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

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

Fix tests.


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
  clang/tools/include-mapping/test.py

Index: clang/tools/include-mapping/test.py
===
--- clang/tools/include-mapping/test.py
+++ clang/tools/include-mapping/test.py
@@ -53,7 +53,7 @@
   
 
 """
-self.assertEqual(_ParseSymbolPage(html, 'foo'), set(['']))
+self.assertEqual(_ParseSymbolPage(html, 'foo', ""), set(['']))
 
 
   def testParseSymbolPage_MulHeaders(self):
@@ -94,7 +94,7 @@
   
 
 """
-self.assertEqual(_ParseSymbolPage(html, "foo"),
+self.assertEqual(_ParseSymbolPage(html, "foo", ""),
  set(['', '']))
 
 
@@ -121,7 +121,7 @@
 
 
 """
-self.assertEqual(_ParseSymbolPage(html, "foo"),
+self.assertEqual(_ParseSymbolPage(html, "foo", ""),
  set(['', '']))
 
   def testParseSymbolPage_MulSymbolsInSameTd(self):
@@ -145,9 +145,9 @@
 
 
 """
-self.assertEqual(_ParseSymbolPage(html, "int8_t"),
+self.assertEqual(_ParseSymbolPage(html, "int8_t", ""),
  set(['']))
-self.assertEqual(_ParseSymbolPage(html, "int16_t"),
+self.assertEqual(_ParseSymbolPage(html, "int16_t", ""),
  set(['']))
 
 
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, variant_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,51 @@
   #   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:

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

2023-01-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 492774.
VitaNuo marked 6 inline comments as done.
VitaNuo added a comment.

Address review comments. No new tests in this version.


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, variant_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,51 @@
   #   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 variant_to_accept != "" and header_code.text.strip("<>") != variant_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 not _HasClass(rows[i], 't-dsc', 

[PATCH] D142713: [clang][ASTImporter] Propagate TemplateArgument::IsDefaulted during import

2023-01-27 Thread Michael Buch 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 rGd194d817b0b2: [clang][ASTImporter] Propagate 
TemplateArgument::IsDefaulted during import (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142713

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1158,6 +1158,26 @@
   ASSERT_EQ(cast(ToArg)->getValue().getLimitedValue(), 1U);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, TemplateArgumentsDefaulted) {
+  Decl *FromTU = getTuDecl(R"(
+   template struct X {};
+   template typename TT = X> struct 
S {};
+   S<> s;
+   )",
+   Lang_CXX17);
+  auto *FromSpec = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("S")));
+  ASSERT_TRUE(FromSpec);
+  auto *ToSpec = Import(FromSpec, Lang_CXX03);
+  ASSERT_TRUE(ToSpec);
+  auto const  = ToSpec->getTemplateArgs();
+  for (auto const  : TList.asArray()) {
+ASSERT_TRUE(Arg.getIsDefaulted());
+  }
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportOfTemplatedDeclOfClassTemplateDecl) {
   Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03);
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -836,7 +836,8 @@
 ExpectedType ToTypeOrErr = import(From.getAsType());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToTypeOrErr);
+return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/ false,
+From.getIsDefaulted());
   }
 
   case TemplateArgument::Integral: {
@@ -853,14 +854,15 @@
 ExpectedType ToTypeOrErr = import(From.getParamTypeForDecl());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToOrErr, *ToTypeOrErr);
+return TemplateArgument(*ToOrErr, *ToTypeOrErr, From.getIsDefaulted());
   }
 
   case TemplateArgument::NullPtr: {
 ExpectedType ToTypeOrErr = import(From.getNullPtrType());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/true);
+return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/ true,
+From.getIsDefaulted());
   }
 
   case TemplateArgument::Template: {
@@ -868,7 +870,7 @@
 if (!ToTemplateOrErr)
   return ToTemplateOrErr.takeError();
 
-return TemplateArgument(*ToTemplateOrErr);
+return TemplateArgument(*ToTemplateOrErr, From.getIsDefaulted());
   }
 
   case TemplateArgument::TemplateExpansion: {
@@ -877,13 +879,13 @@
 if (!ToTemplateOrErr)
   return ToTemplateOrErr.takeError();
 
-return TemplateArgument(
-*ToTemplateOrErr, From.getNumTemplateExpansions());
+return TemplateArgument(*ToTemplateOrErr, From.getNumTemplateExpansions(),
+From.getIsDefaulted());
   }
 
   case TemplateArgument::Expression:
 if (ExpectedExpr ToExpr = import(From.getAsExpr()))
-  return TemplateArgument(*ToExpr);
+  return TemplateArgument(*ToExpr, From.getIsDefaulted());
 else
   return ToExpr.takeError();
 


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1158,6 +1158,26 @@
   ASSERT_EQ(cast(ToArg)->getValue().getLimitedValue(), 1U);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, TemplateArgumentsDefaulted) {
+  Decl *FromTU = getTuDecl(R"(
+   template struct X {};
+   template typename TT = X> struct S {};
+   S<> s;
+   )",
+   Lang_CXX17);
+  auto *FromSpec = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("S")));
+  ASSERT_TRUE(FromSpec);
+  auto *ToSpec = Import(FromSpec, Lang_CXX03);
+  ASSERT_TRUE(ToSpec);
+  auto const  = ToSpec->getTemplateArgs();
+  for (auto const  : TList.asArray()) {
+ASSERT_TRUE(Arg.getIsDefaulted());
+  }
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportOfTemplatedDeclOfClassTemplateDecl) {
   Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03);
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -836,7 +836,8 @@
 ExpectedType ToTypeOrErr = 

[clang] d194d81 - [clang][ASTImporter] Propagate TemplateArgument::IsDefaulted during import

2023-01-27 Thread Michael Buch via cfe-commits

Author: Michael Buch
Date: 2023-01-27T16:39:17Z
New Revision: d194d817b0b29c6e244d01cf7b836b9e4bbe2794

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

LOG: [clang][ASTImporter] Propagate TemplateArgument::IsDefaulted during import

With https://reviews.llvm.org/D141826 `TemplateArgument`s have an
additional field that indicates their defaulted-ness. This gets
used during debug-info generation and in the `clang::TypePrinter`.

This patch copies the field during the import process so consumers
of the ASTImporter can benefit from the other Clang components that
read the field.

**Testing**

* Added unit-test
* Checked that this fixes (in addition to a follow-up LLDB patch)
  fix current test failures in LLDB

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 6f367ef053d2c..e9bac0d0529d4 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -836,7 +836,8 @@ ASTNodeImporter::import(const TemplateArgument ) {
 ExpectedType ToTypeOrErr = import(From.getAsType());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToTypeOrErr);
+return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/ false,
+From.getIsDefaulted());
   }
 
   case TemplateArgument::Integral: {
@@ -853,14 +854,15 @@ ASTNodeImporter::import(const TemplateArgument ) {
 ExpectedType ToTypeOrErr = import(From.getParamTypeForDecl());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToOrErr, *ToTypeOrErr);
+return TemplateArgument(*ToOrErr, *ToTypeOrErr, From.getIsDefaulted());
   }
 
   case TemplateArgument::NullPtr: {
 ExpectedType ToTypeOrErr = import(From.getNullPtrType());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/true);
+return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/ true,
+From.getIsDefaulted());
   }
 
   case TemplateArgument::Template: {
@@ -868,7 +870,7 @@ ASTNodeImporter::import(const TemplateArgument ) {
 if (!ToTemplateOrErr)
   return ToTemplateOrErr.takeError();
 
-return TemplateArgument(*ToTemplateOrErr);
+return TemplateArgument(*ToTemplateOrErr, From.getIsDefaulted());
   }
 
   case TemplateArgument::TemplateExpansion: {
@@ -877,13 +879,13 @@ ASTNodeImporter::import(const TemplateArgument ) {
 if (!ToTemplateOrErr)
   return ToTemplateOrErr.takeError();
 
-return TemplateArgument(
-*ToTemplateOrErr, From.getNumTemplateExpansions());
+return TemplateArgument(*ToTemplateOrErr, From.getNumTemplateExpansions(),
+From.getIsDefaulted());
   }
 
   case TemplateArgument::Expression:
 if (ExpectedExpr ToExpr = import(From.getAsExpr()))
-  return TemplateArgument(*ToExpr);
+  return TemplateArgument(*ToExpr, From.getIsDefaulted());
 else
   return ToExpr.takeError();
 

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index cd33d5017481c..1080b5acd4b30 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -1158,6 +1158,26 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
NonTypeTemplateParmDeclDefaultArg) {
   ASSERT_EQ(cast(ToArg)->getValue().getLimitedValue(), 1U);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, TemplateArgumentsDefaulted) {
+  Decl *FromTU = getTuDecl(R"(
+   template struct X {};
+   template typename TT = X> struct 
S {};
+   S<> s;
+   )",
+   Lang_CXX17);
+  auto *FromSpec = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("S")));
+  ASSERT_TRUE(FromSpec);
+  auto *ToSpec = Import(FromSpec, Lang_CXX03);
+  ASSERT_TRUE(ToSpec);
+  auto const  = ToSpec->getTemplateArgs();
+  for (auto const  : TList.asArray()) {
+ASSERT_TRUE(Arg.getIsDefaulted());
+  }
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportOfTemplatedDeclOfClassTemplateDecl) {
   Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03);



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


[PATCH] D142704: [C++20][Modules] Handle template declarations in header units.

2023-01-27 Thread Iain Sandoe via Phabricator via cfe-commits
iains planned changes to this revision.
iains added a comment.

this is necessary, but not sufficient (I need to make additions)  .. no need to 
review yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142704

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


[clang] 8d4b097 - Correct the link to the latest C DR status page for C11 and C17

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

Author: Aaron Ballman
Date: 2023-01-27T11:19:12-05:00
New Revision: 8d4b0976d5fe92a51f43ccfea50d1f10c4c77e5d

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

LOG: Correct the link to the latest C DR status page for C11 and C17

We were linking against:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm

However, the latest DR page for the 400s is:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm

Added: 


Modified: 
clang/www/c_dr_status.html

Removed: 




diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index 15e92c5eb2ccb..1aaff53d7cef4 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -2033,145 +2033,145 @@ C defect report implementation 
status
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_400;>400
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_400;>400
 C11
 realloc with size zero problems
 Unknown
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_401;>401
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_401;>401
 C11
 "happens before" can not be cyclic
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_402;>402
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_402;>402
 C11
 Memory model coherence is not aligned with C++11
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_403;>403
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_403;>403
 C11
 malloc() and free() in the memory model
 N/A
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_404;>404
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_404;>404
 C11
 Joke fragment remains in a footnote
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_405;>405
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_405;>405
 C11
 The mutex specification
 N/A
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_406;>406
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_406;>406
 C11
 Visible sequences of side effects are redundant
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_407;>407
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_407;>407
 C11
 Memory ordering of atomics
 Unknown
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_408;>408
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_408;>408
 NAD
 Should locks provide intra-thread synchronization
 N/A
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_409;>409
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_409;>409
 C11
 f(inf) is inf being a range error
 N/A
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_410;>410
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_410;>410
 C11
 ilogb inconsistent with lrint, lround
 N/A
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_411;>411
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_411;>411
 C11
 Predefined macro values
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_412;>412
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_412;>412
 C11
 #elif
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_413;>413
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_413;>413
 NAD
 Initialization
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_414;>414
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_414;>414
 C11
 Typos in 6.27 Threads threads.h
 N/A
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_415;>415
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_415;>415
 C11
 Missing divide by zero entry in Annex J
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_416;>416
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_416;>416
 C11
 tss_t destruction unspecified
 N/A
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_417;>417
+https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_417;>417
 C11
 Annex J not updated with necessary aligned_alloc entries
 Yes
   
   
-https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_418;>418
+

[PATCH] D142006: [mlir][bufferization] Fix getAliasingOpOperand/OpResult for non-bufferizable ops

2023-01-27 Thread Matthias Springer via Phabricator via cfe-commits
springerm updated this revision to Diff 492765.
springerm added a comment.
Herald added a subscriber: thopre.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142006

Files:
  mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
  mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
  mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
  mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
  mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-analysis.mlir
  mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-partial.mlir
  
mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-pass-statistics.mlir
  mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize.mlir

Index: mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize.mlir
===
--- mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize.mlir
+++ mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize.mlir
@@ -136,7 +136,7 @@
 
 // CHECK-LABEL: func @select_different_tensors(
 //  CHECK-SAME: %[[t:.*]]: tensor
-func.func @select_different_tensors(%t: tensor, %sz: index, %c: i1) -> tensor {
+func.func @select_different_tensors(%t: tensor, %sz: index, %pos: index, %c: i1) -> f32 {
   // CHECK-DAG: %[[m:.*]] = bufferization.to_memref %[[t]] : memref
   // CHECK-DAG: %[[alloc:.*]] = memref.alloc(%{{.*}}) {{.*}} : memref
   %0 = bufferization.alloc_tensor(%sz) : tensor
@@ -145,7 +145,8 @@
   // CHECK: %[[casted:.*]] = memref.cast %[[alloc]] : memref to memref
   // CHECK: arith.select %{{.*}}, %[[casted]], %[[m]]
   %1 = arith.select %c, %0, %t : tensor
-  return %1 : tensor
+  %2 = tensor.extract %1[%pos] : tensor
+  return %2 : f32
 }
 
 // -
Index: mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-pass-statistics.mlir
===
--- mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-pass-statistics.mlir
+++ mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-pass-statistics.mlir
@@ -5,7 +5,7 @@
 // CHECK:  (S) 1 num-buffer-alloc
 // CHECK:  (S) 1 num-buffer-dealloc
 // CHECK:  (S) 1 num-tensor-in-place
-// CHECK:  (S) 1 num-tensor-out-of-place
+// CHECK:  (S) 2 num-tensor-out-of-place
 func.func @read_after_write_conflict(%cst : f32, %idx : index, %idx2 : index)
 -> (f32, f32) {
   %t = "test.dummy_op"() : () -> (tensor<10xf32>)
Index: mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-partial.mlir
===
--- mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-partial.mlir
+++ mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-partial.mlir
@@ -100,11 +100,14 @@
 %t1: tensor, %o: index, %s: index) -> (tensor, tensor) {
   // CHECK: %[[m1:.*]] = bufferization.to_memref %[[t1]]
   // CHECK: %[[subview:.*]] = memref.subview %[[m1]]
+  // The op must alloc because "test.dummy" may bufferize to a memory write.
+  // CHECK: %[[alloc:.*]] = memref.alloc
+  // CHECK: memref.copy %[[subview]], %[[alloc]]
   %0 = tensor.extract_slice %t1[%o][%s][1] : tensor to tensor
-  // CHECK: %[[subview_tensor:.*]] = bufferization.to_tensor %[[subview]]
-  // CHECK: %[[dummy:.*]] = "test.dummy_op"(%[[subview_tensor]])
+  // CHECK: %[[alloc_tensor:.*]] = bufferization.to_tensor %[[alloc]]
+  // CHECK: %[[dummy:.*]] = "test.dummy_op"(%[[alloc_tensor]])
   %1 = "test.dummy_op"(%0) : (tensor) -> tensor
-  // CHECK: return %[[subview_tensor]], %[[dummy]]
+  // CHECK: return %[[alloc_tensor]], %[[dummy]]
   return %0, %1 : tensor, tensor
 }
 
Index: mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-analysis.mlir
===
--- /dev/null
+++ mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-analysis.mlir
@@ -0,0 +1,34 @@
+// RUN: mlir-opt %s -one-shot-bufferize="test-analysis-only" -allow-unregistered-dialect -split-input-file | FileCheck %s
+
+// CHECK-LABEL: func @unknown_op_aliasing(
+func.func @unknown_op_aliasing(%f: f32, %f2: f32, %pos: index) -> f32 {
+  %0 = tensor.empty() : tensor<10xf32>
+  // CHECK: linalg.fill {__inplace_operands_attr__ = ["none", "true"]}
+  %1 = linalg.fill ins(%f : f32) outs(%0 : tensor<10xf32>) -> tensor<10xf32>
+
+  // Something must bufferize out-of-place because the op may return an alias
+  // of %1.
+  // CHECK: "dummy.dummy_op"(%{{.*}}) {__inplace_operands_attr__ = ["false"]}
+  %alias = "dummy.dummy_op"(%1) : (tensor<10xf32>) -> (tensor<10xf32>)
+
+  // CHECK: linalg.fill {__inplace_operands_attr__ = ["none", "true"]}
+  %2 = linalg.fill ins(%f2 : f32) outs(%1 : tensor<10xf32>) -> tensor<10xf32>
+  %3 = tensor.extract %alias[%pos] : tensor<10xf32>
+  return %3 : f32
+}
+
+// -
+
+// CHECK-LABEL: func 

[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D133574#4085681 , @aaron.ballman 
wrote:

> In D133574#4085472 , @aaron.ballman 
> wrote:
>
>> In D133574#4085372 , 
>> @aaron.ballman wrote:
>>
>>> So by my understanding, my original changes removing the extension warning 
>>> (in D40267 ) were jumping the gun because 
>>> the committee never made the change we said we'd make. So I believe this is 
>>> still an extension as far as C conformance is concerned. That said, I'll 
>>> check with the convener to see if he'd be too frustrated if I filed a CD2 
>>> comment asking for `member-designator` to be replaced with `subobject` 
>>> based on prior discussion, so maabbeee we can fix this for C2x still.
>>
>> I heard back and there's even more confusion -- we were tracking an older 
>> copy of the DR list, and there's an update that clarifies this: 
>> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_496. So you're 
>> right, the array and member access extension warnings need to be removed. 
>> I'll take care of that and get it cherry picked into the Clang 16 branch.
>
> I posted https://reviews.llvm.org/D142723 to address this.

and 63d6b8be6cf248a1a8800d85a11be469c6e2 
 should 
hopefully resolve it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D142723: [C2x] Stop diagnosing member and array access in offsetof as an extension

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

Thanks for the quick review, I've landed this in 
63d6b8be6cf248a1a8800d85a11be469c6e2 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142723

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


[clang] 63d6b8b - Stop diagnosing member and array access in offsetof as an extension

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

Author: Aaron Ballman
Date: 2023-01-27T11:01:58-05:00
New Revision: 63d6b8be6cf248a1a8800d85a11be469c6e2

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

LOG: Stop diagnosing member and array access in offsetof as an extension

This was a mistake from e7300e75b51a7e7d4e81975b4be7a6c65f9a8286
(https://reviews.llvm.org/D133574) caused by us accidentally tracking
an older copy of the C DR list for DR496. The text in
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_496 makes
it clear that subobjects are allowed, which means member and array
access expressions are allowed.

This backs out the changes from the previous commit that relate to this
diagnostic.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseExpr.cpp
clang/test/C/C2x/n2350.c
clang/test/C/drs/dr4xx.c
clang/test/CXX/drs/dr4xx.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 2e99a6072a94..75fcd418e7ea 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2386,21 +2386,19 @@ calculates the offset (in bytes) to a given member of 
the given type.
 
   const int offset_to_i = __builtin_offsetof(struct S, i);
   const int ext1 = __builtin_offsetof(struct U { int i; }, i); // C extension
-  const int ext2 = __builtin_offsetof(struct S, t.f[1]); // C & C++ extension
+  const int ext2 = __builtin_offsetof(struct S, t.f[1]);
 
 **Description**:
 
 This builtin is usable in an integer constant expression which returns a value
 of type ``size_t``. The value returned is the offset in bytes to the subobject
 designated by the member-designator from the beginning of an object of type
-``type-name``. Clang extends the required standard functionality in a few ways:
+``type-name``. Clang extends the required standard functionality in the
+following way:
 
 * In C language modes, the first argument may be the definition of a new type.
   Any type declared this way is scoped to the nearest scope containing the call
   to the builtin.
-* The second argument may be a member-designator designated by a series of
-  member access expressions using the dot (``.``) operator or array subscript
-  expressions.
 
 Query for this feature with ``__has_builtin(__builtin_offsetof)``.
 

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index c367a34b762b..36d4bc2a700d 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1607,11 +1607,6 @@ def err_import_in_wrong_fragment : Error<
 def err_export_empty : Error<"export declaration cannot be empty">;
 }
 
-def ext_offsetof_member_designator : Extension<
-  "using %select{a member access expression|an array subscript expression}0 "
-  "within '%select{__builtin_offsetof|offsetof}1' is a Clang extension">,
-  InGroup;
-
 let CategoryName = "Generics Issue" in {
 
 def err_objc_expected_type_parameter : Error<

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 392ed29467a9..66d937ac5742 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2629,12 +2629,6 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
 Comps.back().LocStart = Comps.back().LocEnd = ConsumeToken();
 
-enum class Kind { MemberAccess, ArraySubscript };
-auto DiagExt = [&](SourceLocation Loc, Kind K) {
-  Diag(Loc, diag::ext_offsetof_member_designator)
-  << (K == Kind::ArraySubscript) << (OOK == Sema::OOK_Macro);
-};
-
 // FIXME: This loop leaks the index expressions on error.
 while (true) {
   if (Tok.is(tok::period)) {
@@ -2648,7 +2642,6 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
   SkipUntil(tok::r_paren, StopAtSemi);
   return ExprError();
 }
-DiagExt(Comps.back().LocStart, Kind::MemberAccess);
 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
 Comps.back().LocEnd = ConsumeToken();
   } else if (Tok.is(tok::l_square)) {
@@ -2666,7 +2659,6 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
   SkipUntil(tok::r_paren, StopAtSemi);
   return Res;
 }
-DiagExt(Comps.back().LocStart, Kind::ArraySubscript);
 Comps.back().U.E = Res.get();
 
 ST.consumeClose();

diff  --git a/clang/test/C/C2x/n2350.c b/clang/test/C/C2x/n2350.c
index 93ab5070b6c6..2f738488a374 100644
--- a/clang/test/C/C2x/n2350.c
+++ b/clang/test/C/C2x/n2350.c
@@ -38,8 +38,7 @@ int struct_in_second_param(void) {
 int a, b;
 int x[20];
   };
-  return 

[PATCH] D142710: [clang][dataflow] Relax validity assumptions in `UncheckedOptionalAccessModel`.

2023-01-27 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:524
 
-void transferSwap(const StorageLocation ,
-  const StorageLocation ,
-  LatticeTransferState ) {
-  auto *OptionalVal1 = State.Env.getValue(OptionalLoc1);
-  assert(OptionalVal1 != nullptr);
+void transferSwap(const Expr , SkipPast E1Skip, const Expr ,
+  Environment ) {

sgatev wrote:
> What do you think about passing `const StorageLocation*` instead of `const 
> Expr&`? This way we don't need to pass `E1Skip`.
Sure, but means we'll be pushing the calls to getStorageLocation to callers. 
I'm fine with that, since it means a less janky API, but just want to call that 
out.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:534
+if (Loc2 != nullptr)
+  Env.setValue(*Loc2, createOptionalValue(Env, Env.makeAtomicBoolValue()));
+return;

sgatev wrote:
> Any reason to not set a fresh value for `Loc1` in this case (similarly a 
> fresh value for `Loc2` below)?
The new value for `Loc1`/`Loc2` won't be connected to anything, so it won't 
bring any benefit to the modeling -- it will only make the code simpler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142710

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


[PATCH] D137268: [clang][Headers] Do not define varargs macros for __need___va_list

2023-01-27 Thread Elliott Hughes via Phabricator via cfe-commits
enh added a comment.

In D137268#4069992 , @zatrazz wrote:

> Could you check if this fixes your issue?

yes, thanks... the person doing the llvm update tried it and reports that it 
works.

here's the patch against our old copy of glibc: 
https://android-review.googlesource.com/c/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/+/2403274


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137268

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


[PATCH] D142710: [clang][dataflow] Relax validity assumptions in `UncheckedOptionalAccessModel`.

2023-01-27 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev added inline comments.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:524
 
-void transferSwap(const StorageLocation ,
-  const StorageLocation ,
-  LatticeTransferState ) {
-  auto *OptionalVal1 = State.Env.getValue(OptionalLoc1);
-  assert(OptionalVal1 != nullptr);
+void transferSwap(const Expr , SkipPast E1Skip, const Expr ,
+  Environment ) {

What do you think about passing `const StorageLocation*` instead of `const 
Expr&`? This way we don't need to pass `E1Skip`.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:534
+if (Loc2 != nullptr)
+  Env.setValue(*Loc2, createOptionalValue(Env, Env.makeAtomicBoolValue()));
+return;

Any reason to not set a fresh value for `Loc1` in this case (similarly a fresh 
value for `Loc2` below)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142710

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


[PATCH] D142724: [clang] use FileEntryRef for SUBMODULE_TOPHEADER

2023-01-27 Thread Richard Howell via Phabricator via cfe-commits
rmaz created this revision.
Herald added a subscriber: arphaman.
Herald added a project: All.
rmaz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Refactor a Module's TopHeaders to use FileEntryRef. This will keep
the paths serialized in a module the same as the ones used to look
up the header initially.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142724

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -8788,7 +8788,7 @@
 return 0;
   Module *Mod = static_cast(CXMod);
   FileManager  = cxtu::getASTUnit(TU)->getFileManager();
-  ArrayRef TopHeaders = Mod->getTopHeaders(FileMgr);
+  auto TopHeaders = Mod->getTopHeaders(FileMgr);
   return TopHeaders.size();
 }
 
@@ -8803,9 +8803,9 @@
   Module *Mod = static_cast(CXMod);
   FileManager  = cxtu::getASTUnit(TU)->getFileManager();
 
-  ArrayRef TopHeaders = Mod->getTopHeaders(FileMgr);
+  auto TopHeaders = Mod->getTopHeaders(FileMgr);
   if (Index < TopHeaders.size())
-return const_cast(TopHeaders[Index]);
+return const_cast([Index].getFileEntry());
 
   return nullptr;
 }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -2878,8 +2878,8 @@
 {
   auto TopHeaders = Mod->getTopHeaders(PP->getFileManager());
   RecordData::value_type Record[] = {SUBMODULE_TOPHEADER};
-  for (auto *H : TopHeaders) {
-SmallString<128> HeaderName(H->getName());
+  for (auto H : TopHeaders) {
+SmallString<128> HeaderName(H.getName());
 PreparePathForOutput(HeaderName);
 Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, HeaderName);
   }
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -660,7 +660,7 @@
   Explicit).first;
   InferredModuleAllowedBy[Result] = UmbrellaModuleMap;
   Result->IsInferred = true;
-  Result->addTopHeader(File);
+  Result->addTopHeader(File->getLastRef());
 
   // If inferred submodules export everything they import, add a
   // wildcard to the set of exports.
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -269,16 +269,16 @@
   Umbrella.dyn_cast()};
 }
 
-void Module::addTopHeader(const FileEntry *File) {
+void Module::addTopHeader(OptionalFileEntryRef File) {
   assert(File);
-  TopHeaders.insert(File);
+  TopHeaders.insert(*File);
 }
 
-ArrayRef Module::getTopHeaders(FileManager ) {
+ArrayRef Module::getTopHeaders(FileManager ) {
   if (!TopHeaderNames.empty()) {
 for (std::vector::iterator
I = TopHeaderNames.begin(), E = TopHeaderNames.end(); I != E; ++I) {
-  if (auto FE = FileMgr.getFile(*I))
+  if (auto FE = FileMgr.getFileRef(*I))
 TopHeaders.insert(*FE);
 }
 TopHeaderNames.clear();
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -189,7 +189,7 @@
   OptionalFileEntryRef ASTFile;
 
   /// The top-level headers associated with this module.
-  llvm::SmallSetVector TopHeaders;
+  llvm::SmallSetVector TopHeaders;
 
   /// top-level header filenames that aren't resolved to FileEntries yet.
   std::vector TopHeaderNames;
@@ -639,7 +639,7 @@
   }
 
   /// Add a top-level header associated with this module.
-  void addTopHeader(const FileEntry *File);
+  void addTopHeader(OptionalFileEntryRef File);
 
   /// Add a top-level header filename associated with this module.
   void addTopHeaderFilename(StringRef Filename) {
@@ -647,7 +647,7 @@
   }
 
   /// The top-level headers associated with this module.
-  ArrayRef getTopHeaders(FileManager );
+  ArrayRef getTopHeaders(FileManager );
 
   /// Determine whether this module has declared its intention to
   /// directly use another module.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142541: [NFC][AArch64] Get extension strings directly from ArchInfo in target parser

2023-01-27 Thread Lucas Prates 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 rG852bb68ddb2b: [NFC][AArch64] Get extension strings directly 
from ArchInfo in target parser (authored by pratlucas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142541

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  llvm/include/llvm/TargetParser/AArch64TargetParser.h
  llvm/lib/TargetParser/AArch64TargetParser.cpp


Index: llvm/lib/TargetParser/AArch64TargetParser.cpp
===
--- llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -25,16 +25,6 @@
   return 0;
 }
 
-void AArch64::getFeatureOption(StringRef Name, std::string ) {
-  for (const auto  : llvm::AArch64::Extensions) {
-if (Name == E.Name) {
-  Feature = E.Feature;
-  return;
-}
-  }
-  Feature = Name.str();
-}
-
 std::optional AArch64::getArchForCpu(StringRef CPU) {
   if (CPU == "generic")
 return ARMV8A;
Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -513,7 +513,6 @@
 StringRef resolveCPUAlias(StringRef CPU);
 
 // Information by Name
-void getFeatureOption(StringRef Name, std::string );
 std::optional getArchForCpu(StringRef CPU);
 
 // Parser
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -973,12 +973,16 @@
   }
 }
   for (const auto  : FeaturesVec)
-if (Feature[0] == '+') {
-  std::string F;
-  llvm::AArch64::getFeatureOption(Feature, F);
-  UpdatedFeaturesVec.push_back(F);
-} else if (Feature[0] != '?')
-  UpdatedFeaturesVec.push_back(Feature);
+if (Feature[0] != '?') {
+  std::string UpdatedFeature = Feature;
+  if (Feature[0] == '+') {
+std::optional Extension =
+  llvm::AArch64::parseArchExtension(Feature.substr(1));
+if (Extension)
+  UpdatedFeature = Extension->Feature.str();
+  }
+  UpdatedFeaturesVec.push_back(UpdatedFeature);
+}
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
 }


Index: llvm/lib/TargetParser/AArch64TargetParser.cpp
===
--- llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -25,16 +25,6 @@
   return 0;
 }
 
-void AArch64::getFeatureOption(StringRef Name, std::string ) {
-  for (const auto  : llvm::AArch64::Extensions) {
-if (Name == E.Name) {
-  Feature = E.Feature;
-  return;
-}
-  }
-  Feature = Name.str();
-}
-
 std::optional AArch64::getArchForCpu(StringRef CPU) {
   if (CPU == "generic")
 return ARMV8A;
Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -513,7 +513,6 @@
 StringRef resolveCPUAlias(StringRef CPU);
 
 // Information by Name
-void getFeatureOption(StringRef Name, std::string );
 std::optional getArchForCpu(StringRef CPU);
 
 // Parser
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -973,12 +973,16 @@
   }
 }
   for (const auto  : FeaturesVec)
-if (Feature[0] == '+') {
-  std::string F;
-  llvm::AArch64::getFeatureOption(Feature, F);
-  UpdatedFeaturesVec.push_back(F);
-} else if (Feature[0] != '?')
-  UpdatedFeaturesVec.push_back(Feature);
+if (Feature[0] != '?') {
+  std::string UpdatedFeature = Feature;
+  if (Feature[0] == '+') {
+std::optional Extension =
+  llvm::AArch64::parseArchExtension(Feature.substr(1));
+if (Extension)
+  UpdatedFeature = Extension->Feature.str();
+  }
+  UpdatedFeaturesVec.push_back(UpdatedFeature);
+}
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 852bb68 - [NFC][AArch64] Get extension strings directly from ArchInfo in target parser

2023-01-27 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2023-01-27T15:17:21Z
New Revision: 852bb68ddb2bf9c91421a6ce59a07a6f44d20641

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

LOG: [NFC][AArch64] Get extension strings directly from ArchInfo in target 
parser

Reviewed By: tmatheson

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/TargetParser/AArch64TargetParser.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index fc171357bb60..33f9d67ef0e9 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -973,12 +973,16 @@ bool AArch64TargetInfo::initFeatureMap(
   }
 }
   for (const auto  : FeaturesVec)
-if (Feature[0] == '+') {
-  std::string F;
-  llvm::AArch64::getFeatureOption(Feature, F);
-  UpdatedFeaturesVec.push_back(F);
-} else if (Feature[0] != '?')
-  UpdatedFeaturesVec.push_back(Feature);
+if (Feature[0] != '?') {
+  std::string UpdatedFeature = Feature;
+  if (Feature[0] == '+') {
+std::optional Extension =
+  llvm::AArch64::parseArchExtension(Feature.substr(1));
+if (Extension)
+  UpdatedFeature = Extension->Feature.str();
+  }
+  UpdatedFeaturesVec.push_back(UpdatedFeature);
+}
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
 }

diff  --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index b7ecd444c7ee..385e7d6dce05 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -513,7 +513,6 @@ StringRef getArchExtFeature(StringRef ArchExt);
 StringRef resolveCPUAlias(StringRef CPU);
 
 // Information by Name
-void getFeatureOption(StringRef Name, std::string );
 std::optional getArchForCpu(StringRef CPU);
 
 // Parser

diff  --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp 
b/llvm/lib/TargetParser/AArch64TargetParser.cpp
index e2519e8212d8..0fea5f77b868 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -25,16 +25,6 @@ static unsigned checkArchVersion(llvm::StringRef Arch) {
   return 0;
 }
 
-void AArch64::getFeatureOption(StringRef Name, std::string ) {
-  for (const auto  : llvm::AArch64::Extensions) {
-if (Name == E.Name) {
-  Feature = E.Feature;
-  return;
-}
-  }
-  Feature = Name.str();
-}
-
 std::optional AArch64::getArchForCpu(StringRef CPU) {
   if (CPU == "generic")
 return ARMV8A;



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


[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D133574#4085472 , @aaron.ballman 
wrote:

> In D133574#4085372 , @aaron.ballman 
> wrote:
>
>> So by my understanding, my original changes removing the extension warning 
>> (in D40267 ) were jumping the gun because 
>> the committee never made the change we said we'd make. So I believe this is 
>> still an extension as far as C conformance is concerned. That said, I'll 
>> check with the convener to see if he'd be too frustrated if I filed a CD2 
>> comment asking for `member-designator` to be replaced with `subobject` based 
>> on prior discussion, so maabbeee we can fix this for C2x still.
>
> I heard back and there's even more confusion -- we were tracking an older 
> copy of the DR list, and there's an update that clarifies this: 
> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_496. So you're 
> right, the array and member access extension warnings need to be removed. 
> I'll take care of that and get it cherry picked into the Clang 16 branch.

I posted https://reviews.llvm.org/D142723 to address this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D142723: [C2x] Stop diagnosing member and array access in offsetof as an extension

2023-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: erichkeane, clang-language-wg, jyknight.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This was a mistake from e7300e75b51a7e7d4e81975b4be7a6c65f9a8286 
 
(https://reviews.llvm.org/D133574) caused by us accidentally tracking an older 
copy of the C DR list for DR496. The text in 
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_496 makes it 
clear that subobjects are allowed, which means member and array access 
expressions are allowed.

This backs out the changes from the previous commit that relate to this 
diagnostic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142723

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExpr.cpp
  clang/test/C/C2x/n2350.c
  clang/test/C/drs/dr4xx.c
  clang/test/CXX/drs/dr4xx.cpp

Index: clang/test/CXX/drs/dr4xx.cpp
===
--- clang/test/CXX/drs/dr4xx.cpp
+++ clang/test/CXX/drs/dr4xx.cpp
@@ -687,9 +687,9 @@
 U<__builtin_offsetof(A, n)>::type a;
 U<__builtin_offsetof(T, n)>::type b; // expected-error +{{}} expected-warning 0+{{}}
 // as an extension, we allow the member-designator to include array indices
-g(__builtin_offsetof(A, a[0])).h(); // expected-error {{using an array subscript expression within '__builtin_offsetof' is a Clang extension}}
-g(__builtin_offsetof(A, a[N])).h(); // expected-error {{using an array subscript expression within '__builtin_offsetof' is a Clang extension}}
-U<__builtin_offsetof(A, a[0])>::type c; // expected-error {{using an array subscript expression within '__builtin_offsetof' is a Clang extension}}
+g(__builtin_offsetof(A, a[0])).h();
+g(__builtin_offsetof(A, a[N])).h();
+U<__builtin_offsetof(A, a[0])>::type c;
 U<__builtin_offsetof(A, a[N])>::type d; // expected-error +{{}} expected-warning 0+{{}}
   }
 }
Index: clang/test/C/drs/dr4xx.c
===
--- clang/test/C/drs/dr4xx.c
+++ clang/test/C/drs/dr4xx.c
@@ -331,19 +331,13 @@
   struct B { struct A a; };
   struct C { struct A a[1]; };
 
-  /* The standard does not require either of these examples to work, but we
-   * support them just the same. The first one is invalid because it's
-   * referencing a member of a different struct, and the second one is invalid
-   * because it references an array of another struct. Clang calculates the
-   * correct offset to each of those fields.
-   */
-  _Static_assert(__builtin_offsetof(struct B, a.n) == 0, ""); /* expected-warning {{using a member access expression within '__builtin_offsetof' is a Clang extension}} */
+  /* Array access & member access expressions are now valid. */
+  _Static_assert(__builtin_offsetof(struct B, a.n) == 0, "");
   /* First int below is for 'n' and the second int is for 'a[0]'; this presumes
* there is no padding involved.
*/
-  _Static_assert(__builtin_offsetof(struct B, a.a[1]) == sizeof(int) + sizeof(int), ""); /* expected-warning {{using a member access expression within '__builtin_offsetof' is a Clang extension}}
-expected-warning {{using an array subscript expression within '__builtin_offsetof' is a Clang extension}}
-  */
+  _Static_assert(__builtin_offsetof(struct B, a.a[1]) == sizeof(int) + sizeof(int), "");
+
   /* However, we do not support using the -> operator to access a member, even
* if that would be a valid expression. FIXME: GCC accepts this, perhaps we
* should as well.
Index: clang/test/C/C2x/n2350.c
===
--- clang/test/C/C2x/n2350.c
+++ clang/test/C/C2x/n2350.c
@@ -38,8 +38,7 @@
 int a, b;
 int x[20];
   };
-  return __builtin_offsetof(struct A, x[sizeof(struct B{int a;})]); // cpp-error {{'B' cannot be defined in a type specifier}} \
-   expected-warning {{using an array subscript expression within '__builtin_offsetof' is a Clang extension}}
+  return __builtin_offsetof(struct A, x[sizeof(struct B{int a;})]); // cpp-error {{'B' cannot be defined in a type specifier}}
 }
 
 
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -2629,12 +2629,6 @@
 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
 Comps.back().LocStart = Comps.back().LocEnd = ConsumeToken();
 
-enum class Kind { MemberAccess, ArraySubscript };
-auto DiagExt = 

[PATCH] D142228: [clangd] Disable tests that are incompatible with Windows

2023-01-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

thanks this makes sense! we were filtering on `target_triple` before, which is 
not right, especially when host triple is not the default target.

as a follow up i'll drop all the `target={{...}}` conditions as we should 
actually be able to run these tests even when they're cross-compiling to 
windows, let's not do this as part of this patch though as it might trigger 
running on new buildbots and failures for unrelated reasons.


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

https://reviews.llvm.org/D142228

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


[PATCH] D142717: [clang] Mark CWG2165 as N/A

2023-01-27 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added a reviewer: clang-language-wg.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

P1787 : "CWG2165 is resolved by removing the 
conflicting definition of it in [basic.scope]."
Wording: [basic.namespace]/p1 changed and [basic.scope.declarative] removed 
entirely


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142717

Files:
  clang/test/CXX/drs/dr21xx.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
@@ -12797,7 +12797,7 @@
 https://wg21.link/cwg2165;>2165
 CD6
 Namespaces, declarative regions, and translation units
-Unknown
+N/A
   
   
 https://wg21.link/cwg2166;>2166
Index: clang/test/CXX/drs/dr21xx.cpp
===
--- clang/test/CXX/drs/dr21xx.cpp
+++ clang/test/CXX/drs/dr21xx.cpp
@@ -127,6 +127,8 @@
 #endif
 }
 
+// dr2165: na
+
 namespace dr2170 { // dr2170: 9
 #if __cplusplus >= 201103L
   void f() {


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -12797,7 +12797,7 @@
 https://wg21.link/cwg2165;>2165
 CD6
 Namespaces, declarative regions, and translation units
-Unknown
+N/A
   
   
 https://wg21.link/cwg2166;>2166
Index: clang/test/CXX/drs/dr21xx.cpp
===
--- clang/test/CXX/drs/dr21xx.cpp
+++ clang/test/CXX/drs/dr21xx.cpp
@@ -127,6 +127,8 @@
 #endif
 }
 
+// dr2165: na
+
 namespace dr2170 { // dr2170: 9
 #if __cplusplus >= 201103L
   void f() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D133574#4085372 , @aaron.ballman 
wrote:

> So by my understanding, my original changes removing the extension warning 
> (in D40267 ) were jumping the gun because 
> the committee never made the change we said we'd make. So I believe this is 
> still an extension as far as C conformance is concerned. That said, I'll 
> check with the convener to see if he'd be too frustrated if I filed a CD2 
> comment asking for `member-designator` to be replaced with `subobject` based 
> on prior discussion, so maabbeee we can fix this for C2x still.

I heard back and there's even more confusion -- we were tracking an older copy 
of the DR list, and there's an update that clarifies this: 
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_496. So you're 
right, the array and member access extension warnings need to be removed. I'll 
take care of that and get it cherry picked into the Clang 16 branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D142713: [clang][ASTImporter] Propagate TemplateArgument::IsDefaulted during import

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

- clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142713

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1158,6 +1158,26 @@
   ASSERT_EQ(cast(ToArg)->getValue().getLimitedValue(), 1U);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, TemplateArgumentsDefaulted) {
+  Decl *FromTU = getTuDecl(R"(
+   template struct X {};
+   template typename TT = X> struct 
S {};
+   S<> s;
+   )",
+   Lang_CXX17);
+  auto *FromSpec = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("S")));
+  ASSERT_TRUE(FromSpec);
+  auto *ToSpec = Import(FromSpec, Lang_CXX03);
+  ASSERT_TRUE(ToSpec);
+  auto const  = ToSpec->getTemplateArgs();
+  for (auto const  : TList.asArray()) {
+ASSERT_TRUE(Arg.getIsDefaulted());
+  }
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportOfTemplatedDeclOfClassTemplateDecl) {
   Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03);
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -836,7 +836,8 @@
 ExpectedType ToTypeOrErr = import(From.getAsType());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToTypeOrErr);
+return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/ false,
+From.getIsDefaulted());
   }
 
   case TemplateArgument::Integral: {
@@ -853,14 +854,15 @@
 ExpectedType ToTypeOrErr = import(From.getParamTypeForDecl());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToOrErr, *ToTypeOrErr);
+return TemplateArgument(*ToOrErr, *ToTypeOrErr, From.getIsDefaulted());
   }
 
   case TemplateArgument::NullPtr: {
 ExpectedType ToTypeOrErr = import(From.getNullPtrType());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/true);
+return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/ true,
+From.getIsDefaulted());
   }
 
   case TemplateArgument::Template: {
@@ -868,7 +870,7 @@
 if (!ToTemplateOrErr)
   return ToTemplateOrErr.takeError();
 
-return TemplateArgument(*ToTemplateOrErr);
+return TemplateArgument(*ToTemplateOrErr, From.getIsDefaulted());
   }
 
   case TemplateArgument::TemplateExpansion: {
@@ -877,13 +879,13 @@
 if (!ToTemplateOrErr)
   return ToTemplateOrErr.takeError();
 
-return TemplateArgument(
-*ToTemplateOrErr, From.getNumTemplateExpansions());
+return TemplateArgument(*ToTemplateOrErr, From.getNumTemplateExpansions(),
+From.getIsDefaulted());
   }
 
   case TemplateArgument::Expression:
 if (ExpectedExpr ToExpr = import(From.getAsExpr()))
-  return TemplateArgument(*ToExpr);
+  return TemplateArgument(*ToExpr, From.getIsDefaulted());
 else
   return ToExpr.takeError();
 


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1158,6 +1158,26 @@
   ASSERT_EQ(cast(ToArg)->getValue().getLimitedValue(), 1U);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, TemplateArgumentsDefaulted) {
+  Decl *FromTU = getTuDecl(R"(
+   template struct X {};
+   template typename TT = X> struct S {};
+   S<> s;
+   )",
+   Lang_CXX17);
+  auto *FromSpec = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("S")));
+  ASSERT_TRUE(FromSpec);
+  auto *ToSpec = Import(FromSpec, Lang_CXX03);
+  ASSERT_TRUE(ToSpec);
+  auto const  = ToSpec->getTemplateArgs();
+  for (auto const  : TList.asArray()) {
+ASSERT_TRUE(Arg.getIsDefaulted());
+  }
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportOfTemplatedDeclOfClassTemplateDecl) {
   Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03);
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -836,7 +836,8 @@
 ExpectedType ToTypeOrErr = import(From.getAsType());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToTypeOrErr);
+return 

[PATCH] D142713: [clang][ASTImporter] Propagate TemplateArgument::IsDefaulted during import

2023-01-27 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: martong, aprantl.
Herald added a subscriber: rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

With https://reviews.llvm.org/D141826 `TemplateArgument`s have an
additional field that indicates their defaulted-ness. This gets
used during debug-info generation and in the `clang::TypePrinter`.

This patch copies the field during the import process so consumers
of the ASTImporter can benefit from the other Clang components that
read the field.

**Testing**

- Added unit-test
- Checked that this fixes (in addition to a follow-up LLDB patch) fix current 
test failures in LLDB


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142713

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1158,6 +1158,25 @@
   ASSERT_EQ(cast(ToArg)->getValue().getLimitedValue(), 1U);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, TemplateArgumentsDefaulted) {
+  Decl *FromTU = getTuDecl(R"(
+   template struct X {};
+   template typename TT = X> struct 
S {};
+   S<> s;
+   )", Lang_CXX17);
+  auto *FromSpec = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("S")));
+  ASSERT_TRUE(FromSpec);
+  auto *ToSpec = Import(FromSpec, Lang_CXX03);
+  ASSERT_TRUE(ToSpec);
+  auto const& TList = ToSpec->getTemplateArgs();
+  for (auto const& Arg : TList.asArray()) {
+ASSERT_TRUE(Arg.getIsDefaulted());
+  }
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportOfTemplatedDeclOfClassTemplateDecl) {
   Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03);
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -836,7 +836,7 @@
 ExpectedType ToTypeOrErr = import(From.getAsType());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToTypeOrErr);
+return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/false, 
From.getIsDefaulted());
   }
 
   case TemplateArgument::Integral: {
@@ -853,14 +853,14 @@
 ExpectedType ToTypeOrErr = import(From.getParamTypeForDecl());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToOrErr, *ToTypeOrErr);
+return TemplateArgument(*ToOrErr, *ToTypeOrErr, From.getIsDefaulted());
   }
 
   case TemplateArgument::NullPtr: {
 ExpectedType ToTypeOrErr = import(From.getNullPtrType());
 if (!ToTypeOrErr)
   return ToTypeOrErr.takeError();
-return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/true);
+return TemplateArgument(*ToTypeOrErr, /*isNullPtr*/true, 
From.getIsDefaulted());
   }
 
   case TemplateArgument::Template: {
@@ -868,7 +868,7 @@
 if (!ToTemplateOrErr)
   return ToTemplateOrErr.takeError();
 
-return TemplateArgument(*ToTemplateOrErr);
+return TemplateArgument(*ToTemplateOrErr, From.getIsDefaulted());
   }
 
   case TemplateArgument::TemplateExpansion: {
@@ -878,12 +878,12 @@
   return ToTemplateOrErr.takeError();
 
 return TemplateArgument(
-*ToTemplateOrErr, From.getNumTemplateExpansions());
+*ToTemplateOrErr, From.getNumTemplateExpansions(), 
From.getIsDefaulted());
   }
 
   case TemplateArgument::Expression:
 if (ExpectedExpr ToExpr = import(From.getAsExpr()))
-  return TemplateArgument(*ToExpr);
+  return TemplateArgument(*ToExpr, From.getIsDefaulted());
 else
   return ToExpr.takeError();
 


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1158,6 +1158,25 @@
   ASSERT_EQ(cast(ToArg)->getValue().getLimitedValue(), 1U);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, TemplateArgumentsDefaulted) {
+  Decl *FromTU = getTuDecl(R"(
+   template struct X {};
+   template typename TT = X> struct S {};
+   S<> s;
+   )", Lang_CXX17);
+  auto *FromSpec = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("S")));
+  ASSERT_TRUE(FromSpec);
+  auto *ToSpec = Import(FromSpec, Lang_CXX03);
+  ASSERT_TRUE(ToSpec);
+  auto const& TList = ToSpec->getTemplateArgs();
+  for (auto const& Arg : TList.asArray()) {
+ASSERT_TRUE(Arg.getIsDefaulted());
+  }
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,

[PATCH] D142703: [ARM] Allow selecting hard-float ABI in integer-only MVE.

2023-01-27 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham retitled this revision from "[ARM] Allow selecting the hard float 
ABI in integer-only MVE." to "[ARM] Allow selecting hard-float ABI in 
integer-only MVE.".
simon_tatham edited the summary of this revision.
simon_tatham updated this revision to Diff 492722.
simon_tatham added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Added draft release notes, and an extra comment in the modified test file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142703

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Target/ARM/ARMFastISel.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/test/CodeGen/Thumb2/float-ops.ll

Index: llvm/test/CodeGen/Thumb2/float-ops.ll
===
--- llvm/test/CodeGen/Thumb2/float-ops.ll
+++ llvm/test/CodeGen/Thumb2/float-ops.ll
@@ -83,7 +83,7 @@
 define float @rem_f(float %a, float %b) {
 entry:
 ; CHECK-LABEL: rem_f:
-; NONE: bl fmodf
+; NONE: {{b|bl}} fmodf
 ; HARD: b fmodf
   %0 = frem float %a, %b
   ret float %0
@@ -92,16 +92,23 @@
 define double @rem_d(double %a, double %b) {
 entry:
 ; CHECK-LABEL: rem_d:
-; NONE: bl fmod
+; NONE: {{b|bl}} fmod
 ; HARD: b fmod
   %0 = frem double %a, %b
   ret double %0
 }
 
+; In the ONLYREGS case (where we have integer MVE but no floating
+; point), we still expect the hard float ABI, because we asked for it
+; in the triple, and since the FP registers exist, it's possible to
+; use them to pass arguments. So the generated code should load the
+; return value into s0, not r0. Similarly for the other load and store
+; tests.
 define float @load_f(ptr %a) {
 entry:
 ; CHECK-LABEL: load_f:
-; NONE: ldr r0, [r0]
+; NOREGS: ldr r0, [r0]
+; ONLYREGS: vldr s0, [r0]
 ; HARD: vldr s0, [r0]
   %0 = load float, ptr %a, align 4
   ret float %0
@@ -120,7 +127,8 @@
 define void @store_f(ptr %a, float %b) {
 entry:
 ; CHECK-LABEL: store_f:
-; NONE: str r1, [r0]
+; NOREGS: str r1, [r0]
+; ONLYREGS: vstr s0, [r0]
 ; HARD: vstr s0, [r0]
   store float %b, ptr %a, align 4
   ret void
@@ -130,7 +138,7 @@
 entry:
 ; CHECK-LABEL: store_d:
 ; NOREGS: strd r2, r3, [r0]
-; ONLYREGS: strd r2, r3, [r0]
+; ONLYREGS: vstr d0, [r0]
 ; HARD: vstr d0, [r0]
   store double %b, ptr %a, align 8
   ret void
@@ -230,7 +238,8 @@
 
 define float @bitcast_i_to_f(i32 %a) {
 ; CHECK-LABEL: bitcast_i_to_f:
-; NONE-NOT: mov
+; NOREGS-NOT: mov
+; ONLYREGS: vmov s0, r0
 ; HARD: vmov s0, r0
   %1 = bitcast i32 %a to float
   ret float %1
@@ -238,15 +247,17 @@
 
 define double @bitcast_i_to_d(i64 %a) {
 ; CHECK-LABEL: bitcast_i_to_d:
-; NONE-NOT: mov
-; HARD: vmov d0, r0, r1
-  %1 = bitcast i64 %a to double
+; NOREGS-NOT: mov
+; ONLYREGS: vmov d0, r0, r1
+; HARD: vmov d0, r0, r1 
+ %1 = bitcast i64 %a to double
   ret double %1
 }
 
 define i32 @bitcast_f_to_i(float %a) {
 ; CHECK-LABEL: bitcast_f_to_i:
-; NONE-NOT: mov
+; NOREGS-NOT: mov
+; ONLYREGS: vmov r0, s0
 ; HARD: vmov r0, s0
   %1 = bitcast float %a to i32
   ret i32 %1
@@ -254,7 +265,8 @@
 
 define i64 @bitcast_d_to_i(double %a) {
 ; CHECK-LABEL: bitcast_d_to_i:
-; NONE-NOT: mov
+; NOREGS-NOT: mov
+; ONLYREGS: vmov r0, r1, d0
 ; HARD: vmov r0, r1, d0
   %1 = bitcast double %a to i64
   ret i64 %1
@@ -264,8 +276,8 @@
 ; CHECK-LABEL: select_f:
 ; NOREGS: lslsr2, r2, #31
 ; NOREGS: moveq   r0, r1
-; ONLYREGS: lslsr2, r2, #31
-; ONLYREGS: vmovne.f32  s2, s0
+; ONLYREGS: lslsr0, r0, #31
+; ONLYREGS: vmovne.f32  s1, s0
 ; HARD: lslsr0, r0, #31
 ; VFP4-ALL: vmovne.f32  s1, s0
 ; VFP4-ALL: vmov.f32s0, s1
@@ -276,8 +288,9 @@
 
 define double @select_d(double %a, double %b, i1 %c) {
 ; CHECK-LABEL: select_d:
-; NONE: ldr{{(.w)?}} [[REG:r[0-9]+]], [sp]
-; NONE: ands[[REG]], [[REG]], #1
+; NOREGS: ldr{{(.w)?}} [[REG:r[0-9]+]], [sp]
+; NOREGS: ands[[REG]], [[REG]], #1
+; ONLYREGS: andsr0, r0, #1
 ; NOREGS-DAG: moveq   r0, r2
 ; NOREGS-DAG: moveq   r1, r3
 ; ONLYREGS-DAG: csel   r0, r0, r2
Index: llvm/lib/Target/ARM/ARMISelLowering.cpp
===
--- llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -2081,7 +2081,7 @@
   case CallingConv::Tail:
 if (!Subtarget->isAAPCS_ABI())
   return CallingConv::ARM_APCS;
-else if (Subtarget->hasVFP2Base() && !Subtarget->isThumb1Only() &&
+else if (Subtarget->hasFPRegs() && !Subtarget->isThumb1Only() &&
  getTargetMachine().Options.FloatABIType == FloatABI::Hard &&
  !isVarArg)
   return CallingConv::ARM_AAPCS_VFP;
Index: llvm/lib/Target/ARM/ARMFastISel.cpp
===
--- llvm/lib/Target/ARM/ARMFastISel.cpp
+++ llvm/lib/Target/ARM/ARMFastISel.cpp
@@ -1842,7 +1842,7 @@
   case CallingConv::CXX_FAST_TLS:
 // Use target triple & subtarget features 

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

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



Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:205
 SYMBOL(basic_syncbuf, std::, )
 SYMBOL(begin, std::, )
 SYMBOL(bernoulli_distribution, std::, )

i think we should have other providers here, 
https://en.cppreference.com/w/cpp/iterator/begin. do we know why they're 
dropped?



Comment at: clang/tools/include-mapping/cppreference_parser.py:165
   # FIXME: use these as a fallback rather than ignoring entirely.
-  variants_for_symbol = variants_to_accept.get(
-  (namespace or "") + symbol_name, ())
-  if variant and variant not in variants_for_symbol:
+  header_to_accept = variants_to_accept.get(
+  (namespace or "") + symbol_name, "")

`variant` is not necessarily the `header`, eg:
```
acos()
acos<>() (std::complex) (since C++11)
acos<>() (std::valarray)
```

in this case variants are `std::complex` and `std::valarray`. 

hence we're not trying to "infer" the header we want to preserve but rather 
decide on which symbol page we want to parse. we should still accept "all the 
headers" mentioned in that variant symbol page.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


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

2023-01-27 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:
> > 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 == `)?
> > > 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 == ` 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 ==  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?
> Thanks for the detailed explanation! But before we go ahead here, what do you 
> think about the new test case I'm talking about above? Do you agree with my 
> conclusion?
i suppose you mean:

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

first of all the version of the patch that i propose doesn't involve any 
changes in behaviour here (as we actually have an implicit cast in between, and 
i am suggesting finding out passby based on type of the parmvardecl only when 
there are no casts in between).

i can see @nridge 's reasoning about indicating copies by saying pass by value 
vs ref, which unfortunately doesn't align with C++ semantics directly (as what 
we have here is a prvalue, and it is indeed passed by value, without any copies 
to the callee).

it isn't very obvious anywhere but the main functionality we wanted to provide 
to the developer was help them figure out if a function call can mutate a 
parameter they were passing in, therefore it didn't prioritise literals at all. 
we probably should've made better wording choices in the UI and talked about 
"immutability". hence from functionality point of view calling this pass by 
`value` vs `const ref` doesn't make a huge difference (but that's probably only 
in my mind and people are already using it to infer other things like whether 
we're going to trigger copies).

so i'd actually leave this case as-is, and think about what we're actually 
trying to provide by showing arg info on literals. as it's currently trying to 
overload the meaning of `passby` and causing confusions. since the initial 
intent was to just convey "immutability" one suggestion would be to just hide 
the `passby` information for literals.
otherwise from value categories point of view, these are always passed by 
value, but this is going to create confusion for people that are using it to 
infer "copies" and getting that right, while preserving the semantics around 
"is this mutable" just complicates things.

best thing moving forward would probably be to just have two separate fields, 
one indicating mutability and another indicating copies and not talking about 
pass by type at all.

---

sorry for the lengthy answer, LMK if it needs clarification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142014


[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D133574#4084215 , @stilor wrote:

> In D133574#4083742 , @aaron.ballman 
> wrote:
>
>> In D133574#4083724 , @asbirlea 
>> wrote:
>>
>>> Following this change, the following emits warnings: 
>>> https://godbolt.org/z/cvGdMWqEa, https://godbolt.org/z/GhTP85WzE
>>>
>>> Can you please fix fwd or revert until resolved?
>>
>> What do you expect to be resolved? You're passing 
>> `-Wgnu-offsetof-extensions` which is warning you about the extensions, and 
>> `-Werror` is turning them from a warning into an error, so you're getting 
>> the behavior I'd expect based on: https://reviews.llvm.org/D133574#4059845
>
> Can you please explain how these warnings are related to the N2350? From what 
> I see in N2350 text, it was only declaring new type definitions inside of 
> `offsetof` to be undefined behavior. Can you please point to the language in 
> N2350 that prohibits member access expressions like `offsetof(x, y.z)` or 
> `offsetof(x, y[1])`?
>
> In fact, a change  some time ago explicitly 
> removed the warning for what it called an "non-identifier designator (e.g. 
> `offsetof(x, a.b[c])`" in response to DR496. The language from DR496 hasn't 
> changed in the most recent publicly available draft of the standard (which 
> includes both DR496 and N2350), so why are these "non-identifier designators" 
> considered extensions now?

Thank you for pointing this out, you're right that there's definitely some 
confusion here and I didn't explain it very well.

DR496 was considered not a defect: 
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_496 and said 
"There was no discussion asserting that this extension, however, was the actual 
intent of the standard, and as such there is was no sentiment to accept these 
extensions with clarified wording. Such a change could only be made in a new 
revision of the standard.", and the current wording of the C2x standard matches 
that of the C17 (still says member-designator and not subobject).

From my notes on the discussions of this DR:

Albuquerque 2017: "Next we moved on to DR 496 which is about offsetof. There 
was an open action item on this which was not written down, but the verbal 
report was that we should be able to safely talk about subobjects. We will 
leave this in open status and look at words later."
Pittsburgh 2017: "We did hit a procedural issue when dealing with DR 496 where 
the information from a previous PCR was not carried forward from one meeting to 
the next and there was some confusion as to what the "response" really is. We 
did mention that we want the last committee response to always be the 
definitive one, rather than making people pull together the history from 
separate locations. This is the way we usually do it, and this may have just 
been a process hiccup."
London 2018: "We looked at an open DR for 496 which we elected to mark C2x."

So by my understanding, my original changes removing the extension warning (in 
D40267 ) were jumping the gun because the 
committee never made the change we said we'd make. So I believe this is still 
an extension as far as C conformance is concerned. That said, I'll check with 
the convener to see if he'd be too frustrated if I filed a CD2 comment asking 
for `member-designator` to be replaced with `subobject` based on prior 
discussion, so maabbeee we can fix this for C2x still.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D142710: [clang][dataflow] Relax validity assumptions in `UncheckedOptionalAccessModel`.

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

Currently, the interpretation of `swap` calls in the optional model assumes the
optional arguments are modeled (and therefore have valid storage locations and
values). This assumption is incorrect, for example, in the case of unmodeled
optional fields (which can be missing either value or location). This patch
relaxes these assumptions, to return rather than assert when either argument is
not modeled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142710

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -11,7 +11,6 @@
 #include "TestingSupport.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/DenseSet.h"
@@ -2124,6 +2123,139 @@
   )");
 }
 
+TEST_P(UncheckedOptionalAccessTest, SwapUnmodeledLocLeft) {
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+struct L { $ns::$optional hd; L* tl; };
+
+void target() {
+  $ns::$optional foo = 3;
+  L bar;
+
+  // Any `tl` beyond the first is not modeled.
+  bar.tl->tl->hd.swap(foo);
+
+  bar.tl->tl->hd.value(); // [[unsafe]]
+  foo.value(); // [[unsafe]]
+}
+  )");
+}
+
+TEST_P(UncheckedOptionalAccessTest, SwapUnmodeledLocRight) {
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+struct L { $ns::$optional hd; L* tl; };
+
+void target() {
+  $ns::$optional foo = 3;
+  L bar;
+
+  // Any `tl` beyond the first is not modeled.
+  foo.swap(bar.tl->tl->hd);
+
+  bar.tl->tl->hd.value(); // [[unsafe]]
+  foo.value(); // [[unsafe]]
+}
+  )");
+}
+
+TEST_P(UncheckedOptionalAccessTest, SwapUnmodeledValueLeftSet) {
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+struct S { int x; };
+struct A { $ns::$optional late; };
+struct B { A f3; };
+struct C { B f2; };
+struct D { C f1; };
+
+void target() {
+  $ns::$optional foo = S{3};
+  D bar;
+
+  bar.f1.f2.f3.late.swap(foo);
+
+  bar.f1.f2.f3.late.value();
+  foo.value(); // [[unsafe]]
+}
+  )");
+}
+
+TEST_P(UncheckedOptionalAccessTest, SwapUnmodeledValueLeftUnset) {
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+struct S { int x; };
+struct A { $ns::$optional late; };
+struct B { A f3; };
+struct C { B f2; };
+struct D { C f1; };
+
+void target() {
+  $ns::$optional foo;
+  D bar;
+
+  bar.f1.f2.f3.late.swap(foo);
+
+  bar.f1.f2.f3.late.value(); // [[unsafe]]
+  foo.value(); // [[unsafe]]
+}
+  )");
+}
+
+// fixme: use recursion instead of depth.
+TEST_P(UncheckedOptionalAccessTest, SwapUnmodeledValueRightSet) {
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+struct S { int x; };
+struct A { $ns::$optional late; };
+struct B { A f3; };
+struct C { B f2; };
+struct D { C f1; };
+
+void target() {
+  $ns::$optional foo = S{3};
+  D bar;
+
+  foo.swap(bar.f1.f2.f3.late);
+
+  bar.f1.f2.f3.late.value();
+  foo.value(); // [[unsafe]]
+}
+  )");
+}
+
+TEST_P(UncheckedOptionalAccessTest, SwapUnmodeledValueRightUnset) {
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+struct S { int x; };
+struct A { $ns::$optional late; };
+struct B { A f3; };
+struct C { B f2; };
+struct D { C f1; };
+
+void target() {
+  $ns::$optional foo;
+  D bar;
+
+  foo.swap(bar.f1.f2.f3.late);
+
+  bar.f1.f2.f3.late.value(); // [[unsafe]]
+  foo.value(); // [[unsafe]]
+}
+  )");
+}
+
 TEST_P(UncheckedOptionalAccessTest, UniquePtrToOptional) {
   // We suppress diagnostics for optionals in smart pointers (other than
   // `optional` itself).
Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
===
--- clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -521,48 +521,54 @@
   

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

2023-01-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

I haven't read though all the change of `_ParseSymbolPage`, left some comments.

I think we need to update proper tests in `include-mapping/test.py` as we 
has changed the parser.




Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:1162
 SYMBOL(subtract_with_carry_engine, std::, )
+SYMBOL(swap, std::, )
 SYMBOL(swap_ranges, std::, )

Is this intended? it seems to me the cppparser doesn't handle this case 
correctly, in the swap symbol page, we have two headers in a single 
`t-dsc-header` tr, the parser should consider both (like the above `size_t`).

```
Defined in header 
Defined in header 
```



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:57
+// ordered alpahbetically in the map.
+unsigned SymIndex = NextAvailSymIndex;
+if (NextAvailSymIndex > 0 &&

We can avoid a local variable by

```
auto Add = [.. SymIndex(-1)] () {
if (SymIndex >=0 &&
SymbolNames[SymIndex].first == NS && ...) {
} else {
// the first symbol, or new symbol.
++SymIndex;
}

SymbolNames[SymIndex] = {NS, Name};

}
```



Comment at: clang/tools/include-mapping/cppreference_parser.py:39
 
-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.

If the `header_to_accept` is set, I think we can just return {header_to_accept} 
directly.



Comment at: clang/tools/include-mapping/cppreference_parser.py:96
+if symbol_name in found_symbols:
+  # FIXME: only update symbol headers on first symbol discovery, assume
+  # same symbol occurence in a subsequent header block is an overload.

IIUC, this is the major and intended change of the function, this is not a 
FIXME.



Comment at: clang/tools/include-mapping/cppreference_parser.py:105
+
+  # If the symbol was never named, consider all named headers.  
+  # FIXME: only consider first symbol, assume further symbols are overloads

The comment doesn't match the current behavior. IIUC, iof the symbol was never 
named, we only consider the first header now.



Comment at: clang/tools/include-mapping/cppreference_parser.py:107
+  # FIXME: only consider first symbol, assume further symbols are overloads
+  all_headers = sorted(list(all_headers))
+  if len(all_headers) > 0:

why sort the headers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


[clang] 0753cf2 - [NFC][AArch64] Get default features directly from ArchInfo and CpuInfo objects

2023-01-27 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2023-01-27T12:37:18Z
New Revision: 0753cf2caca707e3957a70c9756b7f1d42fab2af

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

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

This updates the AArch64's Target Parser and its uses to capture
information about default features directly from ArchInfo and CpuInfo
objects, instead of relying on an API function to access them
indirectly.

Reviewed By: tmatheson

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/TargetParser/AArch64TargetParser.cpp
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 5971489ce8004..fc171357bb605 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -692,10 +692,8 @@ void 
AArch64TargetInfo::setFeatureEnabled(llvm::StringMap ,
   Features[OtherArch->getSubArch()] = Enabled;
 
   // Set any features implied by the architecture
-  uint64_t Extensions =
-  llvm::AArch64::getDefaultExtensions("generic", *ArchInfo);
   std::vector CPUFeats;
-  if (llvm::AArch64::getExtensionFeatures(Extensions, CPUFeats)) {
+  if (llvm::AArch64::getExtensionFeatures(ArchInfo->DefaultExts, CPUFeats)) {
 for (auto F : CPUFeats) {
   assert(F[0] == '+' && "Expected + in target feature!");
   Features[F.drop_front(1)] = true;
@@ -951,7 +949,7 @@ bool AArch64TargetInfo::initFeatureMap(
   // Parse the CPU and add any implied features.
   std::optional CpuInfo = llvm::AArch64::parseCpu(CPU);
   if (CpuInfo) {
-uint64_t Exts = llvm::AArch64::getDefaultExtensions(CPU, CpuInfo->Arch);
+uint64_t Exts = CpuInfo->getImpliedExtensions();
 std::vector CPUFeats;
 llvm::AArch64::getExtensionFeatures(Exts, CPUFeats);
 for (auto F : CPUFeats) {

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 81b0245d57a6c..4476b9f37bd9d 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -140,7 +140,7 @@ static bool DecodeAArch64Mcpu(const Driver , StringRef 
Mcpu, StringRef ,
 
 Features.push_back(ArchInfo->ArchFeature);
 
-uint64_t Extension = llvm::AArch64::getDefaultExtensions(CPU, *ArchInfo);
+uint64_t Extension = CpuInfo->getImpliedExtensions();
 if (!llvm::AArch64::getExtensionFeatures(Extension, Features))
   return false;
   }

diff  --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index ea06d7da29691..b7ecd444c7eef 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -334,6 +334,10 @@ struct CpuInfo {
   const ArchInfo 
   uint64_t DefaultExtensions; // Default extensions for this CPU. These will be
   // ORd with the architecture defaults.
+
+  uint64_t getImpliedExtensions() const {
+return DefaultExtensions | Arch.DefaultExts;
+  }
 };
 
 inline constexpr CpuInfo CpuInfos[] = {
@@ -509,7 +513,6 @@ StringRef getArchExtFeature(StringRef ArchExt);
 StringRef resolveCPUAlias(StringRef CPU);
 
 // Information by Name
-uint64_t getDefaultExtensions(StringRef CPU, const ArchInfo );
 void getFeatureOption(StringRef Name, std::string );
 std::optional getArchForCpu(StringRef CPU);
 

diff  --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp 
b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 840f792325cd2..f42ddf7e53eaa 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -6891,8 +6891,7 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
   // Get the architecture and extension features.
   std::vector AArch64Features;
   AArch64Features.push_back(ArchInfo->ArchFeature);
-  AArch64::getExtensionFeatures(
-  AArch64::getDefaultExtensions("generic", *ArchInfo), AArch64Features);
+  AArch64::getExtensionFeatures(ArchInfo->DefaultExts, AArch64Features);
 
   MCSubtargetInfo  = copySTI();
   std::vector ArchFeatures(AArch64Features.begin(), 
AArch64Features.end());

diff  --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp 
b/llvm/lib/TargetParser/AArch64TargetParser.cpp
index 7dd0c45939b63..e2519e8212d81 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -25,19 +25,6 @@ static 

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

2023-01-27 Thread Lucas Prates 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 rG0753cf2caca7: [NFC][AArch64] Get default features directly 
from ArchInfo and CpuInfo objects (authored by pratlucas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142540

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/include/llvm/TargetParser/AArch64TargetParser.h
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/TargetParser/AArch64TargetParser.cpp
  llvm/unittests/TargetParser/TargetParserTest.cpp

Index: llvm/unittests/TargetParser/TargetParserTest.cpp
===
--- llvm/unittests/TargetParser/TargetParserTest.cpp
+++ llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -966,11 +966,9 @@
   EXPECT_TRUE(Cpu);
   EXPECT_EQ(params.ExpectedArch, Cpu->Arch.Name);
 
-  uint64_t default_extensions =
-  AArch64::getDefaultExtensions(params.CPUName, Cpu->Arch);
   EXPECT_PRED_FORMAT2(
   AssertSameExtensionFlags(params.CPUName),
-  params.ExpectedFlags, default_extensions);
+  params.ExpectedFlags, Cpu->getImpliedExtensions());
 }
 
 INSTANTIATE_TEST_SUITE_P(
@@ -1472,7 +1470,7 @@
   if (!Extension)
 return false;
   std::optional CpuInfo = AArch64::parseCpu(CPUName);
-  return (CpuInfo->Arch.DefaultExts | CpuInfo->DefaultExtensions) & Extension->ID;
+  return CpuInfo->getImpliedExtensions() & Extension->ID;
 }
 
 bool testAArch64Extension(const AArch64::ArchInfo , StringRef ArchExt) {
Index: llvm/lib/TargetParser/AArch64TargetParser.cpp
===
--- llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -25,19 +25,6 @@
   return 0;
 }
 
-uint64_t AArch64::getDefaultExtensions(StringRef CPU,
-   const AArch64::ArchInfo ) {
-  if (CPU == "generic")
-return AI.DefaultExts;
-
-  // Note: this now takes cpu aliases into account
-  std::optional Cpu = parseCpu(CPU);
-  if (!Cpu)
-return AI.DefaultExts;
-
-  return Cpu->Arch.DefaultExts | Cpu->DefaultExtensions;
-}
-
 void AArch64::getFeatureOption(StringRef Name, std::string ) {
   for (const auto  : llvm::AArch64::Extensions) {
 if (Name == E.Name) {
Index: llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===
--- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -6891,8 +6891,7 @@
   // Get the architecture and extension features.
   std::vector AArch64Features;
   AArch64Features.push_back(ArchInfo->ArchFeature);
-  AArch64::getExtensionFeatures(
-  AArch64::getDefaultExtensions("generic", *ArchInfo), AArch64Features);
+  AArch64::getExtensionFeatures(ArchInfo->DefaultExts, AArch64Features);
 
   MCSubtargetInfo  = copySTI();
   std::vector ArchFeatures(AArch64Features.begin(), AArch64Features.end());
Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -334,6 +334,10 @@
   const ArchInfo 
   uint64_t DefaultExtensions; // Default extensions for this CPU. These will be
   // ORd with the architecture defaults.
+
+  uint64_t getImpliedExtensions() const {
+return DefaultExtensions | Arch.DefaultExts;
+  }
 };
 
 inline constexpr CpuInfo CpuInfos[] = {
@@ -509,7 +513,6 @@
 StringRef resolveCPUAlias(StringRef CPU);
 
 // Information by Name
-uint64_t getDefaultExtensions(StringRef CPU, const ArchInfo );
 void getFeatureOption(StringRef Name, std::string );
 std::optional getArchForCpu(StringRef CPU);
 
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -140,7 +140,7 @@
 
 Features.push_back(ArchInfo->ArchFeature);
 
-uint64_t Extension = llvm::AArch64::getDefaultExtensions(CPU, *ArchInfo);
+uint64_t Extension = CpuInfo->getImpliedExtensions();
 if (!llvm::AArch64::getExtensionFeatures(Extension, Features))
   return false;
   }
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -692,10 +692,8 @@
   Features[OtherArch->getSubArch()] = Enabled;
 
   // Set any features implied by the architecture
-  uint64_t Extensions =
-  llvm::AArch64::getDefaultExtensions("generic", *ArchInfo);
   std::vector CPUFeats;
-  if 

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

2023-01-27 Thread Lucas Prates via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
pratlucas marked an inline comment as done.
Closed by commit rG9ea00fc74c3c: [NFC][AArch64] Use optional returns in target 
parser instead of invalid… (authored by pratlucas).

Changed prior to commit:
  https://reviews.llvm.org/D142539?vs=492095=492704#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142539

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/include/llvm/TargetParser/AArch64TargetParser.h
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/TargetParser/AArch64TargetParser.cpp
  llvm/unittests/TargetParser/TargetParserTest.cpp

Index: llvm/unittests/TargetParser/TargetParserTest.cpp
===
--- llvm/unittests/TargetParser/TargetParserTest.cpp
+++ llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -17,6 +17,7 @@
 #include "llvm/TargetParser/Triple.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 
 using namespace llvm;
@@ -961,11 +962,12 @@
 TEST_P(AArch64CPUTestFixture, testAArch64CPU) {
   ARMCPUTestParams params = GetParam();
 
-  const AArch64::ArchInfo  = AArch64::parseCpu(params.CPUName).Arch;
-  EXPECT_EQ(params.ExpectedArch, AI.Name);
+  const std::optional Cpu = AArch64::parseCpu(params.CPUName);
+  EXPECT_TRUE(Cpu);
+  EXPECT_EQ(params.ExpectedArch, Cpu->Arch.Name);
 
   uint64_t default_extensions =
-  AArch64::getDefaultExtensions(params.CPUName, AI);
+  AArch64::getDefaultExtensions(params.CPUName, Cpu->Arch);
   EXPECT_PRED_FORMAT2(
   AssertSameExtensionFlags(params.CPUName),
   params.ExpectedFlags, default_extensions);
@@ -974,10 +976,6 @@
 INSTANTIATE_TEST_SUITE_P(
 AArch64CPUTests, AArch64CPUTestFixture,
 ::testing::Values(
-ARMCPUTestParams("invalid", "invalid", "invalid", AArch64::AEK_NONE,
- ""),
-ARMCPUTestParams("generic", "invalid", "none", AArch64::AEK_NONE, ""),
-
 ARMCPUTestParams("cortex-a34", "armv8-a", "crypto-neon-fp-armv8",
  AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
  AArch64::AEK_FP | AArch64::AEK_SIMD,
@@ -1425,14 +1423,14 @@
   // valid, and match the expected 'magic' count.
   EXPECT_EQ(List.size(), NumAArch64CPUArchs);
   for(StringRef CPU : List) {
-EXPECT_NE(AArch64::parseCpu(CPU).Arch, AArch64::INVALID);
+EXPECT_TRUE(AArch64::parseCpu(CPU));
   }
 }
 
 bool testAArch64Arch(StringRef Arch, StringRef DefaultCPU, StringRef SubArch,
  unsigned ArchAttr) {
-  const AArch64::ArchInfo  = AArch64::parseArch(Arch);
-  return AI != AArch64::INVALID;
+  const std::optional AI = AArch64::parseArch(Arch);
+  return AI.has_value();
 }
 
 TEST(TargetParserTest, testAArch64Arch) {
@@ -1468,81 +1466,92 @@
   ARMBuildAttrs::CPUArch::v8_A));
 }
 
-bool testAArch64Extension(StringRef CPUName, const AArch64::ArchInfo ,
-  StringRef ArchExt) {
-  return AArch64::getDefaultExtensions(CPUName, AI) &
- AArch64::parseArchExt(ArchExt);
+bool testAArch64Extension(StringRef CPUName, StringRef ArchExt) {
+  std::optional Extension =
+  AArch64::parseArchExtension(ArchExt);
+  if (!Extension)
+return false;
+  std::optional CpuInfo = AArch64::parseCpu(CPUName);
+  return (CpuInfo->Arch.DefaultExts | CpuInfo->DefaultExtensions) & Extension->ID;
+}
+
+bool testAArch64Extension(const AArch64::ArchInfo , StringRef ArchExt) {
+  std::optional Extension =
+  AArch64::parseArchExtension(ArchExt);
+  if (!Extension)
+return false;
+  return AI.DefaultExts & Extension->ID;
 }
 
 TEST(TargetParserTest, testAArch64Extension) {
-  EXPECT_FALSE(testAArch64Extension("cortex-a34", AArch64::INVALID, "ras"));
-  EXPECT_FALSE(testAArch64Extension("cortex-a35", AArch64::INVALID, "ras"));
-  EXPECT_FALSE(testAArch64Extension("cortex-a53", AArch64::INVALID, "ras"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a55", AArch64::INVALID, "ras"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a55", AArch64::INVALID, "fp16"));
-  EXPECT_FALSE(testAArch64Extension("cortex-a55", AArch64::INVALID, "fp16fml"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a55", AArch64::INVALID, "dotprod"));
-  EXPECT_FALSE(testAArch64Extension("cortex-a57", AArch64::INVALID, "ras"));
-  EXPECT_FALSE(testAArch64Extension("cortex-a72", AArch64::INVALID, "ras"));
-  EXPECT_FALSE(testAArch64Extension("cortex-a73", AArch64::INVALID, "ras"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a75", AArch64::INVALID, "ras"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a75", AArch64::INVALID, "fp16"));
-  EXPECT_FALSE(testAArch64Extension("cortex-a75", AArch64::INVALID, "fp16fml"));
-  EXPECT_TRUE(testAArch64Extension("cortex-a75", AArch64::INVALID, 

[clang] 9ea00fc - [NFC][AArch64] Use optional returns in target parser instead of 'invalid' objects

2023-01-27 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2023-01-27T12:35:58Z
New Revision: 9ea00fc74c3c0032ff2d9a6774e13449a30e4549

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

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

This updates the parsing methods in AArch64's Target Parser to make use
of optional returns instead of "invalid" enum values, making the API's
behaviour clearer.

Reviewed By: lenary, tmatheson

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/TargetParser/AArch64TargetParser.cpp
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index dfed95f0513f0..5971489ce8004 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/AArch64TargetParser.h"
 #include "llvm/Support/ARMTargetParserCommon.h"
+#include "llvm/TargetParser/AArch64TargetParser.h"
 #include 
 
 using namespace clang;
@@ -223,8 +224,7 @@ bool AArch64TargetInfo::validateBranchProtection(StringRef 
Spec, StringRef,
 }
 
 bool AArch64TargetInfo::isValidCPUName(StringRef Name) const {
-  return Name == "generic" ||
- llvm::AArch64::parseCpu(Name).Arch != llvm::AArch64::INVALID;
+  return Name == "generic" || llvm::AArch64::parseCpu(Name);
 }
 
 bool AArch64TargetInfo::setCPU(const std::string ) {
@@ -681,19 +681,19 @@ void 
AArch64TargetInfo::setFeatureEnabled(llvm::StringMap ,
   Features[Name] = Enabled;
   // If the feature is an architecture feature (like v8.2a), add all previous
   // architecture versions and any dependant target features.
-  const llvm::AArch64::ArchInfo  =
+  const std::optional ArchInfo =
   llvm::AArch64::ArchInfo::findBySubArch(Name);
 
-  if (ArchInfo == llvm::AArch64::INVALID)
+  if (!ArchInfo)
 return; // Not an architecure, nothing more to do.
 
   for (const auto *OtherArch : llvm::AArch64::ArchInfos)
-if (ArchInfo.implies(*OtherArch))
+if (ArchInfo->implies(*OtherArch))
   Features[OtherArch->getSubArch()] = Enabled;
 
   // Set any features implied by the architecture
   uint64_t Extensions =
-  llvm::AArch64::getDefaultExtensions("generic", ArchInfo);
+  llvm::AArch64::getDefaultExtensions("generic", *ArchInfo);
   std::vector CPUFeats;
   if (llvm::AArch64::getExtensionFeatures(Extensions, CPUFeats)) {
 for (auto F : CPUFeats) {
@@ -949,9 +949,9 @@ bool AArch64TargetInfo::initFeatureMap(
 const std::vector ) const {
   std::vector UpdatedFeaturesVec;
   // Parse the CPU and add any implied features.
-  const llvm::AArch64::ArchInfo  = llvm::AArch64::parseCpu(CPU).Arch;
-  if (Arch != llvm::AArch64::INVALID) {
-uint64_t Exts = llvm::AArch64::getDefaultExtensions(CPU, Arch);
+  std::optional CpuInfo = llvm::AArch64::parseCpu(CPU);
+  if (CpuInfo) {
+uint64_t Exts = llvm::AArch64::getDefaultExtensions(CPU, CpuInfo->Arch);
 std::vector CPUFeats;
 llvm::AArch64::getExtensionFeatures(Exts, CPUFeats);
 for (auto F : CPUFeats) {
@@ -1033,13 +1033,14 @@ ParsedTargetAttr 
AArch64TargetInfo::parseTargetAttr(StringRef Features) const {
   FoundArch = true;
   std::pair Split =
   Feature.split("=").second.trim().split("+");
-  const llvm::AArch64::ArchInfo  = 
llvm::AArch64::parseArch(Split.first);
+  const std::optional AI =
+  llvm::AArch64::parseArch(Split.first);
 
   // Parse the architecture version, adding the required features to
   // Ret.Features.
-  if (AI == llvm::AArch64::INVALID)
+  if (!AI)
 continue;
-  Ret.Features.push_back(AI.ArchFeature.str());
+  Ret.Features.push_back(AI->ArchFeature.str());
   // Add any extra features, after the +
   SplitAndAddFeatures(Split.second, Ret.Features);
 } else if (Feature.startswith("cpu=")) {

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 2c559cc8b3b90..81b0245d57a6c 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -123,8 +123,8 @@ static bool DecodeAArch64Features(const Driver , 
StringRef text,
 static bool DecodeAArch64Mcpu(const Driver , StringRef Mcpu, StringRef ,
   std::vector ) {
   std::pair Split = Mcpu.split("+");
+  CPU = Split.first;
   const llvm::AArch64::ArchInfo *ArchInfo = ::AArch64::ARMV8A;
-  CPU = 

[PATCH] D140756: Add clang_CXXMethod_isExplicit to libclang

2023-01-27 Thread 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 rG0a51bc731bcc: Add clang_CXXMethod_isExplicit to libclang 
(authored by Luca Di Sera luca.dis...@qt.io).

Changed prior to commit:
  https://reviews.llvm.org/D140756?vs=492042=492702#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140756

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_cursor.py
  clang/include/clang-c/Index.h
  clang/test/Index/explicit-constructor.cpp
  clang/test/Index/explicit-conversion-function.cpp
  clang/test/Index/get-cursor.cpp
  clang/test/Index/index-file.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/libclang.map

Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -416,6 +416,7 @@
 clang_disposeAPISet;
 clang_getSymbolGraphForCursor;
 clang_getSymbolGraphForUSR;
+clang_CXXMethod_isExplicit;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -8947,6 +8947,25 @@
   return (Method && Method->isMoveAssignmentOperator()) ? 1 : 0;
 }
 
+unsigned clang_CXXMethod_isExplicit(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const FunctionDecl *FD = D->getAsFunction();
+
+  if (!FD)
+return 0;
+
+  if (const auto *Ctor = dyn_cast(FD))
+return Ctor->isExplicit();
+
+  if (const auto *Conv = dyn_cast(FD))
+return Conv->isExplicit();
+
+  return 0;
+}
+
 unsigned clang_CXXRecord_isAbstract(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return 0;
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -916,6 +916,8 @@
   printf(" (copy-assignment operator)");
 if (clang_CXXMethod_isMoveAssignmentOperator(Cursor))
   printf(" (move-assignment operator)");
+if (clang_CXXMethod_isExplicit(Cursor))
+  printf(" (explicit)");
 if (clang_CXXRecord_isAbstract(Cursor))
   printf(" (abstract)");
 if (clang_EnumDecl_isScoped(Cursor))
Index: clang/test/Index/recursive-cxx-member-calls.cpp
===
--- clang/test/Index/recursive-cxx-member-calls.cpp
+++ clang/test/Index/recursive-cxx-member-calls.cpp
@@ -824,7 +824,7 @@
 // CHECK-tokens: Keyword: "public" [86:1 - 86:7] CXXAccessSpecifier=:86:1 (Definition)
 // CHECK-tokens: Punctuation: ":" [86:7 - 86:8] CXXAccessSpecifier=:86:1 (Definition)
 // CHECK-tokens: Keyword: "explicit" [87:3 - 87:11] CXXConstructor=StringSwitch:87:12 (Definition)
-// CHECK-tokens: Identifier: "StringSwitch" [87:12 - 87:24] CXXConstructor=StringSwitch:87:12 (Definition)
+// CHECK-tokens: Identifier: "StringSwitch" [87:12 - 87:24] CXXConstructor=StringSwitch:87:12 (Definition) (explicit)
 // CHECK-tokens: Punctuation: "(" [87:24 - 87:25] CXXConstructor=StringSwitch:87:12 (Definition)
 // CHECK-tokens: Identifier: "StringRef" [87:25 - 87:34] TypeRef=class llvm::StringRef:38:7
 // CHECK-tokens: Identifier: "Str" [87:35 - 87:38] ParmDecl=Str:87:35 (Definition)
@@ -1839,7 +1839,7 @@
 // CHECK: 84:3: TypeRef=class llvm::StringRef:38:7 Extent=[84:3 - 84:12]
 // CHECK: 85:12: FieldDecl=Result:85:12 (Definition) Extent=[85:3 - 85:18]
 // CHECK: 86:1: CXXAccessSpecifier=:86:1 (Definition) Extent=[86:1 - 86:8]
-// CHECK: 87:12: CXXConstructor=StringSwitch:87:12 (Definition) Extent=[87:3 - 87:64]
+// CHECK: 87:12: CXXConstructor=StringSwitch:87:12 (Definition) (explicit) Extent=[87:3 - 87:64]
 // CHECK: 87:35: ParmDecl=Str:87:35 (Definition) Extent=[87:25 - 87:38]
 // CHECK: 87:25: TypeRef=class llvm::StringRef:38:7 Extent=[87:25 - 87:34]
 // CHECK: 87:42: MemberRef=Str:84:13 Extent=[87:42 - 87:45]
Index: clang/test/Index/index-file.cpp
===
--- clang/test/Index/index-file.cpp
+++ clang/test/Index/index-file.cpp
@@ -53,4 +53,4 @@
 // CHECK: [indexDeclaration]: kind: constructor | name: B | {{.*}} | loc: 33:12
 // CHECK: [indexDeclaration]: kind: constructor | name: B | {{.*}} (copy constructor) (converting constructor) | loc: 34:3
 // CHECK: [indexDeclaration]: kind: constructor | name: B | {{.*}} (move constructor) (converting constructor) | loc: 35:3
-// CHECK: [indexDeclaration]: kind: constructor | name: C | {{.*}} (copy constructor) | loc: 39:12
+// CHECK: 

[clang] 0a51bc7 - Add clang_CXXMethod_isExplicit to libclang

2023-01-27 Thread Luca Di Sera via cfe-commits

Author: Luca Di Sera
Date: 2023-01-27T13:23:41+01:00
New Revision: 0a51bc731bcc2c27e4fe97957a83642d93d989be

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

LOG: Add clang_CXXMethod_isExplicit to libclang

The new method is a wrapper of `CXXConstructorDecl::isExplicit` and
`CXXConversionDecl::isExplicit`, allowing the user to recognize whether
the declaration pointed to by a cursor was marked with the explicit
specifier.

An export for the function, together with its documentation, was added
to "clang/include/clang-c/Index.h" with an implementation provided in
"clang/tools/libclang/CIndex.cpp".

The implementation is based on similar `clang_CXXMethod`
implementations, returning a falsy unsigned value when the cursor is not
a declaration, is not a declaration for a constructor or conversion
function or is not a relevant declaration that was marked with the
`explicit` specifier.

The new symbol was added to "clang/tools/libclang/libclang.map" to be
exported, under the LLVM16 tag.

"clang/tools/c-index-test/c-index-test.c" was modified to print a
specific tag, "(explicit)", for cursors that are recognized by
`clang_CXXMethod_isExplicit`.

Two new regression files, "explicit-constructor.cpp" and
"explicit-conversion-function.cpp", were added to "clang/test/Index", to
ensure that the behavior of the new function is correct for constructors
and conversion functions, respectively.

The "get-cursor.cpp", "index-file.cpp" and
"recursive-cxx-member-calls.cpp" regression files in "clang/test/Index"
were updated as they were affected by the new "(explicit)" tag.

A binding for the new function was added to libclang's python's
bindings, in "clang/bindings/python/clang/cindex.py", as the
"is_explicit_method" method under `Cursor`.

An accompanying test was added to
"clang/bindings/python/tests/cindex/test_cursor.py", mimicking the
regression tests for the C side.

The current release note for Clang, "clang/docs/ReleaseNotes.rst" was
modified to report the new addition under the "libclang" section.

Reviewed By: aaron.ballman

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

Added: 
clang/test/Index/explicit-constructor.cpp
clang/test/Index/explicit-conversion-function.cpp

Modified: 
clang/bindings/python/clang/cindex.py
clang/bindings/python/tests/cindex/test_cursor.py
clang/include/clang-c/Index.h
clang/test/Index/get-cursor.cpp
clang/test/Index/index-file.cpp
clang/test/Index/recursive-cxx-member-calls.cpp
clang/tools/c-index-test/c-index-test.c
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/libclang.map

Removed: 




diff  --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 2e32ce2ba6d06..5d13b7bff1498 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1529,6 +1529,51 @@ class Bar {
 """
 return conf.lib.clang_CXXMethod_isMoveAssignmentOperator(self)
 
+def is_explicit_method(self):
+"""Determines if a C++ constructor or conversion function is
+explicit, returning 1 if such is the case and 0 otherwise.
+
+Constructors or conversion functions are declared explicit through
+the use of the explicit specifier.
+
+For example, the following constructor and conversion function are
+not explicit as they lack the explicit specifier:
+
+class Foo {
+Foo();
+operator int();
+};
+
+While the following constructor and conversion function are
+explicit as they are declared with the explicit specifier.
+
+class Foo {
+explicit Foo();
+explicit operator int();
+};
+
+This method will return 0 when given a cursor pointing to one of
+the former declarations and it will return 1 for a cursor pointing
+to the latter declarations.
+
+The explicit specifier allows the user to specify a
+conditional compile-time expression whose value decides
+whether the marked element is explicit or not.
+
+For example:
+
+constexpr bool foo(int i) { return i % 2 == 0; }
+
+class Foo {
+ explicit(foo(1)) Foo();
+ explicit(foo(2)) operator int();
+}
+
+This method will return 0 for the constructor and 1 for
+the conversion function.
+"""
+return conf.lib.clang_CXXMethod_isExplicit(self)
+
 def is_mutable_field(self):
 """Returns True if the cursor refers to a C++ field that is declared
 'mutable'.
@@ -3494,6 +3539,10 @@ def cursor(self):
[Cursor],
bool),
 
+  ("clang_CXXMethod_isExplicit",
+   [Cursor],
+   

[PATCH] D142704: [C++20][Modules] Handle template declarations in header units.

2023-01-27 Thread Iain Sandoe via Phabricator via cfe-commits
iains created this revision.
Herald added a project: All.
iains added reviewers: dblaikie, ChuanqiXu.
iains published this revision for review.
iains added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

@dblaikie - I suspect that this would be useful on the llvm-16 release branch, 
and so I've added you as a reviewer, if you have some chance to look ..
 (I do not think @ChuanqiXu is available until February).

The issue here is that the function decl is extracted from function templates 
(and looks just like any other function definition at this point), so that we 
need to remember that it came from a template.


This addresses part of https://github.com/llvm/llvm-project/issues/60079

The test for external functions was not considering function templates.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142704

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/module/module.import/p6.cpp


Index: clang/test/CXX/module/module.import/p6.cpp
===
--- clang/test/CXX/module/module.import/p6.cpp
+++ clang/test/CXX/module/module.import/p6.cpp
@@ -22,6 +22,8 @@
 
 int bad_var_definition = 3;  // expected-error {{non-inline external 
definitions are not permitted in C++ header units}}
 
+/* The cases below should compile without diagnostics.  */
+
 class A {
 public:
 // This is a declaration instead of definition.
@@ -36,3 +38,10 @@
   S(S&);
 };
 S::S(S&) = default;
+
+template
+int tmpl_OK (_Ep) { return 0; }
+
+template 
+bool
+operator==(_T1& , _T1& ) { return false; }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15108,10 +15108,12 @@
   }
 
   FunctionDecl *FD = nullptr;
+  bool IsFnTemplate = false;
 
-  if (FunctionTemplateDecl *FunTmpl = dyn_cast(D))
+  if (FunctionTemplateDecl *FunTmpl = dyn_cast(D)) {
 FD = FunTmpl->getTemplatedDecl();
-  else
+IsFnTemplate = true;
+  } else
 FD = cast(D);
 
   // Do not push if it is a lambda because one is already pushed when building
@@ -15260,7 +15262,7 @@
   // state is complete.
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
   FD->getFormalLinkage() == Linkage::ExternalLinkage &&
-  !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
+  !FD->isInvalidDecl() && !IsFnTemplate && BodyKind != FnBodyKind::Delete 
&&
   BodyKind != FnBodyKind::Default && !FD->isInlined()) {
 assert(FD->isThisDeclarationADefinition());
 Diag(FD->getLocation(), diag::err_extern_def_in_header_unit);


Index: clang/test/CXX/module/module.import/p6.cpp
===
--- clang/test/CXX/module/module.import/p6.cpp
+++ clang/test/CXX/module/module.import/p6.cpp
@@ -22,6 +22,8 @@
 
 int bad_var_definition = 3;  // expected-error {{non-inline external definitions are not permitted in C++ header units}}
 
+/* The cases below should compile without diagnostics.  */
+
 class A {
 public:
 // This is a declaration instead of definition.
@@ -36,3 +38,10 @@
   S(S&);
 };
 S::S(S&) = default;
+
+template
+int tmpl_OK (_Ep) { return 0; }
+
+template 
+bool
+operator==(_T1& , _T1& ) { return false; }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15108,10 +15108,12 @@
   }
 
   FunctionDecl *FD = nullptr;
+  bool IsFnTemplate = false;
 
-  if (FunctionTemplateDecl *FunTmpl = dyn_cast(D))
+  if (FunctionTemplateDecl *FunTmpl = dyn_cast(D)) {
 FD = FunTmpl->getTemplatedDecl();
-  else
+IsFnTemplate = true;
+  } else
 FD = cast(D);
 
   // Do not push if it is a lambda because one is already pushed when building
@@ -15260,7 +15262,7 @@
   // state is complete.
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
   FD->getFormalLinkage() == Linkage::ExternalLinkage &&
-  !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
+  !FD->isInvalidDecl() && !IsFnTemplate && BodyKind != FnBodyKind::Delete &&
   BodyKind != FnBodyKind::Default && !FD->isInlined()) {
 assert(FD->isThisDeclarationADefinition());
 Diag(FD->getLocation(), diag::err_extern_def_in_header_unit);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141827: [clang][TypePrinter] Test TemplateArgument::IsDefaulted when omitting default arguments

2023-01-27 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

This caused some LLDB test failures for the `import-std-module` setting.  
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/

We construct `TemplateArgument`s manually in the `CxxModuleHandler`. Fix is 
in-flight.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141827

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


[PATCH] D127812: [AArch64] FMV support and necessary target features dependencies.

2023-01-27 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

This patch has made it considerably harder to understand what is going on in 
the TargetParser. If you get a chance, please could you add some clarifying 
comments and tidy-ups. I appreciate that a lot of this is following the lead of 
the pre-existing TargetParser code, but lets try to improve it as we go.




Comment at: clang/include/clang/Basic/TargetInfo.h:1345
+  /// generation and get its dependent options in second argument.
+  virtual bool getFeatureDepOptions(StringRef Feature,
+std::string ) const {

Is this really useful for any other targets? It seems very specific to AArch64 
anf FMV, and at the only 2 call sites you are guaranteed to have an 
AArch64TargetInfo. Seems like an unnecessary extension to the interface.



Comment at: clang/include/clang/Basic/TargetInfo.h:1311
+  /// generation.
+  virtual bool isCodeImpactFeatureName(StringRef Feature) const { return true; 
}
+

samtebbs wrote:
> Similarly to the warning string, I think a name like 
> `featureAffectsCodeGen(...)` would be more clear in its use.
I agree that the function name doesn't suggest what the doc comment says this 
function does. Also, the meaning of the return value (does this affect 
codegen?) seems unrelated to the other output value (list of dependent options) 
so I don't understand why this is one function rather than two.



Comment at: clang/lib/AST/ASTContext.cpp:13302
+if (Target->validateCpuSupports(Feature.str()))
+  ResFeats.push_back("?" + Feature.str());
+  return ResFeats;

Is the meaning of this question mark explained anywhere? Could a more 
meaningful type be used rather than passing around strings?



Comment at: clang/lib/Basic/Targets/AArch64.cpp:664
+bool AArch64TargetInfo::getFeatureDepOptions(StringRef Name,
+ std::string ) const {
+  FeatureVec = llvm::StringSwitch(Name)

FeatureVec is not a vector.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:671
+   .Default("");
+  return FeatureVec != "";
+}

If I'm reading this right, this is saying that the extension "does not affect 
codegen" (from the docstring) if the extension's dependent features 
DEP_FEATURES //happens to be the empty string// (or an invalid extension name 
is passed in). IIUC, this is not a reasonable way to indicate that it does not 
affect codegen; an extra macro parameter/struct field would be more appropriate.



Comment at: llvm/include/llvm/TargetParser/AArch64TargetParser.def:108
 // FIXME: This would be nicer were it tablegen
-AARCH64_ARCH_EXT_NAME("invalid",  AArch64::AEK_INVALID, {},
  {})
-AARCH64_ARCH_EXT_NAME("none", AArch64::AEK_NONE,{},
  {})
-AARCH64_ARCH_EXT_NAME("crc",  AArch64::AEK_CRC, "+crc",
  "-crc")
-AARCH64_ARCH_EXT_NAME("lse",  AArch64::AEK_LSE, "+lse",
  "-lse")
-AARCH64_ARCH_EXT_NAME("rdm",  AArch64::AEK_RDM, "+rdm",
  "-rdm")
-AARCH64_ARCH_EXT_NAME("crypto",   AArch64::AEK_CRYPTO,  "+crypto", 
  "-crypto")
-AARCH64_ARCH_EXT_NAME("sm4",  AArch64::AEK_SM4, "+sm4",
  "-sm4")
-AARCH64_ARCH_EXT_NAME("sha3", AArch64::AEK_SHA3,"+sha3",   
  "-sha3")
-AARCH64_ARCH_EXT_NAME("sha2", AArch64::AEK_SHA2,"+sha2",   
  "-sha2")
-AARCH64_ARCH_EXT_NAME("aes",  AArch64::AEK_AES, "+aes",
  "-aes")
-AARCH64_ARCH_EXT_NAME("dotprod",  AArch64::AEK_DOTPROD, "+dotprod",
  "-dotprod")
-AARCH64_ARCH_EXT_NAME("fp",   AArch64::AEK_FP,  "+fp-armv8",   
  "-fp-armv8")
-AARCH64_ARCH_EXT_NAME("simd", AArch64::AEK_SIMD,"+neon",   
  "-neon")
-AARCH64_ARCH_EXT_NAME("fp16", AArch64::AEK_FP16,"+fullfp16",   
  "-fullfp16")
-AARCH64_ARCH_EXT_NAME("fp16fml",  AArch64::AEK_FP16FML, "+fp16fml",
  "-fp16fml")
-AARCH64_ARCH_EXT_NAME("profile",  AArch64::AEK_PROFILE, "+spe",
  "-spe")
-AARCH64_ARCH_EXT_NAME("ras",  AArch64::AEK_RAS, "+ras",
  "-ras")
-AARCH64_ARCH_EXT_NAME("rasv2",AArch64::AEK_RASv2,   "+rasv2",  
  "-rasv2")
-AARCH64_ARCH_EXT_NAME("sve",  AArch64::AEK_SVE, "+sve",
  "-sve")
-AARCH64_ARCH_EXT_NAME("sve2", AArch64::AEK_SVE2,"+sve2",   
  "-sve2")
-AARCH64_ARCH_EXT_NAME("sve2-aes", AArch64::AEK_SVE2AES, "+sve2-aes",   
  "-sve2-aes")
-AARCH64_ARCH_EXT_NAME("sve2-sm4", AArch64::AEK_SVE2SM4, "+sve2-sm4",   
  "-sve2-sm4")
-AARCH64_ARCH_EXT_NAME("sve2-sha3",AArch64::AEK_SVE2SHA3,"+sve2-sha3",  
  "-sve2-sha3")
-AARCH64_ARCH_EXT_NAME("sve2-bitperm", AArch64::AEK_SVE2BITPERM, 
"+sve2-bitperm", "-sve2-bitperm")

[PATCH] D142702: [Clang][AArch64][SME] Generate target features from +(no)sme.* options

2023-01-27 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc created this revision.
bryanpkc added reviewers: sdesmalen, rsandifo-arm, david-arm.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
bryanpkc requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142702

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-implied-sme-features.c

Index: clang/test/Driver/aarch64-implied-sme-features.c
===
--- /dev/null
+++ clang/test/Driver/aarch64-implied-sme-features.c
@@ -0,0 +1,55 @@
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme %s -### 2>&1 | FileCheck %s --check-prefix=SME-IMPLY
+// SME-IMPLY: "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme %s -### 2>&1 | FileCheck %s --check-prefix=NOSME
+// NOSME: "-target-feature" "-sme"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme+nosme %s -### 2>&1 | FileCheck %s --check-prefix=SME-REVERT
+// SME-REVERT-NOT: "-target-feature" "+sme"
+// SME-REVERT: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme" "-target-feature" "-sme-f64f64" "-target-feature" "-sme-i16i64"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme+nosve %s -### 2>&1 | FileCheck %s --check-prefix=SME-CONFLICT
+// SME-CONFLICT: "-target-feature" "-sve" "-target-feature" "-sve2" "-target-feature" "-sve2-bitperm" "-target-feature" "-sve2-sha3" "-target-feature" "-sve2-aes" "-target-feature" "-sve2-sm4" "-target-feature" "-sme"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme+sve %s -### 2>&1 | FileCheck %s --check-prefix=SME-SVE
+// SME-SVE: "-target-feature" "+sme" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "+sve"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-I16I64
+// SME-I16I64: "-target-feature" "+sme-i16i64" "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=NOSME-I16I64
+// NOSME-I16I64-NOT: "-target-feature" "+sme-i16i64"
+// NOSME-I16I64-NOT: "-target-feature" "+sme"
+// NOSME-I16I64-NOT: "-target-feature" "+sve"
+// NOSME-I16I64-NOT: "-target-feature" "+sve2"
+// NOSME-I16I64-NOT: "-target-feature" "+bf16"
+// NOSME-I16I64: "-target-feature" "-sme-i16i64"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-i16i64+nosme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-I16I64-REVERT
+// SME-I16I64-REVERT: "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme-i16i64"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme-f64f64 %s -### 2>&1 | FileCheck %s --check-prefix=NOSME-F64F64
+// NOSME-F64F64-NOT: "-target-feature" "+sme-f64f64"
+// NOSME-F64F64-NOT: "-target-feature" "+sme"
+// NOSME-F64F64-NOT: "-target-feature" "+sve"
+// NOSME-F64F64-NOT: "-target-feature" "+sve2"
+// NOSME-F64F64-NOT: "-target-feature" "+bf16"
+// NOSME-F64F64: "-target-feature" "-sme-f64f64"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-f64f64+nosme-f64f64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-F64F64-REVERT
+// SME-F64F64-REVERT: "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme-f64f64"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-f64f64+nosme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-SUBFEATURE-MIX
+// SME-SUBFEATURE-MIX: "-target-feature" "+sme-f64f64" "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme-i16i64"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-i16i64+nosme %s -### 2>&1 | FileCheck %s --check-prefix=SME-SUBFEATURE-CONFLICT
+// SME-SUBFEATURE-CONFLICT: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme" "-target-feature" "-sme-f64f64" "-target-feature" "-sme-i16i64"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-f64f64+nosve %s -### 2>&1 | FileCheck %s --check-prefix=SVE-SUBFEATURE-CONFLICT
+// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sve2"
+// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sve"
+// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sme"
+// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sme-f64f64"
+
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme+sme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-SUBFEATURE-CONFLICT-REV
+// SME-SUBFEATURE-CONFLICT-REV: "-target-feature" "-sme-f64f64" "-target-feature" 

[PATCH] D134681: [Clang][AArch64][SME] Add outer product intrinsics

2023-01-27 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 492693.
bryanpkc retitled this revision from "[Clang][AArch64] Add SME outer product 
intrinsics" to "[Clang][AArch64][SME] Add outer product intrinsics".
bryanpkc edited the summary of this revision.
bryanpkc added a comment.

Rebased and cleaned up the patch. Also added `_m` suffix to the intrinsics as 
required by the amendment in https://github.com/ARM-software/acle/pull/218.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134681

Files:
  clang/include/clang/Basic/arm_sme.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mopa-za32.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mopa-za64.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za32.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za64.c

Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za64.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za64.c
@@ -0,0 +1,74 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -o /dev/null %s
+
+#include 
+
+#ifdef SME_OVERLOADED_FORMS
+#define SME_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3
+#else
+#define SME_ACLE_FUNC(A1,A2,A3) A1##A2##A3
+#endif
+
+// CHECK-C-LABEL: @test_svmops_za64_s16(
+// CHECK-CXX-LABEL: @_Z20test_svmops_za64_s16u10__SVBool_tu10__SVBool_tu11__SVInt16_tu11__SVInt16_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.smops.wide.nxv8i16(i32 1,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]],  [[ZM:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svmops_za64_s16(svbool_t pn, svbool_t pm, svint16_t zn, svint16_t zm) {
+  SME_ACLE_FUNC(svmops_za64, _s16, _m)(1, pn, pm, zn, zm);
+}
+
+// CHECK-C-LABEL: @test_svmops_za64_u16(
+// CHECK-CXX-LABEL: @_Z20test_svmops_za64_u16u10__SVBool_tu10__SVBool_tu12__SVUint16_tu12__SVUint16_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.umops.wide.nxv8i16(i32 0,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]],  [[ZM:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svmops_za64_u16(svbool_t pn, svbool_t pm, svuint16_t zn, svuint16_t zm) {
+  SME_ACLE_FUNC(svmops_za64, _u16, _m)(0, pn, pm, zn, zm);
+}
+
+// CHECK-C-LABEL: @test_svmops_za64_f64(
+// CHECK-CXX-LABEL: @_Z20test_svmops_za64_f64u10__SVBool_tu10__SVBool_tu13__SVFloat64_tu13__SVFloat64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.mops.nxv2f64(i32 1,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]],  [[ZM:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svmops_za64_f64(svbool_t pn, svbool_t pm, svfloat64_t zn, svfloat64_t zm) {
+  SME_ACLE_FUNC(svmops_za64, _f64, _m)(1, pn, pm, zn, zm);
+}
+
+// CHECK-C-LABEL: @test_svsumops_za64_s16(
+// CHECK-CXX-LABEL: @_Z22test_svsumops_za64_s16u10__SVBool_tu10__SVBool_tu11__SVInt16_tu12__SVUint16_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  

[PATCH] D134680: [Clang][AArch64][SME] Add intrinsics for adding vector elements to ZA tile

2023-01-27 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 492692.
bryanpkc edited the summary of this revision.
bryanpkc added a comment.

Added `_m` suffix to the intrinsics as required by the amendment in 
https://github.com/ARM-software/acle/pull/218.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134680

Files:
  clang/include/clang/Basic/arm_sme.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i32.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c

Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c
@@ -0,0 +1,110 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -o /dev/null %s
+
+#include 
+
+#ifdef SME_OVERLOADED_FORMS
+#define SME_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3
+#else
+#define SME_ACLE_FUNC(A1,A2,A3) A1##A2##A3
+#endif
+
+// CHECK-C-LABEL: @test_svaddha_za64_u64(
+// CHECK-CXX-LABEL: @_Z21test_svaddha_za64_u64u10__SVBool_tu10__SVBool_tu12__SVUint64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 0,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svaddha_za64_u64(svbool_t pn, svbool_t pm, svuint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _u64, _m)(0, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddha_za64_u64_1(
+// CHECK-CXX-LABEL: @_Z23test_svaddha_za64_u64_1u10__SVBool_tu10__SVBool_tu12__SVUint64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 7,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svaddha_za64_u64_1(svbool_t pn, svbool_t pm, svuint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _u64, _m)(7, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddha_za64_s64(
+// CHECK-CXX-LABEL: @_Z21test_svaddha_za64_s64u10__SVBool_tu10__SVBool_tu11__SVInt64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 0,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svaddha_za64_s64(svbool_t pn, svbool_t pm, svint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _s64, _m)(0, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddha_za64_s64_1(
+// CHECK-CXX-LABEL: @_Z23test_svaddha_za64_s64_1u10__SVBool_tu10__SVBool_tu11__SVInt64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 7,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svaddha_za64_s64_1(svbool_t pn, svbool_t pm, svint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _s64, _m)(7, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddva_za64_u64(
+// CHECK-CXX-LABEL: @_Z21test_svaddva_za64_u64u10__SVBool_tu10__SVBool_tu12__SVUint64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  

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

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

I am not an expert in the frontend or ASTContext area, but I think that if a 
builtin declaration is created (`ASTContext::getBuiltinVaListDecl`) the 
identifier name for it should not be loaded from an external source (in 
function `IdentifierTable::get`). This load of identifier causes it to be get 
from ASTReader which in turn gets va_list it again from `ASTContext` because 
this is a predefined declaration. In this way 2 instances of va_list are added 
to the AST. The following call chain shows the problem (first create of va_list 
happens when Sema is initialized, second create happens when the __va_list is 
loaded by ASTReader as result of the first attempt to create it):

  #0  clang::RecordDecl::RecordDecl (this=0x7fffd407a1c8, 
DK=clang::Decl::Record, TK=clang::TTK_Struct, C=..., DC=0x7fffd4041ec0, 
StartLoc=..., IdLoc=..., Id=0x7fffd407abb8, PrevDecl=0x0) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/Decl.cpp:4700
  #1  0x74f26568 in clang::RecordDecl::Create (C=..., 
TK=clang::TTK_Struct, DC=0x7fffd4041ec0, StartLoc=..., IdLoc=..., 
Id=0x7fffd407abb8, PrevDecl=0x0) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/Decl.cpp:4720
  #2  0x74ac92f6 in clang::ASTContext::buildImplicitRecord 
(this=0x7fffd402b110, Name=..., TK=clang::TTK_Struct) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:1216
  #3  0x74b0a8e3 in CreateAArch64ABIBuiltinVaListDecl 
(Context=0x7fffd402b110) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:8757
  #4  0x74af4be6 in CreateVaListDecl (Context=0x7fffd402b110, 
Kind=clang::TargetInfo::AArch64ABIBuiltinVaList) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9097
  #5  0x74af4b14 in clang::ASTContext::getBuiltinVaListDecl 
(this=0x7fffd402b110) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9117
  #6  0x74af4cab in clang::ASTContext::getVaListTagDecl 
(this=0x7fffd402b110) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9128
  #7  0x758b4461 in getPredefinedDecl (Context=..., 
ID=clang::serialization::PREDEF_DECL_VA_LIST_TAG) at 
/local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:7496
  #8  0x758a38e5 in clang::ASTReader::GetExistingDecl 
(this=0x7fffd40436e0, ID=10) at 
/local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:7525
  #9  0x758acabd in clang::ASTReader::GetDecl (this=0x7fffd40436e0, 
ID=10) at 
/local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:7549
  #10 0x75887f51 in clang::ASTReader::SetGloballyVisibleDecls 
(this=0x7fffd40436e0, II=0x7fffd407abb8, DeclIDs=..., Decls=0x7fffd4079198) at 
/local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:8596
  #11 0x758bafb5 in clang::ASTReader::finishPendingActions 
(this=0x7fffd40436e0) at 
/local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:9276
  #12 0x758be073 in clang::ASTReader::FinishedDeserializing 
(this=0x7fffd40436e0) at 
/local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:9783
  #13 0x758d093f in 
clang::ExternalASTSource::Deserializing::~Deserializing (this=0x7fffe2c990b0) 
at 
/local/clang/llvm2/llvm-project/clang/include/clang/AST/ExternalASTSource.h:86
  #14 0x758b7427 in clang::ASTReader::get (this=0x7fffd40436e0, 
Name=...) at 
/local/clang/llvm2/llvm-project/clang/lib/Serialization/ASTReader.cpp:8126
  #15 0x74b18c4b in clang::IdentifierTable::get (this=0x7fffd401b720, 
Name=...) at 
/local/clang/llvm2/llvm-project/clang/include/clang/Basic/IdentifierTable.h:605
  #16 0x74ac92bd in clang::ASTContext::buildImplicitRecord 
(this=0x7fffd402b110, Name=..., TK=clang::TTK_Struct) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:1217
  #17 0x74b0a8e3 in CreateAArch64ABIBuiltinVaListDecl 
(Context=0x7fffd402b110) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:8757
  #18 0x74af4be6 in CreateVaListDecl (Context=0x7fffd402b110, 
Kind=clang::TargetInfo::AArch64ABIBuiltinVaList) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9097
  #19 0x74af4b14 in clang::ASTContext::getBuiltinVaListDecl 
(this=0x7fffd402b110) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9117
  #20 0x74af4cab in clang::ASTContext::getVaListTagDecl 
(this=0x7fffd402b110) at 
/local/clang/llvm2/llvm-project/clang/lib/AST/ASTContext.cpp:9128
  #21 0x7fffee43a586 in clang::Sema::Initialize (this=0x7fffd406a7e0) at 
/local/clang/llvm2/llvm-project/clang/lib/Sema/Sema.cpp:453
  #22 0x7fffe773b432 in clang::Parser::Initialize (this=0x7fffd40753c0) at 
/local/clang/llvm2/llvm-project/clang/lib/Parse/Parser.cpp:562
  #23 0x7fffe75d3fd4 in clang::ParseAST (S=..., PrintStats=false, 
SkipFunctionBodies=false) at 
/local/clang/llvm2/llvm-project/clang/lib/Parse/ParseAST.cpp:155
  #24 0x76169622 

[PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-01-27 Thread LJC via Phabricator via cfe-commits
paperchalice updated this revision to Diff 492684.
paperchalice added a comment.

Use `LLVM_LIBRARY_OUTPUT_INTDIR`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141907

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Tooling/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  cmake/Modules/GetClangResourceDir.cmake
  compiler-rt/cmake/base-config-ix.cmake
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake
  openmp/CMakeLists.txt

Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -86,8 +86,8 @@
 if(${OPENMP_STANDALONE_BUILD})
   set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
 else()
-  string(REGEX MATCH "[0-9]+" CLANG_VERSION ${PACKAGE_VERSION})
-  set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include")
+  include(GetClangResourceDir)
+  get_clang_resource_dir(LIBOMP_HEADERS_INSTALL_PATH SUBDIR include)
 endif()
 
 # Build host runtime library, after LIBOMPTARGET variables are set since they are needed
Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -257,7 +257,11 @@
 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR
  ${PACKAGE_VERSION})
-  set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
+set(resource_dir ${LLVM_TOOLS_BINARY_DIR}/${CLANG_RESOURCE_DIR})
+  else()
+set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  endif()
   set(flag_types ASM C CXX MODULE_LINKER SHARED_LINKER EXE_LINKER)
   foreach(type ${flag_types})
 set(${type}_flag -DCMAKE_${type}_FLAGS=-resource-dir=${resource_dir})
Index: lldb/unittests/Expression/ClangParserTest.cpp
===
--- lldb/unittests/Expression/ClangParserTest.cpp
+++ lldb/unittests/Expression/ClangParserTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangHost.h"
 #include "TestingSupport/SubsystemRAII.h"
@@ -37,12 +38,16 @@
 TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
 #if !defined(_WIN32)
   std::string path_to_liblldb = "/foo/bar/lib/";
-  std::string path_to_clang_dir =
-  "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING;
+  std::string path_to_clang_dir = std::string(CLANG_RESOURCE_DIR).empty()
+  ? "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME
+"/clang/" CLANG_VERSION_MAJOR_STRING
+  : "/foo/bar/bin/" CLANG_RESOURCE_DIR;
 #else
   std::string path_to_liblldb = "C:\\foo\\bar\\lib";
   std::string path_to_clang_dir =
-  "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
+  std::string(CLANG_RESOURCE_DIR).empty()
+  ? "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING
+  : "C:\\foo\\bar\\bin\\" CLANG_RESOURCE_DIR;
 #endif
   EXPECT_EQ(ComputeClangResourceDir(path_to_liblldb), path_to_clang_dir);
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -54,8 +54,11 @@
 
   static const llvm::StringRef kResourceDirSuffixes[] = {
   // LLVM.org's build of LLDB uses the clang resource directory placed
-  // in $install_dir/lib{,64}/clang/$clang_version.
-  CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING,
+  // in $install_dir/lib{,64}/clang/$clang_version or
+  // $install_dir/bin/$CLANG_RESOURCE_DIR
+  llvm::StringRef(CLANG_RESOURCE_DIR).empty()
+  ? CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING
+  : "bin/" CLANG_RESOURCE_DIR,
   // swift-lldb uses the clang resource directory copied from swift, which
   // by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
   // it there, so we use LLDB_INSTALL_LIBDIR_BASENAME.
Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -7,6 +7,7 @@
 include(CheckIncludeFile)
 include(CheckCXXSourceCompiles)
 

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

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



Comment at: clang/test/CXX/drs/dr23xx.cpp:202
+  // 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::*(); } 

shafik wrote:
> While gcc accepts the first three it does not like the last two: 
> https://godbolt.org/z/js8Pz14Eo
> 
> I believe they should also be covered but not confident.
I agree they should. I can't find any special considerations in the standard 
regarding unqualified name lookup of template arguments.

Are there any action items for me here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142316

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


[PATCH] D134680: [Clang][AArch64][SME] Add intrinsics for adding vector elements to ZA tile

2023-01-27 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 492682.
bryanpkc retitled this revision from "[Clang][AArch64] Add SME svaddha and 
svaddva intrinsics" to "[Clang][AArch64][SME] Add intrinsics for adding vector 
elements to ZA tile".
bryanpkc edited the summary of this revision.
bryanpkc added a comment.

Rebased and cleaned up the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134680

Files:
  clang/include/clang/Basic/arm_sme.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i32.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c

Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c
@@ -0,0 +1,110 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme-i16i64 -target-feature +sve -S -O1 -Werror -o /dev/null %s
+
+#include 
+
+#ifdef SME_OVERLOADED_FORMS
+#define SME_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3
+#else
+#define SME_ACLE_FUNC(A1,A2,A3) A1##A2##A3
+#endif
+
+// CHECK-C-LABEL: @test_svaddha_za64_u64(
+// CHECK-CXX-LABEL: @_Z21test_svaddha_za64_u64u10__SVBool_tu10__SVBool_tu12__SVUint64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 0,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svaddha_za64_u64(svbool_t pn, svbool_t pm, svuint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _u64,)(0, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddha_za64_u64_1(
+// CHECK-CXX-LABEL: @_Z23test_svaddha_za64_u64_1u10__SVBool_tu10__SVBool_tu12__SVUint64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 7,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svaddha_za64_u64_1(svbool_t pn, svbool_t pm, svuint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _u64,)(7, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddha_za64_s64(
+// CHECK-CXX-LABEL: @_Z21test_svaddha_za64_s64u10__SVBool_tu10__SVBool_tu11__SVInt64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 0,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svaddha_za64_s64(svbool_t pn, svbool_t pm, svint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _s64,)(0, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddha_za64_s64_1(
+// CHECK-CXX-LABEL: @_Z23test_svaddha_za64_s64_1u10__SVBool_tu10__SVBool_tu11__SVInt64_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PN:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( [[PM:%.*]])
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.addha.nxv2i64(i32 7,  [[TMP0]],  [[TMP1]],  [[ZN:%.*]])
+// CHECK-NEXT:ret void
+//
+__attribute__((arm_streaming)) void test_svaddha_za64_s64_1(svbool_t pn, svbool_t pm, svint64_t zn) {
+  SME_ACLE_FUNC(svaddha_za64, _s64,)(7, pn, pm, zn);
+}
+
+// CHECK-C-LABEL: @test_svaddva_za64_u64(
+// CHECK-CXX-LABEL: @_Z21test_svaddva_za64_u64u10__SVBool_tu10__SVBool_tu12__SVUint64_t(
+// 

[PATCH] D134679: [Clang][AArch64][SME] Add intrinsics for reading streaming vector length

2023-01-27 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 492681.
bryanpkc retitled this revision from "[Clang][AArch64] Add SME svcntsb/h/w/d C 
intrinsics" to "[Clang][AArch64][SME] Add intrinsics for reading streaming 
vector length".
bryanpkc edited the summary of this revision.
bryanpkc added a comment.

Rebased and cleaned up the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134679

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sme.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_cnt.c

Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_cnt.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_cnt.c
@@ -0,0 +1,46 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -o /dev/null %s
+
+#include 
+
+// CHECK-C-LABEL: @test_svcntsb(
+// CHECK-CXX-LABEL: @_Z12test_svcntsbv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 @llvm.aarch64.sme.cntsb()
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+uint64_t test_svcntsb() {
+  return svcntsb();
+}
+
+// CHECK-C-LABEL: @test_svcntsh(
+// CHECK-CXX-LABEL: @_Z12test_svcntshv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 @llvm.aarch64.sme.cntsh()
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+uint64_t test_svcntsh() {
+  return svcntsh();
+}
+
+// CHECK-C-LABEL: @test_svcntsw(
+// CHECK-CXX-LABEL: @_Z12test_svcntswv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 @llvm.aarch64.sme.cntsw()
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+uint64_t test_svcntsw() {
+  return svcntsw();
+}
+
+// CHECK-C-LABEL: @test_svcntsd(
+// CHECK-CXX-LABEL: @_Z12test_svcntsdv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 @llvm.aarch64.sme.cntsd()
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+uint64_t test_svcntsd() {
+  return svcntsd();
+}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4249,6 +4249,9 @@
   unsigned IntID);
   llvm::Value *EmitAArch64SVEBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
 
+  SmallVector
+  getSMEOverloadTypes(const SMETypeFlags , llvm::Type *ReturnType,
+  ArrayRef Ops);
   llvm::ScalableVectorType *getSVEType(const SMETypeFlags );
   llvm::Value *EmitSMELd1St1(SMETypeFlags TypeFlags,
  llvm::SmallVectorImpl ,
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9309,6 +9309,19 @@
   return Builder.CreateAdd(Base, CastOffset, "tileslice");
 }
 
+SmallVector
+CodeGenFunction::getSMEOverloadTypes(const SMETypeFlags ,
+ llvm::Type *ResultType,
+ ArrayRef Ops) {
+  if (TypeFlags.isOverloadNone())
+return {};
+
+  llvm::Type *DefaultType = getSVEType(TypeFlags);
+
+  assert(TypeFlags.isOverloadDefault() && "Unexpected value for overloads");
+  return {DefaultType};
+}
+
 // Return the llvm vector type corresponding to the specified element TypeFlags.
 llvm::ScalableVectorType *
 CodeGenFunction::getSVEType(const SMETypeFlags ) {
@@ -9893,6 +9906,7 @@
   getContext().GetBuiltinType(BuiltinID, Error, );
   assert(Error == ASTContext::GE_None && "Should not codegen an error");
 
+  llvm::Type *Ty = ConvertType(E->getType());
   llvm::SmallVector Ops;
   for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
 if ((ICEArguments & (1 << i)) == 0)
@@ -9923,6 +9937,12 @@
 return EmitSMEZero(TypeFlags, Ops, Builtin->LLVMIntrinsic);
   else if (TypeFlags.isLoadReg() || TypeFlags.isStoreReg())
 return EmitSMELdrStr(TypeFlags, Ops, Builtin->LLVMIntrinsic);
+  else if (Builtin->LLVMIntrinsic != 0) {
+Function *F = CGM.getIntrinsic(Builtin->LLVMIntrinsic,
+   getSMEOverloadTypes(TypeFlags, Ty, Ops));
+Value *Call = Builder.CreateCall(F, Ops);
+return Call;
+  }
 
   /// Should not happen
   return nullptr;
Index: clang/include/clang/Basic/arm_sme.td
===
--- 

[PATCH] D134677: [Clang][AArch64][SME] Add ZA zeroing intrinsics

2023-01-27 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 492680.
bryanpkc added a comment.

Update patch with more context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134677

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sme.td
  clang/include/clang/Basic/arm_sve_sme_incl.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c

Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c
@@ -0,0 +1,47 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -o /dev/null %s
+
+#include 
+
+// CHECK-C-LABEL: @test_svzero_mask_za(
+// CHECK-CXX-LABEL: @_Z19test_svzero_mask_zav(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero(i32 0)
+// CHECK-NEXT:ret void
+//
+void test_svzero_mask_za() {
+  svzero_mask_za(0);
+}
+
+// CHECK-C-LABEL: @test_svzero_mask_za_1(
+// CHECK-CXX-LABEL: @_Z21test_svzero_mask_za_1v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero(i32 176)
+// CHECK-NEXT:ret void
+//
+void test_svzero_mask_za_1() {
+  svzero_mask_za(176);
+}
+
+// CHECK-C-LABEL: @test_svzero_mask_za_2(
+// CHECK-CXX-LABEL: @_Z21test_svzero_mask_za_2v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero(i32 255)
+// CHECK-NEXT:ret void
+//
+void test_svzero_mask_za_2() {
+  svzero_mask_za(255);
+}
+
+// CHECK-C-LABEL: @test_svzero_za(
+// CHECK-CXX-LABEL: @_Z14test_svzero_zav(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.zero(i32 255)
+// CHECK-NEXT:ret void
+//
+void test_svzero_za() {
+  svzero_za();
+}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4256,6 +4256,9 @@
   llvm::Value *EmitSMEReadWrite(SMETypeFlags TypeFlags,
 llvm::SmallVectorImpl ,
 unsigned IntID);
+  llvm::Value *EmitSMEZero(SMETypeFlags TypeFlags,
+   llvm::SmallVectorImpl ,
+   unsigned IntID);
   llvm::Value *EmitAArch64SMEBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
 
   llvm::Value *EmitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9438,6 +9438,16 @@
   return Builder.CreateCall(F, Ops);
 }
 
+Value *CodeGenFunction::EmitSMEZero(SMETypeFlags TypeFlags,
+SmallVectorImpl ,
+unsigned IntID) {
+  // svzero_za() intrinsic zeros the entire za tile and has no paramters.
+  if (Ops.size() == 0)
+Ops.push_back(llvm::ConstantInt::get(Int32Ty, 255));
+  Function *F = CGM.getIntrinsic(IntID, {});
+  return Builder.CreateCall(F, Ops);
+}
+
 // Limit the usage of scalable llvm IR generated by the ACLE by using the
 // sve dup.x intrinsic instead of IRBuilder::CreateVectorSplat.
 Value *CodeGenFunction::EmitSVEDupX(Value *Scalar, llvm::Type *Ty) {
@@ -9894,6 +9904,8 @@
 return EmitSMELd1St1(TypeFlags, Ops, Builtin->LLVMIntrinsic);
   else if (TypeFlags.isMove())
 return EmitSMEReadWrite(TypeFlags, Ops, Builtin->LLVMIntrinsic);
+  else if (TypeFlags.isZero())
+return EmitSMEZero(TypeFlags, Ops, Builtin->LLVMIntrinsic);
 
   /// Should not happen
   return nullptr;
Index: clang/include/clang/Basic/arm_sve_sme_incl.td
===
--- clang/include/clang/Basic/arm_sve_sme_incl.td
+++ clang/include/clang/Basic/arm_sve_sme_incl.td
@@ -216,6 +216,7 @@
 def IsSharedZA: FlagType<0x20>;
 def IsPreservesZA : FlagType<0x40>;
 def IsMove: FlagType<0x80>;
+def IsZero: FlagType<0x100>;
 
 // These must be kept in sync with the flags in include/clang/Basic/TargetBuiltins.h
 class ImmCheckType {
Index: clang/include/clang/Basic/arm_sme.td

[PATCH] D134678: [Clang][AArch64][SME] Add intrinsics for ZA array load/store (LDR/STR)

2023-01-27 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 492679.
bryanpkc retitled this revision from "[Clang][AArch64] Add SME ldr and str 
intrinsic" to "[Clang][AArch64][SME] Add intrinsics for ZA array load/store 
(LDR/STR)".
bryanpkc edited the summary of this revision.
bryanpkc added a comment.

Rebased and cleaned up the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134678

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sme.td
  clang/include/clang/Basic/arm_sve_sme_incl.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ldr.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_str.c

Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_str.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_str.c
@@ -0,0 +1,43 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -o /dev/null %s
+
+#include 
+
+
+// CHECK-C-LABEL: @test_svstr_vnum_za(
+// CHECK-CXX-LABEL: @_Z18test_svstr_vnum_zajPv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.str(i32 [[SLICE_BASE:%.*]], ptr [[PTR:%.*]])
+// CHECK-NEXT:ret void
+//
+void test_svstr_vnum_za(uint32_t slice_base, void *ptr) {
+  svstr_vnum_za(slice_base, 0, ptr);
+}
+
+// CHECK-C-LABEL: @test_svstr_vnum_za_1(
+// CHECK-CXX-LABEL: @_Z20test_svstr_vnum_za_1jPv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VSCALE:%.*]] = tail call i64 @llvm.vscale.i64()
+// CHECK-NEXT:[[MULVL:%.*]] = mul nuw nsw i64 [[VSCALE]], 240
+// CHECK-NEXT:[[TMP0:%.*]] = getelementptr i8, ptr [[PTR:%.*]], i64 [[MULVL]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.str(i32 [[SLICE_BASE:%.*]], ptr [[TMP0]])
+// CHECK-NEXT:ret void
+//
+void test_svstr_vnum_za_1(uint32_t slice_base, void *ptr) {
+  svstr_vnum_za(slice_base, 15, ptr);
+}
+
+// CHECK-C-LABEL: @test_svstr_vnum_za_2(
+// CHECK-CXX-LABEL: @_Z20test_svstr_vnum_za_2jPv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VSCALE:%.*]] = tail call i64 @llvm.vscale.i64()
+// CHECK-NEXT:[[MULVL:%.*]] = shl nuw nsw i64 [[VSCALE]], 8
+// CHECK-NEXT:[[TMP0:%.*]] = getelementptr i8, ptr [[PTR:%.*]], i64 [[MULVL]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.str(i32 [[SLICE_BASE:%.*]], ptr [[TMP0]])
+// CHECK-NEXT:ret void
+//
+void test_svstr_vnum_za_2(uint32_t slice_base, void *ptr) {
+  svstr_vnum_za(slice_base, 16, ptr);
+}
Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ldr.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ldr.c
@@ -0,0 +1,42 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu -target-feature +sme -target-feature +sve -S -O1 -Werror -o /dev/null %s
+
+#include 
+
+// CHECK-C-LABEL: @test_svldr_vnum_za(
+// CHECK-CXX-LABEL: @_Z18test_svldr_vnum_zajPKv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.ldr(i32 [[SLICE_BASE:%.*]], ptr [[PTR:%.*]])
+// CHECK-NEXT:ret void
+//
+void test_svldr_vnum_za(uint32_t slice_base, const void *ptr) {
+  svldr_vnum_za(slice_base, 0, ptr);
+}
+
+// CHECK-C-LABEL: @test_svldr_vnum_za_1(
+// CHECK-CXX-LABEL: @_Z20test_svldr_vnum_za_1jPKv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VSCALE:%.*]] = tail call i64 @llvm.vscale.i64()
+// CHECK-NEXT:[[MULVL:%.*]] = mul nuw nsw i64 [[VSCALE]], 240
+// CHECK-NEXT:[[TMP0:%.*]] = getelementptr i8, ptr [[PTR:%.*]], i64 [[MULVL]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.ldr(i32 [[SLICE_BASE:%.*]], ptr [[TMP0]])
+// CHECK-NEXT:ret void
+//
+void test_svldr_vnum_za_1(uint32_t slice_base, const void *ptr) {
+  svldr_vnum_za(slice_base, 15, ptr);
+}
+
+// CHECK-C-LABEL: @test_svldr_vnum_za_2(
+// CHECK-CXX-LABEL: @_Z20test_svldr_vnum_za_2jPKv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VSCALE:%.*]] = tail call i64 

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

2023-01-27 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added inline comments.



Comment at: 
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:1026
+concept $Concept_decl[[C2]] = true;
+template $Bracket[[<]]C2$Bracket[[<]]int$Bracket[[>]] 
$TemplateParameter_def[[A]]$Bracket[[>]]
+class $Class_def[[B]] {};

Note that C2 does not get a token here. Maybe we can fix that along the way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


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

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

In D139926#4084868 , @nridge wrote:

> I figured I might as well look through the AST API for classes with 
> getLAngleLoc/getRAngleLoc methods.
>
> It looks like we've got almost all of them (including the ones mentioned in 
> recent comments) except:
>
> - OverloadExpr
> - DependentTemplateSpecializationTypeLoc
> - AutoTypeLoc

Adding AutoTypeLoc broke tons of tests, so I left it out for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


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

2023-01-27 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 492670.
ckandeler marked 3 inline comments as done.
ckandeler added a comment.

Handled more cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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

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

[PATCH] D142697: [WIP][3/N][Clang][RISCV] Add `__riscv_` for overloaded intrinsics

2023-01-27 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: luke, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

This commit adds prefix for the overloaded RVV intrinsics.

This is the 3rd commit of a patch-set to add __riscv_ for all RVV
intrinsics.

This follows the naming guideline under riscv-c-api-doc to add the
`__riscv_` suffix for all RVV intrinsics.

Pull Request:
riscv-non-isa/riscv-c-api-doc#31
riscv-non-isa/rvv-intrinsic-doc#189

Depends on D142644 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142697

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

[PATCH] D141215: [clang-repl][WIP] Implement pretty printing

2023-01-27 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 492665.
junaire added a comment.
Herald added a subscriber: ChuanqiXu.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/Value.cpp
  clang/lib/Interpreter/ValueSynthesize.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Interpreter/pretty-print.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -18,6 +19,8 @@
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h" // llvm_shutdown
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h" // llvm::Initialize*
@@ -66,6 +69,18 @@
   return (Errs || HasError) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
+static void DeclareMagicFunctions(clang::Interpreter ) {
+  llvm::ArrayRef MagicFunctions = {
+  "void __InterpreterCreateValue(void*, void*, char);",
+  "void __InterpreterCreateValue(void*, void*, int);",
+  "void __InterpreterCreateValue(void*, void*, float);",
+  "void __InterpreterCreateValue(void*, void*, double);",
+  };
+  for (llvm::StringRef Function : MagicFunctions) {
+llvm::cantFail(Interp.ParseAndExecute(Function));
+  }
+}
+
 llvm::ExitOnError ExitOnErr;
 int main(int argc, const char **argv) {
   ExitOnErr.setBanner("clang-repl: ");
@@ -110,6 +125,7 @@
 
   bool HasError = false;
 
+  DeclareMagicFunctions(*Interp);
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -12,6 +12,7 @@
   )
 
 clang_target_link_libraries(clang-repl PRIVATE
+  clangAST
   clangBasic
   clangFrontend
   clangInterpreter
Index: clang/test/Interpreter/pretty-print.cpp
===
--- /dev/null
+++ clang/test/Interpreter/pretty-print.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+int x = 42;
+x
+// CHECK: (int) 42
+x - 2
+// CHECK-NEXT: (int) 40
+%quit
+
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -153,10 +153,20 @@
   return true;
 }
 
-bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed) {
+bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed,
+  bool IsTopExpr) {
   if (TryConsumeToken(tok::semi))
 return false;
 
+  // If this is in the incremental C++ mode, then it means we need to pretty
+  // print this expression. Thus, let's pretend we have this semi and continue
+  // parsing.
+  if (PP.isIncrementalProcessingEnabled() && IsTopExpr &&
+  DiagID == diag::err_expected_semi_after_expr) {
+setPrettyPrintMode();
+return false;
+  }
+
   if (Tok.is(tok::code_completion)) {
 handleUnexpectedCodeCompletionToken();
 return false;
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -542,9 +542,9 @@
 // Recover parsing as a case statement.
 return ParseCaseStatement(StmtCtx, /*MissingCase=*/true, Expr);
   }
-
   // Otherwise, eat the semicolon.
-  ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
+  ExpectAndConsumeSemi(diag::err_expected_semi_after_expr, /*TokenUsed=*/"",
+   StmtCtx == ParsedStmtContext::SubStmt);
   return handleExprStmt(Expr, StmtCtx);
 }
 
Index: clang/lib/Interpreter/ValueSynthesize.cpp

[PATCH] D142644: [WIP][2/N][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics

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

Add comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142644

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

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

2023-01-27 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra added a comment.

Limit the description in the release notes to one sentence.


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-27 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra updated this revision to Diff 492661.
sivachandra marked an inline comment as done.
sivachandra added a comment.

Limit the description in the release notes to one sentence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142592

Files:
  clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
  clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
  clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl-check.rst
  clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp
@@ -0,0 +1,66 @@
+// RUN: %check_clang_tidy %s llvmlibc-inline-function-decl-check %t \
+// RUN:   -- -header-filter=.* -- -I %S
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_LLVMLIBC_INLINEFUNCTIONDECL_H
+#define LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_LLVMLIBC_INLINEFUNCTIONDECL_H
+
+#define LIBC_INLINE inline
+
+namespace __llvm_libc {
+
+LIBC_INLINE int addi(int a, int b) {
+  return a + b;
+}
+
+LIBC_INLINE constexpr long addl(long a, long b) {
+  return a + b;
+}
+
+constexpr long long addll(long long a, long long b) {
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addll' must be tagged with the LIBC_INLINE macro
+  return a + b;
+}
+
+inline unsigned long addul(unsigned long a, unsigned long b) {
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addul' must be tagged with the LIBC_INLINE macro
+  return a + b;
+}
+
+class  MyClass {
+  int A;
+public:
+  MyClass() : A(123) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'MyClass' must be tagged with the LIBC_INLINE macro
+
+  LIBC_INLINE MyClass(int V) : A(V) {}
+
+  constexpr operator int() const { return A; }
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator int' must be tagged with the LIBC_INLINE macro
+
+  LIBC_INLINE bool operator==(const MyClass ) {
+return RHS.A == A;
+  }
+
+  static int getVal(const MyClass ) {
+  // CHECK-MESSAGES: warning: 'getVal' must be tagged with the LIBC_INLINE macro
+return V.A;
+  }
+
+  LIBC_INLINE static void setVal(MyClass , int A) {
+V.A = A;
+  }
+
+  constexpr static int addInt(MyClass , int A) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'addInt' must be tagged with the LIBC_INLINE macro
+return V.A += A;
+  }
+
+  static LIBC_INLINE int mulInt(MyClass , int A) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'mulInt' must be tagged with the LIBC_INLINE macro
+return V.A *= A;
+  }
+};
+
+} // namespace __llvm_libc
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_LLVMLIBC_INLINEFUNCTIONDECL_H
Index: clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl-check.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl-check.rst
@@ -0,0 +1,8 @@
+.. title:: clang-tidy - llvmlibc-inline-funciton-decl-check
+
+llvmlibc-inline-function-decl-check
+
+
+Checks that all implicit and explicit inline functions in header files are
+tagged with the ``LIBC_INLINE`` macro. See the `libc style guide
+`_ for more information about this macro.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -97,6 +97,12 @@
 New checks
 ^^
 
+New `llvmlibc-inline-function-decl-check `_
+check.
+
+Checks that all implicit and explicit inline functions in header files are
+tagged with the ``LIBC_INLINE`` macro.
+
 New check aliases
 ^
 
Index: clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
+++ clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "CalleeNamespaceCheck.h"
 #include "ImplementationInNamespaceCheck.h"
+#include "InlineFunctionDeclCheck.h"
 #include "RestrictSystemLibcHeadersCheck.h"
 
 namespace clang::tidy {
@@ -23,6 +24,8 @@
 "llvmlibc-callee-namespace");
 CheckFactories.registerCheck(
 "llvmlibc-implementation-in-namespace");
+CheckFactories.registerCheck(
+"llvmlibc-inline-function-decl-check");
 CheckFactories.registerCheck(
 

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

2023-01-27 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I figured I might as well look through the AST API for classes with 
getLAngleLoc/getRAngleLoc methods.

It looks like we've got almost all of them (including the ones mentioned in 
recent comments) except:

- OverloadExpr
- DependentTemplateSpecializationTypeLoc
- AutoTypeLoc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


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

2023-01-27 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D139926#4084856 , @nridge wrote:

> In D139926#4084854 , @ckandeler 
> wrote:
>
>> I would have expected these to be handled by VisitDeclRefExpr(), but they 
>> aren't. Any idea?
>
> There are two other expression types, `DependentScopeDeclRefExpr` and 
> `CXXDependentScopeMemberExpr`, which are used to model decl-ref-exprs where 
> the referent decl cannot be resolved until instantiation.

Oh and the non-dependent `a.mem` one is `MemberExpr`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


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

2023-01-27 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D139926#4084854 , @ckandeler wrote:

> I would have expected these to be handled by VisitDeclRefExpr(), but they 
> aren't. Any idea?

There are two other expression types, `DependentScopeDeclRefExpr` and 
`CXXDependentScopeMemberExpr`, which are used to model decl-ref-exprs where the 
referent decl cannot be resolved until instantiation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


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

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

In D139926#4084801 , @nridge wrote:

> Function calls are still missing some cases:
>
>   

I would have expected these to be handled by VisitDeclRefExpr(), but they 
aren't. Any idea?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


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

2023-01-27 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:641
+  VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D) {
+for (unsigned i = 0; i < D->getNumTemplateParameterLists(); ++i) {
+  if (auto *TPL = D->getTemplateParameterList(i))

nridge wrote:
> I would suggest moving this loop into `VisitTagDecl()`, as `TagDecl` is the 
> base class of `ClassTemplateSpecializationDecl` that declares 
> `getNumTemplateParameterLists()`. That way, we can be sure every derived 
> class is handled.
(Here's an example of a `TagDecl` which is not a 
`ClassTemplateSpecializationDecl` but has a template parameter list:

```
template 
class A {
  enum class E;
};

template  // <--
enum class A::E {X, Y, Z};
```
)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


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

2023-01-27 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Driver changes LGTM, thanks! I will defer to others for changes in other areas.


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] D139926: [clangd] Add semantic token for angle brackets

2023-01-27 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Two more cases I found:

  template 
  concept C = true;
  
  template  A>  // <-- (inner pair)
  class B {};

This is a `TypeConstraint`, but RecursiveASTVisitor is lacking a Visit() method 
for it, so I think you'll need to override `TraverseTypeConstraint()` instead 
(example 
)

  template 
  class A {
 template  void foo(U a) { }
 template<> void foo(int a) { }  // <--
  };

This one is `ClassScopeFunctionSpecializationDecl::getTemplateArgsAsWritten()`




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:641
+  VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D) {
+for (unsigned i = 0; i < D->getNumTemplateParameterLists(); ++i) {
+  if (auto *TPL = D->getTemplateParameterList(i))

I would suggest moving this loop into `VisitTagDecl()`, as `TagDecl` is the 
base class of `ClassTemplateSpecializationDecl` that declares 
`getNumTemplateParameterLists()`. That way, we can be sure every derived class 
is handled.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:658
+  bool VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D) {
+for (unsigned i = 0; i < D->getNumTemplateParameterLists(); ++i) {
+  if (auto *TPL = D->getTemplateParameterList(i))

Similarly, I would suggest moving this loop into `VisitDeclaratorDecl`.

(The args loop can stay here.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


[clang] f2f8c25 - [clang][Interp][NFC] Print parent class name of methods

2023-01-27 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-27T09:04:14+01:00
New Revision: f2f8c25540753a8be375fc90ad703d4101562342

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

LOG: [clang][Interp][NFC] Print parent class name of methods

in Function::dump().

Added: 


Modified: 
clang/lib/AST/Interp/Disasm.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp
index d362ccdc7328..1c95782536fb 100644
--- a/clang/lib/AST/Interp/Disasm.cpp
+++ b/clang/lib/AST/Interp/Disasm.cpp
@@ -35,13 +35,9 @@ LLVM_DUMP_METHOD void Function::dump() const { 
dump(llvm::errs()); }
 
 LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream ) const {
   if (F) {
-if (auto *Cons = dyn_cast(F)) {
-  DeclarationName Name = Cons->getParent()->getDeclName();
-  OS << Name << "::" << Name;
-} else {
-  OS << F->getDeclName();
-}
-OS << " " << (const void*)this << ":\n";
+if (const auto *MD = dyn_cast(F))
+  OS << MD->getParent()->getDeclName() << "::";
+OS << F->getDeclName() << " " << (const void *)this << ":\n";
   } else {
 OS << "<>\n";
   }



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


[PATCH] D142694: [clang][Interp] Only generate disassembly in debug builds

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

  With the current set of opcodes, this saves 3460 lines in the generated
  Opcodes.inc in release builds (-17%).

The `dump()` code is only used for debugging right now as far as I know (there 
is nothing equivalent to `-ast-dump`), so only generate this code for debug 
builds.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142694

Files:
  clang/lib/AST/Interp/Disasm.cpp
  clang/utils/TableGen/ClangOpcodesEmitter.cpp


Index: clang/utils/TableGen/ClangOpcodesEmitter.cpp
===
--- clang/utils/TableGen/ClangOpcodesEmitter.cpp
+++ clang/utils/TableGen/ClangOpcodesEmitter.cpp
@@ -161,6 +161,7 @@
 }
 
 void ClangOpcodesEmitter::EmitDisasm(raw_ostream , StringRef N, Record *R) {
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   OS << "#ifdef GET_DISASM\n";
   Enumerate(R, N, [R, ](ArrayRef, const Twine ) {
 OS << "case OP_" << ID << ":\n";
@@ -176,6 +177,7 @@
 OS << "  continue;\n";
   });
   OS << "#endif\n";
+#endif
 }
 
 void ClangOpcodesEmitter::EmitEmitter(raw_ostream , StringRef N, Record *R) 
{
Index: clang/lib/AST/Interp/Disasm.cpp
===
--- clang/lib/AST/Interp/Disasm.cpp
+++ clang/lib/AST/Interp/Disasm.cpp
@@ -34,6 +34,7 @@
 LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }
 
 LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream ) const {
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   if (F) {
 if (const auto *MD = dyn_cast(F))
   OS << MD->getParent()->getDeclName() << "::";
@@ -64,6 +65,7 @@
 #undef GET_DISASM
 }
   }
+#endif
 }
 
 LLVM_DUMP_METHOD void Program::dump() const { dump(llvm::errs()); }


Index: clang/utils/TableGen/ClangOpcodesEmitter.cpp
===
--- clang/utils/TableGen/ClangOpcodesEmitter.cpp
+++ clang/utils/TableGen/ClangOpcodesEmitter.cpp
@@ -161,6 +161,7 @@
 }
 
 void ClangOpcodesEmitter::EmitDisasm(raw_ostream , StringRef N, Record *R) {
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   OS << "#ifdef GET_DISASM\n";
   Enumerate(R, N, [R, ](ArrayRef, const Twine ) {
 OS << "case OP_" << ID << ":\n";
@@ -176,6 +177,7 @@
 OS << "  continue;\n";
   });
   OS << "#endif\n";
+#endif
 }
 
 void ClangOpcodesEmitter::EmitEmitter(raw_ostream , StringRef N, Record *R) {
Index: clang/lib/AST/Interp/Disasm.cpp
===
--- clang/lib/AST/Interp/Disasm.cpp
+++ clang/lib/AST/Interp/Disasm.cpp
@@ -34,6 +34,7 @@
 LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }
 
 LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream ) const {
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   if (F) {
 if (const auto *MD = dyn_cast(F))
   OS << MD->getParent()->getDeclName() << "::";
@@ -64,6 +65,7 @@
 #undef GET_DISASM
 }
   }
+#endif
 }
 
 LLVM_DUMP_METHOD void Program::dump() const { dump(llvm::errs()); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-01-27 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Function calls are still missing some cases:

  template  void free();
  
  template 
  struct A {
template  void mem();
  };
  
  void foo() {
A a;
a.mem();  // <--
  }
  
  template
  void bar() {
  free();  // <--
  
  A a;
  a.mem();  // <--
  
  A b;
  b.template mem();  // <--
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


[clang] 435225c - [clang][Interp][NFC] Remove an unnecessary isArray() check

2023-01-27 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-27T09:00:51+01:00
New Revision: 435225c6e2f860ecc53fcd65e193f832569d090e

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

LOG: [clang][Interp][NFC] Remove an unnecessary isArray() check

We already do an isPrimitiveArray() check, so no need for the isArray()
check.

Added: 


Modified: 
clang/lib/AST/Interp/Pointer.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Pointer.cpp 
b/clang/lib/AST/Interp/Pointer.cpp
index fd8c98fae039..e25b4f8b5844 100644
--- a/clang/lib/AST/Interp/Pointer.cpp
+++ b/clang/lib/AST/Interp/Pointer.cpp
@@ -166,22 +166,20 @@ void Pointer::initialize() const {
   Descriptor *Desc = getFieldDesc();
 
   assert(Desc);
-  if (Desc->isArray()) {
-if (Desc->isPrimitiveArray()) {
-  // Primitive global arrays don't have an initmap.
-  if (isStatic() && Base == 0)
-return;
-
-  // Primitive array initializer.
-  InitMap * = getInitMap();
-  if (Map == (InitMap *)-1)
-return;
-  if (Map == nullptr)
-Map = InitMap::allocate(Desc->getNumElems());
-  if (Map->initialize(getIndex())) {
-free(Map);
-Map = (InitMap *)-1;
-  }
+  if (Desc->isPrimitiveArray()) {
+// Primitive global arrays don't have an initmap.
+if (isStatic() && Base == 0)
+  return;
+
+// Primitive array initializer.
+InitMap * = getInitMap();
+if (Map == (InitMap *)-1)
+  return;
+if (Map == nullptr)
+  Map = InitMap::allocate(Desc->getNumElems());
+if (Map->initialize(getIndex())) {
+  free(Map);
+  Map = (InitMap *)-1;
 }
   } else {
 // Field has its bit in an inline descriptor.



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


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

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142607

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


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

2023-01-27 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/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


<    1   2