This patch relaxes the constraints on the error message saved in PDBInputFile when failing to load a pdb file.
Storing an Error member infers that it must be accessed exactly once, which doesn't fit in several scenarios:
- If an invalid PDB file is provided as input file but never used, a loading error is created but never handled, causing an assert at shutdown
- PDB file created using MSVC's /Zi option : The loading error message must be displayed once per obj file.
Also, the state of PDBInputFile was altered when reading (taking) the Error member, causing issues:
- making it look valid whereas it's not properly initialized
- read vs write concurrency on a same PDBInputFile in the ghash parallel algorithm
The solution adopted here was to instead store an optional error string, and generate Error objects from it on demand.
I wouldn't add those two accessor functions, and would keep loadErrorStr public. The intent is already clear enough by accessing std::optional and you seem to only use getLoadError once. What about moving the make_error.. line to the call site and compose it with createFileError?