This is an archive of the discontinued LLVM Phabricator instance.

[SemaCodeComplete] Expose a method to create CodeCompletionString for macros.
ClosedPublic

Authored by ioeric on Jul 5 2018, 7:50 AM.

Details

Summary

The method only takes PPreprocessor and don't require structures that
might not be available (e.g. Sema and ASTContext) when CodeCompletionString
needs to be generated for macros.

Diff Detail

Event Timeline

ioeric created this revision.Jul 5 2018, 7:50 AM

Could you give a little more context about how this will be used? (where the completion items come from, and when the strings will get built)

include/clang/Sema/CodeCompleteConsumer.h
921

please document the new function - particularly why it's different and what's the use case it supports
(if I understand right, it's to allow storing CodeCompletionResult instances for later stringification only when they're for macros - why?)

One of the args you're *not* taking here is ASTContext, but if I understand right it must still be alive: this->Macro points into the IdentifierTable which is owned by ASTContext.
In some sense taking this arg seems like a safety feature!

ioeric updated this revision to Diff 154369.Jul 6 2018, 1:29 AM
  • Addressed review comments.
include/clang/Sema/CodeCompleteConsumer.h
921

Done. Added documentation.

One of the args you're *not* taking here is ASTContext, but if I understand right it must still be alive: this->Macro points into the IdentifierTable which is owned by ASTContext.

ASTContext might not be available during preprocessing. It turned out that ASTContext only holds a reference to the IdentifierTable which is owned by the Preprocessor, so requiring a Preprocessor should be safe.

sammccall accepted this revision.Jul 6 2018, 1:30 AM
This revision is now accepted and ready to land.Jul 6 2018, 1:30 AM

Thanks for the explanation!

ioeric updated this revision to Diff 154370.Jul 6 2018, 1:37 AM
  • Merged with orgin/master
This revision was automatically updated to reflect the committed changes.