llvm-project/clang/unittests
Ben Barham 766a08df12 [Frontend] Only compile modules if not already finalized
It was possible to re-add a module to a shared in-memory module cache
when search paths are changed. This can eventually cause a crash if the
original module is referenced after this occurs.
  1. Module A depends on B
  2. B exists in two paths C and D
  3. First run only has C on the search path, finds A and B and loads
     them
  4. Second run adds D to the front of the search path. A is loaded and
     contains a reference to the already compiled module from C. But
     searching finds the module from D instead, causing a mismatch
  5. B and the modules that depend on it are considered out of date and
     thus rebuilt
  6. The recompiled module A is added to the in-memory cache, freeing
     the previously inserted one

This can never occur from a regular clang process, but is very easy to
do through the API - whether through the use of a shared case or just
running multiple compilations from a single `CompilerInstance`. Update
the compilation to return early if a module is already finalized so that
the pre-condition in the in-memory module cache holds.

Resolves rdar://78180255

Differential Revision: https://reviews.llvm.org/D105328
2021-07-15 18:27:08 -07:00
..
AST [clang] Refactor AST printing tests to share more infrastructure 2021-07-14 19:44:18 -04:00
ASTMatchers [ASTMatchers] Fix bug in `hasUnaryOperand` 2021-06-16 20:17:56 +00:00
Analysis Bump googletest to 1.10.0 2021-05-14 19:16:31 +02:00
Basic [clang][cli] Generate and round-trip language options 2021-02-09 10:18:55 +01:00
CodeGen [clang-repl] Recommit "Land initial infrastructure for incremental parsing" 2021-05-13 06:30:29 +00:00
CrossTU [analyzer][CTU] API for CTU macro expansions 2021-02-22 11:12:22 +01:00
DirectoryWatcher Revert "Re-Revert "DirectoryWatcher: add an implementation for Windows"" 2021-06-19 09:19:52 -07:00
Driver [clang] accept -fsanitize-ignorelist= in addition to -fsanitize-blacklist= 2021-05-04 10:24:00 -04:00
Format [clang-format] Make BreakAfterReturnType work with K&R C functions 2021-07-14 14:38:02 -07:00
Frontend PR51018: Remove explicit conversions from SmallString to StringRef to future-proof against C++23 2021-07-08 13:37:57 -07:00
Index [index] Improve macro indexing support 2021-04-06 09:12:14 -07:00
Interpreter Reland "[clang-repl] Implement partial translation units and error recovery." 2021-07-12 15:21:22 +00:00
Introspection [AST] Fix DeclarationNameInfo introspection 2021-04-26 18:49:13 +01:00
Lex [Lexer] Fix bug in `makeFileCharRange` called on split tokens. 2021-07-14 14:36:31 +00:00
Rename Bump googletest to 1.10.0 2021-05-14 19:16:31 +02:00
Rewrite [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug 2019-08-15 21:17:48 +00:00
Sema [clang][CodeComplete] Fix crash on ParenListExprs 2021-02-08 13:16:49 +01:00
Serialization [Frontend] Only compile modules if not already finalized 2021-07-15 18:27:08 -07:00
StaticAnalyzer [clang][Analyzer] Add symbol uninterestingness to bug report. 2021-07-15 10:02:18 +02:00
Tooling [libTooling] Add support for implicit `this` to `buildAddressOf`. 2021-07-07 17:35:04 +00:00
libclang [libclang] Add CXRewriter to libclang API 2020-09-04 14:17:03 -07:00
CMakeLists.txt [clang-repl] Recommit "Land initial infrastructure for incremental parsing" 2021-05-13 06:30:29 +00:00