Skip to content
Merged
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
7 changes: 6 additions & 1 deletion llvm/lib/Support/Windows/Signals.inc
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,13 @@ bool sys::RemoveFileOnSignal(StringRef Filename, std::string *ErrMsg) {
return true;
}

if (FilesToRemove == NULL)
if (FilesToRemove == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can change FilesToRemove from static std::vector<std::string> *FilesToRemove = NULL; to static std::vector<std::string> FilesToRemove;, and change all pices where FilesToRemove == NULL to FilesToRemove.empty(), What do you think?

Copy link
Member Author

@aganea aganea Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that. However if we make it a non-pointer, and it is destroyed during global destruction; if any other subsequent global variable destructor code tries to access FilesToRemove after its destruction, that might crash in unexpected ways. Whereas here, as a pointer, it is clearly set to NULL and we already check if (FilesToRemove != NULL) in all the APIs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yes, it's may depends on globals destruct order.

FilesToRemove = new std::vector<std::string>;
std::atexit([]() {
delete FilesToRemove;
FilesToRemove = NULL;
});
}

FilesToRemove->push_back(std::string(Filename));

Expand Down
Loading