@@ -36,7 +36,7 @@ namespace {
36
36
using ::testing::ElementsAre;
37
37
using ::testing::IsEmpty;
38
38
39
- constexpr InlayHintOptions DefaultInlayHintOpts{ };
39
+ constexpr InlayHintOptions DefaultOptsForTests{ 2 };
40
40
41
41
std::vector<InlayHint> hintsOfKind (ParsedAST &AST, InlayHintKind Kind,
42
42
InlayHintOptions Opts) {
@@ -123,15 +123,15 @@ template <typename... ExpectedHints>
123
123
void assertParameterHints (llvm::StringRef AnnotatedSource,
124
124
ExpectedHints... Expected) {
125
125
ignore (Expected.Side = Left...);
126
- assertHints (InlayHintKind::Parameter, AnnotatedSource, DefaultInlayHintOpts ,
126
+ assertHints (InlayHintKind::Parameter, AnnotatedSource, DefaultOptsForTests ,
127
127
Expected...);
128
128
}
129
129
130
130
template <typename ... ExpectedHints>
131
131
void assertTypeHints (llvm::StringRef AnnotatedSource,
132
132
ExpectedHints... Expected) {
133
133
ignore (Expected.Side = Right...);
134
- assertHints (InlayHintKind::Type, AnnotatedSource, DefaultInlayHintOpts ,
134
+ assertHints (InlayHintKind::Type, AnnotatedSource, DefaultOptsForTests ,
135
135
Expected...);
136
136
}
137
137
@@ -141,7 +141,7 @@ void assertDesignatorHints(llvm::StringRef AnnotatedSource,
141
141
Config Cfg;
142
142
Cfg.InlayHints .Designators = true ;
143
143
WithContextValue WithCfg (Config::Key, std::move (Cfg));
144
- assertHints (InlayHintKind::Designator, AnnotatedSource, DefaultInlayHintOpts ,
144
+ assertHints (InlayHintKind::Designator, AnnotatedSource, DefaultOptsForTests ,
145
145
Expected...);
146
146
}
147
147
@@ -158,7 +158,7 @@ void assertBlockEndHintsWithOpts(llvm::StringRef AnnotatedSource,
158
158
template <typename ... ExpectedHints>
159
159
void assertBlockEndHints (llvm::StringRef AnnotatedSource,
160
160
ExpectedHints... Expected) {
161
- assertBlockEndHintsWithOpts (AnnotatedSource, DefaultInlayHintOpts ,
161
+ assertBlockEndHintsWithOpts (AnnotatedSource, DefaultOptsForTests ,
162
162
Expected...);
163
163
}
164
164
@@ -1241,7 +1241,7 @@ TEST(ParameterHints, IncludeAtNonGlobalScope) {
1241
1241
1242
1242
// Ensure the hint for the call in foo.inc is NOT materialized in foo.cc.
1243
1243
EXPECT_EQ (
1244
- hintsOfKind (*AST, InlayHintKind::Parameter, DefaultInlayHintOpts ).size (),
1244
+ hintsOfKind (*AST, InlayHintKind::Parameter, DefaultOptsForTests ).size (),
1245
1245
0u );
1246
1246
}
1247
1247
@@ -1504,12 +1504,12 @@ TEST(DefaultArguments, Smoke) {
1504
1504
void baz(int = 5) { if (false) baz($unnamed[[)]]; };
1505
1505
)cpp" ;
1506
1506
1507
- assertHints (InlayHintKind::DefaultArgument, Code, DefaultInlayHintOpts ,
1507
+ assertHints (InlayHintKind::DefaultArgument, Code, DefaultOptsForTests ,
1508
1508
ExpectedHint{" A: 4" , " default1" , Left},
1509
1509
ExpectedHint{" , B: 1, C: foo()" , " default2" , Left},
1510
1510
ExpectedHint{" 5" , " unnamed" , Left});
1511
1511
1512
- assertHints (InlayHintKind::Parameter, Code, DefaultInlayHintOpts ,
1512
+ assertHints (InlayHintKind::Parameter, Code, DefaultOptsForTests ,
1513
1513
ExpectedHint{" A: " , " explicit" , Left});
1514
1514
}
1515
1515
@@ -1544,14 +1544,14 @@ TEST(DefaultArguments, WithoutParameterNames) {
1544
1544
}
1545
1545
)cpp" ;
1546
1546
1547
- assertHints (InlayHintKind::DefaultArgument, Code, DefaultInlayHintOpts ,
1547
+ assertHints (InlayHintKind::DefaultArgument, Code, DefaultOptsForTests ,
1548
1548
ExpectedHint{" ..." , " abbreviated" , Left},
1549
1549
ExpectedHint{" , Baz{}" , " paren" , Left},
1550
1550
ExpectedHint{" , Baz{}" , " brace1" , Left},
1551
1551
ExpectedHint{" , Baz{}" , " brace2" , Left},
1552
1552
ExpectedHint{" , Baz{}" , " brace3" , Left});
1553
1553
1554
- assertHints (InlayHintKind::Parameter, Code, DefaultInlayHintOpts );
1554
+ assertHints (InlayHintKind::Parameter, Code, DefaultOptsForTests );
1555
1555
}
1556
1556
1557
1557
TEST (TypeHints, Deduplication) {
@@ -1589,7 +1589,7 @@ TEST(TypeHints, Aliased) {
1589
1589
TU.ExtraArgs .push_back (" -xc" );
1590
1590
auto AST = TU.build ();
1591
1591
1592
- EXPECT_THAT (hintsOfKind (AST, InlayHintKind::Type, DefaultInlayHintOpts ),
1592
+ EXPECT_THAT (hintsOfKind (AST, InlayHintKind::Type, DefaultOptsForTests ),
1593
1593
IsEmpty ());
1594
1594
}
1595
1595
@@ -1606,7 +1606,7 @@ TEST(TypeHints, CallingConvention) {
1606
1606
TU.PredefineMacros = true ; // for the __cdecl
1607
1607
auto AST = TU.build ();
1608
1608
1609
- EXPECT_THAT (hintsOfKind (AST, InlayHintKind::Type, DefaultInlayHintOpts ),
1609
+ EXPECT_THAT (hintsOfKind (AST, InlayHintKind::Type, DefaultOptsForTests ),
1610
1610
IsEmpty ());
1611
1611
}
1612
1612
@@ -1689,7 +1689,7 @@ TEST(TypeHints, SubstTemplateParameterAliases) {
1689
1689
)cpp" ;
1690
1690
1691
1691
assertHintsWithHeader (
1692
- InlayHintKind::Type, VectorIntPtr, Header, DefaultInlayHintOpts ,
1692
+ InlayHintKind::Type, VectorIntPtr, Header, DefaultOptsForTests ,
1693
1693
ExpectedHint{" : int *" , " no_modifier" },
1694
1694
ExpectedHint{" : int **" , " ptr_modifier" },
1695
1695
ExpectedHint{" : int *&" , " ref_modifier" },
@@ -1713,7 +1713,7 @@ TEST(TypeHints, SubstTemplateParameterAliases) {
1713
1713
)cpp" ;
1714
1714
1715
1715
assertHintsWithHeader (
1716
- InlayHintKind::Type, VectorInt, Header, DefaultInlayHintOpts ,
1716
+ InlayHintKind::Type, VectorInt, Header, DefaultOptsForTests ,
1717
1717
ExpectedHint{" : int" , " no_modifier" },
1718
1718
ExpectedHint{" : int *" , " ptr_modifier" },
1719
1719
ExpectedHint{" : int &" , " ref_modifier" },
@@ -1740,7 +1740,7 @@ TEST(TypeHints, SubstTemplateParameterAliases) {
1740
1740
)cpp" ;
1741
1741
1742
1742
assertHintsWithHeader (InlayHintKind::Type, TypeAlias, Header,
1743
- DefaultInlayHintOpts ,
1743
+ DefaultOptsForTests ,
1744
1744
ExpectedHint{" : Short" , " short_name" },
1745
1745
ExpectedHint{" : static_vector<int>" , " vector_name" });
1746
1746
}
@@ -2033,6 +2033,7 @@ TEST(BlockEndHints, If) {
2033
2033
assertBlockEndHints (
2034
2034
R"cpp(
2035
2035
void foo(bool cond) {
2036
+ void* ptr;
2036
2037
if (cond)
2037
2038
;
2038
2039
@@ -2058,13 +2059,17 @@ TEST(BlockEndHints, If) {
2058
2059
2059
2060
if (int i = 0; i > 10) {
2060
2061
$init_cond[[}]]
2062
+
2063
+ if (ptr != nullptr) {
2064
+ $null_check[[}]]
2061
2065
} // suppress
2062
2066
)cpp" ,
2063
2067
ExpectedHint{" // if cond" , " simple" },
2064
2068
ExpectedHint{" // if cond" , " ifelse" }, ExpectedHint{" // if" , " elseif" },
2065
2069
ExpectedHint{" // if !cond" , " inner" },
2066
2070
ExpectedHint{" // if cond" , " outer" }, ExpectedHint{" // if X" , " init" },
2067
- ExpectedHint{" // if i > 10" , " init_cond" });
2071
+ ExpectedHint{" // if i > 10" , " init_cond" },
2072
+ ExpectedHint{" // if ptr != nullptr" , " null_check" });
2068
2073
}
2069
2074
2070
2075
TEST (BlockEndHints, Loops) {
@@ -2339,6 +2344,10 @@ TEST(BlockEndHints, PointerToMemberFunction) {
2339
2344
}
2340
2345
2341
2346
TEST (BlockEndHints, MinLineLimit) {
2347
+ InlayHintOptions Opts;
2348
+ Opts.HintMinLineLimit = 10 ;
2349
+
2350
+ // namespace ns below is exactly 10 lines
2342
2351
assertBlockEndHintsWithOpts (
2343
2352
R"cpp(
2344
2353
namespace ns {
@@ -2372,7 +2381,7 @@ TEST(BlockEndHints, MinLineLimit) {
2372
2381
$method2[[}]]
2373
2382
$foo[[}]]
2374
2383
)cpp" ,
2375
- InlayHintOptions{ 10 } , ExpectedHint{" // namespace ns" , " namespace" },
2384
+ Opts , ExpectedHint{" // namespace ns" , " namespace" },
2376
2385
ExpectedHint{" // foo" , " foo" });
2377
2386
}
2378
2387
0 commit comments