summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Index/IndexTests.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-02-11 13:02:21 +0000
committerKadir Cetinkaya <kadircet@google.com>2019-02-11 13:02:21 +0000
commit0468fc0b8d7193f68432a21148eea9444df61712 (patch)
tree176671f02f96ca57a2b51d5d21a585d8c8240a74 /clang/unittests/Index/IndexTests.cpp
parentcf13bfee0012424e3364672c598185a4f628c089 (diff)
downloadbcm5719-llvm-0468fc0b8d7193f68432a21148eea9444df61712.tar.gz
bcm5719-llvm-0468fc0b8d7193f68432a21148eea9444df61712.zip
[clang][Index] Add a knob to index function parameters in declarations
Summary: Parameters in declarations are useful for clangd, so that we can provide symbol information for them as well. It also helps clangd to be consistent whether a function's definition is accessible or not. Reviewers: hokein, akyrtzi Subscribers: ilya-biryukov, ioeric, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57949 llvm-svn: 353695
Diffstat (limited to 'clang/unittests/Index/IndexTests.cpp')
-rw-r--r--clang/unittests/Index/IndexTests.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/unittests/Index/IndexTests.cpp b/clang/unittests/Index/IndexTests.cpp
index 147f7a714ad..2b574a53fc3 100644
--- a/clang/unittests/Index/IndexTests.cpp
+++ b/clang/unittests/Index/IndexTests.cpp
@@ -119,6 +119,21 @@ TEST(IndexTest, IndexPreprocessorMacros) {
EXPECT_THAT(Index->Symbols, UnorderedElementsAre());
}
+TEST(IndexTest, IndexParametersInDecls) {
+ std::string Code = "void foo(int bar);";
+ auto Index = std::make_shared<Indexer>();
+ IndexingOptions Opts;
+ Opts.IndexFunctionLocals = true;
+ Opts.IndexParametersInDeclarations = true;
+ tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+ EXPECT_THAT(Index->Symbols, Contains(QName("bar")));
+
+ Opts.IndexParametersInDeclarations = false;
+ Index->Symbols.clear();
+ tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+ EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar"))));
+}
+
} // namespace
} // namespace index
} // namespace clang
OpenPOWER on IntegriCloud