This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Do not format likely xml
ClosedPublic

Authored by krasimir on Aug 25 2017, 2:42 AM.

Details

Summary

This patch detects the leading '<' in likely xml files and stops formatting in
that case. A recent use of a Qt xml file with a .ts extension triggered this:
http://doc.qt.io/qt-4.8/linguist-ts-file-format.html

Diff Detail

Repository
rL LLVM

Event Timeline

krasimir created this revision.Aug 25 2017, 2:42 AM
djasper accepted this revision.Aug 29 2017, 5:12 AM

Just a few minor comments, otherwise looks good.

lib/Format/Format.cpp
1542 ↗(On Diff #112669)

Rename to isLikelyXml.

1552 ↗(On Diff #112669)

Just add a separate if statement. Or merge with previous one, but I think three separate if statements is actually easiest to read.

1902 ↗(On Diff #112669)

Same here.

This revision is now accepted and ready to land.Aug 29 2017, 5:12 AM
krasimir updated this revision to Diff 113085.Aug 29 2017, 6:48 AM
krasimir marked 3 inline comments as done.
  • Address review comments
This revision was automatically updated to reflect the committed changes.