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:41 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 80428.Dec 6 2016, 8:41 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.
vsk added a subscriber: vsk.Dec 6 2016, 5:21 PM
vsk added inline comments.
clang-tidy/ClangTidyDiagnosticConsumer.cpp
156

If there *is* an error here, then implicitly converting the Expected instance to a bool doesn't mark the error as checked. I.e in asserts mode, you'll abort before you make it out of this if body. If that's really what you want, I think an assert would be a clearer / more lightweight way of doing it. This applies elsewhere in your patch: I think it makes sense to use Expected as a kind of exception mechanism, and not as a heavyweight assert.

clang-tidy/readability/IdentifierNamingCheck.cpp
234

Could you explain the rationale behind this change? Since we can verify that the regexes are valid at compile-time, why is there a need to wrap them with Expected?

dlj updated this revision to Diff 80672.Dec 7 2016, 2:52 PM
  • Fix long line.
dlj updated this revision to Diff 80818.Dec 8 2016, 1:37 PM
  • Fix long line.
  • Fix some broken regexes.