SuccessChanges

Summary

  1. [NFC] Introduce function getIVStep for further reuse (details)
  2. [NFC] Detect IV increment expressed as uadd_with_overflow and usub_with_overflow (details)
  3. [clangd] Use flags from open files when opening headers they include (details)
Commit 8d835f42a57f15c0b9053bd7c41ea95821a40e5f by mkazantsev
[NFC] Introduce function getIVStep for further reuse
The file was modifiedllvm/lib/CodeGen/CodeGenPrepare.cpp
Commit 9fac8496eae809c288096037d7a3f5a1a3d04c7a by mkazantsev
[NFC] Detect IV increment expressed as uadd_with_overflow and usub_with_overflow

Current callers do not call it with such argument, so this is NFC.
But for further changes, it can be very useful to detect such cases.
The file was modifiedllvm/lib/CodeGen/CodeGenPrepare.cpp
Commit 588db1ccff713332c1f9358f423e682f18c06e8e by sam.mccall
[clangd] Use flags from open files when opening headers they include

Currently our strategy for getting header compile flags is something like:

A) look for flags for the header in compile_commands.json
   This basically never works, build systems don't generate this info.
B) try to match to an impl file in compile_commands.json and use its flags
   This only (mostly) works if the headers are in the same project.
C) give up and use fallback flags
   This kind of works for stdlib in the default configuration, and
   otherwise doesn't.

Obviously there are big gaps here.

This patch inserts a new attempt between A and B: if the header is
transitively included by any open file (whether same project or not),
then we use its compile command.

This doesn't make any attempt to solve some related problems:
- parsing non-self-contained header files in context (importing PP state)
- using the compile flags of non-opened candidate files found in the index

Fixes https://github.com/clangd/clangd/issues/123
Fixes https://github.com/clangd/clangd/issues/695
See https://github.com/clangd/clangd/issues/519

Differential Revision: https://reviews.llvm.org/D97351
The file was modifiedclang-tools-extra/clangd/Headers.h
The file was modifiedclang-tools-extra/clangd/test/memory_tree.test
The file was modifiedclang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
The file was modifiedclang/unittests/Tooling/CompilationDatabaseTest.cpp
The file was modifiedclang/lib/Tooling/InterpolatingCompilationDatabase.cpp
The file was modifiedclang/include/clang/Tooling/CompilationDatabase.h
The file was modifiedclang-tools-extra/clangd/TUScheduler.cpp
The file was modifiedclang-tools-extra/clangd/TUScheduler.h