Skip to content

[Modules] EvaluateAsInitializer executed in every importer when a variable template depends on a conversion operator #61892

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

Closed
davidstone opened this issue Apr 2, 2023 · 1 comment
Assignees
Labels
clang:modules C++20 modules and Clang Header Modules

Comments

@davidstone
Copy link
Contributor

davidstone commented Apr 2, 2023

Given the following two module files

export module a;

struct integer {
	explicit operator int() const {
		return 0;
	}
};

template<typename>
int a = static_cast<int>(integer());

void aa() {
	a<void>;
}
import a;

int main() {
}

And compiling them with

clang++ -std=c++20 -x c++-module -fmodule-output=a.pcm --precompile -c a.cpp
clang++ -ftime-trace -std=c++20 -fmodule-file=a=a.pcm -c b.cpp

We see one additional entry in the b.json time trace compared to the output if we delete the line that instantiates the variable template:

{
	"pid": 53878,
	"tid": 53889,
	"ph": "X",
	"ts": 0,
	"dur": 60,
	"name": "Total EvaluateAsInitializer",
	"args": {
		"count": 1,
		"avg ms": 0
	}
}
@EugeneZelenko EugeneZelenko added clang:modules C++20 modules and Clang Header Modules and removed new issue labels Apr 2, 2023
@llvmbot
Copy link
Member

llvmbot commented Apr 2, 2023

@llvm/issue-subscribers-clang-modules

@ChuanqiXu9 ChuanqiXu9 self-assigned this May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

No branches or pull requests

4 participants