<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Mar 17, 2014, at 11:57 AM, Benjamin Kramer <<a href="mailto:benny.kra@gmail.com">benny.kra@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br>On 17.03.2014, at 19:47, Pete Cooper <<a href="mailto:peter_cooper@apple.com">peter_cooper@apple.com</a>> wrote:<br><br><blockquote type="cite">Hi all<br><br>Please review this patch to make StringMap be aware of when it contains POD types allocated on a BumpPtrAllocator.  In this case its unnecessary to clear the map in its destructor.  This is particularly painful on IdentiferTable in clang where we walk an 8192 entry map of pointers and uselessly destruct them.<br></blockquote><br>Ugh. This is really something that the optimizer should do. Have you checked<br>what's preventing LLVM from killing the loop that does nothing?<br></blockquote>I think it’ll do the right thing in terms of the destructors for each element being empty.  The tricky thing is that unless ~StringMap inlines clear(), the resetting of all of the elements to the tombstone key will also still happen, and on a large map that can be really slow.<br><blockquote type="cite"><br><blockquote type="cite">Unfortunately I needed to move a couple of class declarations inside their headers instead of cpp files (to use isPODLike), but otherwise I hope this looks ok.  I’m totally open to suggestions on better naming or a better way to enable this functionality.<br><br>There’s also a small clang diff.  I’ll didn’t want to cross-post both lists so will wait until the other details are worked out before I email it there.<br></blockquote><br>If I'm reading the source correctly, clang::tooling::FileMatchTrieNode contains a<br>std::string. That's very non-POD-like.<br></blockquote>Yeah, thats a nasty piece of code.  I was hoping someone with more C++ template knowledge might know what i’m doing wrong in having to declare this.</div><div><br></div><div>Without that declaration, I get these errors</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">In file included from /Volumes/Data/llvm/tools/clang/lib/Tooling/FileMatchTrie.cpp:14:</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">In file included from /Volumes/Data/llvm/tools/clang/lib/Tooling/../../include/clang/Tooling/FileMatchTrie.h:18:</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">In file included from /Volumes/Data/llvm/tools/clang/lib/Tooling/../../include/clang/Basic/LLVM.h:22:</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">In file included from /Volumes/Data/llvm/include/llvm/Support/Casting.h:19:</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><b>/Volumes/Data/llvm/include/llvm/Support/type_traits.h:34:29: </b><span style="color: #c33720"><b>error: </b></span><b>incomplete type</b></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><b>      'clang::tooling::FileMatchTrieNode' used in type trait expression</b></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  static const bool value = __is_trivially_copyable(T);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(52, 189, 38);"><b>                            ^</b></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><b>/Volumes/Data/llvm/include/llvm/ADT/StringMap.h:253:29: note: </b>in instantiation of template class</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">      'llvm::isPodLike<clang::tooling::FileMatchTrieNode>' requested here</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">    public StringMapClearer<isPodLike<ValueTy>::value, AllocatorTy> {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(52, 189, 38);"><b>                            ^</b></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><b>/Volumes/Data/llvm/tools/clang/lib/Tooling/FileMatchTrie.cpp:136:21: note: </b>in instantiation of template</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">      class 'llvm::StringMap<clang::tooling::FileMatchTrieNode, llvm::MallocAllocator>' requested here</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">              llvm::StringMap<FileMatchTrieNode>::const_iterator Except) const {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(52, 189, 38);"><b>                    ^</b></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><b>/Volumes/Data/llvm/tools/clang/lib/Tooling/FileMatchTrie.cpp:36:7: note: </b>definition of</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">      'clang::tooling::FileMatchTrieNode' is not complete until the closing '}'</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">class FileMatchTrieNode {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">Pete</div><blockquote type="cite"><br>- Ben<br><br></blockquote></div><br></body></html>