Skip to content

[clang-repl] Fix PCH with delayed template parsing #103028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,7 @@ Token ASTReader::ReadToken(ModuleFile &M, const RecordDataImpl &Record,
case tok::annot_pragma_unused:
case tok::annot_pragma_openacc:
case tok::annot_pragma_openacc_end:
case tok::annot_repl_input_end:
break;
default:
llvm_unreachable("missing deserialization code for annotation token");
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4734,6 +4734,7 @@ void ASTWriter::AddToken(const Token &Tok, RecordDataImpl &Record) {
case tok::annot_pragma_unused:
case tok::annot_pragma_openacc:
case tok::annot_pragma_openacc_end:
case tok::annot_repl_input_end:
break;
default:
llvm_unreachable("missing serialization code for annotation token");
Expand Down
25 changes: 25 additions & 0 deletions clang/test/Interpreter/delayed-template-parsing-pch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Test the setup without incremental extensions first
// RUN: %clang_cc1 -std=c++17 -fdelayed-template-parsing -fpch-instantiate-templates %s -emit-pch -o %t.pch -verify
// RUN: %clang_cc1 -std=c++17 -fdelayed-template-parsing -include-pch %t.pch %s -verify

// RUN: %clang_cc1 -std=c++17 -fdelayed-template-parsing -fincremental-extensions -fpch-instantiate-templates %s -emit-pch -o %t.incremental.pch -verify
// RUN: %clang_cc1 -std=c++17 -fdelayed-template-parsing -fincremental-extensions -include-pch %t.incremental.pch %s -verify

// expected-no-diagnostics

#ifndef PCH
#define PCH

// Have one template that is instantiated in the PCH (via the passed option
// -fpch-instantiate-templates) and then serialized
template <typename T> T ft1() { return 0; }
inline int f1() { return ft1<int>(); }

// Have a second late-parsed template that needs to be deserialized
template <typename T> T ft2() { return 0; }

#else

int f2() { return ft2<int>(); }

#endif
Loading