21 changes: 11 additions & 10 deletions clang/test/Modules/ASTSignature.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -iquote %S/Inputs/ASTHash/ -fsyntax-only -fmodules \
// RUN: -fimplicit-module-maps -fmodules-strict-context-hash \
// RUN: %clang_cc1 -iquote %S/Inputs/ASTHash/ -fsyntax-only \
// RUN: -fmodules -fimplicit-module-maps -fmodules-strict-context-hash \
// RUN: -fmodules-cache-path=%t -fdisable-module-hash %s
// RUN: cp %t/MyHeader2.pcm %t1.pcm
// RUN: rm -rf %t
// RUN: %clang_cc1 -nostdinc++ -iquote %S/Inputs/ASTHash/ -fsyntax-only \
// RUN: -fmodules -fimplicit-module-maps -fmodules-strict-context-hash \
// RUN: -fmodules-cache-path=%t -fdisable-module-hash %s
// RUN: cp %t/MyHeader2.pcm %t2.pcm
// RUN: llvm-bcanalyzer --dump --disable-histogram %t1.pcm > %t1.dump
// RUN: llvm-bcanalyzer --dump --disable-histogram %t2.pcm > %t2.dump
// RUN: llvm-bcanalyzer --dump --disable-histogram --show-binary-blobs %t1.pcm > %t1.dump
// RUN: llvm-bcanalyzer --dump --disable-histogram --show-binary-blobs %t2.pcm > %t2.dump
// RUN: cat %t1.dump %t2.dump | FileCheck %s

#include "my_header_2.h"

my_int var = 42;

// CHECK: [[AST_BLOCK_HASH:<AST_BLOCK_HASH .*>]]
// CHECK: [[SIGNATURE:<SIGNATURE .*>]]
// CHECK: [[AST_BLOCK_HASH]]
// CHECK-NOT: [[SIGNATURE]]
// The modules built by this test are designed to yield the same AST. If this
// test fails, it means that the AST block is has become non-relocatable.
// CHECK: <AST_BLOCK_HASH abbrevid={{[0-9]+}}/> blob data = '[[AST_BLOCK_HASH:.*]]'
// CHECK: <SIGNATURE abbrevid={{[0-9]+}}/> blob data = '[[SIGNATURE:.*]]'
// CHECK: <AST_BLOCK_HASH abbrevid={{[0-9]+}}/> blob data = '[[AST_BLOCK_HASH]]'
// CHECK-NOT: <SIGNATURE abbrevid={{[0-9]+}}/> blob data = '[[SIGNATURE]]'
// The modules built by this test are designed to yield the same AST but distinct AST files.
// If this test fails, it means that either the AST block has become non-relocatable,
// or the file signature stopped hashing some parts of the AST file.
28 changes: 28 additions & 0 deletions clang/test/Modules/diag-mappings-affecting.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Test that pruning non-affecting input files happens before serializing
// diagnostic pragma mappings.

// RUN: rm -rf %t
// RUN: split-file %s %t

// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
// RUN: -I %t/include_a -I %t/include_textual -fsyntax-only %t/tu.c

//--- tu.c
#include "a1.h"

//--- include_a/module.modulemap
module A {
header "a1.h"
header "a2.h"
}
//--- include_a/a1.h
#include "textual.h" // This will also load the non-affecting
// include_textual/module.modulemap.
#include "a2.h"
//--- include_a/a2.h
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wfloat-equal"
#pragma clang diagnostic pop

//--- include_textual/module.modulemap
//--- include_textual/textual.h