Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang-tools-extra/clangd/unittests/PreambleTests.cpp
Show All 35 Lines | |||||
#include <memory> | #include <memory> | ||||
#include <optional> | #include <optional> | ||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
using testing::AllOf; | using testing::AllOf; | ||||
using testing::Contains; | using testing::Contains; | ||||
using testing::ElementsAre; | using testing::ElementsAre; | ||||
using testing::ElementsAreArray; | |||||
using testing::Eq; | using testing::Eq; | ||||
using testing::Field; | using testing::Field; | ||||
using testing::HasSubstr; | using testing::HasSubstr; | ||||
using testing::IsEmpty; | using testing::IsEmpty; | ||||
using testing::Matcher; | using testing::Matcher; | ||||
using testing::MatchesRegex; | using testing::MatchesRegex; | ||||
using testing::Not; | using testing::Not; | ||||
using testing::UnorderedElementsAre; | using testing::UnorderedElementsAre; | ||||
▲ Show 20 Lines • Show All 649 Lines • ▼ Show 20 Lines | $foo[[#include "foo.h"]])"); | ||||
// Check ranges for notes. | // Check ranges for notes. | ||||
Annotations NewCode(R"(#define BARXYZ 1 | Annotations NewCode(R"(#define BARXYZ 1 | ||||
#define $foo1[[FOO]] 1 | #define $foo1[[FOO]] 1 | ||||
void foo(); | void foo(); | ||||
#define $foo2[[FOO]] 2)"); | #define $foo2[[FOO]] 2)"); | ||||
auto AST = createPatchedAST(Code.code(), NewCode.code(), AdditionalFiles); | auto AST = createPatchedAST(Code.code(), NewCode.code(), AdditionalFiles); | ||||
EXPECT_THAT( | EXPECT_THAT( | ||||
*AST->getDiagnostics(), | *AST->getDiagnostics(), | ||||
ElementsAre(AllOf( | ElementsAre(AllOf(Diag(NewCode.range("foo2"), "-Wmacro-redefined"), | ||||
Diag(NewCode.range("foo2"), "-Wmacro-redefined"), | withNote(Diag(NewCode.range("foo1")))))); | ||||
// FIXME: This should be translated into main file. | |||||
withNote(Field(&Note::File, HasSubstr("_preamble_patch_")))))); | |||||
} | } | ||||
} | } | ||||
TEST(PreamblePatch, TranslatesDiagnosticsInPreamble) { | TEST(PreamblePatch, TranslatesDiagnosticsInPreamble) { | ||||
Config Cfg; | Config Cfg; | ||||
Cfg.Diagnostics.AllowStalePreamble = true; | Cfg.Diagnostics.AllowStalePreamble = true; | ||||
WithContextValue WithCfg(Config::Key, std::move(Cfg)); | WithContextValue WithCfg(Config::Key, std::move(Cfg)); | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |