Revision D38639 needs this commit in order to properly make open definition calls on include statements work.
Since this modifies clang and not clangd, I decided to include it in a different patch.
Details
- Reviewers
malaperle krasimir bkramer ilya-biryukov - Commits
- rG41e90bcb77a2: [clang] Add PPCallbacks list to preprocessor when building a preacompiled…
rC320804: [clang] Add PPCallbacks list to preprocessor when building a preacompiled…
rL320804: [clang] Add PPCallbacks list to preprocessor when building a preacompiled…
Diff Detail
- Repository
- rC Clang
- Build Status
Buildable 12834 Build 12834: arc lint + arc unit
Event Timeline
Can you revert the formatting changes in places you haven’t touched (mainly astunit.cpp)? I think you should be able to do that with git checkout -p HEAD~1
Could you please take a different approach and add the callbacks you need into PreambleCallbacks class?
It already has this one:
virtual void HandleMacroDefined(const Token &MacroNameTok, const MacroDirective *MD);
Otherwise we'll be creating too many ways to do the same thing.
We should also definitely get rid of all the unrelated formatting changes.
lib/Frontend/PrecompiledPreamble.cpp | ||
---|---|---|
242 | Could we add a method to PreambleCallbacks to create PPCallbacks instead? class PreambleCallbacks { public: // ... /// Remove this. virtual void HandleMacroDefined(...); // Add this instead. virtual std::unique_ptr<PPCallbacks> createPPCallbacks(); } Alternatively, follow the current pattern in PreambleCallbacks and add some extra functions from the PPCallbacks interface to it. This would not require changes to the existing usages of PrecompiledPreamble in ASTUnit. Albeit, I'd prefer the first option. class PreambleCallbacks { public: // ... // Keep this virtual void HandleMacroDefined(...); // Add the ones you need, e.g. virtual void InclusionDirective(...); virtual void FileChanged(...); }; |
lib/Frontend/PrecompiledPreamble.cpp | ||
---|---|---|
242 | If we were to do that, one would then be required to define a wrapper class for PPCallbacks and create an instance of it inside createPPCallbacks() for the purpose of creating a unique_ptr? Then that unique_ptr would be sent from within the PreambleCallbacks parameter in the Build function? |
lib/Frontend/PrecompiledPreamble.cpp | ||
---|---|---|
242 | We're already passing our own wrapper around PreambleCallbacks anyway (see PreambleMacroCallbacks), we'll pass the unique_ptr<PPCallbacks> instead. Or, have I misunderstood the question entirely? |
lib/Frontend/PrecompiledPreamble.cpp | ||
---|---|---|
242 | No this is fine. I was just making sure I understood correctly. |
Removed unique_ptr parameter in PrecompiledPreamble::Build
Added method createPPCallbacks() in PreambleCallback to be overriden
include/clang/Frontend/PrecompiledPreamble.h | ||
---|---|---|
263 | It doesn't add, it creates.It's also not a "list". Is it true that it will process includes outside the preamble? I would think building the preamble stopped at the end of the preamble. | |
lib/Frontend/PrecompiledPreamble.cpp | ||
354 | extract this to a local variable |
LGTM modulo a few comments.
AFAIK, @Nebiroth does not have a commit access, so I'll land this with minor tweaks to unblock the other patch.
include/clang/Frontend/PrecompiledPreamble.h | ||
---|---|---|
261 | This method can now be removed as its use-case is now covered by createPPCallbacks | |
lib/Frontend/PrecompiledPreamble.cpp | ||
713 | Please clang-format the code when submitting patches. |
This method can now be removed as its use-case is now covered by createPPCallbacks