[cfe-dev] Late Parsed Template support for PCH

Tom Honermann thonermann at coverity.com
Wed Jul 24 19:58:03 PDT 2013


On 07/24/2013 12:18 PM, Will Wilson wrote:
> Hi All,
>
> I've discovered a rather nasty issue with -fdelayed-template-parsing
> enabled. If this is used to build a PCH all of the stored template
> tokens are lost leading an incomplete AST when the PCH is used to create
> the complete TU.
>
> Is this by design or a missing feature for the serialization code?

I would guess a missing feature.  Problems can be demonstrated quite easily:

$ cat t.cpp
template<typename T>
T f(const T& t) {
     return t;
}

int main() {
     f(5);
}

$ clang --version
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

# No problems without -fdelayed-template-parsing...
$ clang -emit-ast t.cpp
$ clang -o t t.ast

# But with -fdelayed-template-parsing...
$ clang -emit-ast -fdelayed-template-parsing t.cpp
$ clang -o t t.ast
/tmp/t-YAfQmm.o: In function `main':
t.ast:(.text+0x14): undefined reference to `int f<int>(int const&)'
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

Tom.




More information about the cfe-dev mailing list