In ASTUnit::LoadFromASTFile, the context object is set up using default-constructed
LangOptions (which only later get populated). As the language options are used in the constructor
of PrintingPolicy, this needs to be updated explicitly after the language options are available.
Details
Diff Detail
Event Timeline
I wonder if it's possible to do away with the calls to 'updated()'... it seems strange that we initialize the same preprocessor repeatedly. Is there any way to finalize an ASTInfoCollector after ReadAST happens (or ASTReaderListeners in general)?
I can look into this but would prefer to do so in a different patch, as this would require refactoring beyond this simple bug fix. Would it be okay to land this patch as-is?
Not having worked on this code I'm afraid I can't say. Usually it's a good idea to include a regression test.
Thanks for adding the test! This is looking good.
unittests/Frontend/ASTUnitTest.cpp | ||
---|---|---|
32 | If a directory isn't necessary to exercise the desired functionality, it'd be better to use createTemporaryFile() to open a temporary file descriptor, and then to use tool_output_file() to manage the descriptor's lifetime. Tool_output_file has logic to clean up files when a signal is received, etc. | |
48 | It doesn't look like all of the directories which could be created here would be deleted? With any luck it'll be possible to use tool_output_file() to side step the issue. |
Update regression test to use createTemporaryFile() and tool_output_file as suggested.
Thanks, LGTM! This seems like a pretty straightforward bug fix. Since it's not my usual area maybe it'd be worth waiting a day or so for more feedback.
Thanks! I do not have commit access so it would be great if you could commit it on my behalf.
If a directory isn't necessary to exercise the desired functionality, it'd be better to use createTemporaryFile() to open a temporary file descriptor, and then to use tool_output_file() to manage the descriptor's lifetime. Tool_output_file has logic to clean up files when a signal is received, etc.