This is an archive of the discontinued LLVM Phabricator instance.

Fix use of dangling stack allocated string in IncludeFixer
ClosedPublic

Authored by dgoldman on Nov 15 2022, 10:51 AM.

Details

Summary

IncludeFixer uses this BuildDir string later on if given relative paths.

Diff Detail

Event Timeline

dgoldman created this revision.Nov 15 2022, 10:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2022, 10:51 AM
Herald added a subscriber: arphaman. · View Herald Transcript
dgoldman requested review of this revision.Nov 15 2022, 10:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2022, 10:51 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

LMK of the best way to add a test for this, maybe I can somehow make a test with relative path arguments?

yeah unfortunately testing this is hard, but bug&fix are obvious so it's fine to land without a test.

but i think we should rather fix the broken call site at clang-tools-extra/clangd/ParsedAST.cpp and move BuildDir to outer scope where it'll outlive IncludeFixer (~line 468).

dgoldman updated this revision to Diff 475850.Nov 16 2022, 9:41 AM

Fix in ParsedAST.cpp

yeah unfortunately testing this is hard, but bug&fix are obvious so it's fine to land without a test.

but i think we should rather fix the broken call site at clang-tools-extra/clangd/ParsedAST.cpp and move BuildDir to outer scope where it'll outlive IncludeFixer (~line 468).

Done.

kadircet accepted this revision.Nov 16 2022, 9:53 AM

thanks!

This revision is now accepted and ready to land.Nov 16 2022, 9:53 AM