clang cannot parse libc++ headers? <vector>


I was trying clang on windows. I just compiled the latest version from svn (updated llvm also).
compiling a simple C program works great but I could not compile any C++ one.

The msvc headers don't parse, the gcc4.4 either (vararg template) and I don't have an older version of mingw. So I decided to try llvm libc++ but juste including <vector> give this (compiled with clang -std=c++0x test.cpp):

In file included from test.cpp:3:
In file included from C:\perso\libc++\include/vector:242:
C:\perso\libc++\include/__config(119) : error: 'char16_t' cannot be signed or unsigned
     typedef unsigned short char16_t;
C:\perso\libc++\include/__config(119) : error: 'short char16_t' is invalid
     typedef unsigned short char16_t;
C:\perso\libc++\include/__config(120) : error: cannot combine with previous 'int' declaration
     typedef unsigned int char32_t;

I "fixed" these error by modifying __config, but clang should be detected... but the problem is next:

In file included from test.cpp:3:
In file included from C:\perso\libc++\include/vector:243:
In file included from C:\perso\libc++\include/__bit_reference:15:
In file included from C:\perso\libc++\include/algorithm:554:
C:\perso\libc++\include/memory(3317) : error: expected the class name after '~' to name a

and finaly a crash:

Assertion failed: DefinitionData && "queried property of class with no definition", file C:\perso\ll
vm\tools\clang\include\clang/AST/DeclCXX.h, line 364
Stack dump:
0. Program arguments: C:/perso/llvm/bin/bin/Debug/clang.exe -cc1 -triple i686-pc-win32 -S -disa
ble-free -main-file-name test.cpp -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases
-v -resource-dir C:/perso/llvm/bin/bin/lib/clang/2.0 -I C:\perso\libc++\include -I c:\program files\
pythonxy\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++ -I c:\program files\pythonxy\mingw\bin\../li
b/gcc/mingw32/4.4.0/include/c++/mingw32 -I c:\program files\pythonxy\mingw\bin\../lib/gcc/mingw32/4.
4.0/include/c++/backward -I c:\program files\pythonxy\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../..
/include -I c:\program files\pythonxy\mingw\bin\../lib/gcc/mingw32/4.4.0/include -I c:\program files
\pythonxy\mingw\bin\../lib/gcc/mingw32/4.4.0/include-fixed -std=c++0x -ferror-limit 19 -fmessage-len
gth 100 -fexceptions -fms-extensions -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o
C:/DOCUME~1/Cedric/LOCALS~1/Temp/cc-000000.s -x c++ test.cpp
1. C:\perso\libc++\include/memory:3641:24: current parser token '('
2. C:\perso\libc++\include/memory:205:1 <Spelling=C:\perso\libc++\include/__config:102:37>: par
sing namespace 'std'
1023C355 (0x0000000A 0xCCCCCCCC 0xCCCCCCCC 0xCCCCCCCC), _get_pgmptr()+0453 bytes(s)
102DE9AD (0x02E6CF54 0x02E6CEC8 0x02E6C41C 0x0049CB2B), abort()+0045 bytes(s)
102CE8D6 (0x01DC0F78 0x01DC1000 0x0000016C 0x02E6D254), _wassert()+0214 bytes(s)
00587718 (0x030F22D0 0x02E6CF60 0x00BDEC49 0x86081ABD), clang::CXXRecordDecl::data()+0056 bytes(s),
c:\perso\llvm\tools\clang\include\clang\ast\declcxx.h, line 364+0041 byte(s)
00600FD6 (0x86081ABD 0x02E6D0FC 0x02E6D254 0xCCCCCCCC), clang::CXXRecordDecl::bases_begin()+0022 byt
es(s), c:\perso\llvm\tools\clang\include\clang\ast\declcxx.h, line 445+0022 byte(s)
00BDEC49 (0x00BA2C20 0x00000000 0x00000001 0x030F22D0), clang::CXXRecordDecl::forallBases()+0105 byt
es(s), c:\perso\llvm\tools\clang\lib\ast\cxxinheritance.cpp, line 124+0008 byte(s)
00BA2C05 (0x860804D5 0x02E6D228 0x02E6D254 0xCCCCCCCC), clang::CXXRecordDecl::hasAnyDependentBases()
+0053 bytes(s), c:\perso\llvm\tools\clang\lib\ast\declcxx.cpp, line 155+0017 byte(s)
00915476 (0x02E6D1A4 0x030F22F4 0x00000000 0x860807E9), clang::Sema::LookupQualifiedName()+0518 byte
s(s), c:\perso\llvm\tools\clang\lib\sema\semalookup.cpp, line 1139+0034 byte(s)
007A4928 (0x030F07D4 0x00098743 0x02F396A8 0x02E6D864), clang::Sema::getTypeName()+0440 bytes(s), c:
\perso\llvm\tools\clang\lib\sema\semadecl.cpp, line 118
00C5134A (0x02E6D864 0x00000001 0x00000001 0x00000001), clang::Parser::ParseUnqualifiedId()+0362 byt
es(s), c:\perso\llvm\tools\clang\lib\parse\parseexprcxx.cpp, line 1413+0054 byte(s)
00C33625 (0x02E6D860 0x8608021D 0x02E6DC04 0x02E6DC2C), clang::Parser::ParseDirectDeclarator()+0533
bytes(s), c:\perso\llvm\tools\clang\lib\parse\parsedecl.cpp, line 2682+0037 byte(s)
00C32E32 (0x02E6D860 0x00C33410 0x02E6E40C 0x02E6DC10), clang::Parser::ParseDeclaratorInternal()+029
0 bytes(s), c:\perso\llvm\tools\clang\lib\parse\parsedecl.cpp, line 2496+0012 byte(s)
00C32CFF (0x02E6D860 0x860809CD 0x02E6DD14 0x02E6DC2C), clang::Parser::ParseDeclarator()+0031 bytes(
s), c:\perso\llvm\tools\clang\lib\parse\parsedecl.cpp, line 2455
00C27FE9 (0x02E6DDB8 0x00000000 0x02E6DC38 0x02E6DF60), clang::Parser::ParseSingleDeclarationAfterTe
mplate()+0489 bytes(s), c:\perso\llvm\tools\clang\lib\parse\parsetemplate.cpp, line 213
00C27CE1 (0x02E6DDB8 0x00000000 0x02E6DF60 0x00000003), clang::Parser::ParseTemplateDeclarationOrSpe
cialization()+0865 bytes(s), c:\perso\llvm\tools\clang\lib\parse\parsetemplate.cpp, line 155+0050 by
00C27961 (0x02E6DDB8 0x00000000 0x02E6DF60 0x00000003), clang::Parser::ParseDeclarationStartingWithT
emplate()+0145 bytes(s), c:\perso\llvm\tools\clang\lib\parse\parsetemplate.cpp, line 32+0024 byte(s)

00C2CAC1 (0x02E6DFDC 0x00000000 0x02E6DF60 0x00000000), clang::Parser::ParseDeclaration()+0257 bytes
(s), c:\perso\llvm\tools\clang\lib\parse\parsedecl.cpp, line 321+0022 byte(s)
00C01C35 (0x02E6DFDC 0x00000000 0x00000000 0x00000000), clang::Parser::ParseExternalDeclaration()+14
77 bytes(s), c:\perso\llvm\tools\clang\lib\parse\parser.cpp, line 483+0046 byte(s)
00C19C61 (0x02E6E13C 0x00000000 0x02E6E2FC 0x86083441), clang::Parser::ParseNamespace()+1105 bytes(s
), c:\perso\llvm\tools\clang\lib\parse\parsedeclcxx.cpp, line 114
00C2CB3C (0x02E6E374 0x00000000 0x02E6E2FC 0x00000000), clang::Parser::ParseDeclaration()+0380 bytes
(s), c:\perso\llvm\tools\clang\lib\parse\parsedecl.cpp, line 327+0020 byte(s)
00C01C35 (0x02E6E374 0x00000000 0x00000000 0x00000000), clang::Parser::ParseExternalDeclaration()+14
77 bytes(s), c:\perso\llvm\tools\clang\lib\parse\parser.cpp, line 483+0046 byte(s)
00C01561 (0x02E6E3EC 0x86083911 0x02E6EE10 0x02E6ECE8), clang::Parser::ParseTopLevelDecl()+0225 byte
s(s), c:\perso\llvm\tools\clang\lib\parse\parser.cpp, line 371+0040 byte(s)
00741FE9 (0x02E77178 0x02E8F880 0x02E8C848 0x00000000), clang::ParseAST()+0409 bytes(s), c:\perso\ll
vm\tools\clang\lib\sema\parseast.cpp, line 87+0018 byte(s)
0044D242 (0x86083BC1 0x02E6EE58 0x02E6EE24 0xCCCCCCCC), clang::ASTFrontendAction::ExecuteAction()+02
26 bytes(s), c:\perso\llvm\tools\clang\lib\frontend\frontendaction.cpp, line 251+0079 byte(s)
005D7615 (0x86083BB9 0x02E6EECC 0x02E6EE6C 0x02E6EE1C), clang::CodeGenAction::ExecuteAction()+0741 b
ytes(s), c:\perso\llvm\tools\clang\lib\codegen\codegenaction.cpp, line 333
0044CF0A (0x86083B05 0x02E6F724 0x02E6EEE4 0xCCCCCCCC), clang::FrontendAction::Execute()+0282 bytes(
s), c:\perso\llvm\tools\clang\lib\frontend\frontendaction.cpp, line 177+0015 byte(s)
0042A3AD (0x02E77FC0 0x860822ED 0x02E6FF5C 0x00000000), clang::CompilerInstance::ExecuteAction()+071
7 bytes(s), c:\perso\llvm\tools\clang\lib\frontend\compilerinstance.cpp, line 498
0040E8D4 (0x00035B68 0x00035C10 0x00035C14 0x004017A3), cc1_main()+2004 bytes(s), c:\perso\llvm\tool
s\clang\tools\driver\cc1_main.cpp, line 282+0027 byte(s)
0040325D (0x0000002C 0x00035B60 0x000335F0 0x86082A65), main()+0253 bytes(s), c:\perso\llvm\tools\cl
ang\tools\driver\driver.cpp, line 186+0033 byte(s)
01766488 (0x02E6FFF0 0x7C817077 0x02E6E812 0x00000000), __tmainCRTStartup()+0424 bytes(s), f:\dd\vct
ools\crt_bld\self_x86\crt\src\crtexe.c, line 582+0025 byte(s)
017662CF (0x02E6E812 0x00000000 0x7FFDF000 0x80000003), mainCRTStartup()+0015 bytes(s), f:\dd\vctool
s\crt_bld\self_x86\crt\src\crtexe.c, line 399
7C817077 (0x017662C0 0x00000000 0x00000008 0x01000100), RegisterWaitForInputIdle()+0073 bytes(s)
clang++: error: clang frontend command failed due to signal 2147483645 (use -v to see invocation)

Is this expected to work? I was thinking that libc++ was compiling with clang. Did I dream or is it a regression?



Is this expected to work? I was thinking that libc++ was compiling with
clang. Did I dream or is it a regression?

Currently - dream, noone is working on libc++ outside of darwin world.

Is this expected to work? I was thinking that libc++ was compiling with
clang. Did I dream or is it a regression?

Currently - dream, noone is working on libc++ outside of darwin world.
yes, I can see it would not compile/run but I am only interested in parsing files (with semantic) and the main error was that someclass<T>::~someclass() was not correctly understood. This should work the same on darwin or windows. And the libc++ site claims to compile with clang.

I'm not seeing this error on Mac OS. I imagine that if someclass<T>::~someclass() isn't compiling it should be pretty easy to create a reduced test case.


Yes, it was pretty easy, this code:

template<class _Tp>
class shared_ptr {

template<class _Tp>
shared_ptr<_Tp>::~shared_ptr() {}

does not compile here with the commandline

         clang++ --std=c++0x test.cpp

but it work if I don't specify the --std=c++0x (ie clang++ test.cpp compile fine)

svn rev 106623 with msvc2008 in debug configuration.


File a bug, please.