diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-24 20:21:13 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-24 20:21:13 +0000 |
commit | 1fbb447e9d43c2c676e94081fbfee7eb6cbe933b (patch) | |
tree | 1b3026ad766c51ee8e035705d31c63f123c9d4d0 /include | |
parent | f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9 (diff) |
Implement preprocessor code completion where a macro name is expected,
e.g., after #ifdef/#ifndef or #undef, or inside a defined <macroname>
expression in a preprocessor conditional.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111954 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Lex/CodeCompletionHandler.h | 7 | ||||
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 5 | ||||
-rw-r--r-- | include/clang/Parse/Parser.h | 1 | ||||
-rw-r--r-- | include/clang/Sema/Action.h | 11 | ||||
-rw-r--r-- | include/clang/Sema/CodeCompleteConsumer.h | 7 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 1 |
6 files changed, 31 insertions, 1 deletions
diff --git a/include/clang/Lex/CodeCompletionHandler.h b/include/clang/Lex/CodeCompletionHandler.h index 4cc3b12d47..ee02a227e6 100644 --- a/include/clang/Lex/CodeCompletionHandler.h +++ b/include/clang/Lex/CodeCompletionHandler.h @@ -35,6 +35,13 @@ public: /// \brief Callback invoked when performing code completion within a block of /// code that was excluded due to preprocessor conditionals. virtual void CodeCompleteInConditionalExclusion() { } + + /// \brief Callback invoked when performing code completion in a context + /// where the name of a macro is expected. + /// + /// \param IsDefinition Whether this is the definition of a macro, e.g., + /// in a #define. + virtual void CodeCompleteMacroName(bool IsDefinition) { } }; } diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 712feaa425..543cb74226 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -382,6 +382,11 @@ public: CodeComplete = &Handler; } + /// \brief Retrieve the current code-completion handler. + CodeCompletionHandler *getCodeCompletionHandler() const { + return CodeComplete; + } + /// \brief Clear out the code completion handler. void clearCodeCompletionHandler() { CodeComplete = 0; diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 83b42fd172..e485963026 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -1535,6 +1535,7 @@ private: // Preprocessor code-completion pass-through virtual void CodeCompleteDirective(bool InConditional); virtual void CodeCompleteInConditionalExclusion(); + virtual void CodeCompleteMacroName(bool IsDefinition); }; } // end namespace clang diff --git a/include/clang/Sema/Action.h b/include/clang/Sema/Action.h index d407037515..aebb2b4d2b 100644 --- a/include/clang/Sema/Action.h +++ b/include/clang/Sema/Action.h @@ -3215,6 +3215,17 @@ public: /// \brief Code completion while in an area of the translation unit that was /// excluded due to preprocessor conditionals. virtual void CodeCompleteInPreprocessorConditionalExclusion(Scope *S) { } + + /// \brief Code completion in the preprocessor where an already-defined + /// macro name is expected, e.g., an #ifdef or #undef. + /// + /// \param S The scope in which the macro name occurs. + /// + /// \param IsDefinition Whether this code completion for a macro name occurs + /// in a definition of the macro (#define) or in another use that already + /// expects that the macro is defined (e.g., #undef or #ifdef). + virtual void CodeCompletePreprocessorMacroName(Scope *S, bool IsDefinition) { + } //@} }; diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h index 59d8a4fd04..f9cf484953 100644 --- a/include/clang/Sema/CodeCompleteConsumer.h +++ b/include/clang/Sema/CodeCompleteConsumer.h @@ -169,7 +169,12 @@ public: CCC_Name, /// \brief Code completion occurred where a new name is expected and a /// qualified name is permissible. - CCC_PotentiallyQualifiedName + CCC_PotentiallyQualifiedName, + /// \brief Code completion occurred where an macro is being defined. + CCC_MacroName, + /// \brief Code completion occurred where a macro name is expected + /// (without any arguments, in the case of a function-like macro). + CCC_MacroNameUse }; private: diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index b4449ff45c..1ad6ca690a 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -4692,6 +4692,7 @@ public: unsigned NumSelIdents); virtual void CodeCompletePreprocessorDirective(Scope *S, bool InConditional); virtual void CodeCompleteInPreprocessorConditionalExclusion(Scope *S); + virtual void CodeCompletePreprocessorMacroName(Scope *S, bool IsDefinition); void GatherGlobalCodeCompletions( llvm::SmallVectorImpl<CodeCompleteConsumer::Result> &Results); //@} |