diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-24 22:20:20 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-24 22:20:20 +0000 |
commit | f29c5233085a5af795c3c01b94d319e5b3235d56 (patch) | |
tree | 29a09575d6701839943ab6c54aab7ac4a476db0e /lib/Sema/SemaCodeComplete.cpp | |
parent | db918646c0d549a48b85734cb735e094886890d2 (diff) |
Implement code completion for preprocessor expressions and in macro
arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111976 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 06e65784e8..e25a47c2a5 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -4608,7 +4608,7 @@ void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S, Results.data(),Results.size()); } -void Sema::CodeCompletePreprocessorDirective(Scope *S, bool InConditional) { +void Sema::CodeCompletePreprocessorDirective(bool InConditional) { ResultBuilder Results(*this); Results.EnterNewScope(); @@ -4785,11 +4785,12 @@ void Sema::CodeCompletePreprocessorDirective(Scope *S, bool InConditional) { } void Sema::CodeCompleteInPreprocessorConditionalExclusion(Scope *S) { - CodeCompleteOrdinaryName(S, Action::PCC_RecoveryInFunction); + CodeCompleteOrdinaryName(S, + S->getFnParent()? Action::PCC_RecoveryInFunction + : Action::PCC_Namespace); } -void Sema::CodeCompletePreprocessorMacroName(Scope *S, bool IsDefinition) { - typedef CodeCompleteConsumer::Result Result; +void Sema::CodeCompletePreprocessorMacroName(bool IsDefinition) { ResultBuilder Results(*this); if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) { // Add just the names of macros, not their arguments. @@ -4812,6 +4813,40 @@ void Sema::CodeCompletePreprocessorMacroName(Scope *S, bool IsDefinition) { Results.data(), Results.size()); } +void Sema::CodeCompletePreprocessorExpression() { + ResultBuilder Results(*this); + + if (!CodeCompleter || CodeCompleter->includeMacros()) + AddMacroResults(PP, Results); + + // defined (<macro>) + Results.EnterNewScope(); + CodeCompletionString *Pattern = new CodeCompletionString; + Pattern->AddTypedTextChunk("defined"); + Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); + Pattern->AddChunk(CodeCompletionString::CK_LeftParen); + Pattern->AddPlaceholderChunk("macro"); + Pattern->AddChunk(CodeCompletionString::CK_RightParen); + Results.AddResult(Pattern); + Results.ExitScope(); + + HandleCodeCompleteResults(this, CodeCompleter, + CodeCompletionContext::CCC_PreprocessorExpression, + Results.data(), Results.size()); +} + +void Sema::CodeCompletePreprocessorMacroArgument(Scope *S, + IdentifierInfo *Macro, + MacroInfo *MacroInfo, + unsigned Argument) { + // FIXME: In the future, we could provide "overload" results, much like we + // do for function calls. + + CodeCompleteOrdinaryName(S, + S->getFnParent()? Action::PCC_RecoveryInFunction + : Action::PCC_Namespace); +} + void Sema::GatherGlobalCodeCompletions( llvm::SmallVectorImpl<CodeCompleteConsumer::Result> &Results) { ResultBuilder Builder(*this); |