r175533 - Correctly format macro with unfinished template declaration.

Sean Silva silvas at purdue.edu
Tue Feb 19 09:47:30 PST 2013


A pathological example of incomplete code in macros like
<http://research.swtch.com/shmacro> may flush out some other
unexpected code paths.

It is probably possible to get sensible formatting even for code
containing this kind of macros with unfinished code (provided we can
see the macro definition, which might be too strong a requirement).
One possibility is to look at what they expand to pick up information
like "there is an open brace here" or "there is a semicolon here", and
then format accordingly. This would permit formatting macros like the
INITIALZE_PASS_* ones in include/llvm/PassSupport.h, e.g.

INITIALIZE_PASS_BEGIN(BranchProbabilityInfo, "branch-prob",
                      "Branch Probability Analysis", false, true)
INITIALIZE_PASS_DEPENDENCY(LoopInfo)
INITIALIZE_PASS_END(BranchProbabilityInfo, "branch-prob",
                    "Branch Probability Analysis", false, true)

This also might be necessary to correctly format "foreach"-type macros
that are commonly used in C code. Qt also uses them
<http://doc.qt.digia.com/stable/qtglobal.html#foreach>.

-- Sean Silva



More information about the cfe-commits mailing list