[PATCH] Propagate ASTReaderListener API in ChainedASTReaderListener

Justin Bogner mail at justinbogner.com
Wed May 21 18:56:15 PDT 2014


I ran into some issues in ChainedASTReaderListener while trying to use
ASTReader::addListener. When there are multiple listeners, a couple of
problems can (and do!) occur:

1. Listeners can be called for file types they don't expect (ie, system
   files when they return false for needsSystemInputFileVisitation),
   leading to asserts and other bad behaviour.

2. Listeners may not be called at all, due to the shortcutting || in
   visitInputFile.

The attached patch fixes this by adding checks to and removing
shortcutting from ChainedASTReaderListener::visitInputFile. We could,
alternatively, avoid the extra checks, update the docs for
ASTReaderListener to say that visitInputFile may be called for file
types the client didn't ask for, and update all clients, but that seems
like a worse approach.

Okay to commit?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: chained-reader-listener.patch
Type: text/x-patch
Size: 1940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140521/c0702ddb/attachment.bin>


More information about the cfe-commits mailing list