[PATCH] D151188: [LLD][COFF] Add LLVM toolchain library paths by default.

2023-07-14 Thread Tobias Hieta 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 rGaf744f0b84e2: [LLD][COFF] Add LLVM toolchain library paths 
by default. (authored by thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151188

Files:
  clang/lib/Driver/Driver.cpp
  lld/COFF/Driver.cpp
  lld/COFF/Driver.h
  lld/docs/ReleaseNotes.rst
  lld/test/COFF/print-search-paths.s

Index: lld/test/COFF/print-search-paths.s
===
--- lld/test/COFF/print-search-paths.s
+++ lld/test/COFF/print-search-paths.s
@@ -4,11 +4,17 @@
 # RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t_32.obj
 # RUN: lld-link -safeseh:no /dll /noentry /winsysroot:%t.dir/sysroot /vctoolsversion:1.1.1.1 /winsdkversion:10.0.1 %t_32.obj -print-search-paths | FileCheck -DSYSROOT=%t.dir -check-prefix=X86 %s
 # CHECK: Library search paths:
+# CHECK:   [[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# CHECK:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# CHECK:   [[CPATH]]lib
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}um{{[/\\]}}x64
 # X86: Library search paths:
+# X86:   [[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# X86:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# X86:   [[CPATH]]lib
 # X86:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x86
 # X86:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x86
 # X86:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x86
Index: lld/docs/ReleaseNotes.rst
===
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -42,6 +42,12 @@
   current directory.
   I.e. ``lld-link /libpath:c:\relative\root relative\path\my.lib`` where before
   we would have to do ``lld-link /libpath:c:\relative\root\relative\path my.lib``
+* lld-link learned -print-search-paths that will print all the paths where it will
+  search for libraries.
+* By default lld-link will now search for libraries in the toolchain directories.
+  Specifically it will search:
+  ``/lib``, ``/lib/clang//lib`` and
+  ``/lib/clang//lib/windows``.
 
 MinGW Improvements
 --
Index: lld/COFF/Driver.h
===
--- lld/COFF/Driver.h
+++ lld/COFF/Driver.h
@@ -84,6 +84,8 @@
   // config->machine has been set.
   void addWinSysRootLibSearchPaths();
 
+  void addClangLibSearchPaths(const std::string );
+
   // Used by the resolver to parse .drectve section contents.
   void parseDirectives(InputFile *file);
 
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -637,6 +637,31 @@
   }
 }
 
+void LinkerDriver::addClangLibSearchPaths(const std::string ) {
+  std::string lldBinary = sys::fs::getMainExecutable(argv0.c_str(), nullptr);
+  SmallString<128> binDir(lldBinary);
+  sys::path::remove_filename(binDir); // remove lld-link.exe
+  StringRef rootDir = sys::path::parent_path(binDir); // remove 'bin'
+
+  SmallString<128> libDir(rootDir);
+  sys::path::append(libDir, "lib");
+  // We need to prepend the paths here in order to make sure that we always
+  // try to link the clang versions of the builtins over the ones supplied by MSVC.
+  searchPaths.insert(searchPaths.begin(), saver().save(libDir.str()));
+
+  // Add the resource dir library path
+  SmallString<128> runtimeLibDir(rootDir);
+  sys::path::append(runtimeLibDir, "lib", "clang", std::to_string(LLVM_VERSION_MAJOR), "lib");
+  searchPaths.insert(searchPaths.begin(), saver().save(runtimeLibDir.str()));
+
+  // Resource dir + osname, which is hardcoded to windows since we are in the
+  // COFF driver.
+  SmallString<128> runtimeLibDirWithOS(runtimeLibDir);
+  sys::path::append(runtimeLibDirWithOS, "windows");
+  searchPaths.insert(searchPaths.begin(), saver().save(runtimeLibDirWithOS.str()));
+
+}
+
 void LinkerDriver::addWinSysRootLibSearchPaths() {
   if (!diaPath.empty()) {
 // The DIA SDK always uses the legacy vc arch, even in new MSVC versions.
@@ -1543,6 +1568,7 @@
   detectWinSysRoot(args);
   if (!args.hasArg(OPT_lldignoreenv) && 

[PATCH] D151188: [LLD][COFF] Add LLVM toolchain library paths by default.

2023-07-14 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 540344.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151188

Files:
  clang/lib/Driver/Driver.cpp
  lld/COFF/Driver.cpp
  lld/COFF/Driver.h
  lld/docs/ReleaseNotes.rst
  lld/test/COFF/print-search-paths.s

Index: lld/test/COFF/print-search-paths.s
===
--- lld/test/COFF/print-search-paths.s
+++ lld/test/COFF/print-search-paths.s
@@ -4,11 +4,17 @@
 # RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t_32.obj
 # RUN: lld-link -safeseh:no /dll /noentry /winsysroot:%t.dir/sysroot /vctoolsversion:1.1.1.1 /winsdkversion:10.0.1 %t_32.obj -print-search-paths | FileCheck -DSYSROOT=%t.dir -check-prefix=X86 %s
 # CHECK: Library search paths:
+# CHECK:   [[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# CHECK:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# CHECK:   [[CPATH]]lib
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}um{{[/\\]}}x64
 # X86: Library search paths:
+# X86:   [[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# X86:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# X86:   [[CPATH]]lib
 # X86:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x86
 # X86:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x86
 # X86:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x86
Index: lld/docs/ReleaseNotes.rst
===
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -42,6 +42,12 @@
   current directory.
   I.e. ``lld-link /libpath:c:\relative\root relative\path\my.lib`` where before
   we would have to do ``lld-link /libpath:c:\relative\root\relative\path my.lib``
+* lld-link learned -print-search-paths that will print all the paths where it will
+  search for libraries.
+* By default lld-link will now search for libraries in the toolchain directories.
+  Specifically it will search:
+  ``/lib``, ``/lib/clang//lib`` and
+  ``/lib/clang//lib/windows``.
 
 MinGW Improvements
 --
Index: lld/COFF/Driver.h
===
--- lld/COFF/Driver.h
+++ lld/COFF/Driver.h
@@ -84,6 +84,8 @@
   // config->machine has been set.
   void addWinSysRootLibSearchPaths();
 
+  void addClangLibSearchPaths(const std::string );
+
   // Used by the resolver to parse .drectve section contents.
   void parseDirectives(InputFile *file);
 
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -637,6 +637,31 @@
   }
 }
 
+void LinkerDriver::addClangLibSearchPaths(const std::string ) {
+  std::string lldBinary = sys::fs::getMainExecutable(argv0.c_str(), nullptr);
+  SmallString<128> binDir(lldBinary);
+  sys::path::remove_filename(binDir); // remove lld-link.exe
+  StringRef rootDir = sys::path::parent_path(binDir); // remove 'bin'
+
+  SmallString<128> libDir(rootDir);
+  sys::path::append(libDir, "lib");
+  // We need to prepend the paths here in order to make sure that we always
+  // try to link the clang versions of the builtins over the ones supplied by MSVC.
+  searchPaths.insert(searchPaths.begin(), saver().save(libDir.str()));
+
+  // Add the resource dir library path
+  SmallString<128> runtimeLibDir(rootDir);
+  sys::path::append(runtimeLibDir, "lib", "clang", std::to_string(LLVM_VERSION_MAJOR), "lib");
+  searchPaths.insert(searchPaths.begin(), saver().save(runtimeLibDir.str()));
+
+  // Resource dir + osname, which is hardcoded to windows since we are in the
+  // COFF driver.
+  SmallString<128> runtimeLibDirWithOS(runtimeLibDir);
+  sys::path::append(runtimeLibDirWithOS, "windows");
+  searchPaths.insert(searchPaths.begin(), saver().save(runtimeLibDirWithOS.str()));
+
+}
+
 void LinkerDriver::addWinSysRootLibSearchPaths() {
   if (!diaPath.empty()) {
 // The DIA SDK always uses the legacy vc arch, even in new MSVC versions.
@@ -1543,6 +1568,7 @@
   detectWinSysRoot(args);
   if (!args.hasArg(OPT_lldignoreenv) && !args.hasArg(OPT_winsysroot))
 addLibSearchPaths();
+  addClangLibSearchPaths(argsArr[0]);
 
   // Handle /ignore
   for (auto *arg : args.filtered(OPT_ignore)) {
Index: 

[PATCH] D155273: [clang-format] Add TypeNames option to disambiguate types/objects

2023-07-14 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Thanks for doing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155273

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


[PATCH] D151188: [LLD][COFF] Add LLVM toolchain library paths by default.

2023-07-14 Thread Tobias Hieta via Phabricator via cfe-commits
thieta marked 6 inline comments as done.
thieta added a comment.

- Split the relative patch to this diff https://reviews.llvm.org/D155268
- Added some comments in both Clang and LLD
- Fixed some code style.
- Removed stray changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151188

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


[PATCH] D151188: [LLD][COFF] Add LLVM toolchain library paths by default.

2023-07-14 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 540304.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151188

Files:
  clang/lib/Driver/Driver.cpp
  lld/COFF/Driver.cpp
  lld/COFF/Driver.h
  lld/test/COFF/print-search-paths.s


Index: lld/test/COFF/print-search-paths.s
===
--- lld/test/COFF/print-search-paths.s
+++ lld/test/COFF/print-search-paths.s
@@ -4,11 +4,17 @@
 # RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t_32.obj
 # RUN: lld-link -safeseh:no /dll /noentry /winsysroot:%t.dir/sysroot 
/vctoolsversion:1.1.1.1 /winsdkversion:10.0.1 %t_32.obj -print-search-paths | 
FileCheck -DSYSROOT=%t.dir -check-prefix=X86 %s
 # CHECK: Library search paths:
+# CHECK:   
[[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# CHECK:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# CHECK:   [[CPATH]]lib
 # CHECK:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows 
Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows 
Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}um{{[/\\]}}x64
 # X86: Library search paths:
+# X86:   
[[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# X86:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# X86:   [[CPATH]]lib
 # X86:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x86
 # X86:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x86
 # X86:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows 
Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x86
Index: lld/COFF/Driver.h
===
--- lld/COFF/Driver.h
+++ lld/COFF/Driver.h
@@ -84,6 +84,8 @@
   // config->machine has been set.
   void addWinSysRootLibSearchPaths();
 
+  void addClangLibSearchPaths(const std::string );
+
   // Used by the resolver to parse .drectve section contents.
   void parseDirectives(InputFile *file);
 
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -638,6 +638,31 @@
   }
 }
 
+void LinkerDriver::addClangLibSearchPaths(const std::string ) {
+  std::string lldBinary = sys::fs::getMainExecutable(argv0.c_str(), nullptr);
+  SmallString<128> binDir(lldBinary);
+  sys::path::remove_filename(binDir); // remove lld-link.exe
+  StringRef rootDir = sys::path::parent_path(binDir); // remove 'bin'
+
+  SmallString<128> libDir(rootDir);
+  sys::path::append(libDir, "lib");
+  // We need to prepend the paths here in order to make sure that we always
+  // try to link the clang versions of the builtins over the ones supplied by 
MSVC.
+  searchPaths.insert(searchPaths.begin(), saver().save(libDir.str()));
+
+  // Add the resource dir library path
+  SmallString<128> runtimeLibDir(rootDir);
+  sys::path::append(runtimeLibDir, "lib", "clang", 
std::to_string(LLVM_VERSION_MAJOR), "lib");
+  searchPaths.insert(searchPaths.begin(), saver().save(runtimeLibDir.str()));
+
+  // Resource dir + osname, which is hardcoded to windows since we are in the
+  // COFF driver.
+  SmallString<128> runtimeLibDirWithOS(runtimeLibDir);
+  sys::path::append(runtimeLibDirWithOS, "windows");
+  searchPaths.insert(searchPaths.begin(), 
saver().save(runtimeLibDirWithOS.str()));
+
+}
+
 void LinkerDriver::addWinSysRootLibSearchPaths() {
   if (!diaPath.empty()) {
 // The DIA SDK always uses the legacy vc arch, even in new MSVC versions.
@@ -1544,6 +1569,7 @@
   detectWinSysRoot(args);
   if (!args.hasArg(OPT_lldignoreenv) && !args.hasArg(OPT_winsysroot))
 addLibSearchPaths();
+  addClangLibSearchPaths(argsArr[0]);
 
   // Handle /ignore
   for (auto *arg : args.filtered(OPT_ignore)) {
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -184,6 +184,8 @@
 // path of the embedding binary, which for LLVM binaries will be in bin/.
 // ../lib gets us to lib/ in both cases.
 P = llvm::sys::path::parent_path(Dir);
+// This search path is also created in the COFF driver of lld, so any
+// changes here also needs to happen in lld/COFF/Driver.cpp
 llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
 CLANG_VERSION_MAJOR_STRING);
   }


Index: lld/test/COFF/print-search-paths.s
===

[PATCH] D151188: [LLD][COFF] Add LLVM toolchain library paths by default.

2023-07-14 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 540302.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151188

Files:
  clang/lib/Driver/Driver.cpp
  lld/COFF/Driver.cpp
  lld/COFF/Driver.h
  lld/test/COFF/print-search-paths.s


Index: lld/test/COFF/print-search-paths.s
===
--- lld/test/COFF/print-search-paths.s
+++ lld/test/COFF/print-search-paths.s
@@ -4,11 +4,17 @@
 # RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t_32.obj
 # RUN: lld-link -safeseh:no /dll /noentry /winsysroot:%t.dir/sysroot 
/vctoolsversion:1.1.1.1 /winsdkversion:10.0.1 %t_32.obj -print-search-paths | 
FileCheck -DSYSROOT=%t.dir -check-prefix=X86 %s
 # CHECK: Library search paths:
+# CHECK:   
[[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# CHECK:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# CHECK:   [[CPATH]]lib
 # CHECK:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows 
Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows 
Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}um{{[/\\]}}x64
 # X86: Library search paths:
+# X86:   
[[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# X86:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# X86:   [[CPATH]]lib
 # X86:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x86
 # X86:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x86
 # X86:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows 
Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x86
Index: lld/COFF/Driver.h
===
--- lld/COFF/Driver.h
+++ lld/COFF/Driver.h
@@ -84,6 +84,8 @@
   // config->machine has been set.
   void addWinSysRootLibSearchPaths();
 
+  void addClangLibSearchPaths(const std::string& argv0);
+
   // Used by the resolver to parse .drectve section contents.
   void parseDirectives(InputFile *file);
 
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -638,6 +638,31 @@
   }
 }
 
+void LinkerDriver::addClangLibSearchPaths(const std::string ) {
+  std::string lldBinary = sys::fs::getMainExecutable(argv0.c_str(), nullptr);
+  SmallString<128> binDir(lldBinary);
+  sys::path::remove_filename(binDir); // remove lld-link.exe
+  StringRef rootDir = sys::path::parent_path(binDir); // remove 'bin'
+
+  SmallString<128> libDir(rootDir);
+  sys::path::append(libDir, "lib");
+  // We need to prepend the paths here in order to make sure that we always
+  // try to link the clang versions of the builtins over the ones supplied by 
MSVC.
+  searchPaths.insert(searchPaths.begin(), saver().save(libDir.str()));
+
+  // Add the resource dir library path
+  SmallString<128> runtimeLibDir(rootDir);
+  sys::path::append(runtimeLibDir, "lib", "clang", 
std::to_string(LLVM_VERSION_MAJOR), "lib");
+  searchPaths.insert(searchPaths.begin(), saver().save(runtimeLibDir.str()));
+
+  // Resource dir + osname, which is hardcoded to windows since we are in the
+  // COFF driver.
+  SmallString<128> runtimeLibDirWithOS(runtimeLibDir);
+  sys::path::append(runtimeLibDirWithOS, "windows");
+  searchPaths.insert(searchPaths.begin(), 
saver().save(runtimeLibDirWithOS.str()));
+
+}
+
 void LinkerDriver::addWinSysRootLibSearchPaths() {
   if (!diaPath.empty()) {
 // The DIA SDK always uses the legacy vc arch, even in new MSVC versions.
@@ -1544,6 +1569,7 @@
   detectWinSysRoot(args);
   if (!args.hasArg(OPT_lldignoreenv) && !args.hasArg(OPT_winsysroot))
 addLibSearchPaths();
+  addClangLibSearchPaths(argsArr[0]);
 
   // Handle /ignore
   for (auto *arg : args.filtered(OPT_ignore)) {
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -184,6 +184,8 @@
 // path of the embedding binary, which for LLVM binaries will be in bin/.
 // ../lib gets us to lib/ in both cases.
 P = llvm::sys::path::parent_path(Dir);
+// This search path is also created in the COFF driver of lld, so any
+// changes here also needs to happen in lld/COFF/Driver.cpp
 llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
 CLANG_VERSION_MAJOR_STRING);
   }


Index: lld/test/COFF/print-search-paths.s

[PATCH] D151188: [LLD][COFF] Add LLVM toolchain library paths by default.

2023-07-14 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 540301.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151188

Files:
  clang/lib/Driver/Driver.cpp
  lld/COFF/Driver.cpp
  lld/COFF/Driver.h
  lld/test/COFF/print-search-paths.s


Index: lld/test/COFF/print-search-paths.s
===
--- lld/test/COFF/print-search-paths.s
+++ lld/test/COFF/print-search-paths.s
@@ -4,11 +4,17 @@
 # RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t_32.obj
 # RUN: lld-link -safeseh:no /dll /noentry /winsysroot:%t.dir/sysroot 
/vctoolsversion:1.1.1.1 /winsdkversion:10.0.1 %t_32.obj -print-search-paths | 
FileCheck -DSYSROOT=%t.dir -check-prefix=X86 %s
 # CHECK: Library search paths:
+# CHECK:   
[[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# CHECK:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# CHECK:   [[CPATH]]lib
 # CHECK:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows 
Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x64
 # CHECK:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows 
Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}um{{[/\\]}}x64
 # X86: Library search paths:
+# X86:   
[[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# X86:   [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# X86:   [[CPATH]]lib
 # X86:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}x86
 # X86:   
[[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}x86
 # X86:   [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows 
Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}x86
Index: lld/COFF/Driver.h
===
--- lld/COFF/Driver.h
+++ lld/COFF/Driver.h
@@ -84,6 +84,8 @@
   // config->machine has been set.
   void addWinSysRootLibSearchPaths();
 
+  void addClangLibSearchPaths(const std::string& argv0);
+
   // Used by the resolver to parse .drectve section contents.
   void parseDirectives(InputFile *file);
 
Index: lld/COFF/Driver.cpp
===
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -638,6 +638,31 @@
   }
 }
 
+void LinkerDriver::addClangLibSearchPaths(const std::string& argv0) {
+  std::string lldBinary = sys::fs::getMainExecutable(argv0.c_str(), nullptr);
+  SmallString<128> binDir(lldBinary);
+  sys::path::remove_filename(binDir); // remove lld-link.exe
+  StringRef rootDir = sys::path::parent_path(binDir); // remove 'bin'
+
+  SmallString<128> libDir(rootDir);
+  sys::path::append(libDir, "lib");
+  // We need to prepend the paths here in order to make sure that we always
+  // try to link the clang versions of the builtins over the ones supplied by 
MSVC.
+  searchPaths.insert(searchPaths.begin(), saver().save(libDir.str()));
+
+  // Add the resource dir library path
+  SmallString<128> runtimeLibDir(rootDir);
+  sys::path::append(runtimeLibDir, "lib", "clang", 
std::to_string(LLVM_VERSION_MAJOR), "lib");
+  searchPaths.insert(searchPaths.begin(), saver().save(runtimeLibDir.str()));
+
+  // Resource dir + osname, which is hardcoded to windows since we are in the
+  // COFF driver.
+  SmallString<128> runtimeLibDirWithOS(runtimeLibDir);
+  sys::path::append(runtimeLibDirWithOS, "windows");
+  searchPaths.insert(searchPaths.begin(), 
saver().save(runtimeLibDirWithOS.str()));
+
+}
+
 void LinkerDriver::addWinSysRootLibSearchPaths() {
   if (!diaPath.empty()) {
 // The DIA SDK always uses the legacy vc arch, even in new MSVC versions.
@@ -1544,6 +1569,7 @@
   detectWinSysRoot(args);
   if (!args.hasArg(OPT_lldignoreenv) && !args.hasArg(OPT_winsysroot))
 addLibSearchPaths();
+  addClangLibSearchPaths(argsArr[0]);
 
   // Handle /ignore
   for (auto *arg : args.filtered(OPT_ignore)) {
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -184,6 +184,8 @@
 // path of the embedding binary, which for LLVM binaries will be in bin/.
 // ../lib gets us to lib/ in both cases.
 P = llvm::sys::path::parent_path(Dir);
+// This search path is also created in the COFF driver of lld, so any
+// changes here also needs to happen in lld/COFF/Driver.cpp
 llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
 CLANG_VERSION_MAJOR_STRING);
   }


Index: 

[PATCH] D154983: [clang-extdef-mapping] register necessary targest for ms-style asm block

2023-07-12 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Yes, I can do that, but I rather wait for @balazske to also approve this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154983

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


[PATCH] D154983: [clang-extdef-mapping] register necessary targest for ms-style asm block

2023-07-11 Thread Tobias Hieta via Phabricator via cfe-commits
thieta accepted this revision.
thieta added a comment.
This revision is now accepted and ready to land.

Looks fine to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154983

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


[PATCH] D150761: [NFC][Py Reformat] Reformat python files in clang and clang-tools-extra

2023-05-23 Thread Tobias Hieta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd3c26a045c0: [NFC][Py Reformat] Reformat python files in 
clang and clang-tools-extra (authored by thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150761

Files:
  
clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
  clang-tools-extra/clangd/TidyFastChecks.py
  clang-tools-extra/clangd/quality/CompletionModelCodegen.py
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.local.cfg
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
  clang-tools-extra/clangd/unittests/lit.cfg.py
  clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
  clang-tools-extra/docs/conf.py
  clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py
  clang-tools-extra/include-cleaner/test/lit.cfg.py
  clang-tools-extra/pseudo/test/Unit/lit.cfg.py
  clang-tools-extra/pseudo/test/lit.cfg.py
  clang-tools-extra/pseudo/test/lit.local.cfg
  clang-tools-extra/test/Unit/lit.cfg.py
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py
  clang-tools-extra/test/lit.cfg.py
  clang/bindings/python/clang/__init__.py
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/clang/enumerations.py
  clang/bindings/python/examples/cindex/cindex-dump.py
  clang/bindings/python/examples/cindex/cindex-includes.py
  clang/bindings/python/tests/cindex/test_access_specifiers.py
  clang/bindings/python/tests/cindex/test_cdb.py
  clang/bindings/python/tests/cindex/test_code_completion.py
  clang/bindings/python/tests/cindex/test_comment.py
  clang/bindings/python/tests/cindex/test_cursor.py
  clang/bindings/python/tests/cindex/test_cursor_kind.py
  clang/bindings/python/tests/cindex/test_diagnostics.py
  clang/bindings/python/tests/cindex/test_exception_specification_kind.py
  clang/bindings/python/tests/cindex/test_file.py
  clang/bindings/python/tests/cindex/test_index.py
  clang/bindings/python/tests/cindex/test_linkage.py
  clang/bindings/python/tests/cindex/test_location.py
  clang/bindings/python/tests/cindex/test_tls_kind.py
  clang/bindings/python/tests/cindex/test_token_kind.py
  clang/bindings/python/tests/cindex/test_tokens.py
  clang/bindings/python/tests/cindex/test_translation_unit.py
  clang/bindings/python/tests/cindex/test_type.py
  clang/bindings/python/tests/cindex/util.py
  clang/docs/analyzer/conf.py
  clang/docs/conf.py
  clang/docs/tools/dump_ast_matchers.py
  clang/docs/tools/dump_format_help.py
  clang/docs/tools/dump_format_style.py
  clang/docs/tools/generate_formatted_state.py
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/test/AST/gen_ast_dump_json_test.py
  clang/test/Analysis/analyzer_test.py
  clang/test/Analysis/check-analyzer-fixit.py
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/lit.local.cfg
  clang/test/Analysis/scan-build/lit.local.cfg
  clang/test/CodeGen/builtins-nvptx-mma.py
  clang/test/CodeGenHIP/lit.local.cfg
  clang/test/CodeGenHLSL/lit.local.cfg
  clang/test/CodeGenObjC/lit.local.cfg
  clang/test/CodeGenObjCXX/lit.local.cfg
  clang/test/Driver/XRay/lit.local.cfg
  clang/test/Driver/ftime-trace-sections.py
  clang/test/Driver/lit.local.cfg
  clang/test/Format/lit.local.cfg
  clang/test/Frontend/lit.local.cfg
  clang/test/Headers/lit.local.cfg
  clang/test/Index/skip-parsed-bodies/lit.local.cfg
  clang/test/Interpreter/lit.local.cfg
  clang/test/LibClang/lit.local.cfg
  clang/test/OpenMP/lit.local.cfg
  clang/test/ParserHLSL/lit.local.cfg
  clang/test/Sema/lit.local.cfg
  clang/test/SemaCUDA/lit.local.cfg
  clang/test/SemaHLSL/lit.local.cfg
  clang/test/SemaObjCXX/lit.local.cfg
  clang/test/SemaOpenCL/lit.local.cfg
  clang/test/TableGen/lit.local.cfg
  clang/test/Unit/lit.cfg.py
  clang/test/lit.cfg.py
  clang/test/utils/update_cc_test_checks/lit.local.cfg
  clang/tools/clang-format/clang-format-diff.py
  clang/tools/clang-format/clang-format-sublime.py
  clang/tools/clang-format/clang-format.py
  clang/tools/clang-rename/clang-rename.py
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py
  clang/tools/include-mapping/test.py
  clang/tools/libclang/linker-script-to-export-list.py
  clang/tools/scan-build-py/lib/libear/__init__.py
  clang/tools/scan-build-py/lib/libscanbuild/__init__.py
  clang/tools/scan-build-py/lib/libscanbuild/analyze.py
  clang/tools/scan-build-py/lib/libscanbuild/arguments.py
  clang/tools/scan-build-py/lib/libscanbuild/clang.py
  clang/tools/scan-build-py/lib/libscanbuild/compilation.py
  clang/tools/scan-build-py/lib/libscanbuild/intercept.py
  

[PATCH] D150761: [NFC][Py Reformat] Reformat python files in clang and clang-tools-extra

2023-05-19 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 523680.
thieta added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150761

Files:
  
clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
  clang-tools-extra/clangd/TidyFastChecks.py
  clang-tools-extra/clangd/quality/CompletionModelCodegen.py
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.local.cfg
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
  clang-tools-extra/clangd/unittests/lit.cfg.py
  clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
  clang-tools-extra/docs/conf.py
  clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py
  clang-tools-extra/include-cleaner/test/lit.cfg.py
  clang-tools-extra/pseudo/test/Unit/lit.cfg.py
  clang-tools-extra/pseudo/test/lit.cfg.py
  clang-tools-extra/pseudo/test/lit.local.cfg
  clang-tools-extra/test/Unit/lit.cfg.py
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py
  clang-tools-extra/test/lit.cfg.py
  clang/bindings/python/clang/__init__.py
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/clang/enumerations.py
  clang/bindings/python/examples/cindex/cindex-dump.py
  clang/bindings/python/examples/cindex/cindex-includes.py
  clang/bindings/python/tests/cindex/test_access_specifiers.py
  clang/bindings/python/tests/cindex/test_cdb.py
  clang/bindings/python/tests/cindex/test_code_completion.py
  clang/bindings/python/tests/cindex/test_comment.py
  clang/bindings/python/tests/cindex/test_cursor.py
  clang/bindings/python/tests/cindex/test_cursor_kind.py
  clang/bindings/python/tests/cindex/test_diagnostics.py
  clang/bindings/python/tests/cindex/test_exception_specification_kind.py
  clang/bindings/python/tests/cindex/test_file.py
  clang/bindings/python/tests/cindex/test_index.py
  clang/bindings/python/tests/cindex/test_linkage.py
  clang/bindings/python/tests/cindex/test_location.py
  clang/bindings/python/tests/cindex/test_tls_kind.py
  clang/bindings/python/tests/cindex/test_token_kind.py
  clang/bindings/python/tests/cindex/test_tokens.py
  clang/bindings/python/tests/cindex/test_translation_unit.py
  clang/bindings/python/tests/cindex/test_type.py
  clang/bindings/python/tests/cindex/util.py
  clang/docs/analyzer/conf.py
  clang/docs/conf.py
  clang/docs/tools/dump_ast_matchers.py
  clang/docs/tools/dump_format_help.py
  clang/docs/tools/dump_format_style.py
  clang/docs/tools/generate_formatted_state.py
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/test/AST/gen_ast_dump_json_test.py
  clang/test/Analysis/analyzer_test.py
  clang/test/Analysis/check-analyzer-fixit.py
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/lit.local.cfg
  clang/test/Analysis/scan-build/lit.local.cfg
  clang/test/CodeGen/builtins-nvptx-mma.py
  clang/test/CodeGenHIP/lit.local.cfg
  clang/test/CodeGenHLSL/lit.local.cfg
  clang/test/CodeGenObjC/lit.local.cfg
  clang/test/CodeGenObjCXX/lit.local.cfg
  clang/test/Driver/XRay/lit.local.cfg
  clang/test/Driver/ftime-trace-sections.py
  clang/test/Driver/lit.local.cfg
  clang/test/Format/lit.local.cfg
  clang/test/Frontend/lit.local.cfg
  clang/test/Headers/lit.local.cfg
  clang/test/Index/skip-parsed-bodies/lit.local.cfg
  clang/test/Interpreter/lit.local.cfg
  clang/test/LibClang/lit.local.cfg
  clang/test/OpenMP/lit.local.cfg
  clang/test/ParserHLSL/lit.local.cfg
  clang/test/Sema/lit.local.cfg
  clang/test/SemaCUDA/lit.local.cfg
  clang/test/SemaHLSL/lit.local.cfg
  clang/test/SemaObjCXX/lit.local.cfg
  clang/test/SemaOpenCL/lit.local.cfg
  clang/test/TableGen/lit.local.cfg
  clang/test/Unit/lit.cfg.py
  clang/test/lit.cfg.py
  clang/test/utils/update_cc_test_checks/lit.local.cfg
  clang/tools/clang-format/clang-format-diff.py
  clang/tools/clang-format/clang-format-sublime.py
  clang/tools/clang-format/clang-format.py
  clang/tools/clang-rename/clang-rename.py
  clang/tools/include-mapping/cppreference_parser.py
  clang/tools/include-mapping/gen_std.py
  clang/tools/include-mapping/test.py
  clang/tools/libclang/linker-script-to-export-list.py
  clang/tools/scan-build-py/lib/libear/__init__.py
  clang/tools/scan-build-py/lib/libscanbuild/__init__.py
  clang/tools/scan-build-py/lib/libscanbuild/analyze.py
  clang/tools/scan-build-py/lib/libscanbuild/arguments.py
  clang/tools/scan-build-py/lib/libscanbuild/clang.py
  clang/tools/scan-build-py/lib/libscanbuild/compilation.py
  clang/tools/scan-build-py/lib/libscanbuild/intercept.py
  clang/tools/scan-build-py/lib/libscanbuild/report.py
  clang/tools/scan-build-py/lib/libscanbuild/shell.py
  

[PATCH] D150761: [NFC][Py Reformat] Reformat python files in clang and clang-tools-extra

2023-05-17 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added inline comments.



Comment at: 
clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py:9
 #
-#======#
+# 
======#
 

barannikov88 wrote:
> This is unfortunate. The comment is now asymmetric.
> I guess this is not a big deal, but maybe someone has an idea how to prettify 
> it.
> 
I'll see if I can make it better after this diff has landed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150761

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


[PATCH] D150761: [NFC][Py Reformat] Reformat python files in clang and clang-tools-extra

2023-05-17 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added reviewers: jhenderson, JDevlieghere, MatzeB.
Herald added subscribers: PiotrZSL, kadircet, mattd, asavonic, carlosgalvezp, 
abrachet, phosek, arphaman, fedor.sergeev, whisperity.
Herald added a reviewer: NoQ.
Herald added a reviewer: njames93.
Herald added a project: All.
thieta requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added projects: clang, clang-tools-extra.

This is an ongoing series of commits that are reformatting our
Python code.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours  and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150761

Files:
  
clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
  clang-tools-extra/clangd/TidyFastChecks.py
  clang-tools-extra/clangd/quality/CompletionModelCodegen.py
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.local.cfg
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
  clang-tools-extra/clangd/unittests/lit.cfg.py
  clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
  clang-tools-extra/docs/conf.py
  clang-tools-extra/include-cleaner/test/Unit/lit.cfg.py
  clang-tools-extra/include-cleaner/test/lit.cfg.py
  clang-tools-extra/pseudo/test/Unit/lit.cfg.py
  clang-tools-extra/pseudo/test/lit.cfg.py
  clang-tools-extra/pseudo/test/lit.local.cfg
  clang-tools-extra/test/Unit/lit.cfg.py
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py
  clang-tools-extra/test/lit.cfg.py
  clang/bindings/python/clang/__init__.py
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/clang/enumerations.py
  clang/bindings/python/examples/cindex/cindex-dump.py
  clang/bindings/python/examples/cindex/cindex-includes.py
  clang/bindings/python/tests/cindex/test_access_specifiers.py
  clang/bindings/python/tests/cindex/test_cdb.py
  clang/bindings/python/tests/cindex/test_code_completion.py
  clang/bindings/python/tests/cindex/test_comment.py
  clang/bindings/python/tests/cindex/test_cursor.py
  clang/bindings/python/tests/cindex/test_cursor_kind.py
  clang/bindings/python/tests/cindex/test_diagnostics.py
  clang/bindings/python/tests/cindex/test_exception_specification_kind.py
  clang/bindings/python/tests/cindex/test_file.py
  clang/bindings/python/tests/cindex/test_index.py
  clang/bindings/python/tests/cindex/test_linkage.py
  clang/bindings/python/tests/cindex/test_location.py
  clang/bindings/python/tests/cindex/test_tls_kind.py
  clang/bindings/python/tests/cindex/test_token_kind.py
  clang/bindings/python/tests/cindex/test_tokens.py
  clang/bindings/python/tests/cindex/test_translation_unit.py
  clang/bindings/python/tests/cindex/test_type.py
  clang/bindings/python/tests/cindex/util.py
  clang/docs/analyzer/conf.py
  clang/docs/conf.py
  clang/docs/tools/dump_ast_matchers.py
  clang/docs/tools/dump_format_help.py
  clang/docs/tools/dump_format_style.py
  clang/docs/tools/generate_formatted_state.py
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/test/AST/gen_ast_dump_json_test.py
  clang/test/Analysis/analyzer_test.py
  clang/test/Analysis/check-analyzer-fixit.py
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/lit.local.cfg
  clang/test/Analysis/scan-build/lit.local.cfg
  clang/test/CodeGen/builtins-nvptx-mma.py
  clang/test/CodeGenHIP/lit.local.cfg
  clang/test/CodeGenHLSL/lit.local.cfg
  clang/test/CodeGenObjC/lit.local.cfg
  clang/test/CodeGenObjCXX/lit.local.cfg
  clang/test/Driver/XRay/lit.local.cfg
  clang/test/Driver/ftime-trace-sections.py
  clang/test/Driver/lit.local.cfg
  clang/test/Format/lit.local.cfg
  clang/test/Frontend/lit.local.cfg
  clang/test/Headers/lit.local.cfg
  clang/test/Index/skip-parsed-bodies/lit.local.cfg
  clang/test/Interpreter/lit.local.cfg
  clang/test/LibClang/lit.local.cfg
  clang/test/OpenMP/lit.local.cfg
  clang/test/ParserHLSL/lit.local.cfg
  clang/test/Sema/lit.local.cfg
  clang/test/SemaCUDA/lit.local.cfg
  clang/test/SemaHLSL/lit.local.cfg
  clang/test/SemaObjCXX/lit.local.cfg
  clang/test/SemaOpenCL/lit.local.cfg
  clang/test/TableGen/lit.local.cfg
  clang/test/Unit/lit.cfg.py
  clang/test/lit.cfg.py
  clang/test/utils/update_cc_test_checks/lit.local.cfg
  clang/tools/clang-format/clang-format-diff.py
  

[PATCH] D137327: [clang-format] Handle object instansiation in if-statements

2023-04-14 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D137327#4267342 , @MyDeveloperDay 
wrote:

> You have commit rights correct? you really need to own your change especially 
> if it causes a regression.

Alright - I did that now. Sorry I am just used to be on the other side as my 
role as a release manager and I thought you where asking me to revert it in 
that role.

I will see if I find time to add the new Types directive soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137327

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


[PATCH] D137327: [clang-format] Handle object instansiation in if-statements

2023-04-14 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.
Herald added a reviewer: rymiel.

In D137327#4235255 , @MyDeveloperDay 
wrote:

> In D137327#4234463 , @thieta wrote:
>
>> This was released in LLVM 16.0.0.
>
> The prior behaviour was there before, it’s marked in GitHub as a regression, 
> can you please revert, we’ll mark the issue to be cherry picked, then let’s 
> go back and rework a solution that means your issue can be resolved

Sorry this slipped under my radar. Can you please push a revert to `main` and 
then file a issue to backport this to the release branch if it's something you 
still want to do. It's hard for me to keep track of the issues unless they are 
added to the 16.x milestone.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137327

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


[PATCH] D137327: [clang-format] Handle object instansiation in if-statements

2023-03-30 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

This was released in LLVM 16.0.0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137327

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


[PATCH] D137327: [clang-format] Handle object instansiation in if-statements

2023-03-30 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D137327#4233290 , @MyDeveloperDay 
wrote:

> because of https://github.com/llvm/llvm-project/issues/61785 should this 
> really be reverted?  is basically saying `X * Y {`  must be `X *Y{`  but that 
> obviously not the case

Tricky one. Any ideas on how we could differentiate those two cases? Maybe 
impossible? Not sure what the normal way to handle ambiguous things like that 
in clang-format is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137327

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


[PATCH] D143632: [clang] Handle __declspec() attributes in using

2023-02-13 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Thanks for the review and the explanations! I fixed your nits and landed this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143632

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


[PATCH] D143632: [clang] Handle __declspec() attributes in using

2023-02-13 Thread Tobias Hieta 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 rG877859a09bda: [clang] Handle __declspec() attributes in 
using (authored by thieta).

Changed prior to commit:
  https://reviews.llvm.org/D143632?vs=496906=496961#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143632

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseDecl.cpp
  clang/test/SemaCXX/using-declspec.cpp


Index: clang/test/SemaCXX/using-declspec.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-declspec.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
+
+// This should ignore the alignment and issue a warning about
+// align not being used
+auto func() -> __declspec(align(16)) int; // expected-warning{{attribute 
ignored when parsing type}}
+static_assert(alignof(decltype(func())) == alignof(int));
+
+// The following should NOT assert since alignment should
+// follow the type
+struct Test { int a; };
+using AlignedTest = __declspec(align(16)) const Test;
+static_assert(alignof(AlignedTest) == 16, "error");
+
+// Same here, no declaration to shift to
+int i = (__declspec(align(16))int)12; // expected-warning{{attribute ignored 
when parsing type}}
+
+// But there is a declaration here!
+typedef __declspec(align(16)) int Foo;
+static_assert(alignof(Foo) == 16);
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -56,6 +56,18 @@
   if (OwnedType)
 *OwnedType = DS.isTypeSpecOwned() ? DS.getRepAsDecl() : nullptr;
 
+  // Move declspec attributes to ParsedAttributes
+  if (Attrs) {
+llvm::SmallVector ToBeMoved;
+for (ParsedAttr  : DS.getAttributes()) {
+  if (AL.isDeclspecAttribute())
+ToBeMoved.push_back();
+}
+
+for (ParsedAttr *AL : ToBeMoved)
+  Attrs->takeOneFrom(DS.getAttributes(), AL);
+  }
+
   // Parse the abstract-declarator, if present.
   Declarator DeclaratorInfo(DS, ParsedAttributesView::none(), Context);
   ParseDeclarator(DeclaratorInfo);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -109,6 +109,10 @@
 bounds memory accesses. It emits warnings at call sites to such functions when
 the flag ``-Wunsafe-buffer-usage`` is enabled.
 
+``__declspec`` attributes can now be used together with the using keyword. 
Before
+the attributes on ``__declspec`` was ignored, while now it will be forwarded 
to the
+point where the alias is used.
+
 Windows Support
 ---
 


Index: clang/test/SemaCXX/using-declspec.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-declspec.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
+
+// This should ignore the alignment and issue a warning about
+// align not being used
+auto func() -> __declspec(align(16)) int; // expected-warning{{attribute ignored when parsing type}}
+static_assert(alignof(decltype(func())) == alignof(int));
+
+// The following should NOT assert since alignment should
+// follow the type
+struct Test { int a; };
+using AlignedTest = __declspec(align(16)) const Test;
+static_assert(alignof(AlignedTest) == 16, "error");
+
+// Same here, no declaration to shift to
+int i = (__declspec(align(16))int)12; // expected-warning{{attribute ignored when parsing type}}
+
+// But there is a declaration here!
+typedef __declspec(align(16)) int Foo;
+static_assert(alignof(Foo) == 16);
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -56,6 +56,18 @@
   if (OwnedType)
 *OwnedType = DS.isTypeSpecOwned() ? DS.getRepAsDecl() : nullptr;
 
+  // Move declspec attributes to ParsedAttributes
+  if (Attrs) {
+llvm::SmallVector ToBeMoved;
+for (ParsedAttr  : DS.getAttributes()) {
+  if (AL.isDeclspecAttribute())
+ToBeMoved.push_back();
+}
+
+for (ParsedAttr *AL : ToBeMoved)
+  Attrs->takeOneFrom(DS.getAttributes(), AL);
+  }
+
   // Parse the abstract-declarator, if present.
   Declarator DeclaratorInfo(DS, ParsedAttributesView::none(), Context);
   ParseDeclarator(DeclaratorInfo);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -109,6 +109,10 @@
 bounds memory accesses. It emits warnings at call sites to such functions when
 the flag ``-Wunsafe-buffer-usage`` is enabled.
 
+``__declspec`` attributes can now be used together with the using keyword. Before

[PATCH] D143632: [clang] Handle __declspec() attributes in using

2023-02-13 Thread Tobias Hieta via Phabricator via cfe-commits
thieta marked an inline comment as done.
thieta added a comment.

Thanks for your comments - feel free to comment on the release note, I was 
struggling with describing the fix well for a short release note paragraph.




Comment at: clang/lib/Parse/ParseDecl.cpp:61-63
+  for (ParsedAttr  : DS.getAttributes())
+if (AL.isDeclspecAttribute())
+  ToBeMoved.push_back();

aaron.ballman wrote:
> How about using an algorithm for this (would need to be reformatted for 80 
> col)?
I spent a while on trying to figure this out. I am not that great with the 
algorithms in the standard library since we don't really use that at work. But 
from my testing I couldn't get it to work:

- DS.getAttributes() returns a `ParsedAttr&`, but ToBeMoved needs a pointer to 
ParsedAttr. So your example code above fails because it can't convert 
ParsedAttr& to ParsedAttr* in the back_inserter()
- I tried to change ToBeMoved to be a list of references instead, but 
ParsedAttr disallows copying (I think, the error message was a bit confusing).
- I could do transform() to a list of pointers and then copy_if() but that 
seemed to really make it harder to understand.
- A transform_if() would solve the problem or I guess replace back_inserter() 
with some out iterator that could transform. But I couldn't find anything used 
like this browsing the LLVM source code.

So yeah - I might totally be missing something obvious here, feel free to point 
it out.



Comment at: clang/lib/Parse/ParseDecl.cpp:65-66
+
+  for (ParsedAttr *AL : ToBeMoved)
+Attrs->takeOneFrom(DS.getAttributes(), AL);
+

aaron.ballman wrote:
> Similar here, but this one might be less of a win in terms of readability.
yeah I can do this - I'll wait to see what we do with the block above first.



Comment at: clang/test/SemaCXX/using-declspec.cpp:4
+
+struct Test { int a; };
+using AlignedTest = __declspec(align(16)) const Test;

aaron.ballman wrote:
> Because we're touching `ParseTypeName()` and that is called in a lot of 
> contexts, I think we should have extra testing in non-alias declaration cases 
> and verify that MSVC behaves the same way. e.g., (search for 
> `ParseTypeName()`, see where we parse type names, devise some test cases)
> ```
> // I don't think the align attribute has a declaration to move onto in this 
> case...
> auto func() -> __declspec(align(16)) int;
> // So I *think* the alignment of the return type isn't changed?
> static_assert(alignof(decltype(func())) == alignof(int));
> 
> // Same here, no declaration to shift to
> int i = (__declspec(align(16))int)12;
> 
> // But there is a declaration here!
> typedef __declspec(align(16)) int Foo;
> static_assert(alignof(Foo) == 16);
> ```
> (There are possibly other interesting tests to consider.)
> 
> I suspect we should be issuing some "attribute ignored" diagnostics for the 
> cases where the attribute has no effect (even if MSVC does not warn).
Thanks for the expanded tests here! I tried all these tests on MSVC and they 
behave exactly as you described them above and they found bug in my 
implementation - Attrs in ParseTypeName() could be a nullptr.

We already emit warnings where the attribute is not used as you can see in the 
test case below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143632

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


[PATCH] D143632: [clang] Handle __declspec() attributes in using

2023-02-13 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 496906.
thieta marked 2 inline comments as done.
thieta added a comment.

- Expand on tests
- Fix crash when Attrs was null
- Added release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143632

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseDecl.cpp
  clang/test/SemaCXX/using-declspec.cpp


Index: clang/test/SemaCXX/using-declspec.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-declspec.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
+
+// This should ignore the alignment and issue a warning about
+// align not being used
+auto func() -> __declspec(align(16)) int; // expected-warning{{attribute 
ignored when parsing type}}
+static_assert(alignof(decltype(func())) == alignof(int));
+
+// The following should NOT assert since alignment should
+// follow the type
+struct Test { int a; };
+using AlignedTest = __declspec(align(16)) const Test;
+static_assert(alignof(AlignedTest) == 16, "error");
+
+// Same here, no declaration to shift to
+int i = (__declspec(align(16))int)12; // expected-warning{{attribute ignored 
when parsing type}}
+
+// But there is a declaration here!
+typedef __declspec(align(16)) int Foo;
+static_assert(alignof(Foo) == 16);
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -56,6 +56,19 @@
   if (OwnedType)
 *OwnedType = DS.isTypeSpecOwned() ? DS.getRepAsDecl() : nullptr;
 
+  // Move declspec attributes to ParsedAttributes
+  if (Attrs)
+  {
+llvm::SmallVector ToBeMoved;
+for (ParsedAttr  : DS.getAttributes()) {
+  if (AL.isDeclspecAttribute())
+ToBeMoved.push_back();
+}
+
+for (ParsedAttr *AL : ToBeMoved)
+  Attrs->takeOneFrom(DS.getAttributes(), AL);
+  }
+
   // Parse the abstract-declarator, if present.
   Declarator DeclaratorInfo(DS, ParsedAttributesView::none(), Context);
   ParseDeclarator(DeclaratorInfo);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -109,6 +109,10 @@
 bounds memory accesses. It emits warnings at call sites to such functions when
 the flag ``-Wunsafe-buffer-usage`` is enabled.
 
+__declspec attributes can now be used together with the using keyword. Before
+the attributes on __declspec was ignored, while now it will be forwarded to the
+point where the alias is used.
+
 Windows Support
 ---
 


Index: clang/test/SemaCXX/using-declspec.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-declspec.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
+
+// This should ignore the alignment and issue a warning about
+// align not being used
+auto func() -> __declspec(align(16)) int; // expected-warning{{attribute ignored when parsing type}}
+static_assert(alignof(decltype(func())) == alignof(int));
+
+// The following should NOT assert since alignment should
+// follow the type
+struct Test { int a; };
+using AlignedTest = __declspec(align(16)) const Test;
+static_assert(alignof(AlignedTest) == 16, "error");
+
+// Same here, no declaration to shift to
+int i = (__declspec(align(16))int)12; // expected-warning{{attribute ignored when parsing type}}
+
+// But there is a declaration here!
+typedef __declspec(align(16)) int Foo;
+static_assert(alignof(Foo) == 16);
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -56,6 +56,19 @@
   if (OwnedType)
 *OwnedType = DS.isTypeSpecOwned() ? DS.getRepAsDecl() : nullptr;
 
+  // Move declspec attributes to ParsedAttributes
+  if (Attrs)
+  {
+llvm::SmallVector ToBeMoved;
+for (ParsedAttr  : DS.getAttributes()) {
+  if (AL.isDeclspecAttribute())
+ToBeMoved.push_back();
+}
+
+for (ParsedAttr *AL : ToBeMoved)
+  Attrs->takeOneFrom(DS.getAttributes(), AL);
+  }
+
   // Parse the abstract-declarator, if present.
   Declarator DeclaratorInfo(DS, ParsedAttributesView::none(), Context);
   ParseDeclarator(DeclaratorInfo);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -109,6 +109,10 @@
 bounds memory accesses. It emits warnings at call sites to such functions when
 the flag ``-Wunsafe-buffer-usage`` is enabled.
 
+__declspec attributes can now be used together with the using keyword. Before
+the attributes on __declspec was ignored, while now it will be forwarded to the
+point where the alias is used.
+
 Windows Support
 

[PATCH] D138254: [llvm] Fix the build on OpenBSD by removing LLVM_VERSION_SUFFIX from created shared library names

2023-02-09 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

@brad is this something you still need for OpenBSD?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138254

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


[PATCH] D143632: [clang] Handle __declspec() attributes in using

2023-02-09 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added reviewers: aaron.ballman, rsmith, tbaeder, saudi.
Herald added a project: All.
thieta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch fixes so that declspec attributes are forwarded
to the alias declaration.

Before this patch this would assert:

class Test { int a; };
using AlignedTest = __declspec(align(16)) const Test;
static_assert(alignof(AlignedTest) == 16, "error");

But afterwards it behaves the same as MSVC does and doesn't
assert.

Fixes: llvm/llvm-project#60513


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143632

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/SemaCXX/using-declspec.cpp


Index: clang/test/SemaCXX/using-declspec.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-declspec.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct Test { int a; };
+using AlignedTest = __declspec(align(16)) const Test;
+static_assert(alignof(AlignedTest) == 16, "error");
\ No newline at end of file
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -56,6 +56,15 @@
   if (OwnedType)
 *OwnedType = DS.isTypeSpecOwned() ? DS.getRepAsDecl() : nullptr;
 
+  // Move declspec attributes to ParsedAttributes
+  llvm::SmallVector ToBeMoved;
+  for (ParsedAttr  : DS.getAttributes())
+if (AL.isDeclspecAttribute())
+  ToBeMoved.push_back();
+
+  for (ParsedAttr *AL : ToBeMoved)
+Attrs->takeOneFrom(DS.getAttributes(), AL);
+
   // Parse the abstract-declarator, if present.
   Declarator DeclaratorInfo(DS, ParsedAttributesView::none(), Context);
   ParseDeclarator(DeclaratorInfo);


Index: clang/test/SemaCXX/using-declspec.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-declspec.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct Test { int a; };
+using AlignedTest = __declspec(align(16)) const Test;
+static_assert(alignof(AlignedTest) == 16, "error");
\ No newline at end of file
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -56,6 +56,15 @@
   if (OwnedType)
 *OwnedType = DS.isTypeSpecOwned() ? DS.getRepAsDecl() : nullptr;
 
+  // Move declspec attributes to ParsedAttributes
+  llvm::SmallVector ToBeMoved;
+  for (ParsedAttr  : DS.getAttributes())
+if (AL.isDeclspecAttribute())
+  ToBeMoved.push_back();
+
+  for (ParsedAttr *AL : ToBeMoved)
+Attrs->takeOneFrom(DS.getAttributes(), AL);
+
   // Parse the abstract-declarator, if present.
   Declarator DeclaratorInfo(DS, ParsedAttributesView::none(), Context);
   ParseDeclarator(DeclaratorInfo);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139632: [clang-cl] Ignore #pragma managed / #pragma unmanaged

2022-12-09 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

It still looks odd to me, but since the rest of the file has comments like that 
I am fine with it. But I think we should figure out if they are like that 
because some tool is parsing them or if it's just legacy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139632

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


[PATCH] D139632: [clang-cl] Ignore #pragma managed / #pragma unmanaged

2022-12-08 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added inline comments.



Comment at: clang/lib/Lex/Pragma.cpp:1960
 
+/// "\#pragma managed"
+/// "\#pragma managed(...)"

I don't see the other comments in this file having `"\#` I think you can drop 
that. Also two `/` for the comments, not three.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139632

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


[PATCH] D138254: [llvm] Fix the build on OpenBSD by removing LLVM_VERSION_SUFFIX from created shared library names

2022-12-06 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

If this fixes OpenBSD it looks fine I think. But I wonder if we shouldn't just 
do this if we are on OpenBSD, changing the SOVERSION has been fraught with 
problems before since people have scripts that expect certain layouts.

Without having more tests and more investigation I will only accept this if the 
change only happens on OpenBSD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138254

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


[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-12-06 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

I think this is ready to land @Mordante or is there anything else missing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D139167: [clang][Windows]Ignore Options '/d1nodatetime' and '/d1import_no_registry'

2022-12-02 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Makes sense they are not documented and we probably can ignore them in that 
case!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139167

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


[PATCH] D139167: [clang][Windows]Ignore Options '/d1nodatetime' and '/d1import_no_registry'

2022-12-02 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

I tried to look up what these options do exactly - but they don't seem to be 
documented.

`/d1nodatetime` seems like an option that should be implemented instead of just 
ignored since it can have real reproducible problems not being there.

Do you know what `/d1import_no_registry` actually does?

I think we can ignore options that are not applicable in clang-cl, but I think 
if there are options that expect to change something, it's probably better to 
fail than to silently accept them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139167

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


[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-11-09 Thread Tobias Hieta via Phabricator via cfe-commits
thieta accepted this revision as: thieta.
thieta added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, JDevlieghere.

I think this is fine as we have discussed before. But I really dislike the code 
duplication for the check. We could put it in a include() I guess - but maybe 
it's not worth it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D137322: [clang][pdb] Don't include -fmessage-length in PDB buildinfo

2022-11-08 Thread Tobias Hieta 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 rGaa99b607b5cf: [clang][pdb] Dont include 
-fmessage-length in PDB buildinfo (authored by thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137322

Files:
  clang/test/CodeGen/debug-info-codeview-buildinfo.c
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp


Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -908,6 +908,9 @@
 }
 if (Arg.startswith("-object-file-name") || Arg == MainFilename)
   continue;
+// Skip fmessage-length for reproduciability.
+if (Arg.startswith("-fmessage-length"))
+  continue;
 if (PrintedOneArg)
   OS << " ";
 llvm::sys::printArg(OS, Arg, /*Quote=*/true);
Index: clang/test/CodeGen/debug-info-codeview-buildinfo.c
===
--- clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -8,6 +8,10 @@
 // RUN: %clang_cl -gno-codeview-command-line --target=i686-windows-msvc /c /Z7 
/Fo%t.obj -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix DISABLE
 
+// -fmessage-length shouldn't be included in the command line since it breaks 
reproducibility
+// RUN: %clang_cl -gcodeview-command-line --target=i686-windows-msvc -Xclang 
-fmessage-length=100 /c /Z7 /Fo%t.obj -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix 
MESSAGELEN
+
 int main(void) { return 42; }
 
 // CHECK:   Types (.debug$T)
@@ -36,3 +40,8 @@
 // DISABLE-NEXT:  0x{{.+}}: `{{.*}}`
 // DISABLE-NEXT:  0x{{.+}}: ``
 // DISABLE-NEXT:  : ``
+
+// MESSAGELEN:   Types (.debug$T)
+// MESSAGELEN: 
+// MESSAGELEN: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// MESSAGELEN-NOT: -fmessage-length


Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -908,6 +908,9 @@
 }
 if (Arg.startswith("-object-file-name") || Arg == MainFilename)
   continue;
+// Skip fmessage-length for reproduciability.
+if (Arg.startswith("-fmessage-length"))
+  continue;
 if (PrintedOneArg)
   OS << " ";
 llvm::sys::printArg(OS, Arg, /*Quote=*/true);
Index: clang/test/CodeGen/debug-info-codeview-buildinfo.c
===
--- clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -8,6 +8,10 @@
 // RUN: %clang_cl -gno-codeview-command-line --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix DISABLE
 
+// -fmessage-length shouldn't be included in the command line since it breaks reproducibility
+// RUN: %clang_cl -gcodeview-command-line --target=i686-windows-msvc -Xclang -fmessage-length=100 /c /Z7 /Fo%t.obj -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix MESSAGELEN
+
 int main(void) { return 42; }
 
 // CHECK:   Types (.debug$T)
@@ -36,3 +40,8 @@
 // DISABLE-NEXT:  0x{{.+}}: `{{.*}}`
 // DISABLE-NEXT:  0x{{.+}}: ``
 // DISABLE-NEXT:  : ``
+
+// MESSAGELEN:   Types (.debug$T)
+// MESSAGELEN: 
+// MESSAGELEN: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// MESSAGELEN-NOT: -fmessage-length
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137322: [clang][pdb] Don't include -fmessage-length in PDB buildinfo

2022-11-08 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Thanks @hans


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137322

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


[PATCH] D137322: [clang][pdb] Don't include -fmessage-length in PDB buildinfo

2022-11-08 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 473912.
thieta added a comment.

Updated from feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137322

Files:
  clang/test/CodeGen/debug-info-codeview-buildinfo.c
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp


Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -908,6 +908,9 @@
 }
 if (Arg.startswith("-object-file-name") || Arg == MainFilename)
   continue;
+// Skip fmessage-length for reproduciability.
+if (Arg.startswith("-fmessage-length"))
+  continue;
 if (PrintedOneArg)
   OS << " ";
 llvm::sys::printArg(OS, Arg, /*Quote=*/true);
Index: clang/test/CodeGen/debug-info-codeview-buildinfo.c
===
--- clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -8,6 +8,10 @@
 // RUN: %clang_cl -gno-codeview-command-line --target=i686-windows-msvc /c /Z7 
/Fo%t.obj -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix DISABLE
 
+// -fmessage-length shouldn't be included in the command line since it breaks 
reproducibility
+// RUN: %clang_cl -gcodeview-command-line --target=i686-windows-msvc -Xclang 
-fmessage-length=100 /c /Z7 /Fo%t.obj -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix 
MESSAGELEN
+
 int main(void) { return 42; }
 
 // CHECK:   Types (.debug$T)
@@ -36,3 +40,8 @@
 // DISABLE-NEXT:  0x{{.+}}: `{{.*}}`
 // DISABLE-NEXT:  0x{{.+}}: ``
 // DISABLE-NEXT:  : ``
+
+// MESSAGELEN:   Types (.debug$T)
+// MESSAGELEN: 
+// MESSAGELEN: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// MESSAGELEN-NOT: -fmessage-length


Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -908,6 +908,9 @@
 }
 if (Arg.startswith("-object-file-name") || Arg == MainFilename)
   continue;
+// Skip fmessage-length for reproduciability.
+if (Arg.startswith("-fmessage-length"))
+  continue;
 if (PrintedOneArg)
   OS << " ";
 llvm::sys::printArg(OS, Arg, /*Quote=*/true);
Index: clang/test/CodeGen/debug-info-codeview-buildinfo.c
===
--- clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -8,6 +8,10 @@
 // RUN: %clang_cl -gno-codeview-command-line --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix DISABLE
 
+// -fmessage-length shouldn't be included in the command line since it breaks reproducibility
+// RUN: %clang_cl -gcodeview-command-line --target=i686-windows-msvc -Xclang -fmessage-length=100 /c /Z7 /Fo%t.obj -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix MESSAGELEN
+
 int main(void) { return 42; }
 
 // CHECK:   Types (.debug$T)
@@ -36,3 +40,8 @@
 // DISABLE-NEXT:  0x{{.+}}: `{{.*}}`
 // DISABLE-NEXT:  0x{{.+}}: ``
 // DISABLE-NEXT:  : ``
+
+// MESSAGELEN:   Types (.debug$T)
+// MESSAGELEN: 
+// MESSAGELEN: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// MESSAGELEN-NOT: -fmessage-length
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137322: [clang][pdb] Don't include -fmessage-length in PDB buildinfo

2022-11-07 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a reviewer: hans.
thieta added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137322

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


[PATCH] D137327: [clang-format] Handle object instansiation in if-statements

2022-11-06 Thread Tobias Hieta 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 rG70de684d4413: [clang-format] Handle object instansiation in 
if-statements (authored by thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137327

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -145,6 +145,18 @@
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
   EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
   EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("if (Foo * Bar / Test)");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("if (Class* obj {getObj()})");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("if (Foo* Bar = getObj())");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -362,7 +362,8 @@
   FormatToken *Next = CurrentToken->Next;
   if (PrevPrev && PrevPrev->is(tok::identifier) &&
   Prev->isOneOf(tok::star, tok::amp, tok::ampamp) &&
-  CurrentToken->is(tok::identifier) && Next->isNot(tok::equal)) {
+  CurrentToken->is(tok::identifier) &&
+  !Next->isOneOf(tok::equal, tok::l_brace)) {
 Prev->setType(TT_BinaryOperator);
 LookForDecls = false;
   }
@@ -2387,6 +2388,12 @@
   return TT_PointerOrReference;
 }
 
+// if (Class* obj { function() })
+if (PrevToken->Tok.isAnyIdentifier() && NextToken->Tok.isAnyIdentifier() &&
+NextToken->Next && NextToken->Next->is(tok::l_brace)) {
+  return TT_PointerOrReference;
+}
+
 if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
   return TT_UnaryOperator;
 


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -145,6 +145,18 @@
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
   EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
   EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("if (Foo * Bar / Test)");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("if (Class* obj {getObj()})");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("if (Foo* Bar = getObj())");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -362,7 +362,8 @@
   FormatToken *Next = CurrentToken->Next;
   if (PrevPrev && PrevPrev->is(tok::identifier) &&
   Prev->isOneOf(tok::star, tok::amp, tok::ampamp) &&
-  CurrentToken->is(tok::identifier) && Next->isNot(tok::equal)) {
+  CurrentToken->is(tok::identifier) &&
+  !Next->isOneOf(tok::equal, tok::l_brace)) {
 Prev->setType(TT_BinaryOperator);
 LookForDecls = false;
   }
@@ -2387,6 +2388,12 @@
   return TT_PointerOrReference;
 }
 
+// if (Class* obj { function() })
+if (PrevToken->Tok.isAnyIdentifier() && NextToken->Tok.isAnyIdentifier() &&
+NextToken->Next && NextToken->Next->is(tok::l_brace)) {
+  return TT_PointerOrReference;
+}
+
 if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
   return TT_UnaryOperator;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137327: [clang-format] Handle object instansiation in if-statements

2022-11-04 Thread Tobias Hieta via Phabricator via cfe-commits
thieta marked 2 inline comments as done.
thieta added a comment.

I have expanded testing and moved it to the place you suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137327

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


[PATCH] D137327: [clang-format] Handle object instansiation in if-statements

2022-11-04 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 473169.
thieta added a comment.

Expand and move testing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137327

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -145,6 +145,18 @@
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
   EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
   EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("if (Foo * Bar / Test)");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("if (Class* obj {getObj()})");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("if (Foo* Bar = getObj())");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -362,7 +362,8 @@
   FormatToken *Next = CurrentToken->Next;
   if (PrevPrev && PrevPrev->is(tok::identifier) &&
   Prev->isOneOf(tok::star, tok::amp, tok::ampamp) &&
-  CurrentToken->is(tok::identifier) && Next->isNot(tok::equal)) {
+  CurrentToken->is(tok::identifier) &&
+  !Next->isOneOf(tok::equal, tok::l_brace)) {
 Prev->setType(TT_BinaryOperator);
 LookForDecls = false;
   }
@@ -2385,6 +2386,12 @@
   return TT_PointerOrReference;
 }
 
+// if (Class* obj { function() })
+if (PrevToken->Tok.isAnyIdentifier() && NextToken->Tok.isAnyIdentifier() &&
+NextToken->Next && NextToken->Next->is(tok::l_brace)) {
+  return TT_PointerOrReference;
+}
+
 if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
   return TT_UnaryOperator;
 


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -145,6 +145,18 @@
   EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
   EXPECT_TOKEN(Tokens[7], tok::star, TT_UnaryOperator);
   EXPECT_TOKEN(Tokens[12], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("if (Foo * Bar / Test)");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("if (Class* obj {getObj()})");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("if (Foo* Bar = getObj())");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -362,7 +362,8 @@
   FormatToken *Next = CurrentToken->Next;
   if (PrevPrev && PrevPrev->is(tok::identifier) &&
   Prev->isOneOf(tok::star, tok::amp, tok::ampamp) &&
-  CurrentToken->is(tok::identifier) && Next->isNot(tok::equal)) {
+  CurrentToken->is(tok::identifier) &&
+  !Next->isOneOf(tok::equal, tok::l_brace)) {
 Prev->setType(TT_BinaryOperator);
 LookForDecls = false;
   }
@@ -2385,6 +2386,12 @@
   return TT_PointerOrReference;
 }
 
+// if (Class* obj { function() })
+if (PrevToken->Tok.isAnyIdentifier() && NextToken->Tok.isAnyIdentifier() &&
+NextToken->Next && NextToken->Next->is(tok::l_brace)) {
+  return TT_PointerOrReference;
+}
+
 if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
   return TT_UnaryOperator;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137327: [clang-format] Handle object instansiation in if-statements

2022-11-03 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added reviewers: MyDeveloperDay, curdeius, owenpan.
Herald added a project: All.
thieta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before this patch code like this:

  if (Class* obj{getObject()}) { }

would be mis-formated since the * would be annotated as a
binaryoperator.

This patch changes the * to become a PointerOrReference instead
and fixes the formatting issues.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137327

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1035,6 +1035,12 @@
   EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_Unknown);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandIfInitializer) {
+  auto Tokens = annotate("if (Class* obj {getObj()}) ");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsVerilogOperators) {
   auto Annotate = [this](llvm::StringRef Code) {
 return annotate(Code, getLLVMStyle(FormatStyle::LK_Verilog));
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -362,7 +362,8 @@
   FormatToken *Next = CurrentToken->Next;
   if (PrevPrev && PrevPrev->is(tok::identifier) &&
   Prev->isOneOf(tok::star, tok::amp, tok::ampamp) &&
-  CurrentToken->is(tok::identifier) && Next->isNot(tok::equal)) {
+  CurrentToken->is(tok::identifier) &&
+  !Next->isOneOf(tok::equal, tok::l_brace)) {
 Prev->setType(TT_BinaryOperator);
 LookForDecls = false;
   }
@@ -2385,6 +2386,12 @@
   return TT_PointerOrReference;
 }
 
+// if (Class* obj { function() })
+if (PrevToken->Tok.isAnyIdentifier() && NextToken->Tok.isAnyIdentifier() &&
+NextToken->Next && NextToken->Next->is(tok::l_brace)) {
+  return TT_PointerOrReference;
+}
+
 if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
   return TT_UnaryOperator;
 


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1035,6 +1035,12 @@
   EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_Unknown);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandIfInitializer) {
+  auto Tokens = annotate("if (Class* obj {getObj()}) ");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsVerilogOperators) {
   auto Annotate = [this](llvm::StringRef Code) {
 return annotate(Code, getLLVMStyle(FormatStyle::LK_Verilog));
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -362,7 +362,8 @@
   FormatToken *Next = CurrentToken->Next;
   if (PrevPrev && PrevPrev->is(tok::identifier) &&
   Prev->isOneOf(tok::star, tok::amp, tok::ampamp) &&
-  CurrentToken->is(tok::identifier) && Next->isNot(tok::equal)) {
+  CurrentToken->is(tok::identifier) &&
+  !Next->isOneOf(tok::equal, tok::l_brace)) {
 Prev->setType(TT_BinaryOperator);
 LookForDecls = false;
   }
@@ -2385,6 +2386,12 @@
   return TT_PointerOrReference;
 }
 
+// if (Class* obj { function() })
+if (PrevToken->Tok.isAnyIdentifier() && NextToken->Tok.isAnyIdentifier() &&
+NextToken->Next && NextToken->Next->is(tok::l_brace)) {
+  return TT_PointerOrReference;
+}
+
 if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
   return TT_UnaryOperator;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136474: [CodeView][clang] Add flag to disable emitting command line into CodeView

2022-11-03 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

I posted https://reviews.llvm.org/D137322 to remove `-fmessage-length`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136474

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


[PATCH] D137322: [clang][pdb] Don't include -fmessage-length in PDB buildinfo

2022-11-03 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added reviewers: aganea, rnk, thakis, aeubanks.
Herald added a subscriber: hiraditya.
Herald added a project: All.
thieta requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

As discussed in https://reviews.llvm.org/D136474 -fmessage-length
creates problems with reproduciability in the PDB files.

This patch just drops that argument when writing the PDB file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137322

Files:
  clang/test/CodeGen/debug-info-codeview-buildinfo.c
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp


Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -908,6 +908,9 @@
 }
 if (Arg.startswith("-object-file-name") || Arg == MainFilename)
   continue;
+// Skip fmessage-length for reproduciability
+if (Arg.startswith("-fmessage-length"))
+  continue;
 if (PrintedOneArg)
   OS << " ";
 llvm::sys::printArg(OS, Arg, /*Quote=*/true);
Index: clang/test/CodeGen/debug-info-codeview-buildinfo.c
===
--- clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -8,6 +8,10 @@
 // RUN: %clang_cl -gno-codeview-command-line --target=i686-windows-msvc /c /Z7 
/Fo%t.obj -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix DISABLE
 
+// -fmessage length shouldn't be included in the command line since it breaks 
reproducibility
+// RUN: %clang_cl -gcodeview-command-line --target=i686-windows-msvc -Xclang 
-fmessage-length=100 /c /Z7 /Fo%t.obj -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix 
MESSAGELEN
+
 int main(void) { return 42; }
 
 // CHECK:   Types (.debug$T)
@@ -36,3 +40,8 @@
 // DISABLE-NEXT:  0x{{.+}}: `{{.*}}`
 // DISABLE-NEXT:  0x{{.+}}: ``
 // DISABLE-NEXT:  : ``
+
+// MESSAGELEN:   Types (.debug$T)
+// MESSAGELEN: 
+// MESSAGELEN: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// MESSAGELEN-NOT:  0x{{.+}}: `"{{.+}}-fmessage-length=


Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -908,6 +908,9 @@
 }
 if (Arg.startswith("-object-file-name") || Arg == MainFilename)
   continue;
+// Skip fmessage-length for reproduciability
+if (Arg.startswith("-fmessage-length"))
+  continue;
 if (PrintedOneArg)
   OS << " ";
 llvm::sys::printArg(OS, Arg, /*Quote=*/true);
Index: clang/test/CodeGen/debug-info-codeview-buildinfo.c
===
--- clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -8,6 +8,10 @@
 // RUN: %clang_cl -gno-codeview-command-line --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix DISABLE
 
+// -fmessage length shouldn't be included in the command line since it breaks reproducibility
+// RUN: %clang_cl -gcodeview-command-line --target=i686-windows-msvc -Xclang -fmessage-length=100 /c /Z7 /Fo%t.obj -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix MESSAGELEN
+
 int main(void) { return 42; }
 
 // CHECK:   Types (.debug$T)
@@ -36,3 +40,8 @@
 // DISABLE-NEXT:  0x{{.+}}: `{{.*}}`
 // DISABLE-NEXT:  0x{{.+}}: ``
 // DISABLE-NEXT:  : ``
+
+// MESSAGELEN:   Types (.debug$T)
+// MESSAGELEN: 
+// MESSAGELEN: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// MESSAGELEN-NOT:  0x{{.+}}: `"{{.+}}-fmessage-length=
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136474: [CodeView][clang] Disable emitting command line into CodeView by default and add flag to enable

2022-10-27 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

I am fine with this plan as well. And I am willing to chip in and try to fix 
the issues with the current implementation since we actually use the feature.

@thakis do you mind explaining the issues you see and how to replicate them and 
I can have a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136474

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


[PATCH] D126903: [clang] Add support for __builtin_memset_inline

2022-10-26 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

We have been building a two stage clang and our internal projects with this 
version of rpmalloc and clang 15.x a while now and I haven't see the issue you 
see @aganea. I don't think this patch is the problem as @efriedma suggested, 
could be in rpmalloc but since I have used this successfully already I am not 
sure about that either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126903

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


[PATCH] D136336: [clang-format] Mark pragma region lines as StringLiterals

2022-10-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1345
   while (CurrentToken) {
-if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator))
+if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator)) {
   CurrentToken->setType(TT_ImplicitStringLiteral);

HazardyKnusperkeks wrote:
> This shouldn't be here. There is no closing brace for this, or am I missing 
> something?
No you are right it was a miss in the rebase. But it's fixed on main now. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136336

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


[PATCH] D136474: [CodeView][clang] Disable emitting command line into CodeView by default and add flag to enable

2022-10-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Also this should have a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136474

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


[PATCH] D136474: [CodeView][clang] Disable emitting command line into CodeView by default and add flag to enable

2022-10-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

We have tooling that uses this command line from the PDB. I think the 
conservative approach is to emit the command line by default since this is how 
MSVC behaves. I don't mind this flag now that I know about it, but I think we 
should keep the default to what MSVC does for clang-cl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136474

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


[PATCH] D136336: [clang-format] Mark pragma region lines as StringLiterals

2022-10-25 Thread Tobias Hieta 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 rGfd1d93db7106: [clang-format] Mark pragma region lines as 
StringLiterals (authored by thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136336

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -649,6 +649,22 @@
   EXPECT_TOKEN(Tokens[14], tok::l_brace, TT_RequiresExpressionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsPragmaRegion) {
+  // Everything after #pragma region should be ImplicitStringLiteral
+  auto Tokens = annotate("#pragma region Foo(Bar: Hello)");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[6], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[7], tok::identifier, TT_ImplicitStringLiteral);
+
+  // Make sure it's annotated correctly inside a function as well
+  Tokens = annotate("void test(){\n#pragma region Foo(Bar: Hello)\n}");
+  ASSERT_EQ(Tokens.size(), 16u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[11], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[12], tok::identifier, TT_ImplicitStringLiteral);
+}
+
 TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
   const char *BaseCode = nullptr;
   const char *ConstrainedCode = nullptr;
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19965,9 +19965,7 @@
 TEST_F(FormatTest, UnderstandPragmaRegion) {
   auto Style = getLLVMStyleWithColumns(0);
   verifyFormat("#pragma region TEST(FOO : BAR)", Style);
-
-  EXPECT_EQ("#pragma region TEST(FOO : BAR)",
-format("#pragma region TEST(FOO : BAR)", Style));
+  verifyFormat("#pragma region TEST(FOO: NOSPACE)", Style);
 }
 
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1337,14 +1337,15 @@
 if (CurrentToken &&
 CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option,
   Keywords.kw_region)) {
-  bool IsMark = CurrentToken->is(Keywords.kw_mark);
+  bool IsMarkOrRegion =
+  CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_region);
   next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
-if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator))
+if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator)) {
   CurrentToken->setType(TT_ImplicitStringLiteral);
 next();
-  }
+}
 }
   }
 


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -649,6 +649,22 @@
   EXPECT_TOKEN(Tokens[14], tok::l_brace, TT_RequiresExpressionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsPragmaRegion) {
+  // Everything after #pragma region should be ImplicitStringLiteral
+  auto Tokens = annotate("#pragma region Foo(Bar: Hello)");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[6], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[7], tok::identifier, TT_ImplicitStringLiteral);
+
+  // Make sure it's annotated correctly inside a function as well
+  Tokens = annotate("void test(){\n#pragma region Foo(Bar: Hello)\n}");
+  ASSERT_EQ(Tokens.size(), 16u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[11], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[12], tok::identifier, TT_ImplicitStringLiteral);
+}
+
 TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
   const char *BaseCode = nullptr;
   const char *ConstrainedCode = nullptr;
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19965,9 +19965,7 @@
 TEST_F(FormatTest, UnderstandPragmaRegion) {
   auto Style = getLLVMStyleWithColumns(0);
   verifyFormat("#pragma region TEST(FOO : BAR)", Style);
-

[PATCH] D136337: [clang-format] Discard pre-processor statements in parseBracedList()

2022-10-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta abandoned this revision.
thieta added a comment.

In D136337#3881476 , @owenpan wrote:

> Can you create an issue on GitHub and include the details on how to reproduce 
> the problem using the latest clang-format?

Ah I re-tested this with main and it seems like there has been a lot of changes 
to parseBracedList() since I started to investigate this and it seems to work 
out of the box now. I will close this diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136337

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


[PATCH] D136336: [clang-format] Mark pragma region lines as StringLiterals

2022-10-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 470380.
thieta added a comment.

git clang-format
removed accidental include


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136336

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -649,6 +649,22 @@
   EXPECT_TOKEN(Tokens[14], tok::l_brace, TT_RequiresExpressionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsPragmaRegion) {
+  // Everything after #pragma region should be ImplicitStringLiteral
+  auto Tokens = annotate("#pragma region Foo(Bar: Hello)");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[6], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[7], tok::identifier, TT_ImplicitStringLiteral);
+
+  // Make sure it's annotated correctly inside a function as well
+  Tokens = annotate("void test(){\n#pragma region Foo(Bar: Hello)\n}");
+  ASSERT_EQ(Tokens.size(), 16u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[11], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[12], tok::identifier, TT_ImplicitStringLiteral);
+}
+
 TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
   const char *BaseCode = nullptr;
   const char *ConstrainedCode = nullptr;
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19965,9 +19965,7 @@
 TEST_F(FormatTest, UnderstandPragmaRegion) {
   auto Style = getLLVMStyleWithColumns(0);
   verifyFormat("#pragma region TEST(FOO : BAR)", Style);
-
-  EXPECT_EQ("#pragma region TEST(FOO : BAR)",
-format("#pragma region TEST(FOO : BAR)", Style));
+  verifyFormat("#pragma region TEST(FOO: NOSPACE)", Style);
 }
 
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1337,14 +1337,15 @@
 if (CurrentToken &&
 CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option,
   Keywords.kw_region)) {
-  bool IsMark = CurrentToken->is(Keywords.kw_mark);
+  bool IsMarkOrRegion =
+  CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_region);
   next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
-if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator))
+if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator)) {
   CurrentToken->setType(TT_ImplicitStringLiteral);
 next();
-  }
+}
 }
   }
 


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -649,6 +649,22 @@
   EXPECT_TOKEN(Tokens[14], tok::l_brace, TT_RequiresExpressionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsPragmaRegion) {
+  // Everything after #pragma region should be ImplicitStringLiteral
+  auto Tokens = annotate("#pragma region Foo(Bar: Hello)");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[6], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[7], tok::identifier, TT_ImplicitStringLiteral);
+
+  // Make sure it's annotated correctly inside a function as well
+  Tokens = annotate("void test(){\n#pragma region Foo(Bar: Hello)\n}");
+  ASSERT_EQ(Tokens.size(), 16u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[11], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[12], tok::identifier, TT_ImplicitStringLiteral);
+}
+
 TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
   const char *BaseCode = nullptr;
   const char *ConstrainedCode = nullptr;
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19965,9 +19965,7 @@
 TEST_F(FormatTest, UnderstandPragmaRegion) {
   auto Style = getLLVMStyleWithColumns(0);
   verifyFormat("#pragma region TEST(FOO : BAR)", Style);
-
-  EXPECT_EQ("#pragma region TEST(FOO : BAR)",
-format("#pragma region TEST(FOO : BAR)", Style));
+  

[PATCH] D136337: [clang-format] Discard pre-processor statements in parseBracedList()

2022-10-24 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136337

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


[PATCH] D136336: [clang-format] Mark pragma region lines as StringLiterals

2022-10-24 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D136336#3877238 , @owenpan wrote:

> Can you add a test to `TokenAnnotatorTest.cpp`?

Thanks for the review. Fixed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136336

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


[PATCH] D136336: [clang-format] Mark pragma region lines as StringLiterals

2022-10-24 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 470092.
thieta added a comment.

Added TokenAnnotatorTest and removed reduntant FormatTests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136336

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -6,6 +6,7 @@
 //
 
//===--===//
 
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
 
 #include "FormatTestUtils.h"
@@ -649,6 +650,23 @@
   EXPECT_TOKEN(Tokens[14], tok::l_brace, TT_RequiresExpressionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsPragmaRegion) {
+  // Everything after #pragma region should be ImplicitStringLiteral
+  auto Tokens = annotate("#pragma region Foo(Bar: Hello)");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[6], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[7], tok::identifier, TT_ImplicitStringLiteral);
+
+  // Make sure it's annotated correctly inside a function as well
+  Tokens = annotate("void test(){\n#pragma region Foo(Bar: Hello)\n}");
+  ASSERT_EQ(Tokens.size(), 16u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[11], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[12], tok::identifier, TT_ImplicitStringLiteral);
+
+}
+
 TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
   const char *BaseCode = nullptr;
   const char *ConstrainedCode = nullptr;
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19965,9 +19965,7 @@
 TEST_F(FormatTest, UnderstandPragmaRegion) {
   auto Style = getLLVMStyleWithColumns(0);
   verifyFormat("#pragma region TEST(FOO : BAR)", Style);
-
-  EXPECT_EQ("#pragma region TEST(FOO : BAR)",
-format("#pragma region TEST(FOO : BAR)", Style));
+  verifyFormat("#pragma region TEST(FOO: NOSPACE)", Style);
 }
 
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1337,11 +1337,11 @@
 if (CurrentToken &&
 CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option,
   Keywords.kw_region)) {
-  bool IsMark = CurrentToken->is(Keywords.kw_mark);
+  bool IsMarkOrRegion = CurrentToken->isOneOf(Keywords.kw_mark, 
Keywords.kw_region);
   next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
-if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator))
+if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator))
   CurrentToken->setType(TT_ImplicitStringLiteral);
 next();
   }


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
 
 #include "FormatTestUtils.h"
@@ -649,6 +650,23 @@
   EXPECT_TOKEN(Tokens[14], tok::l_brace, TT_RequiresExpressionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsPragmaRegion) {
+  // Everything after #pragma region should be ImplicitStringLiteral
+  auto Tokens = annotate("#pragma region Foo(Bar: Hello)");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[6], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[7], tok::identifier, TT_ImplicitStringLiteral);
+
+  // Make sure it's annotated correctly inside a function as well
+  Tokens = annotate("void test(){\n#pragma region Foo(Bar: Hello)\n}");
+  ASSERT_EQ(Tokens.size(), 16u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::identifier, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[11], tok::colon, TT_ImplicitStringLiteral);
+  EXPECT_TOKEN(Tokens[12], tok::identifier, TT_ImplicitStringLiteral);
+
+}
+
 TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
   const char *BaseCode = nullptr;
   const char *ConstrainedCode = nullptr;
Index: clang/unittests/Format/FormatTest.cpp

[PATCH] D136337: [clang-format] Discard pre-processor statements in parseBracedList()

2022-10-20 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added reviewers: MyDeveloperDay, curdeius, owenpan.
Herald added a project: All.
thieta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We had some code that looked like this:

  int foo()
  {
#pragma region hello(foo)
#pragma endregion
  }
  
  foo* bar() {}

This was confusingly indented like:

  int foo()
{
  #pragma region...
}

After some investigation I noticed that this is because
`parseBracedList()` thought that this was a initializer list.

The check here: 
https://github.com/tru/llvm-project/blob/main/clang/lib/Format/UnwrappedLineParser.cpp#L709
will mark the code above as ProbablyBracedList and then it
will format it totally wrong depending on your style settings.

My initial fix was to change the check above, but it became
really complicated to keep both initializer lists and my code
working.

My approach here instead is to discard any line that starts with #
since that is a pre-processor statement we shouldn't really care
about it in this case.

This fix passes all the unittests and our internal code-base, so
I am fairly confident in it, but I am no clang-format expert.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136337

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19970,6 +19970,14 @@
 format("#pragma region TEST(FOO : BAR)", Style));
 }
 
+TEST_F(FormatTest, PragmaRegionShouldNotBeBraceInitializers) {
+  auto Style = getLLVMStyleWithColumns(0);
+  verifyFormat("CxxClass::CxxClass() {\n#pragma region test(hello)\n}", Style);
+  EXPECT_EQ("CxxClass::CxxClass()\n#pragma region TEST(bar: foo)\n{\n#pragma 
region TEST(foo: bar)\n#pragma endregion\n}\nCxxClass *Hello() {}",
+format("CxxClass::CxxClass()\n#pragma region TEST(bar: foo)\n{\n  
#pragma region TEST(foo: bar)\n  #pragma endregion\n}\nCxxClass* Hello()\n{}", 
Style));
+
+}
+
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
   FormatStyle Style = getLLVMStyleWithColumns(20);
 
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -751,6 +751,11 @@
   if (!LBraceStack.empty() && LBraceStack.back()->is(BK_Unknown))
 LBraceStack.back()->setBlockKind(BK_Block);
   break;
+case tok::hash:
+  do {
+NextTok = Tokens->getNextToken();
+  } while (NextTok->isNot(tok::eof));
+  break;
 default:
   break;
 }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19970,6 +19970,14 @@
 format("#pragma region TEST(FOO : BAR)", Style));
 }
 
+TEST_F(FormatTest, PragmaRegionShouldNotBeBraceInitializers) {
+  auto Style = getLLVMStyleWithColumns(0);
+  verifyFormat("CxxClass::CxxClass() {\n#pragma region test(hello)\n}", Style);
+  EXPECT_EQ("CxxClass::CxxClass()\n#pragma region TEST(bar: foo)\n{\n#pragma region TEST(foo: bar)\n#pragma endregion\n}\nCxxClass *Hello() {}",
+format("CxxClass::CxxClass()\n#pragma region TEST(bar: foo)\n{\n  #pragma region TEST(foo: bar)\n  #pragma endregion\n}\nCxxClass* Hello()\n{}", Style));
+
+}
+
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
   FormatStyle Style = getLLVMStyleWithColumns(20);
 
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -751,6 +751,11 @@
   if (!LBraceStack.empty() && LBraceStack.back()->is(BK_Unknown))
 LBraceStack.back()->setBlockKind(BK_Block);
   break;
+case tok::hash:
+  do {
+NextTok = Tokens->getNextToken();
+  } while (NextTok->isNot(tok::eof));
+  break;
 default:
   break;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136336: [clang-format] Mark pragma region lines as StringLiterals

2022-10-20 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added reviewers: MyDeveloperDay, curdeius, owenpan.
Herald added a project: All.
thieta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In our code-base we auto-generate pragma regions the regions
look like method signatures like:

`#pragma region MYREGION(Foo: bar)`

The problem here was that the rest of the line after region
was not marked as stringliteral as in the case of pragma mark
so clang-format tried to change the formatting based on the
method signature.

Added test and mark it similar as pragma mark.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136336

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19968,6 +19968,11 @@
 
   EXPECT_EQ("#pragma region TEST(FOO : BAR)",
 format("#pragma region TEST(FOO : BAR)", Style));
+
+  verifyFormat("#pragma region TEST(FOO: NOSPACE)", Style);
+  EXPECT_EQ("#pragma region TEST(FOO: NOSPACE)",
+format("#pragma region TEST(FOO: NOSPACE)", Style));
+
 }
 
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1337,11 +1337,11 @@
 if (CurrentToken &&
 CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option,
   Keywords.kw_region)) {
-  bool IsMark = CurrentToken->is(Keywords.kw_mark);
+  bool IsMarkOrRegion = CurrentToken->isOneOf(Keywords.kw_mark, 
Keywords.kw_region);
   next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
-if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator))
+if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator))
   CurrentToken->setType(TT_ImplicitStringLiteral);
 next();
   }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19968,6 +19968,11 @@
 
   EXPECT_EQ("#pragma region TEST(FOO : BAR)",
 format("#pragma region TEST(FOO : BAR)", Style));
+
+  verifyFormat("#pragma region TEST(FOO: NOSPACE)", Style);
+  EXPECT_EQ("#pragma region TEST(FOO: NOSPACE)",
+format("#pragma region TEST(FOO: NOSPACE)", Style));
+
 }
 
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1337,11 +1337,11 @@
 if (CurrentToken &&
 CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option,
   Keywords.kw_region)) {
-  bool IsMark = CurrentToken->is(Keywords.kw_mark);
+  bool IsMarkOrRegion = CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_region);
   next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
-if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator))
+if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator))
   CurrentToken->setType(TT_ImplicitStringLiteral);
 next();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135128: [clang][cli] Simplify repetitive macro invocations

2022-10-06 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

This looks fine to me in principle. But I wonder if we should land the flag 
change first separately and make sure that no buildbots break because of it. 
Then we can merge the simplification a few days later when we are sure it's 
stabilized, since something similar happened when we upgraded to C++17 - and 
people already had merged code that used C++17 it was really hard to revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135128

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


[PATCH] D134468: [Driver] Ignore -fmsc-version= -fms-compatibility-version= values smaller than 19

2022-09-23 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

I think we should define a policy for this. I doubt we have many users on these 
older versions but I think maybe we should give deprecation messages for at 
least one release before we drop it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134468

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


[PATCH] D133800: [Clang 15.0.1] Downgrade implicit int and implicit function declaration to warning only

2022-09-13 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

I think the easiest way to handle this is that when you have it approved here - 
push it to fork on GitHub based on the release branch and create a GitHub issue 
and write /branch aballman/llvm-project/my_branch in a comment and it will 
queue up the cherry pick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133800

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


[PATCH] D133044: [Frontend] Restore Preprocessor::getPredefines()

2022-08-31 Thread Tobias Hieta via Phabricator via cfe-commits
thieta accepted this revision.
thieta added a comment.

LGTM and seems pretty safe so I am not opposed to merge it before 15 final.

I would maybe add a link to the GitHub issue in the comment, but that's a nit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133044

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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Hmm. 15.0.0 is just a week away - I am not planning any more RCs unless we hit 
something critical. What's the risk of taking this specific change at this 
point? Would it make more sense to wait for 15.0.1? (I am guessing it's better 
if it goes into 15.0.0 or not in 15.x at all).

I am just pushing back because I don't want to introduce to much risk this late 
in the cycle - but I will defer to you guys since you are the domain experts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[PATCH] D132791: Fix formatting in release notes

2022-08-29 Thread Tobias Hieta via Phabricator via cfe-commits
thieta accepted this revision.
thieta added a comment.
This revision is now accepted and ready to land.

Thanks for doing this pass! Much appreciated. As long as you tried to build the 
docs after you changes and it passes without any warnings or errors I am happy 
for you to commit this directly to `release/15.x` - just let me know if you do 
it so I can sync the repos.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132791

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


[PATCH] D132486: SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

2022-08-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D132486#3748546 , @thakis wrote:

> Was this reviewed by anyone on the original change? As far as I can tell, 
> there was no agreement on the original change or here that reverting is the 
> way to go. Was this discussed elsewhere?
>
> (I don't have an opinion on which approach is better myself.)

The bulk of the discussion was done in this thread: 
https://discourse.llvm.org/t/rationale-for-removing-versioned-libclang-middle-ground-to-keep-it-behind-option/64410

I think the original revert in https://reviews.llvm.org/D129160 was probably a 
little hasty. But since this was raised pretty late in the 15.x release process 
this is the compromise that was the least bad IMHO. I had some offline 
discussions with Tom and Hans about it as well and the conclusion is that we 
should decide a proper way forward but the end of 15.x release window was the 
wrong place to have that discussion. I hope we can sort this out before 16 is 
branched and released.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132486

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


[PATCH] D132486: SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

2022-08-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added inline comments.



Comment at: clang/tools/libclang/CMakeLists.txt:9-12
+else()
+  # ... unless explicily overridden
+  set(LIBCLANG_SOVERSION ${CLANG_VERSION_MAJOR})
+endif()

h-vetinari wrote:
> Sorry I didn't get to comment in time, but now that the default was switched 
> from OFF to ON, the comments here are lying...
Thanks - will fix it in main as a NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132486

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


[PATCH] D132486: SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

2022-08-25 Thread Tobias Hieta via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f28d4856630: SONAME introduce option 
CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION (authored by h-vetinari, committed by 
thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132486

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/libclang.exports
  clang/tools/libclang/libclang.map
  clang/tools/libclang/linker-script-to-export-list.py

Index: clang/tools/libclang/linker-script-to-export-list.py
===
--- /dev/null
+++ clang/tools/libclang/linker-script-to-export-list.py
@@ -0,0 +1,11 @@
+import re
+import os
+import sys
+
+input_file = open(sys.argv[1])
+output_file = open(sys.argv[2], 'w')
+
+for line in input_file:
+m = re.search('^\s+(clang_[^;]+)', line)
+if m:
+output_file.write(m.group(1) + "\n")
Index: clang/tools/libclang/libclang.map
===
--- /dev/null
+++ clang/tools/libclang/libclang.map
@@ -0,0 +1,413 @@
+# If you add a symbol to this file, make sure to add it with the correct
+# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+# symbols with the version LLVM_14.
+# On platforms where versions scripts are not used, this file will be used to
+# generate a list of exports for libclang.so
+
+LLVM_13 {
+  global:
+clang_BlockCommandComment_getArgText;
+clang_BlockCommandComment_getCommandName;
+clang_BlockCommandComment_getNumArgs;
+clang_BlockCommandComment_getParagraph;
+clang_CXCursorSet_contains;
+clang_CXCursorSet_insert;
+clang_CXIndex_getGlobalOptions;
+clang_CXIndex_setGlobalOptions;
+clang_CXIndex_setInvocationEmissionPathOption;
+clang_CXRewriter_create;
+clang_CXRewriter_dispose;
+clang_CXRewriter_insertTextBefore;
+clang_CXRewriter_overwriteChangedFiles;
+clang_CXRewriter_removeText;
+clang_CXRewriter_replaceText;
+clang_CXRewriter_writeMainFileToStdOut;
+clang_CXXConstructor_isConvertingConstructor;
+clang_CXXConstructor_isCopyConstructor;
+clang_CXXConstructor_isDefaultConstructor;
+clang_CXXConstructor_isMoveConstructor;
+clang_CXXField_isMutable;
+clang_CXXMethod_isConst;
+clang_CXXMethod_isDefaulted;
+clang_CXXMethod_isPureVirtual;
+clang_CXXMethod_isStatic;
+clang_CXXMethod_isVirtual;
+clang_CXXRecord_isAbstract;
+clang_Comment_getChild;
+clang_Comment_getKind;
+clang_Comment_getNumChildren;
+clang_Comment_isWhitespace;
+clang_CompilationDatabase_dispose;
+clang_CompilationDatabase_fromDirectory;
+clang_CompilationDatabase_getAllCompileCommands;
+clang_CompilationDatabase_getCompileCommands;
+clang_CompileCommand_getArg;
+clang_CompileCommand_getDirectory;
+clang_CompileCommand_getFilename;
+clang_CompileCommand_getMappedSourceContent;
+clang_CompileCommand_getMappedSourcePath;
+clang_CompileCommand_getNumArgs;
+clang_CompileCommand_getNumMappedSources;
+clang_CompileCommands_dispose;
+clang_CompileCommands_getCommand;
+clang_CompileCommands_getSize;
+clang_Cursor_Evaluate;
+clang_Cursor_getArgument;
+clang_Cursor_getBriefCommentText;
+clang_Cursor_getCXXManglings;
+clang_Cursor_getCommentRange;
+clang_Cursor_getMangling;
+clang_Cursor_getModule;
+clang_Cursor_getNumArguments;
+clang_Cursor_getNumTemplateArguments;
+clang_Cursor_getObjCDeclQualifiers;
+clang_Cursor_getObjCManglings;
+clang_Cursor_getObjCPropertyAttributes;
+clang_Cursor_getObjCPropertyGetterName;
+clang_Cursor_getObjCPropertySetterName;
+clang_Cursor_getObjCSelectorIndex;
+clang_Cursor_getOffsetOfField;
+clang_Cursor_getParsedComment;
+clang_Cursor_getRawCommentText;
+clang_Cursor_getReceiverType;
+clang_Cursor_getSpellingNameRange;
+clang_Cursor_getStorageClass;
+clang_Cursor_getTemplateArgumentKind;
+clang_Cursor_getTemplateArgumentType;
+clang_Cursor_getTemplateArgumentUnsignedValue;
+clang_Cursor_getTemplateArgumentValue;
+clang_Cursor_getTranslationUnit;
+clang_Cursor_getVarDeclInitializer;
+clang_Cursor_hasAttrs;
+clang_Cursor_hasVarDeclExternalStorage;
+clang_Cursor_hasVarDeclGlobalStorage;
+clang_Cursor_isAnonymous;
+clang_Cursor_isAnonymousRecordDecl;
+clang_Cursor_isBitField;
+clang_Cursor_isDynamicCall;
+clang_Cursor_isExternalSymbol;
+clang_Cursor_isFunctionInlined;
+clang_Cursor_isInlineNamespace;
+clang_Cursor_isMacroBuiltin;
+clang_Cursor_isMacroFunctionLike;
+clang_Cursor_isNull;
+clang_Cursor_isObjCOptional;
+clang_Cursor_isVariadic;
+clang_EnumDecl_isScoped;
+ 

[PATCH] D132486: SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

2022-08-24 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

@jrtc27 What do you think about this patch with the default flipped? I think 
this is how it should land personally as discussed on discourse.

I have been trying to listen in how people want to handle this and I hope this 
is a good middle ground that we can agree on for 15.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132486

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


[PATCH] D132486: SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

2022-08-24 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 455088.
thieta added a comment.

Fixed variable name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132486

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/libclang.exports
  clang/tools/libclang/libclang.map
  clang/tools/libclang/linker-script-to-export-list.py

Index: clang/tools/libclang/linker-script-to-export-list.py
===
--- /dev/null
+++ clang/tools/libclang/linker-script-to-export-list.py
@@ -0,0 +1,11 @@
+import re
+import os
+import sys
+
+input_file = open(sys.argv[1])
+output_file = open(sys.argv[2], 'w')
+
+for line in input_file:
+m = re.search('^\s+(clang_[^;]+)', line)
+if m:
+output_file.write(m.group(1) + "\n")
Index: clang/tools/libclang/libclang.map
===
--- /dev/null
+++ clang/tools/libclang/libclang.map
@@ -0,0 +1,413 @@
+# If you add a symbol to this file, make sure to add it with the correct
+# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+# symbols with the version LLVM_14.
+# On platforms where versions scripts are not used, this file will be used to
+# generate a list of exports for libclang.so
+
+LLVM_13 {
+  global:
+clang_BlockCommandComment_getArgText;
+clang_BlockCommandComment_getCommandName;
+clang_BlockCommandComment_getNumArgs;
+clang_BlockCommandComment_getParagraph;
+clang_CXCursorSet_contains;
+clang_CXCursorSet_insert;
+clang_CXIndex_getGlobalOptions;
+clang_CXIndex_setGlobalOptions;
+clang_CXIndex_setInvocationEmissionPathOption;
+clang_CXRewriter_create;
+clang_CXRewriter_dispose;
+clang_CXRewriter_insertTextBefore;
+clang_CXRewriter_overwriteChangedFiles;
+clang_CXRewriter_removeText;
+clang_CXRewriter_replaceText;
+clang_CXRewriter_writeMainFileToStdOut;
+clang_CXXConstructor_isConvertingConstructor;
+clang_CXXConstructor_isCopyConstructor;
+clang_CXXConstructor_isDefaultConstructor;
+clang_CXXConstructor_isMoveConstructor;
+clang_CXXField_isMutable;
+clang_CXXMethod_isConst;
+clang_CXXMethod_isDefaulted;
+clang_CXXMethod_isPureVirtual;
+clang_CXXMethod_isStatic;
+clang_CXXMethod_isVirtual;
+clang_CXXRecord_isAbstract;
+clang_Comment_getChild;
+clang_Comment_getKind;
+clang_Comment_getNumChildren;
+clang_Comment_isWhitespace;
+clang_CompilationDatabase_dispose;
+clang_CompilationDatabase_fromDirectory;
+clang_CompilationDatabase_getAllCompileCommands;
+clang_CompilationDatabase_getCompileCommands;
+clang_CompileCommand_getArg;
+clang_CompileCommand_getDirectory;
+clang_CompileCommand_getFilename;
+clang_CompileCommand_getMappedSourceContent;
+clang_CompileCommand_getMappedSourcePath;
+clang_CompileCommand_getNumArgs;
+clang_CompileCommand_getNumMappedSources;
+clang_CompileCommands_dispose;
+clang_CompileCommands_getCommand;
+clang_CompileCommands_getSize;
+clang_Cursor_Evaluate;
+clang_Cursor_getArgument;
+clang_Cursor_getBriefCommentText;
+clang_Cursor_getCXXManglings;
+clang_Cursor_getCommentRange;
+clang_Cursor_getMangling;
+clang_Cursor_getModule;
+clang_Cursor_getNumArguments;
+clang_Cursor_getNumTemplateArguments;
+clang_Cursor_getObjCDeclQualifiers;
+clang_Cursor_getObjCManglings;
+clang_Cursor_getObjCPropertyAttributes;
+clang_Cursor_getObjCPropertyGetterName;
+clang_Cursor_getObjCPropertySetterName;
+clang_Cursor_getObjCSelectorIndex;
+clang_Cursor_getOffsetOfField;
+clang_Cursor_getParsedComment;
+clang_Cursor_getRawCommentText;
+clang_Cursor_getReceiverType;
+clang_Cursor_getSpellingNameRange;
+clang_Cursor_getStorageClass;
+clang_Cursor_getTemplateArgumentKind;
+clang_Cursor_getTemplateArgumentType;
+clang_Cursor_getTemplateArgumentUnsignedValue;
+clang_Cursor_getTemplateArgumentValue;
+clang_Cursor_getTranslationUnit;
+clang_Cursor_getVarDeclInitializer;
+clang_Cursor_hasAttrs;
+clang_Cursor_hasVarDeclExternalStorage;
+clang_Cursor_hasVarDeclGlobalStorage;
+clang_Cursor_isAnonymous;
+clang_Cursor_isAnonymousRecordDecl;
+clang_Cursor_isBitField;
+clang_Cursor_isDynamicCall;
+clang_Cursor_isExternalSymbol;
+clang_Cursor_isFunctionInlined;
+clang_Cursor_isInlineNamespace;
+clang_Cursor_isMacroBuiltin;
+clang_Cursor_isMacroFunctionLike;
+clang_Cursor_isNull;
+clang_Cursor_isObjCOptional;
+clang_Cursor_isVariadic;
+clang_EnumDecl_isScoped;
+clang_EvalResult_dispose;
+clang_EvalResult_getAsDouble;
+clang_EvalResult_getAsInt;
+clang_EvalResult_getAsLongLong;
+clang_EvalResult_getAsStr;
+clang_EvalResult_getAsUnsigned;
+

[PATCH] D132486: SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

2022-08-24 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 455087.
thieta added a comment.

Updated the option to default to ON - meaning we keep the current 
behavior found in main. This rationel for this is explained in my post here:

https://discourse.llvm.org/t/rationale-for-removing-versioned-libclang-middle-ground-to-keep-it-behind-option/64410/32


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132486

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/libclang.exports
  clang/tools/libclang/libclang.map
  clang/tools/libclang/linker-script-to-export-list.py

Index: clang/tools/libclang/linker-script-to-export-list.py
===
--- /dev/null
+++ clang/tools/libclang/linker-script-to-export-list.py
@@ -0,0 +1,11 @@
+import re
+import os
+import sys
+
+input_file = open(sys.argv[1])
+output_file = open(sys.argv[2], 'w')
+
+for line in input_file:
+m = re.search('^\s+(clang_[^;]+)', line)
+if m:
+output_file.write(m.group(1) + "\n")
Index: clang/tools/libclang/libclang.map
===
--- /dev/null
+++ clang/tools/libclang/libclang.map
@@ -0,0 +1,413 @@
+# If you add a symbol to this file, make sure to add it with the correct
+# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+# symbols with the version LLVM_14.
+# On platforms where versions scripts are not used, this file will be used to
+# generate a list of exports for libclang.so
+
+LLVM_13 {
+  global:
+clang_BlockCommandComment_getArgText;
+clang_BlockCommandComment_getCommandName;
+clang_BlockCommandComment_getNumArgs;
+clang_BlockCommandComment_getParagraph;
+clang_CXCursorSet_contains;
+clang_CXCursorSet_insert;
+clang_CXIndex_getGlobalOptions;
+clang_CXIndex_setGlobalOptions;
+clang_CXIndex_setInvocationEmissionPathOption;
+clang_CXRewriter_create;
+clang_CXRewriter_dispose;
+clang_CXRewriter_insertTextBefore;
+clang_CXRewriter_overwriteChangedFiles;
+clang_CXRewriter_removeText;
+clang_CXRewriter_replaceText;
+clang_CXRewriter_writeMainFileToStdOut;
+clang_CXXConstructor_isConvertingConstructor;
+clang_CXXConstructor_isCopyConstructor;
+clang_CXXConstructor_isDefaultConstructor;
+clang_CXXConstructor_isMoveConstructor;
+clang_CXXField_isMutable;
+clang_CXXMethod_isConst;
+clang_CXXMethod_isDefaulted;
+clang_CXXMethod_isPureVirtual;
+clang_CXXMethod_isStatic;
+clang_CXXMethod_isVirtual;
+clang_CXXRecord_isAbstract;
+clang_Comment_getChild;
+clang_Comment_getKind;
+clang_Comment_getNumChildren;
+clang_Comment_isWhitespace;
+clang_CompilationDatabase_dispose;
+clang_CompilationDatabase_fromDirectory;
+clang_CompilationDatabase_getAllCompileCommands;
+clang_CompilationDatabase_getCompileCommands;
+clang_CompileCommand_getArg;
+clang_CompileCommand_getDirectory;
+clang_CompileCommand_getFilename;
+clang_CompileCommand_getMappedSourceContent;
+clang_CompileCommand_getMappedSourcePath;
+clang_CompileCommand_getNumArgs;
+clang_CompileCommand_getNumMappedSources;
+clang_CompileCommands_dispose;
+clang_CompileCommands_getCommand;
+clang_CompileCommands_getSize;
+clang_Cursor_Evaluate;
+clang_Cursor_getArgument;
+clang_Cursor_getBriefCommentText;
+clang_Cursor_getCXXManglings;
+clang_Cursor_getCommentRange;
+clang_Cursor_getMangling;
+clang_Cursor_getModule;
+clang_Cursor_getNumArguments;
+clang_Cursor_getNumTemplateArguments;
+clang_Cursor_getObjCDeclQualifiers;
+clang_Cursor_getObjCManglings;
+clang_Cursor_getObjCPropertyAttributes;
+clang_Cursor_getObjCPropertyGetterName;
+clang_Cursor_getObjCPropertySetterName;
+clang_Cursor_getObjCSelectorIndex;
+clang_Cursor_getOffsetOfField;
+clang_Cursor_getParsedComment;
+clang_Cursor_getRawCommentText;
+clang_Cursor_getReceiverType;
+clang_Cursor_getSpellingNameRange;
+clang_Cursor_getStorageClass;
+clang_Cursor_getTemplateArgumentKind;
+clang_Cursor_getTemplateArgumentType;
+clang_Cursor_getTemplateArgumentUnsignedValue;
+clang_Cursor_getTemplateArgumentValue;
+clang_Cursor_getTranslationUnit;
+clang_Cursor_getVarDeclInitializer;
+clang_Cursor_hasAttrs;
+clang_Cursor_hasVarDeclExternalStorage;
+clang_Cursor_hasVarDeclGlobalStorage;
+clang_Cursor_isAnonymous;
+clang_Cursor_isAnonymousRecordDecl;
+clang_Cursor_isBitField;
+clang_Cursor_isDynamicCall;
+clang_Cursor_isExternalSymbol;
+clang_Cursor_isFunctionInlined;
+clang_Cursor_isInlineNamespace;
+clang_Cursor_isMacroBuiltin;
+clang_Cursor_isMacroFunctionLike;
+clang_Cursor_isNull;
+clang_Cursor_isObjCOptional;
+clang_Cursor_isVariadic;

[PATCH] D132486: Revert "libclang.so: Make SONAME the same as LLVM version"

2022-08-23 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
Herald added subscribers: fedor.sergeev, mgorny.
Herald added a project: All.
thieta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit bc39d7bdd4977a953b2e102f8f7eb479ad78984e 
.

rename CLANG_SONAME to LIBCLANG_SOVERSION

[clang][cmake] introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132486

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/libclang.exports
  clang/tools/libclang/libclang.map
  clang/tools/libclang/linker-script-to-export-list.py

Index: clang/tools/libclang/linker-script-to-export-list.py
===
--- /dev/null
+++ clang/tools/libclang/linker-script-to-export-list.py
@@ -0,0 +1,11 @@
+import re
+import os
+import sys
+
+input_file = open(sys.argv[1])
+output_file = open(sys.argv[2], 'w')
+
+for line in input_file:
+m = re.search('^\s+(clang_[^;]+)', line)
+if m:
+output_file.write(m.group(1) + "\n")
Index: clang/tools/libclang/libclang.map
===
--- /dev/null
+++ clang/tools/libclang/libclang.map
@@ -0,0 +1,413 @@
+# If you add a symbol to this file, make sure to add it with the correct
+# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+# symbols with the version LLVM_14.
+# On platforms where versions scripts are not used, this file will be used to
+# generate a list of exports for libclang.so
+
+LLVM_13 {
+  global:
+clang_BlockCommandComment_getArgText;
+clang_BlockCommandComment_getCommandName;
+clang_BlockCommandComment_getNumArgs;
+clang_BlockCommandComment_getParagraph;
+clang_CXCursorSet_contains;
+clang_CXCursorSet_insert;
+clang_CXIndex_getGlobalOptions;
+clang_CXIndex_setGlobalOptions;
+clang_CXIndex_setInvocationEmissionPathOption;
+clang_CXRewriter_create;
+clang_CXRewriter_dispose;
+clang_CXRewriter_insertTextBefore;
+clang_CXRewriter_overwriteChangedFiles;
+clang_CXRewriter_removeText;
+clang_CXRewriter_replaceText;
+clang_CXRewriter_writeMainFileToStdOut;
+clang_CXXConstructor_isConvertingConstructor;
+clang_CXXConstructor_isCopyConstructor;
+clang_CXXConstructor_isDefaultConstructor;
+clang_CXXConstructor_isMoveConstructor;
+clang_CXXField_isMutable;
+clang_CXXMethod_isConst;
+clang_CXXMethod_isDefaulted;
+clang_CXXMethod_isPureVirtual;
+clang_CXXMethod_isStatic;
+clang_CXXMethod_isVirtual;
+clang_CXXRecord_isAbstract;
+clang_Comment_getChild;
+clang_Comment_getKind;
+clang_Comment_getNumChildren;
+clang_Comment_isWhitespace;
+clang_CompilationDatabase_dispose;
+clang_CompilationDatabase_fromDirectory;
+clang_CompilationDatabase_getAllCompileCommands;
+clang_CompilationDatabase_getCompileCommands;
+clang_CompileCommand_getArg;
+clang_CompileCommand_getDirectory;
+clang_CompileCommand_getFilename;
+clang_CompileCommand_getMappedSourceContent;
+clang_CompileCommand_getMappedSourcePath;
+clang_CompileCommand_getNumArgs;
+clang_CompileCommand_getNumMappedSources;
+clang_CompileCommands_dispose;
+clang_CompileCommands_getCommand;
+clang_CompileCommands_getSize;
+clang_Cursor_Evaluate;
+clang_Cursor_getArgument;
+clang_Cursor_getBriefCommentText;
+clang_Cursor_getCXXManglings;
+clang_Cursor_getCommentRange;
+clang_Cursor_getMangling;
+clang_Cursor_getModule;
+clang_Cursor_getNumArguments;
+clang_Cursor_getNumTemplateArguments;
+clang_Cursor_getObjCDeclQualifiers;
+clang_Cursor_getObjCManglings;
+clang_Cursor_getObjCPropertyAttributes;
+clang_Cursor_getObjCPropertyGetterName;
+clang_Cursor_getObjCPropertySetterName;
+clang_Cursor_getObjCSelectorIndex;
+clang_Cursor_getOffsetOfField;
+clang_Cursor_getParsedComment;
+clang_Cursor_getRawCommentText;
+clang_Cursor_getReceiverType;
+clang_Cursor_getSpellingNameRange;
+clang_Cursor_getStorageClass;
+clang_Cursor_getTemplateArgumentKind;
+clang_Cursor_getTemplateArgumentType;
+clang_Cursor_getTemplateArgumentUnsignedValue;
+clang_Cursor_getTemplateArgumentValue;
+clang_Cursor_getTranslationUnit;
+clang_Cursor_getVarDeclInitializer;
+clang_Cursor_hasAttrs;
+clang_Cursor_hasVarDeclExternalStorage;
+clang_Cursor_hasVarDeclGlobalStorage;
+clang_Cursor_isAnonymous;
+clang_Cursor_isAnonymousRecordDecl;
+clang_Cursor_isBitField;
+clang_Cursor_isDynamicCall;
+clang_Cursor_isExternalSymbol;
+clang_Cursor_isFunctionInlined;
+clang_Cursor_isInlineNamespace;
+clang_Cursor_isMacroBuiltin;
+clang_Cursor_isMacroFunctionLike;
+

[PATCH] D127293: [clang-tidy] Ignore other members in a union if any member of it is initialized in cppcoreguidelines-pro-type-member-init

2022-08-15 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Hi @Sockke - this seems to be ready to land. Is there something holding it 
back? We ran into the same issue recently.


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

https://reviews.llvm.org/D127293

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-11 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added inline comments.



Comment at: llvm/docs/ReleaseNotes.rst:57
+
+* GCC >= 7.1
+* Clang >= 5.0

xbolva00 wrote:
> Do we have bots which uses last supported compiler versions? GCC 7.1, Clang 
> 5.0 and MSVC 16.7.
> 
> It is bad to promise something and then breakages here and there, for 
> example: https://github.com/llvm/llvm-project/issues/57057 so probably no 
> such bots.
I am not sure. I think it would be good if you posted that to discourse so that 
bot owners can reply to that. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-10 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Hi - I tried to incorporate all the feedback here and added a post to discourse 
suggesting tweaks to the developer policy - please have a look and review it: 
https://discourse.llvm.org/t/rfc-updates-to-developer-policy-around-c-standards-bump/64383


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-09 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

I think a week or two of moratorium would be good for sure. I think we can 
table this discussion for now and I will write a RFC post in discourse when I 
have time and we can discuss the details there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-09 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3709742 , @aaron.ballman 
wrote:

> One thing I think would be a definite improvement is to have done an RFC on 
> Discourse for these changes so that downstreams have a chance to weigh in on 
> the impact. The patch was put up on Jul 28 and landed about a week later 
> without any notification to the rest of the community who might not be 
> watching cfe-commits -- that's a very fast turnaround and very little 
> notification for such a significant change.

Yeah this is on me. Honestly I didn't expect it to be that much of a problem 
but rather the toolchain requirement we posted as part of it would be the big 
hurdle where bot owners would have to upgrade to get the right versions. But 
lesson learned  and we should add some more delays in the policy here: 
https://llvm.org/docs/DeveloperPolicy.html#id23 and cover the C++ standards 
upgrade.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-09 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added inline comments.



Comment at: llvm/cmake/modules/CheckCompilerVersion.cmake:16
 # _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
-set(MSVC_MIN 19.20)
+set(MSVC_MIN 19.27)
 set(MSVC_SOFT_ERROR 19.27)

glandium wrote:
> thieta wrote:
> > glandium wrote:
> > > You didn't update llvm/cmake/platforms/WinMsvc.cmake accordingly
> > AHA! That explains the fms-compatibility issue. Will you push a NFC commit 
> > or do you want me to do that?
> I don't have push access.
fixed it here: 
https://github.com/llvm/llvm-project/commit/15eaefa5fe3608b03f1abefc31129efaf9eab88e


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-09 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added inline comments.



Comment at: llvm/cmake/modules/CheckCompilerVersion.cmake:16
 # _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
-set(MSVC_MIN 19.20)
+set(MSVC_MIN 19.27)
 set(MSVC_SOFT_ERROR 19.27)

glandium wrote:
> You didn't update llvm/cmake/platforms/WinMsvc.cmake accordingly
AHA! That explains the fms-compatibility issue. Will you push a NFC commit or 
do you want me to do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-08 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3706424 , @aaron.ballman 
wrote:

> +1, thank you for thinking about how we can improve this process in the 
> future! Given that C++17 adoption across compilers has been far better than 
> C++20, I suspect the next time we bump the language version will be even more 
> of a challenge with these sort of weird issues.

I'll happily ignore that for another 3 years 

> Yeah, this is rather deeply concerning to be honest. I triple-checked and the 
> only changes in my tree were yours to compiler-rt and when I looked at the 
> configure logs, they clearly showed `compiler-rt project is disabled` in the 
> logs. It is really weird that a change to compiler-rt's cmake would have any 
> impact on Clang's ability to build when compiler-rt is disabled. I think 
> that's worth some investigative work.

Hmmm - something is really funny, with my cache nuking change it seems like 
this bot is back to working again: 
https://lab.llvm.org/buildbot/#/builders/123/builds/12164

> It seems like we might need that, but it also seems like it would be good to 
> understand why compiler-rt is impacting the rest of Clang when it's disabled. 
> That said, the goal is to get the build lab back to green as quickly as 
> possible, so I think it may make sense to land sooner rather than later.

I'll hold off a bit on this - it seems like my commit above have fixed at least 
some of the issues. There are still some msvc bots failing - but they seem to 
be failing because they have a too old version of MSVC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-08 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3706336 , @aaron.ballman 
wrote:

> That's the only reason this hasn't been reverted already. Landing sweeping 
> changes on a weekend is a good way to reduce the pain, but we really need to 
> be sure someone watches the build lab and reacts when subsequent changes 
> break everything like this.

Agreed, I think we need to update the protocol for changing the C++ standard in 
the future to account for more testing beforehand. I might push some changes to 
the policy document when all this has settled down to see if we can make sure 
it will be smoother the time we move to C++20. It's unfortunate that some stuff 
broke considering we where running some bots before it was merged and it didn't 
show any errors. And local windows builds for me have been clean as well.

>> Can you try to locally rebuild with this patch 
>> https://reviews.llvm.org/D131382 ?
>
> That improves things but the build still isn't clean:
> ...
> (FWIW, I don't know if any of the Windows builders in the lab are building 
> with /WX)

I am not sure either - but at least this removed the problem with the std=c++17 
not being passed around correctly.

>> I think all the runtime errors is because of that one above - basically we 
>> don't set std=c++17 for any of the compiler-rt projects.
>
> I wasn't building compiler-rt, so no idea why this improved things for me. 
> FWIW, he's my CMake config: `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON 
> -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_IDE=ON 
> -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" 
> -DLLVM_PARALLEL_COMPILE_JOBS=112 -DLLVM_PARALLEL_LINK_JOBS=16`

That is very odd. I would suspect that the problem was the compiler-rt not 
getting the right flag. But it seems to influence something else as well?

>> I also think we should merge https://reviews.llvm.org/D131367 for now - we 
>> can revert that later on if we think it adds to much complexity, since it 
>> will delete the bad cache values automatcially.
>
> Seems reasonable to me.

I landed this now - hopefully that fixes some of the issues seen in the bots - 
but we might need https://reviews.llvm.org/D131382 as well before they go 
green. I am not sure what the protocol is here, since @MaskRay suggested the 
change maybe we should wait for him to land it, or should we get it in ASAP to 
see if that fixes the bots?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-08 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3706263 , @aaron.ballman 
wrote:

> 



> Something odd is going on here and we might want to consider a revert of this 
> patch until we resolve it. When I do a git pull and cmake files change, 
> Visual Studio's built-in CMake support automatically re-runs the configure 
> step. This should be all that's necessary to switch the toolchain, but it 
> isn't for some reason (today's build is also failing for me with C++17 
> related issues after I did another pulldown this morning). I deleted my cache 
> explicitly and regenerated CMake from scratch and am still getting the same 
> build errors. The failures I am getting are the same as what's shown by the 
> sanitizer bot for Windows: 
> https://lab.llvm.org/buildbot/#/builders/127/builds/33980/steps/4/logs/stdio 
> (I'm using VS 2019 16.11.17 FWIW).
>
> I hope we can resolve this quickly as basically no MSVC builds are green 
> right now in the build lab.

While we can revert this one - we also need to revert all changes that add 
C++17 features at this point as well. That will be a lot of churn. Let's see if 
we can figure out what's wrong first.

Can you try to locally rebuild with this patch https://reviews.llvm.org/D131382 
?

I think all the runtime errors is because of that one above - basically we 
don't set std=c++17 for any of the compiler-rt projects.

I also think we should merge https://reviews.llvm.org/D131367 for now - we can 
revert that later on if we think it adds to much complexity, since it will 
delete the bad cache values automatcially.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-08 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3706199 , @cor3ntin wrote:

> Trying to read the logs,, notably 
> `C:\PROGRA~2\MIB055~1\2019\PROFES~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe
>  `, it would seem that this particular bot is running a version much older 
> than the current requirements  (Visual Studio 2019 16.7)
> Either I'm reading that wrong or the CMake script does not check the msvc 
> version?

The compilers are definitely version checked here: 
https://github.com/llvm/llvm-project/blob/main/llvm/cmake/modules/CheckCompilerVersion.cmake#L50

But reading the cmake log it seems like it's using a cache already and it's 
hard to say if it's using the same version of MSVC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-08 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3705579 , @Jake-Egan wrote:

> There is a failure on the AIX bot also:
> ...
> https://lab.llvm.org/buildbot/#/builders/214/builds/2707/steps/5/logs/stdio

Filed an issue here: https://github.com/llvm/llvm-project/issues/56995


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-08 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3705474 , @dyung wrote:

> We are seeing an additional failure on an internal linux bot due to the 
> change to using C++17 by default when using GNU ld:
> ...
> Switching between BFD ld and gold still fails (although gold fails for a 
> slightly different reason). Superficially it seems that switching to C++17 
> for some reason might be causing the compiler to emit debug info that these 
> older non-lld linkers cannot understand for some reason?

Filed this issue here: https://github.com/llvm/llvm-project/issues/56994


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3705236 , @royjacobson 
wrote:

> This affects people on their work branches as well, and it's not obvious that 
> it's a configuration error and not a broken master.
>
> The CMake approach sounds cleaner to me, but I don't know CMake well enough 
> to do it - if you could post a follow up patch I think it would be quite 
> helpful.

Good point - I tried a few things and came up with an approach that works here: 
https://reviews.llvm.org/D131367 - have a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3705131 , @royjacobson 
wrote:

> This seems to have been more disruptive than expected, since an existing 
> CMakeCache.txt can make LLVM compile in previous C++14 configuration. This 
> seems to make some of the bots fail in a way that makes the patches making 
> use of C++17 features seem at fault.
>
> See:
> https://github.com/llvm/llvm-project/commit/ede96de751224487aea122af8bfb4e82bc54840b#commitcomment-80507826
> https://reviews.llvm.org/rG32fd0b7fd5ab
>
> How would you feel about adding something like
>
>   #if defined(__cplusplus) && __cplusplus < 201703L
>   #error "LLVM requires at least C++17"
>   #endif
>
> to some central header, to make this switch more visible?

I am not opposed to that directly. But this seems a bit dangerous where bots 
retain the cmakecache - there must be other cases where we can't really protect 
in this way.

Another approach would be to unset CMAKE_CXX_STANDARD if it's below 17 in cmake 
directly.

But in general - I am not a huge fan of CI / bots trying to keep the cache 
around - many weird issues can arise from this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-06 Thread Tobias Hieta 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 rGb1356504e63a: [LLVM] Update C++ standard to 17 (authored by 
thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/CodingStandards.rst
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -47,6 +47,18 @@
 Update on required toolchains to build LLVM
 ---
 
+LLVM is now built with C++17 by default. This means C++17 can be used in
+the code base.
+
+The previous "soft" toolchain requirements have now been changed to "hard".
+This means that the the following versions are now required to build LLVM
+and there is no way to suppress this error.
+
+* GCC >= 7.1
+* Clang >= 5.0
+* Apple Clang >= 9.3
+* Visual Studio 2019 >= 16.7
+
 Changes to the LLVM IR
 --
 
Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -53,7 +53,7 @@
 C++ Standard Versions
 -
 
-Unless otherwise documented, LLVM subprojects are written using standard C++14
+Unless otherwise documented, LLVM subprojects are written using standard C++17
 code and avoid unnecessary vendor-specific extensions.
 
 Nevertheless, we restrict ourselves to features which are available in the
@@ -63,7 +63,13 @@
 Each toolchain provides a good reference for what it accepts:
 
 * Clang: https://clang.llvm.org/cxx_status.html
-* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx14
+
+  * libc++: https://libcxx.llvm.org/Status/Cxx17.html
+
+* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx17
+
+  * libstdc++: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017
+
 * MSVC: https://msdn.microsoft.com/en-us/library/hh567368.aspx
 
 
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,21 +4,19 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 5.1)
+set(GCC_MIN 7.1)
 set(GCC_SOFT_ERROR 7.1)
-set(CLANG_MIN 3.5)
+set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
-set(APPLECLANG_MIN 6.0)
+set(APPLECLANG_MIN 9.3)
 set(APPLECLANG_SOFT_ERROR 9.3)
 
 # https://en.wikipedia.org/wiki/Microsoft_Visual_C#Internal_version_numbering
-# _MSC_VER == 1920 MSVC++ 14.20 Visual Studio 2019 Version 16.0
 # _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
-set(MSVC_MIN 19.20)
+set(MSVC_MIN 19.27)
 set(MSVC_SOFT_ERROR 19.27)
 
-# Map the above GCC versions to dates: https://gcc.gnu.org/develop.html#timeline
-set(GCC_MIN_DATE 20150422)
+set(LIBSTDCXX_MIN 7)
 set(LIBSTDCXX_SOFT_ERROR 7)
 
 
@@ -76,22 +74,14 @@
 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
 set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
-# Test for libstdc++ version of at least 4.8 by checking for _ZNKSt17bad_function_call4whatEv.
-# Note: We should check _GLIBCXX_RELEASE when possible (i.e., for GCC 7.1 and up).
 check_cxx_source_compiles("
 #include 
 #if defined(__GLIBCXX__)
-#if __GLIBCXX__ < ${GCC_MIN_DATE}
+#if !defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE < ${LIBSTDCXX_MIN}
 #error Unsupported libstdc++ version
 #endif
 #endif
-#if defined(__GLIBCXX__)
-extern const char _ZNKSt17bad_function_call4whatEv[];
-const char *chk = _ZNKSt17bad_function_call4whatEv;
-#else
-const char *chk = \"\";
-#endif
-int main() { ++chk; return 0; }
+int main() { return 0; }
 "
   LLVM_LIBSTDCXX_MIN)
 if(NOT LLVM_LIBSTDCXX_MIN)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -58,7 +58,7 @@
 # Must go after project(..)
 include(GNUInstallDirs)
 
-set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
 set(CMAKE_CXX_STANDARD_REQUIRED YES)
 if (CYGWIN)
   # Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -20,7 +20,7 @@
 if(LLDB_BUILT_STANDALONE)
   include(LLDBStandalone)
 
-  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+  set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to 

[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-05 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 450364.
thieta added a comment.

Fixed spelling error and added links to C++ standard libraries


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/CodingStandards.rst
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -47,6 +47,18 @@
 Update on required toolchains to build LLVM
 ---
 
+LLVM is now built with C++17 by default. This means C++17 can be used in
+the code base.
+
+The previous "soft" toolchain requirements have now been changed to "hard".
+This means that the the following versions are now required to build LLVM
+and there is no way to suppress this error.
+
+* GCC >= 7.1
+* Clang >= 5.0
+* Apple Clang >= 9.3
+* Visual Studio 2019 >= 16.7
+
 Changes to the LLVM IR
 --
 
Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -53,7 +53,7 @@
 C++ Standard Versions
 -
 
-Unless otherwise documented, LLVM subprojects are written using standard C++14
+Unless otherwise documented, LLVM subprojects are written using standard C++17
 code and avoid unnecessary vendor-specific extensions.
 
 Nevertheless, we restrict ourselves to features which are available in the
@@ -63,7 +63,13 @@
 Each toolchain provides a good reference for what it accepts:
 
 * Clang: https://clang.llvm.org/cxx_status.html
-* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx14
+
+  * libc++: https://libcxx.llvm.org/Status/Cxx17.html
+
+* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx17
+
+  * libstdc++: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017
+
 * MSVC: https://msdn.microsoft.com/en-us/library/hh567368.aspx
 
 
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,21 +4,19 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 5.1)
+set(GCC_MIN 7.1)
 set(GCC_SOFT_ERROR 7.1)
-set(CLANG_MIN 3.5)
+set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
-set(APPLECLANG_MIN 6.0)
+set(APPLECLANG_MIN 9.3)
 set(APPLECLANG_SOFT_ERROR 9.3)
 
 # https://en.wikipedia.org/wiki/Microsoft_Visual_C#Internal_version_numbering
-# _MSC_VER == 1920 MSVC++ 14.20 Visual Studio 2019 Version 16.0
 # _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
-set(MSVC_MIN 19.20)
+set(MSVC_MIN 19.27)
 set(MSVC_SOFT_ERROR 19.27)
 
-# Map the above GCC versions to dates: https://gcc.gnu.org/develop.html#timeline
-set(GCC_MIN_DATE 20150422)
+set(LIBSTDCXX_MIN 7)
 set(LIBSTDCXX_SOFT_ERROR 7)
 
 
@@ -76,22 +74,14 @@
 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
 set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
-# Test for libstdc++ version of at least 4.8 by checking for _ZNKSt17bad_function_call4whatEv.
-# Note: We should check _GLIBCXX_RELEASE when possible (i.e., for GCC 7.1 and up).
 check_cxx_source_compiles("
 #include 
 #if defined(__GLIBCXX__)
-#if __GLIBCXX__ < ${GCC_MIN_DATE}
+#if !defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE < ${LIBSTDCXX_MIN}
 #error Unsupported libstdc++ version
 #endif
 #endif
-#if defined(__GLIBCXX__)
-extern const char _ZNKSt17bad_function_call4whatEv[];
-const char *chk = _ZNKSt17bad_function_call4whatEv;
-#else
-const char *chk = \"\";
-#endif
-int main() { ++chk; return 0; }
+int main() { return 0; }
 "
   LLVM_LIBSTDCXX_MIN)
 if(NOT LLVM_LIBSTDCXX_MIN)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -58,7 +58,7 @@
 # Must go after project(..)
 include(GNUInstallDirs)
 
-set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
 set(CMAKE_CXX_STANDARD_REQUIRED YES)
 if (CYGWIN)
   # Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -20,7 +20,7 @@
 if(LLDB_BUILT_STANDALONE)
   include(LLDBStandalone)
 
-  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+  set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 

[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-04 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

All right! Last call - I am going fix the spelling error and merge this 
tomorrow EU time unless someone objects. Thanks for all reviews so far!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-03 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

@nikic @thakis I fixed this issue in https://reviews.llvm.org/D131063 and it 
can be built with CXX_STANDARD=17 and OSX_DEPLOYMENT_TARGET=10.11.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-01 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3690274 , @nikic wrote:

> Given 
> https://github.com/llvm/llvm-project/blob/2bb7c54621f31a957302a4deb3d25b752acb07bd/llvm/include/llvm/Support/RWMutex.h#L22-L27,
>  it seems like this is supposed to be supported. This is probably just a 
> matter of moving the shared_mutex use behind the LLVM_USE_RW_MUTEX_IMPL guard?

Yeah - I just realized that when I checked this. Just building the rest of the 
tree now to confirm this is the only change we need and I will publish this a 
different diff first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-01 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3689157 , @thakis wrote:

> Is it expected and intentional that this increases the mac deployment target 
> to 10.12?

I wasn't aware of that - but I think it's expected since the check in RWMutex 
checks for the C++ standard and doesn't care about the deployment target for 
macOS. It seems pretty easy to change, but I wonder if that matters? 10.12 was 
released in 2016 so it's pretty old and this wouldn't affect most users of LLVM.

My gut feeling say that we should be fine with requiring 10.12 and if that 
becomes a big problem during the development phase someone could propose a 
patch to improve the check in RWMutex.

But in that case we should probably have a check for the deployment target as 
part of the cmake config and error if CXX_STANDARD > 17 and 
OSX_DEPLOYMENT_TARGET < 10.12.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-29 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3686723 , @h-vetinari 
wrote:

> I don't think the standard library can be called a vendor-specific extension, 
> and so I think this still could/should be made clearer (even though the 
> status links below would show upon inspection that there's no full support 
> yet, but that's a bit too tucked away I feel).

For libstdc++ and libc++ there are also pages with status in a specific 
version. Maybe we should link those matrixes as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-29 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3686718 , @thieta wrote:

> In D130689#3684399 , @h-vetinari 
> wrote:
>
>> It may be worth calling out that this is about C++17 core language and not 
>> the standard library?
>>
>> libstdcxx only finished C++17 support in GCC 12, and libcxx is still missing 
>> various pieces even today (much less for Clang 5).
>
> I will add a small line about this in the coding standards document.

Actually - never mind this is already well documented in the coding standards 
document:

  Unless otherwise documented, LLVM subprojects are written using standard C++17
  code and avoid unnecessary vendor-specific extensions.
  
  Nevertheless, we restrict ourselves to features which are available in the
  major toolchains supported as host compilers (see :doc:`GettingStarted` page,
  section `Software`).
  
  Each toolchain provides a good reference for what it accepts:
  
  * Clang: https://clang.llvm.org/cxx_status.html
  * GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx17
  * MSVC: https://msdn.microsoft.com/en-us/library/hh567368.aspx

I feel that's good enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-29 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3684399 , @h-vetinari 
wrote:

> It may be worth calling out that this is about C++17 core language and not 
> the standard library?
>
> libstdcxx only finished C++17 support in GCC 12, and libcxx is still missing 
> various pieces even today (much less for Clang 5).

I will add a small line about this in the coding standards document.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-29 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3686397 , @thakis wrote:

> It'd be nice if this was landed opt-in behind some cmake variable at first, 
> so that folks could try it out on their bots and see how well things work.

You can already test this with `-DCMAKE_CXX_STANDARD=17` afaik. I wonder how 
many bot owners would actually test this if we made another flag available.

Since we can already test this with a current flag maybe we should just post to 
discourse that bot-owners can test it and a date when this will be merged. But 
I don't expect this to be a big problem, when we merged the soft error earlier 
this year - it only broke one bot which was out of date.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-28 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 448262.
thieta added a comment.

Fixed unintended indentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/CodingStandards.rst
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -47,6 +47,18 @@
 Update on required toolchains to build LLVM
 ---
 
+LLVM is now built with C++17 by default. This means C++17 can be used in
+the code base.
+
+The previous "soft" toolchain requirements have now been changed to "hard".
+This means that the the following versions are now required to build LLVM
+and there is no way to supress this error.
+
+* GCC >= 7.1
+* Clang >= 5.0
+* Apple Clang >= 9.3
+* Visual Studio 2019 >= 16.7
+
 Changes to the LLVM IR
 --
 
Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -53,7 +53,7 @@
 C++ Standard Versions
 -
 
-Unless otherwise documented, LLVM subprojects are written using standard C++14
+Unless otherwise documented, LLVM subprojects are written using standard C++17
 code and avoid unnecessary vendor-specific extensions.
 
 Nevertheless, we restrict ourselves to features which are available in the
@@ -63,7 +63,7 @@
 Each toolchain provides a good reference for what it accepts:
 
 * Clang: https://clang.llvm.org/cxx_status.html
-* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx14
+* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx17
 * MSVC: https://msdn.microsoft.com/en-us/library/hh567368.aspx
 
 
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,21 +4,19 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 5.1)
+set(GCC_MIN 7.1)
 set(GCC_SOFT_ERROR 7.1)
-set(CLANG_MIN 3.5)
+set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
-set(APPLECLANG_MIN 6.0)
+set(APPLECLANG_MIN 9.3)
 set(APPLECLANG_SOFT_ERROR 9.3)
 
 # https://en.wikipedia.org/wiki/Microsoft_Visual_C#Internal_version_numbering
-# _MSC_VER == 1920 MSVC++ 14.20 Visual Studio 2019 Version 16.0
 # _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
-set(MSVC_MIN 19.20)
+set(MSVC_MIN 19.27)
 set(MSVC_SOFT_ERROR 19.27)
 
-# Map the above GCC versions to dates: https://gcc.gnu.org/develop.html#timeline
-set(GCC_MIN_DATE 20150422)
+set(LIBSTDCXX_MIN 7)
 set(LIBSTDCXX_SOFT_ERROR 7)
 
 
@@ -76,22 +74,14 @@
 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
 set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
-# Test for libstdc++ version of at least 4.8 by checking for _ZNKSt17bad_function_call4whatEv.
-# Note: We should check _GLIBCXX_RELEASE when possible (i.e., for GCC 7.1 and up).
 check_cxx_source_compiles("
 #include 
 #if defined(__GLIBCXX__)
-#if __GLIBCXX__ < ${GCC_MIN_DATE}
+#if !defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE < ${LIBSTDCXX_MIN}
 #error Unsupported libstdc++ version
 #endif
 #endif
-#if defined(__GLIBCXX__)
-extern const char _ZNKSt17bad_function_call4whatEv[];
-const char *chk = _ZNKSt17bad_function_call4whatEv;
-#else
-const char *chk = \"\";
-#endif
-int main() { ++chk; return 0; }
+int main() { return 0; }
 "
   LLVM_LIBSTDCXX_MIN)
 if(NOT LLVM_LIBSTDCXX_MIN)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -58,7 +58,7 @@
 # Must go after project(..)
 include(GNUInstallDirs)
 
-set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
 set(CMAKE_CXX_STANDARD_REQUIRED YES)
 if (CYGWIN)
   # Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -20,7 +20,7 @@
 if(LLDB_BUILT_STANDALONE)
   include(LLDBStandalone)
 
-  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+  set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 endif()
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -11,7 +11,7 @@
 

[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-28 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3684334 , @ChuanqiXu wrote:

> So it is free that developers want to use some C++17 features in a small 
> amount of code, right?

As soon as this land C++ 17 should be free to use everywhere yeah!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-28 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3684360 , @barannikov88 
wrote:

> There are a few places (primarily in ADT and Support) that check __cplusplus 
> > 201402. Do they need to be cleaned up?

Sounds good - but maybe that can be addressed in a separate diff unless they 
make the build fail after this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-28 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 448261.
thieta added a comment.

Address some old comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/CodingStandards.rst
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -47,6 +47,18 @@
 Update on required toolchains to build LLVM
 ---
 
+LLVM is now built with C++17 by default. This means C++17 can be used in
+the code base.
+
+The previous "soft" toolchain requirements have now been changed to "hard".
+This means that the the following versions are now required to build LLVM
+and there is no way to supress this error.
+
+* GCC >= 7.1
+* Clang >= 5.0
+* Apple Clang >= 9.3
+* Visual Studio 2019 >= 16.7
+
 Changes to the LLVM IR
 --
 
Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -53,7 +53,7 @@
 C++ Standard Versions
 -
 
-Unless otherwise documented, LLVM subprojects are written using standard C++14
+Unless otherwise documented, LLVM subprojects are written using standard C++17
 code and avoid unnecessary vendor-specific extensions.
 
 Nevertheless, we restrict ourselves to features which are available in the
@@ -63,7 +63,7 @@
 Each toolchain provides a good reference for what it accepts:
 
 * Clang: https://clang.llvm.org/cxx_status.html
-* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx14
+* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx17
 * MSVC: https://msdn.microsoft.com/en-us/library/hh567368.aspx
 
 
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,21 +4,19 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 5.1)
+set(GCC_MIN 7.1)
 set(GCC_SOFT_ERROR 7.1)
-set(CLANG_MIN 3.5)
+set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
-set(APPLECLANG_MIN 6.0)
+set(APPLECLANG_MIN 9.3)
 set(APPLECLANG_SOFT_ERROR 9.3)
 
 # https://en.wikipedia.org/wiki/Microsoft_Visual_C#Internal_version_numbering
-# _MSC_VER == 1920 MSVC++ 14.20 Visual Studio 2019 Version 16.0
 # _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
-set(MSVC_MIN 19.20)
+set(MSVC_MIN 19.27)
 set(MSVC_SOFT_ERROR 19.27)
 
-# Map the above GCC versions to dates: https://gcc.gnu.org/develop.html#timeline
-set(GCC_MIN_DATE 20150422)
+set(LIBSTDCXX_MIN 7)
 set(LIBSTDCXX_SOFT_ERROR 7)
 
 
@@ -76,23 +74,15 @@
 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
 set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
-# Test for libstdc++ version of at least 4.8 by checking for _ZNKSt17bad_function_call4whatEv.
-# Note: We should check _GLIBCXX_RELEASE when possible (i.e., for GCC 7.1 and up).
 check_cxx_source_compiles("
-#include 
-#if defined(__GLIBCXX__)
-#if __GLIBCXX__ < ${GCC_MIN_DATE}
-#error Unsupported libstdc++ version
-#endif
-#endif
-#if defined(__GLIBCXX__)
-extern const char _ZNKSt17bad_function_call4whatEv[];
-const char *chk = _ZNKSt17bad_function_call4whatEv;
-#else
-const char *chk = \"\";
-#endif
-int main() { ++chk; return 0; }
-"
+  #include 
+  #if defined(__GLIBCXX__)
+  #if !defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE < ${LIBSTDCXX_MIN}
+  #error Unsupported libstdc++ version
+  #endif
+  #endif
+  int main() { return 0; }
+  "
   LLVM_LIBSTDCXX_MIN)
 if(NOT LLVM_LIBSTDCXX_MIN)
   message(FATAL_ERROR "libstdc++ version must be at least ${GCC_MIN}.")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -58,7 +58,7 @@
 # Must go after project(..)
 include(GNUInstallDirs)
 
-set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
 set(CMAKE_CXX_STANDARD_REQUIRED YES)
 if (CYGWIN)
   # Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -20,7 +20,7 @@
 if(LLDB_BUILT_STANDALONE)
   include(LLDBStandalone)
 
-  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+  set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 

[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-28 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3684330 , @mehdi_amini 
wrote:

> What does it mean exactly? We can't use **anything** C++17 without writing it 
> in the coding standards?
> I'm not sure it'll be manageable: how do you see this playing out?

Probably poorly worded - what I was trying to convey is that if we want to use 
a C++17 feature that's really impactful on the syntax/readability we should 
probably consider recommending ways to use it in the coding standards, similar 
to our guidelines on using for() loops 
(https://llvm.org/docs/CodingStandards.html#use-range-based-for-loops-wherever-possible)
 or the auto keyword 
(https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D129446: [clang][driver] Find Apple default SDK path

2022-07-28 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Ping - any thoughts on this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129446

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-07-28 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added reviewers: mehdi_amini, jyknight, jhenderson, hans, tstellar, 
cor3ntin, MaskRay.
Herald added subscribers: ayermolo, StephenFan, mgorny.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
thieta requested review of this revision.
Herald added subscribers: lldb-commits, cfe-commits, yota9.
Herald added projects: clang, LLDB, LLVM.

Also make the soft toolchain requirements hard. This allows
us to use C++17 features in LLVM now. Remember that if we want
to adopt some new feature in a bigger way it should be discussed
and added to the CodingStandard document.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130689

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/CheckCompilerVersion.cmake
  llvm/docs/CodingStandards.rst
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -47,6 +47,18 @@
 Update on required toolchains to build LLVM
 ---
 
+LLVM is now built with C++17 by default. This means C++17 can be used in
+the code base.
+
+The previous "soft" toolchain requirements have now been changed to "hard".
+This means that the the following versions are now required to build LLVM
+and there is no way to supress this error.
+
+* GCC >= 7.1
+* Clang >= 5.0
+* Apple Clang >= 9.3
+* Visual Studio 2019 >= 16.7
+
 Changes to the LLVM IR
 --
 
Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -53,7 +53,7 @@
 C++ Standard Versions
 -
 
-Unless otherwise documented, LLVM subprojects are written using standard C++14
+Unless otherwise documented, LLVM subprojects are written using standard C++17
 code and avoid unnecessary vendor-specific extensions.
 
 Nevertheless, we restrict ourselves to features which are available in the
@@ -63,7 +63,7 @@
 Each toolchain provides a good reference for what it accepts:
 
 * Clang: https://clang.llvm.org/cxx_status.html
-* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx14
+* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx17
 * MSVC: https://msdn.microsoft.com/en-us/library/hh567368.aspx
 
 
Index: llvm/cmake/modules/CheckCompilerVersion.cmake
===
--- llvm/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/cmake/modules/CheckCompilerVersion.cmake
@@ -4,21 +4,21 @@
 
 include(CheckCXXSourceCompiles)
 
-set(GCC_MIN 5.1)
+set(GCC_MIN 7.1)
 set(GCC_SOFT_ERROR 7.1)
-set(CLANG_MIN 3.5)
+set(CLANG_MIN 5.0)
 set(CLANG_SOFT_ERROR 5.0)
-set(APPLECLANG_MIN 6.0)
+set(APPLECLANG_MIN 9.3)
 set(APPLECLANG_SOFT_ERROR 9.3)
 
 # https://en.wikipedia.org/wiki/Microsoft_Visual_C#Internal_version_numbering
 # _MSC_VER == 1920 MSVC++ 14.20 Visual Studio 2019 Version 16.0
 # _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
-set(MSVC_MIN 19.20)
+set(MSVC_MIN 19.27)
 set(MSVC_SOFT_ERROR 19.27)
 
 # Map the above GCC versions to dates: https://gcc.gnu.org/develop.html#timeline
-set(GCC_MIN_DATE 20150422)
+set(LIBSTDCXX_MIN 7)
 set(LIBSTDCXX_SOFT_ERROR 7)
 
 
@@ -79,20 +79,14 @@
 # Test for libstdc++ version of at least 4.8 by checking for _ZNKSt17bad_function_call4whatEv.
 # Note: We should check _GLIBCXX_RELEASE when possible (i.e., for GCC 7.1 and up).
 check_cxx_source_compiles("
-#include 
-#if defined(__GLIBCXX__)
-#if __GLIBCXX__ < ${GCC_MIN_DATE}
-#error Unsupported libstdc++ version
-#endif
-#endif
-#if defined(__GLIBCXX__)
-extern const char _ZNKSt17bad_function_call4whatEv[];
-const char *chk = _ZNKSt17bad_function_call4whatEv;
-#else
-const char *chk = \"\";
-#endif
-int main() { ++chk; return 0; }
-"
+  #include 
+  #if defined(__GLIBCXX__)
+  #if !defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE < ${LIBSTDCXX_MIN}
+  #error Unsupported libstdc++ version
+  #endif
+  #endif
+  int main() { return 0; }
+  "
   LLVM_LIBSTDCXX_MIN)
 if(NOT LLVM_LIBSTDCXX_MIN)
   message(FATAL_ERROR "libstdc++ version must be at least ${GCC_MIN}.")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -58,7 +58,7 @@
 # Must go after project(..)
 include(GNUInstallDirs)
 
-set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
 set(CMAKE_CXX_STANDARD_REQUIRED YES)
 if (CYGWIN)
   # Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in
Index: lldb/CMakeLists.txt
===
--- 

[PATCH] D129446: [clang][driver] Find Apple default SDK path

2022-07-10 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added reviewers: egorzhdan, t.p.northover, dexonsmith, ldionne.
Herald added a project: All.
thieta requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

Currently if you download clang and install it on macOS it will
not be able to compile C++ applications out of the box. The
driver can't find the SDK path without help of SDKROOT or -isysroot.

For the Xcode toolchain this is always supplied with xcrun or
the wrapper binary that sets the correct SDKROOT.

But for new users this might be very confusing and since the
path for the SDKs is stable unless the user decide to install
Xcode to an alternative path we can try a naive search for it.

Currently this patch fails a bunch of tests that seems to assume
that no SDK is found and then the macosx-min stuff is set to
something very low. This changes when you have a real SDK.

I also haven't added any new tests to test this since I am didn't
want to assume that Xcode is installed on the system running the
tests. Does anyone have a good idea for testing this?

Tagged a bunch of apple people that have touched the driver
recently - but feel free to add more in here if needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129446

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -18,7 +18,9 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Support/Path.h"
@@ -2039,6 +2041,30 @@
 
 } // namespace
 
+static const std::string guessSDKPath(const llvm::Triple::OSType OSType) {
+  std::string Platform;
+
+  if (OSType == llvm::Triple::OSType::MacOSX || OSType == 
llvm::Triple::OSType::Darwin) {
+// Assume macOS when nothing specific is specified.
+Platform = "MacOSX";
+  } else if (OSType == llvm::Triple::OSType::IOS) {
+Platform = "IPhoneOS";
+  } else if (OSType == llvm::Triple::OSType::TvOS) {
+Platform = "AppleTVOS";
+  } else if (OSType == llvm::Triple::OSType::WatchOS) {
+Platform = "WatchOS";
+  }
+
+  std::string GuessPath = (
+"/Applications/Xcode.app/Contents/Developer/Platforms/"
++ Platform
++ ".platform/Developer/SDKs/"
++ Platform
++ ".sdk");
+
+  return GuessPath;
+}
+
 void Darwin::AddDeploymentTarget(DerivedArgList ) const {
   const OptTable  = getDriver().getOpts();
 
@@ -2058,6 +2084,14 @@
 Args.append(Args.MakeSeparateArg(
 nullptr, Opts.getOption(options::OPT_isysroot), env));
   }
+} else {
+  // If the user doesn't pass -isysroot nor SDKROOT we will try to guess
+  // the standard path of the SDK (in /Applications/Xcode.app ...)
+  const std::string GuessPath = guessSDKPath(getTriple().getOS());
+  if (getVFS().exists(GuessPath)) {
+Args.append(Args.MakeSeparateArg(
+  nullptr, Opts.getOption(options::OPT_isysroot), GuessPath));
+  }
 }
   }
 
@@ -2251,6 +2285,7 @@
 return DriverArgs.getLastArgValue(options::OPT_isysroot);
   if (!getDriver().SysRoot.empty())
 return getDriver().SysRoot;
+
   return "/";
 }
 


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -18,7 +18,9 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Support/Path.h"
@@ -2039,6 +2041,30 @@
 
 } // namespace
 
+static const std::string guessSDKPath(const llvm::Triple::OSType OSType) {
+  std::string Platform;
+
+  if (OSType == llvm::Triple::OSType::MacOSX || OSType == llvm::Triple::OSType::Darwin) {
+// Assume macOS when nothing specific is specified.
+Platform = "MacOSX";
+  } else if (OSType == llvm::Triple::OSType::IOS) {
+Platform = "IPhoneOS";
+  } else if (OSType == llvm::Triple::OSType::TvOS) {
+Platform = "AppleTVOS";
+  } else if (OSType == llvm::Triple::OSType::WatchOS) {
+Platform = "WatchOS";
+  }
+
+  std::string GuessPath = (
+"/Applications/Xcode.app/Contents/Developer/Platforms/"
++ Platform
++ ".platform/Developer/SDKs/"
++ Platform
++ ".sdk");
+
+  return GuessPath;
+}
+
 void Darwin::AddDeploymentTarget(DerivedArgList ) const {
   const OptTable  = getDriver().getOpts();
 
@@ -2058,6 +2084,14 @@
 

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

2022-07-07 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added inline comments.



Comment at: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp:42
+  : Ctx(Context), SM(Context.getSourceManager()) {
+CurrentFileName = astFilePath.str();
+  }

steakhal wrote:
> Why is this not initialized in the //initialized-list// like the rest of the 
> members?
Ah no reason - I think I moved this around a few times so it just happened to 
end up here. I will push a NFC with that.



Comment at: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp:149
+  if (!CI)
+CI = new CompilerInstance();
+

steakhal wrote:
> What takes the ownership of `CI`? When is it deleted?
I don't think anyone takes ownership and it's never properly deleted. I don't 
think we really need to since this application just runs and exits and never 
really keep any state. Do you see a problem with it never being deleted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128704

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


  1   2   >