[cfe-dev] clang-format turning tests into no-ops
Richard
legalize at xmission.com
Fri Nov 8 06:32:51 PST 2013
In article <527C7B81.3030100 at nuanti.com>,
Alp Toker <alp at nuanti.com> writes:
> It was a mystery why people keep checking in tests like this:
>
> |// RUN: clang-check "%s" -- -target x86_64-apple-darwin10 -fasm-blocks
> 2>&1 |||
> ||// ||FileCheck %s|
>
> The first line will run successfully, and the second doesn't begin with
> RUN so the test passes silently. Not good.
>
> Then it dawned on me -- contributors must be running clang-format before
> committing, causing their RUN lines to get split up at the line boundary.
The more general problem seems to be that not all comments are created
equal.
There should be a way to tell clang-format that comments matching a
certain pattern should be left alone. I can think of any number of
tools that use metadata embedded in comments that should never be
reformatted. These lit test metadata lines are one example and other
examples are:
* comments suppressing cppcheck diagnostics
* comments suppressing lint diagnostics
* comments suppressing coverity diagnostics
* comments indicating editor options (emacs mode?)
* comments containing version control metadata $Id$, etc.
I'm sure we can think of some more examples.
It seems there should be some sort of option providing clang-format
with a pattern that can be matched against a comment line/block that
will tell clang-format to leave the line/block alone. This would also
be useful for marking ASCII art as unmolestable.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
More information about the cfe-dev
mailing list