From: Ted Kremenek Date: Tue, 17 Nov 2009 18:18:02 +0000 (+0000) Subject: Allow "source_filename" to be an optional argument (the client can provide NULL)... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4633d1b26949346b6c0e707f76b899c79948b592;p=clang Allow "source_filename" to be an optional argument (the client can provide NULL). This allows the client to put the source_filename in the command_line_args without fear of the file being named twice. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89118 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index bd79eb0803..ccdddf6cdb 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -605,7 +605,8 @@ clang_getNumCompletionChunks(CXCompletionString completion_string); * \param source_filename the name of the source file that should be parsed * to perform code-completion. This source file must be the same as or * include the filename described by \p complete_filename, or no code-completion - * results will be produced. + * results will be produced. NOTE: One can also specify NULL for this argument if + * the source file is included in command_line_args. * * \param num_command_line_args the number of command-line arguments stored in * \p command_line_args. diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index 216638d718..2e0eafebb2 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -1211,7 +1211,8 @@ void clang_codeComplete(CXIndex CIdx, // Add the source file name (FIXME: later, we'll want to build temporary // file from the buffer, or just feed the source text via standard input). - argv.push_back(source_filename); + if (source_filename) + argv.push_back(source_filename); // Process the compiler options, stripping off '-o', '-c', '-fsyntax-only'. for (int i = 0; i < num_command_line_args; ++i)