Changes

Summary

  1. [clang][Fuchsia] Add additional unit test for availability attr (details)
  2. When generating C++ code, use C++ string escaping. (details)
  3. [ELF] Change SharedFile::soName from std::string to StringRef (details)
  4. [clangd] Print current request context along with the stack trace (details)
  5. [gn build] Port 045695f85cb8 (details)
  6. Bitcode: Use Expected<T>::takeError() and moveInto() more, NFC (details)
  7. [lld-macho][nfc] Test that we don't emit undef symbol errors for dead code (details)
  8. [clangd] Flush stderr after signal handlers run, so we always get the full stack/crash info (details)
  9. [lldb] Configure CMake policy CMP0116 for standalone builds (details)
  10. [ELF] Simplify sortSection. NFC (details)
  11. [lld-macho] Fix incremental builds (details)
  12. [lld-macho] Fix incremental build (again) from D112485 (details)
Commit 07bed3ae52b0a94d9de7f12ca5f2a92589c6c4b6 by haowei
[clang][Fuchsia] Add additional unit test for availability attr

This change adds additional unit tests for availability attribute
support for Fuchsia platform.

Differential Revision: https://reviews.llvm.org/D112271
The file was modifiedclang/test/Sema/attr-availability-fuchsia.c
Commit 16e530d43b2b24bc30e0afa1f74dc3ea475fde5b by jeffniu22
When generating C++ code, use C++ string escaping.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D112468
The file was modifiedmlir/include/mlir/TableGen/CodeGenHelpers.h
The file was modifiedmlir/tools/mlir-tblgen/RewriterGen.cpp
The file was modifiedmlir/test/mlir-tblgen/predicate.td
The file was modifiedmlir/tools/mlir-tblgen/CodeGenHelpers.cpp
The file was modifiedmlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Commit 4d9f6caee3ac159cd4907f31e0716a3797de5bf0 by i
[ELF] Change SharedFile::soName from std::string to StringRef
The file was modifiedlld/ELF/Driver.cpp
The file was modifiedlld/ELF/InputFiles.h
Commit 045695f85cb8cdf9b8373123749efe1781f337b4 by sam.mccall
[clangd] Print current request context along with the stack trace

Motivation:

At the moment it is hard to attribute a clangd crash to a specific request out of all in-flight requests that might be processed concurrently. So before we can act on production clangd crashes, we have to do quite some digging through the log tables populated by our in-house VSCode extension or sometimes even directly reach out to the affected developer. Having all the details needed to reproduce a crash printed alongside its stack trace has a potential to save us quite some time, that could better be spent on fixing the actual problems.

Implementation approach:

* introduce `ThreadCrashReporter` class that allows to set a temporary signal handler for the current thread
* follow RAII pattern to simplify printing context for crashes occurring within a particular scope
* hold `std::function` as a handler to allow capturing context to print
* set local `ThreadCrashReporter` within `JSONTransport::loop()` to print request JSON for main thread crashes, and in `ASTWorker::run()` to print the file paths, arguments and contents for worker thread crashes

`ThreadCrashReporter` currently allows only one active handler per thread, but the approach can be extended to support stacked handlers printing context incrementally.

Example output for main thread crashes:

  ```
  ...
  #15 0x00007f7ddc819493 __libc_start_main (/lib64/libc.so.6+0x23493)
  #16 0x000000000249775e _start (/home/emmablink/local/llvm-project/build/bin/clangd+0x249775e)
  Signalled while processing message:
  {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"uri": "file:///home/emmablink/test.cpp", "languageId": "cpp", "version": 1, "text": "template <typename>\nclass Bar {\n  Bar<int> *variables_to_modify;\n  foo() {\n    for (auto *c : *variables_to_modify)\n      delete c;\n  }\n};\n"}}}
  ```

Example output for AST worker crashes:

  ```
  ...
  #41 0x00007fb18304c14a start_thread pthread_create.c:0:0
  #42 0x00007fb181bfcdc3 clone (/lib64/libc.so.6+0xfcdc3)
  Signalled during AST action:
  Filename: test.cpp
  Directory: /home/emmablink
  Command Line: /usr/bin/clang -resource-dir=/data/users/emmablink/llvm-project/build/lib/clang/14.0.0 -- /home/emmablink/test.cpp
  Version: 1
  Contents:
  template <typename>
  class Bar {
    Bar<int> *variables_to_modify;
    foo() {
      for (auto *c : *variables_to_modify)
        delete c;
    }
  };
  ```

Testing:

The unit test covers the thread-localitity and nesting aspects of `ThreadCrashReporter`. There might be way to set up a lit-based integration test that would spawn clangd, send a message to it, signal it immediately and check the standard output, but this might be prone to raceconditions.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D109506
The file was modifiedclang-tools-extra/clangd/unittests/CMakeLists.txt
The file was addedclang-tools-extra/clangd/support/ThreadCrashReporter.h
The file was addedclang-tools-extra/clangd/test/crash.test
The file was modifiedclang-tools-extra/clangd/tool/ClangdMain.cpp
The file was modifiedclang-tools-extra/clangd/JSONTransport.cpp
The file was modifiedclang-tools-extra/clangd/support/CMakeLists.txt
The file was modifiedclang-tools-extra/clangd/TUScheduler.cpp
The file was addedclang-tools-extra/clangd/support/ThreadCrashReporter.cpp
The file was addedclang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp
Commit df05babc9606011fc9f4013b21ba6ed9fe4aa74c by llvmgnsyncbot
[gn build] Port 045695f85cb8
The file was modifiedllvm/utils/gn/secondary/clang-tools-extra/clangd/support/BUILD.gn
The file was modifiedllvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
Commit b12a864c2930acc6f71e3bf248b663470d356db5 by Duncan P. N. Exon Smith
Bitcode: Use Expected<T>::takeError() and moveInto() more, NFC

Avoid naming some Expected<T> values in the Bitcode reader by using
takeError() and moveInto() more often. This follows the smaller set of
changes included in 2410fb4616b2c08bbaddd44e6c11da8285fbd1d3.
The file was modifiedllvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
The file was modifiedllvm/lib/Bitcode/Reader/BitcodeReader.cpp
The file was modifiedllvm/lib/Bitcode/Reader/MetadataLoader.cpp
Commit 413e249a47ce82b44a656dc3df32b584fc3036d5 by jezng
[lld-macho][nfc] Test that we don't emit undef symbol errors for dead code

This is what ld64 does too, so we have parity here (though I think ld64
still removes dead code more effectively than we do...)

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D112485
The file was modifiedlld/test/MachO/treat-undef-sym.s
Commit aa1ac2ae451e54dfa19dce2794800bbd034e2194 by sam.mccall
[clangd] Flush stderr after signal handlers run, so we always get the full stack/crash info
The file was modifiedclang-tools-extra/clangd/tool/ClangdMain.cpp
Commit 65dae8b2f20c32632e48922456a305504f4e6fbe by davelee.com
[lldb] Configure CMake policy CMP0116 for standalone builds

Using CMake >=3.20 results in many warnings about this new policy. This change silences the warnings by explicitly declaring use of the "OLD" behavior.

This applies D101083 to LLDBStandalone.cmake.

Differential Revision: https://reviews.llvm.org/D112497
The file was modifiedlldb/cmake/modules/LLDBStandalone.cmake
Commit 3b42fc8a07c37e47efae80c931eff7e63103e0e9 by i
[ELF] Simplify sortSection. NFC
The file was modifiedlld/ELF/Writer.cpp
Commit d3ddd569eb78ae4e042502775704bd27c0c0a543 by jezng
[lld-macho] Fix incremental builds
The file was modifiedlld/test/MachO/treat-undef-sym.s
Commit 46ef187dccd3be85d0490cf3e5dc73607a4a2ef2 by vyng
[lld-macho] Fix incremental build (again) from D112485
The file was modifiedlld/test/MachO/treat-undef-sym.s