[cfe-dev] The need for good location info
Chris Lattner
clattner at apple.com
Sat Dec 15 15:19:29 PST 2007
This boggles the mind. Here's my (bad) code:
llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs;
for (unsigned i = 0; i != SearchList.size(); ++i) {
// If this isn't the first time we've seen this dir, remove it.
655: if (!SeenDirs.insert(SearchList[i].getDir()).second) {
...
G++ emits:
clang.cpp: In function ‘void
RemoveDuplicates(std::vector<clang::DirectoryLookup,
std::allocator<clang::DirectoryLookup> >&)’:
clang.cpp:655: error: request for member ‘second’ in ‘SeenDirs.
llvm::SmallPtrSet<PtrType, SmallSize>::insert [with PtrType = const
clang::DirectoryEntry*, unsigned int SmallSize = 8u]((+(+ SearchList)-
>std::vector<_Tp, _Alloc>::operator[] [with _Tp =
clang::DirectoryLookup, _Alloc =
std::allocator<clang::DirectoryLookup>](((long unsigned int)i)))-
>clang::DirectoryLookup::getDir())’, which is of non-class type ‘bool’
The ".second" is invalid (because insert on smallptrset returns a
bool). GCC is trying to pretty print out the expression, but it's
already prelowered stuff as it parsed. Hopefully we'll be able to
just do:
clang.cpp:655: error: invalid field 'second' on object of type 'bool'
if (!SeenDirs.insert(SearchList[i].getDir()).second) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
or something. When is C++ support in clang coming? ;-)
-Chris
More information about the cfe-dev
mailing list