]> granicus.if.org Git - clang/commit
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)
commit2807f026db5bd56d92704d6568424cc7b6849e09
tree1a83b3f09c5638025a8d66f76efddfa240de7877
parent8a4ab9f7f73f68949bb7095bf2322c51d94fd36c
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280842 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Serialization/ASTReader.h
lib/Serialization/ASTReader.cpp
test/PCH/no-validate-pch.cl [new file with mode: 0644]