Rather than giving SmallPtrSetImpl a member field SmallArray which is magically
authorDuncan Sands <baldrick@free.fr>
Wed, 30 Jun 2010 15:02:37 +0000 (15:02 +0000)
committerDuncan Sands <baldrick@free.fr>
Wed, 30 Jun 2010 15:02:37 +0000 (15:02 +0000)
commit2a8bf425bd0aff1a6406805c095d99089a1dfaae
treeda45d2ae14149f88a569873653259d43e8a8b3a6
parente767e6bbb78dae999040a6123d2314a7ed11a5c4
Rather than giving SmallPtrSetImpl a member field SmallArray which is magically
replaced by a bigger array in SmallPtrSet (by overridding it), instead just use a
pointer to the start of the storage, and have SmallPtrSet pass in the value to use.
This has the disadvantage that SmallPtrSet becomes bigger by one pointer.  It has
the advantage that it no longer uses tricky C++ rules, and is clearly correct while
I'm not sure the previous version was.  This was inspired by g++-4.6 pointing out
that SmallPtrSetImpl was writing off the end of SmallArray, which it was.  Since
SmallArray is replaced with a bigger array in SmallPtrSet, the write was still to
valid memory.  But it was writing off the end of the declared array type - sounds
kind of dubious to me, like it sounded dubious to g++-4.6.  Maybe g++-4.6 is wrong
and this construct is perfectly valid and correctly compiled by all compilers, but
I think it is better to avoid the whole can of worms by avoiding this construct.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107285 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/SmallPtrSet.h
lib/Support/SmallPtrSet.cpp