Added support for producing clang compilation databases.

This is useful for using tools like ycmd. The intention is that this patch won't impact anyone who doesn't care about creating clang compilation databases. I use these databases for C++ completion via ycmd in emacs, so it's convenient for me to include these changes in the repository.