50 const auto *StrExpr = Result.Nodes.getNodeAs<ObjCStringLiteral>(
"str_lit");
51 const StringLiteral *SL = cast<ObjCStringLiteral>(StrExpr)->getString();
52 const StringRef SR = SL->getString();
55 diag(StrExpr->getExprLoc(),
"invalid date format specifier");
57 if (SR.contains(
'y') && SR.contains(
'w') && !SR.contains(
'Y')) {
58 diag(StrExpr->getExprLoc(),
59 "use of calendar year (y) with week of the year (w); "
60 "did you mean to use week-year (Y) instead?");
62 if (SR.contains(
'F')) {
63 if (!(SR.contains(
'e') || SR.contains(
'E'))) {
64 diag(StrExpr->getExprLoc(),
65 "day of week in month (F) used without day of the week (e or E); "
66 "did you forget e (or E) in the format string?");
68 if (!SR.contains(
'M')) {
69 diag(StrExpr->getExprLoc(),
70 "day of week in month (F) used without the month (M); "
71 "did you forget M in the format string?");
74 if (SR.contains(
'W') && !SR.contains(
'M')) {
75 diag(StrExpr->getExprLoc(),
"Week of Month (W) used without the month (M); "
76 "did you forget M in the format string?");
78 if (SR.contains(
'Y') && SR.contains(
'Q') && !SR.contains(
'y')) {
79 diag(StrExpr->getExprLoc(),
80 "use of week year (Y) with quarter number (Q); "
81 "did you mean to use calendar year (y) instead?");
83 if (SR.contains(
'Y') && SR.contains(
'M') && !SR.contains(
'y')) {
84 diag(StrExpr->getExprLoc(),
85 "use of week year (Y) with month (M); "
86 "did you mean to use calendar year (y) instead?");
88 if (SR.contains(
'Y') && SR.contains(
'D') && !SR.contains(
'y')) {
89 diag(StrExpr->getExprLoc(),
90 "use of week year (Y) with day of the year (D); "
91 "did you mean to use calendar year (y) instead?");
93 if (SR.contains(
'Y') && SR.contains(
'W') && !SR.contains(
'y')) {
94 diag(StrExpr->getExprLoc(),
95 "use of week year (Y) with week of the month (W); "
96 "did you mean to use calendar year (y) instead?");
98 if (SR.contains(
'Y') && SR.contains(
'F') && !SR.contains(
'y')) {
99 diag(StrExpr->getExprLoc(),
100 "use of week year (Y) with day of the week in month (F); "
101 "did you mean to use calendar year (y) instead?");