llvm-project/clang/test/Modules/add-remove-irrelevant-module-map.m
Jan Svoboda 6924a49690 [clang][modules] Account for non-affecting inputs in ASTWriter
In D106876, we stopped serializing module map files that didn't affect compilation of the current module.

However, since each `SourceLocation` is simply an offset into `SourceManager`'s global buffer of concatenated input files in, these need to be adjusted during serialization. Otherwise, they can incorrectly point after the buffer or into subsequent input file.

This patch starts adjusting `SourceLocation`s, `FileID`s and other `SourceManager` offsets in `ASTWriter`.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D136624
2022-11-01 19:31:51 -07:00

33 lines
966 B
Objective-C

// RUN: rm -rf %t && mkdir %t
// RUN: split-file %s %t
//--- a/module.modulemap
module a {}
//--- b/module.modulemap
module b {}
//--- c/module.modulemap
module c {}
//--- module.modulemap
module m { header "m.h" }
//--- m.h
@import c;
//--- test-simple.m
// expected-no-diagnostics
@import m;
// Build modules with the non-affecting "a/module.modulemap".
// RUN: %clang_cc1 -I %t/a -I %t/b -I %t/c -I %t -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -fdisable-module-hash %t/test-simple.m -verify
// RUN: mv %t/cache %t/cache-with
// Build modules without the non-affecting "a/module.modulemap".
// RUN: rm -rf %t/a/module.modulemap
// RUN: %clang_cc1 -I %t/a -I %t/b -I %t/c -I %t -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -fdisable-module-hash %t/test-simple.m -verify
// RUN: mv %t/cache %t/cache-without
// Check that the PCM files are bit-for-bit identical.
// RUN: diff %t/cache-with/m.pcm %t/cache-without/m.pcm