Lines Matching defs:CDB
89 OverlayCDB CDB(Base.get());
90 EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
92 EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), std::nullopt);
95 EXPECT_TRUE(CDB.setCompileCommand(testPath("foo.cc"), Override));
96 EXPECT_FALSE(CDB.setCompileCommand(testPath("foo.cc"), Override));
97 EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
99 EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), std::nullopt);
100 EXPECT_TRUE(CDB.setCompileCommand(testPath("missing.cc"), Override));
101 EXPECT_FALSE(CDB.setCompileCommand(testPath("missing.cc"), Override));
102 EXPECT_THAT(CDB.getCompileCommand(testPath("missing.cc"))->CommandLine,
107 OverlayCDB CDB(Base.get(), {"-DA=4"});
108 EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
113 OverlayCDB CDB(nullptr, {"-DA=6"});
114 EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), std::nullopt);
116 EXPECT_TRUE(CDB.setCompileCommand(testPath("bar.cc"), Override));
117 EXPECT_THAT(CDB.getCompileCommand(testPath("bar.cc"))->CommandLine,
120 EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
142 OverlayCDB CDB(Base.get(), {"-DFallback"},
148 auto Cmd = *CDB.getCompileCommand(testPath("foo.cc"));
156 EXPECT_TRUE(CDB.setCompileCommand(testPath("bar.cc"), BarCommand));
157 Cmd = *CDB.getCompileCommand(testPath("bar.cc"));
163 Cmd = CDB.getFallbackCommand("baz.cc");
176 OverlayCDB CDB(Base.get(), {"-DFallback"});
178 CDB.setCompileCommand(testPath("foo.cc"), Override);
179 EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
249 // a.cc uses another directory's CDB, so it won't be discovered.
253 // gen.cc has CDB search disabled, so it won't be discovered.
269 // Does not use the root CDB, so no broadcast.
272 EXPECT_THAT(Cmd->CommandLine, Contains("-DFOO")) << "a.cc uses foo/ CDB";
274 EXPECT_THAT(DiscoveredFiles, IsEmpty()) << "Root CDB not discovered yet";
276 // No special config for b.cc, so we trigger broadcast of the root CDB.
282 // No CDB search so no discovery/broadcast triggered for build/ CDB.
322 const char *const CDB =
338 llvm::formatv(CDB, llvm::sys::path::convert_to_slash(testRoot()));
347 DirectoryBasedGlobalCompilationDatabase CDB(FS);
348 auto Commands = CDB.getCompileCommand(testPath("x/y.cpp"));
379 DirectoryBasedGlobalCompilationDatabase CDB(Opts);
382 EXPECT_FALSE(CDB.getCompileCommand(testPath("foo.cc")));
383 EXPECT_THAT(CDB.getCompileCommand(testPath("x/foo.cc")), hasArg("-DX"));
384 EXPECT_THAT(CDB.getCompileCommand(testPath("x/y/foo.cc")), hasArg("-DX"));
385 EXPECT_THAT(CDB.getCompileCommand(testPath("x/y/z/foo.cc")), hasArg("-DZ"));
388 EXPECT_FALSE(CDB.getCompileCommand(testPath("foo.cc")));
389 EXPECT_FALSE(CDB.getCompileCommand(testPath("x/foo.cc")));
390 EXPECT_FALSE(CDB.getCompileCommand(testPath("x/y/foo.cc")));
391 EXPECT_FALSE(CDB.getCompileCommand(testPath("x/y/z/foo.cc")));
395 EXPECT_FALSE(CDB.getCompileCommand(testPath("foo.cc")));
396 EXPECT_FALSE(CDB.getCompileCommand(testPath("x/foo.cc")));
397 EXPECT_FALSE(CDB.getCompileCommand(testPath("x/y/foo.cc")));
398 EXPECT_FALSE(CDB.getCompileCommand(testPath("x/y/z/foo.cc")));
401 EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc")), hasArg("-DZ"));
402 EXPECT_THAT(CDB.getCompileCommand(testPath("x/foo.cc")), hasArg("-DZ"));
403 EXPECT_THAT(CDB.getCompileCommand(testPath("x/y/foo.cc")), hasArg("-DZ"));
404 EXPECT_THAT(CDB.getCompileCommand(testPath("x/y/z/foo.cc")), hasArg("-DZ"));
461 const char *const CDB =
472 llvm::formatv(CDB, llvm::sys::path::convert_to_slash(testRoot()),
475 // File from CDB.
477 // File not in CDB, use inference.
494 return std::move(Result->CDB);
529 // Add a compilation database to a subdirectory - CDB loaded.
538 // Mtime changed, but no content change - CDB not reloaded.
542 // Content changed, but not size or mtime - CDB not reloaded.
551 // Size and content both change - CDB reloaded.
573 // However this *does* cause a CDB reload (we cache only one CDB per dir).
577 EXPECT_NE(FoobarAgain, FooBar) << "CDB discarded (shadowed within directory)";
579 // Removing the directory's CDB leaves the parent CDB active.
580 // The parent CDB is *not* reloaded (we cache the CDB per-directory).
583 << "CDB retained (shadowed by another directory)";