summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/unittests/TestTU.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-04-29 10:25:44 +0000
committerKadir Cetinkaya <kadircet@google.com>2019-04-29 10:25:44 +0000
commit01efe64c2d60e44bb035501205fa595f80028ca7 (patch)
tree5d74ae5a0e28887154287900a2aa451afe8e10e5 /clang-tools-extra/clangd/unittests/TestTU.cpp
parent2078eb745d91b08400c3e723e7cb24d965628426 (diff)
downloadbcm5719-llvm-01efe64c2d60e44bb035501205fa595f80028ca7.tar.gz
bcm5719-llvm-01efe64c2d60e44bb035501205fa595f80028ca7.zip
[clangd] Surface diagnostics from headers inside main file
Reviewers: ioeric, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59302 llvm-svn: 359432
Diffstat (limited to 'clang-tools-extra/clangd/unittests/TestTU.cpp')
-rw-r--r--clang-tools-extra/clangd/unittests/TestTU.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang-tools-extra/clangd/unittests/TestTU.cpp b/clang-tools-extra/clangd/unittests/TestTU.cpp
index 05c7fbf8bf4..8f48eab537e 100644
--- a/clang-tools-extra/clangd/unittests/TestTU.cpp
+++ b/clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -21,11 +21,17 @@ ParsedAST TestTU::build() const {
std::string FullFilename = testPath(Filename),
FullHeaderName = testPath(HeaderFilename),
ImportThunk = testPath("import_thunk.h");
- std::vector<const char *> Cmd = {"clang", FullFilename.c_str()};
// We want to implicitly include HeaderFilename without messing up offsets.
// -include achieves this, but sometimes we want #import (to simulate a header
// guard without messing up offsets). In this case, use an intermediate file.
std::string ThunkContents = "#import \"" + FullHeaderName + "\"\n";
+
+ llvm::StringMap<std::string> Files(AdditionalFiles);
+ Files[FullFilename] = Code;
+ Files[FullHeaderName] = HeaderCode;
+ Files[ImportThunk] = ThunkContents;
+
+ std::vector<const char *> Cmd = {"clang", FullFilename.c_str()};
// FIXME: this shouldn't need to be conditional, but it breaks a
// GoToDefinition test for some reason (getMacroArgExpandedLocation fails).
if (!HeaderCode.empty()) {
@@ -39,9 +45,7 @@ ParsedAST TestTU::build() const {
Inputs.CompileCommand.CommandLine = {Cmd.begin(), Cmd.end()};
Inputs.CompileCommand.Directory = testRoot();
Inputs.Contents = Code;
- Inputs.FS = buildTestFS({{FullFilename, Code},
- {FullHeaderName, HeaderCode},
- {ImportThunk, ThunkContents}});
+ Inputs.FS = buildTestFS(Files);
Inputs.Opts = ParseOptions();
Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
Inputs.Index = ExternalIndex;
OpenPOWER on IntegriCloud