Do not validate pch when -fno-validate-pch is set
authorYaxun Liu <Yaxun.Liu@amd.com>
Wed, 7 Sep 2016 18:40:20 +0000 (18:40 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Wed, 7 Sep 2016 18:40:20 +0000 (18:40 +0000)
commit43712e05eafef51596be8d7415874514d68571c6
tree8c0a1da002f6263411210b010f33b5d4c9a31397
parent90658fff1bd90c229136c869f69c5cc96c8f0a31
Do not validate pch when -fno-validate-pch is set

There is a bug causing pch to be validated even though -fno-validate-pch is set. This patch fixes it.

ASTReader relies on ASTReaderListener to initialize SuggestedPredefines, which is required for compilations using PCH. Before this change, PCHValidator is the default ASTReaderListener. After this change, when -fno-validate-pch is set, PCHValidator is disabled, but we need a replacement ASTReaderListener to initialize SuggestedPredefines. Class SimpleASTReaderListener is implemented for this purpose.

This change only affects -fno-validate-pch. There is no functional change if -fno-validate-pch is not set.

If -fno-validate-pch is not set, conflicts in predefined macros between pch and current compiler instance causes error.

If -fno-validate-pch is set, predefine macros in current compiler override those in pch so that compilation can continue.

Differential Revision: https://reviews.llvm.org/D24054

llvm-svn: 280842
clang/include/clang/Serialization/ASTReader.h
clang/lib/Serialization/ASTReader.cpp
clang/test/PCH/no-validate-pch.cl [new file with mode: 0644]