This addresses part of https://github.com/llvm/llvm-project/issues/60079
The test for external functions was not considering function templates.
Differential D142704
[C++20][Modules] Handle template declarations in header units. iains on Jan 27 2023, 4:12 AM. Authored by
Details This addresses part of https://github.com/llvm/llvm-project/issues/60079 The test for external functions was not considering function templates.
Diff Detail
Unit Tests Event TimelineComment Actions @dblaikie - I suspect that this would be useful on the llvm-16 release branch, and so I've added you as a reviewer, if you have some chance to look .. The issue here is that the function decl is extracted from function templates (and looks just like any other function definition at this point), so that we need to remember that it came from a template. Comment Actions this is necessary, but not sufficient (I need to make additions) .. no need to review yet.
Comment Actions in my local testing, I was able to consume all libc++ headers individually.
Comment Actions tried the patch and it seems to work (but libc++ seem's to have a little problem :D) > rm -rf .xmake build; xmake f --toolchain=clang; xmake b checking for platform ... linux checking for architecture ... x86_64 [ 0%]: generating.module.deps src/main.cpp [ 4%]: compiling.headerunit.release iostream [ 4%]: compiling.headerunit.release utility [ 4%]: compiling.headerunit.release cstdio [ 4%]: compiling.headerunit.release vector [ 4%]: compiling.headerunit.release fstream [ 4%]: compiling.headerunit.release memory [ 4%]: compiling.headerunit.release queue [ 4%]: compiling.headerunit.release string [ 4%]: compiling.headerunit.release map [ 4%]: compiling.headerunit.release complex [ 4%]: compiling.headerunit.release deque [ 4%]: compiling.headerunit.release iomanip [ 4%]: compiling.headerunit.release cstdlib [ 4%]: compiling.headerunit.release set [ 4%]: compiling.headerunit.release algorithm [ 4%]: compiling.headerunit.release exception [ 4%]: compiling.headerunit.release stack [ 4%]: compiling.headerunit.release list [ 88%]: compiling.release src/main.cpp [ 92%]: linking.release stl_headerunit_cpp_only [100%]: build ok! > rm -rf .xmake build; xmake f --toolchain=clang --cxxflags="-stdlib=libc++"; xmake b checking for platform ... linux checking for architecture ... x86_64 [ 0%]: generating.module.deps src/main.cpp [ 4%]: compiling.headerunit.release memory [ 4%]: compiling.headerunit.release exception [ 4%]: compiling.headerunit.release queue [ 4%]: compiling.headerunit.release iomanip [ 4%]: compiling.headerunit.release vector [ 4%]: compiling.headerunit.release utility [ 4%]: compiling.headerunit.release deque [ 4%]: compiling.headerunit.release set [ 4%]: compiling.headerunit.release map [ 4%]: compiling.headerunit.release fstream [ 4%]: compiling.headerunit.release cstdio [ 4%]: compiling.headerunit.release complex [ 4%]: compiling.headerunit.release cstdlib [ 4%]: compiling.headerunit.release iostream [ 4%]: compiling.headerunit.release list [ 4%]: compiling.headerunit.release string [ 4%]: compiling.headerunit.release stack [ 4%]: compiling.headerunit.release algorithm [ 88%]: compiling.release src/main.cpp error: /usr/bin/../include/c++/v1/ostream:254:20: error: 'std::basic_ostream<char>::operator<<' from module '/usr/bin/../include/c++/v1/complex' is not present in definition of 'std::ostream' in module '/usr/bin/../include/c++/v1/iostream' basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); ^ /usr/bin/../include/c++/v1/ostream:221:20: note: declaration of 'operator<<' does not match basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) ^ /usr/bin/../include/c++/v1/ostream:225:20: note: declaration of 'operator<<' does not match basic_ostream& operator<<(basic_ios<char_type, traits_type>& ^ /usr/bin/../include/c++/v1/ostream:230:20: note: declaration of 'operator<<' does not match basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)) ^ /usr/bin/../include/c++/v1/ostream:233:20: note: declaration of 'operator<<' does not match basic_ostream& operator<<(bool __n); ^ /usr/bin/../include/c++/v1/ostream:234:20: note: declaration of 'operator<<' does not match basic_ostream& operator<<(short __n); > in src/main.cpp > cat src/main.cpp import <iostream>; import <algorithm>; import <deque>; import <iostream>; import <map>; import <memory>; import <set>; import <utility>; import <vector>; import <string>; import <queue>; import <cstdlib>; import <utility>; import <exception>; import <list>; import <stack>; import <complex>; import <fstream>; import <cstdio>; import <iomanip>; using namespace std; int main(int argc, char** argv) { cout << "hello world!" << endl; return 0; } Comment Actions These seem to be a different diagnostic, do you find that is in some way related to the changes in D140261 + follow on patches?
Comment Actions I think we need to find a way to proceed - because this causes a regression on the llvm-16 branch, and that should be resolved soon, if possible.
Comment Actions I think we need to find a way to proceed - because this causes a regression on the llvm-16 branch, and that should be resolved soon, if possible.
Comment Actions Yeah, this is a pretty severe problem. Luckily clang16 is going to be released in early March. So we have roughly one month to solve this problem. Even if we failed to solve this in the last minute, I think it is not too bad to revert https://github.com/llvm/llvm-project/commit/335668b116439d13c7555616e126acdc608ce59e.
Comment Actions rebased, added tests for instantiated variable/function templates.
|
Would it make sense to use !isa<FunctionTemplateDecl>(D) here instead of adding IsFnTemplate?