Add ability to turn off -fpch-instantiate-templates in clang-cl
authorShivanshu Goyal <Shivanshu.Goyal@microsoft.com>
Tue, 6 Oct 2020 14:12:48 +0000 (16:12 +0200)
committerHans Wennborg <hans@chromium.org>
Tue, 6 Oct 2020 14:23:23 +0000 (16:23 +0200)
commit66e4f07198761bbb4dcd55235024c1081ed15c75
tree59afc4c0584e62539a93f1a3fc755928617df703
parentb3876ef49093b17555ae058eb87bb9c70a525c49
Add ability to turn off -fpch-instantiate-templates in clang-cl

A lot of our code building with clang-cl.exe using Clang 11 was failing with
the following 2 type of errors:

1. explicit specialization of 'foo' after instantiation
2. no matching function for call to 'bar'

Note that we also use -fdelayed-template-parsing in our builds.

I tried pretty hard to get a small repro for these failures, but couldn't. So
there is some subtle edge case in the -fpch-instantiate-templates feature
introduced by this change: https://reviews.llvm.org/D69585

When I tried turning this off using -fno-pch-instantiate-templates, builds
would silently fail with the same error without any indication that
-fno-pch-instantiate-templates was being ignored by the compiler. Then I
realized this "no" option wasn't actually working when I ran Clang under a
debugger.

Differential revision: https://reviews.llvm.org/D88680
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/pch-instantiate-templates.c [new file with mode: 0644]