[all-commits] [llvm/llvm-project] 030047: [Clang] Eagerly instantiate used constexpr functio...
cor3ntin via All-commits
all-commits at lists.llvm.org
Wed Nov 29 23:45:20 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 030047c432cac133738be68fa0974f70e69dd58d
https://github.com/llvm/llvm-project/commit/030047c432cac133738be68fa0974f70e69dd58d
Author: cor3ntin <corentinjabot at gmail.com>
Date: 2023-11-30 (Thu, 30 Nov 2023)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Sema/ExternalSemaSource.h
M clang/include/clang/Sema/MultiplexExternalSemaSource.h
M clang/include/clang/Sema/Sema.h
M clang/include/clang/Serialization/ASTBitCodes.h
M clang/include/clang/Serialization/ASTReader.h
M clang/lib/Sema/MultiplexExternalSemaSource.cpp
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaExpr.cpp
M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
M clang/lib/Serialization/ASTReader.cpp
M clang/lib/Serialization/ASTWriter.cpp
A clang/test/PCH/instantiate-used-constexpr-function.cpp
A clang/test/SemaTemplate/instantiate-used-constexpr-function.cpp
Log Message:
-----------
[Clang] Eagerly instantiate used constexpr function upon definition. (#73463)
Despite CWG2497 not being resolved, it is reasonable to expect the
following code to compile (and which is supported by other compilers)
```cpp
template<typename T> constexpr T f();
constexpr int g() { return f<int>(); } // #1
template<typename T> constexpr T f() { return 123; }
int k[g()];
// #2
```
To that end, we eagerly instantiate all referenced specializations of
constexpr functions when they are defined.
We maintain a map of (pattern, [instantiations]) independent of
`PendingInstantiations` to avoid having to iterate that list after each
function definition.
We should apply the same logic to constexpr variables, but I wanted to
keep the PR small.
Fixes #73232
More information about the All-commits
mailing list