[cfe-dev] Tests for C++0x Confusion
Sebastian Redl
sebastian.redl at getdesigned.at
Mon Dec 20 01:15:02 PST 2010
On 19.12.2010 20:15, Michael Price wrote:
> I'm a bit confused about the organization of the C++0x tests. Under
> the clang/test directory I see the following seemingly C++0x related
> directories:
>
> Lexer/
> SemaCXX/
> CodeGenCXX/
> Fixit/
> Lexer/
> PCH/
> Parser/
> Preprocessor/
> SemaTemplate/
> (this is the one that confuses me the most, are thing organized by
> compiler arch, or by language/version?) CXX/
>
> Am I in the dark on how these thing are organized?
>
You're mostly looking at a historical artifact.
When Clang started as a C/Obj-C compiler (C++ was meant to be in there,
but wasn't really planned for), it had some test directories:
Preprocessor, Lexer, Parser, Sema, and CodeGen. This made sense, because
in C those components are pretty much completely distinct. We had the
MinimalAction, which just provided enough semantic analysis to make C
parsing work, so you could run the C parser without Sema. When ObjC
became a reality, only Sema and CodeGen received a significant number of
new tests, so SemaObjC and CodeGenObjC were added.
When C++ support came into being, SemaCXX and CodeGenCXX were added
along the same lines of reasoning. Templates were so complex and
demanded so many tests that SemaTemplate was split out of SemaCXX.
However, the organization as it is makes a lot less sense for C++ than
for C. For C++, there's no real minimal analysis that you can use for
parsing. Correctly parsing C++ already means understanding namespaces
and templates. So MinimalAction fell into disuse and bitrot, and
eventually the entire Action interface was removed. Sema became the only
action. Anyway, because separating parser and sema tests for C++ doesn't
make much sense, and to better get a feeling for test coverage, the CXX
directory was introduced, which contains tests organized by where the
feature they describe appears in the standard. (This happened long
before removing Action, by the way.)
Nowadays, if you add a test for C++, it's best to add it to CXX.
Occasionally we still add them to other directories, though: to PCH if
it only tests PCH functionality, and to SemaCXX or CodeGenCXX if the
test is not easily associated with a specific section of the standard.
(Some features are all over the place.)
Hope that helps.
Sebastian
More information about the cfe-dev
mailing list