[PATCH] Fix bug in clang-format while merging short function (PR19461)

Dinesh Dwivedi dinesh.d at samsung.com
Mon Apr 28 07:15:55 PDT 2014


The problem is due to code 'I[1]->First->Type == TT_FunctionLBrace' [Format.cpp:562]
where we assume that I[0] contains something which we can join with rest of the lines.
I have experimented with logic to check flags for all token in lines being merged
except first token for MustBreakBefore flags and they cause other side effects while
solving this problem.

I have re-placed check for First->MustBreakBefore from 'tryMergeSimpleBlock()' to 
'tryFitMultipleLinesInOne()' so it will only take effect for above case. I have updated
test cases to check for even more conditions.

http://reviews.llvm.org/D3439

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3439.8886.patch
Type: text/x-patch
Size: 4455 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140428/124736c7/attachment.bin>


More information about the cfe-commits mailing list