This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix UB when string.front() is used for the empty string
ClosedPublic

Authored by DmitryPolukhin on Jun 29 2021, 7:34 AM.

Details

Summary

Compilation database might have empty string as a command line argument.
But ExpandResponseFilesDatabase::expand doesn't expect this and assumes
that string.front() can be used for any argument. It is undefined behaviour if
string is empty. With debug build mode it causes crash in clangd.

Test Plan: check-clang

Diff Detail

Event Timeline

DmitryPolukhin created this revision.Jun 29 2021, 7:34 AM
DmitryPolukhin requested review of this revision.Jun 29 2021, 7:34 AM
DmitryPolukhin updated this revision to Diff 355233.

Replace tab with spaces

sammccall accepted this revision.Jun 29 2021, 8:19 AM
This revision is now accepted and ready to land.Jun 29 2021, 8:19 AM

Fix clang-tidy style warning