This is an archive of the discontinued LLVM Phabricator instance.

Use the fallible llvm::Regex constructor in Clang.
Needs ReviewPublic

Authored by dlj on Dec 6 2016, 8:40 AM.

Details

Summary

This change updates Clang to check for an llvm::Expected<llvm::Regex>, instead
of constructing an invalid Regex and checking .isValid().

Since most of the uses already (silently) ignore invalid llvm::Regex objects,
I've not tried too hard to propagate construction-time errors.

Event Timeline

dlj updated this revision to Diff 80427.Dec 6 2016, 8:40 AM
dlj retitled this revision from to Use the fallible llvm::Regex constructor in Clang..
dlj updated this object.
dlj added reviewers: rsmith, llvm-commits.
dlj added a subscriber: klimek.
vsk added a subscriber: vsk.Dec 6 2016, 5:37 PM
vsk added inline comments.
lib/Driver/Multilib.cpp
220–221

I have the same comments about this patch as I did re: D27465, but I thought I'd chime in here with an extra warning.

I don't think this will compile. The errs() object doesn't take ownership of the Error or check it. Better to write: llvm::toString(R.takeError()).

dlj updated this revision to Diff 80670.Dec 7 2016, 2:49 PM
  • Added comments about dropped assertion checks, and ensured checks in other places.
  • (Probably?) Fixed a unit test. The intent isn't clear, it's an un-handleable erroneous input case.