[Lldb-commits] [PATCH] D18530: Move some functions from ClangASTContext to ClangUtil

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 28 16:31:53 PDT 2016

zturner created this revision.
zturner added reviewers: spyffe, clayborg.
zturner added a subscriber: lldb-commits.

This is pretty mechanical, so you don't really have to look at this in too much detail.  I'm mostly posting it here to make sure people are ok with the high level idea.  Basically ClangASTContext is a monstrous file and I want to reduce the size by splitting out some of the functionality.  There's a ton of functions in `ClangASTContext` that are static and are basically helper functions, but then other people like `DWARFASTParserClang`, or `ClangASTImporter`, or other places re-use those functions.  So the idea is just to move all these common clang helper functions into a single place.

In doing so, it makes testing this type of functionality very easy, because you can write a unit test for every function in the file.  I did that in this patch, and actually found one bug as a result of my unittest failing (yay for unit tests).  Since that is the only functional change in the patch, you may want to look at it specifically.  It's `ClangUtil::RemoveFastQualifiers`.  The version before my patch did nothing, it returned exactly the same value it was passed in, because `QualType::getQualifiers()` returns a `clang::Qualifiers` by value, so it was not modifying the `QualType`'s qualifiers, but a copy of them, which was immediately discarded.

If anyone can think of a way to exercise this in a public API test, let me know.

I'm hoping to gradually move some more of the `ClangASTContext` functions over to `ClangUtil` in subsequent patches.  It makes understanding the important parts of `ClangASTContext` easier, and it will allow me to add more unittests for the rest of the functions as well (hopefully turning up more bugs).



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18530.51853.patch
Type: text/x-patch
Size: 78826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160328/cef53c72/attachment-0001.bin>

More information about the lldb-commits mailing list