Skip to content

Commit 0250e29

Browse files
committed
Fix CodeCompleteTest.cpp for older gcc plus ccache builds
Some versions of gcc, especially when invoked through ccache (-E), can have trouble with raw string literals inside macros. This moves the string out of the macro. llvm-svn: 349059
1 parent 791ae69 commit 0250e29

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

clang/unittests/Sema/CodeCompleteTest.cpp

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -183,113 +183,113 @@ TEST(SemaCodeCompleteTest, VisitedNSWithoutQualifier) {
183183

184184
TEST(PreferredTypeTest, BinaryExpr) {
185185
// Check various operations for arithmetic types.
186-
EXPECT_THAT(collectPreferredTypes(R"cpp(
186+
StringRef code1 = R"cpp(
187187
void test(int x) {
188188
x = ^10;
189189
x += ^10; x -= ^10; x *= ^10; x /= ^10; x %= ^10;
190190
x + ^10; x - ^10; x * ^10; x / ^10; x % ^10;
191-
})cpp"),
192-
Each("int"));
193-
EXPECT_THAT(collectPreferredTypes(R"cpp(
191+
})cpp";
192+
EXPECT_THAT(collectPreferredTypes(code1), Each("int"));
193+
StringRef code2 = R"cpp(
194194
void test(float x) {
195195
x = ^10;
196196
x += ^10; x -= ^10; x *= ^10; x /= ^10; x %= ^10;
197197
x + ^10; x - ^10; x * ^10; x / ^10; x % ^10;
198-
})cpp"),
199-
Each("float"));
198+
})cpp";
199+
EXPECT_THAT(collectPreferredTypes(code2), Each("float"));
200200

201201
// Pointer types.
202-
EXPECT_THAT(collectPreferredTypes(R"cpp(
202+
StringRef code3 = R"cpp(
203203
void test(int *ptr) {
204204
ptr - ^ptr;
205205
ptr = ^ptr;
206-
})cpp"),
207-
Each("int *"));
206+
})cpp";
207+
EXPECT_THAT(collectPreferredTypes(code3), Each("int *"));
208208

209-
EXPECT_THAT(collectPreferredTypes(R"cpp(
209+
StringRef code4 = R"cpp(
210210
void test(int *ptr) {
211211
ptr + ^10;
212212
ptr += ^10;
213213
ptr -= ^10;
214-
})cpp"),
215-
Each("long")); // long is normalized 'ptrdiff_t'.
214+
})cpp";
215+
EXPECT_THAT(collectPreferredTypes(code4), Each("long")); // long is normalized 'ptrdiff_t'.
216216

217217
// Comparison operators.
218-
EXPECT_THAT(collectPreferredTypes(R"cpp(
218+
StringRef code5 = R"cpp(
219219
void test(int i) {
220220
i <= ^1; i < ^1; i >= ^1; i > ^1; i == ^1; i != ^1;
221221
}
222-
)cpp"),
223-
Each("int"));
222+
)cpp";
223+
EXPECT_THAT(collectPreferredTypes(code5), Each("int"));
224224

225-
EXPECT_THAT(collectPreferredTypes(R"cpp(
225+
StringRef code6 = R"cpp(
226226
void test(int *ptr) {
227227
ptr <= ^ptr; ptr < ^ptr; ptr >= ^ptr; ptr > ^ptr;
228228
ptr == ^ptr; ptr != ^ptr;
229229
}
230-
)cpp"),
231-
Each("int *"));
230+
)cpp";
231+
EXPECT_THAT(collectPreferredTypes(code6), Each("int *"));
232232

233233
// Relational operations.
234-
EXPECT_THAT(collectPreferredTypes(R"cpp(
234+
StringRef code7 = R"cpp(
235235
void test(int i, int *ptr) {
236236
i && ^1; i || ^1;
237237
ptr && ^1; ptr || ^1;
238238
}
239-
)cpp"),
240-
Each("_Bool"));
239+
)cpp";
240+
EXPECT_THAT(collectPreferredTypes(code7), Each("_Bool"));
241241

242242
// Bitwise operations.
243-
EXPECT_THAT(collectPreferredTypes(R"cpp(
243+
StringRef code8 = R"cpp(
244244
void test(long long ll) {
245245
ll | ^1; ll & ^1;
246246
}
247-
)cpp"),
248-
Each("long long"));
247+
)cpp";
248+
EXPECT_THAT(collectPreferredTypes(code8), Each("long long"));
249249

250-
EXPECT_THAT(collectPreferredTypes(R"cpp(
250+
StringRef code9 = R"cpp(
251251
enum A {};
252252
void test(A a) {
253253
a | ^1; a & ^1;
254254
}
255-
)cpp"),
256-
Each("enum A"));
255+
)cpp";
256+
EXPECT_THAT(collectPreferredTypes(code9), Each("enum A"));
257257

258-
EXPECT_THAT(collectPreferredTypes(R"cpp(
258+
StringRef code10 = R"cpp(
259259
enum class A {};
260260
void test(A a) {
261261
// This is technically illegal with the 'enum class' without overloaded
262262
// operators, but we pretend it's fine.
263263
a | ^a; a & ^a;
264264
}
265-
)cpp"),
266-
Each("enum A"));
265+
)cpp";
266+
EXPECT_THAT(collectPreferredTypes(code10), Each("enum A"));
267267

268268
// Binary shifts.
269-
EXPECT_THAT(collectPreferredTypes(R"cpp(
269+
StringRef code11 = R"cpp(
270270
void test(int i, long long ll) {
271271
i << ^1; ll << ^1;
272272
i <<= ^1; i <<= ^1;
273273
i >> ^1; ll >> ^1;
274274
i >>= ^1; i >>= ^1;
275275
}
276-
)cpp"),
277-
Each("int"));
276+
)cpp";
277+
EXPECT_THAT(collectPreferredTypes(code11), Each("int"));
278278

279279
// Comma does not provide any useful information.
280-
EXPECT_THAT(collectPreferredTypes(R"cpp(
280+
StringRef code12 = R"cpp(
281281
class Cls {};
282282
void test(int i, int* ptr, Cls x) {
283283
(i, ^i);
284284
(ptr, ^ptr);
285285
(x, ^x);
286286
}
287-
)cpp"),
288-
Each("NULL TYPE"));
287+
)cpp";
288+
EXPECT_THAT(collectPreferredTypes(code12), Each("NULL TYPE"));
289289

290290
// User-defined types do not take operator overloading into account.
291291
// However, they provide heuristics for some common cases.
292-
EXPECT_THAT(collectPreferredTypes(R"cpp(
292+
StringRef code13 = R"cpp(
293293
class Cls {};
294294
void test(Cls c) {
295295
// we assume arithmetic and comparions ops take the same type.
@@ -298,28 +298,28 @@ TEST(PreferredTypeTest, BinaryExpr) {
298298
// same for the assignments.
299299
c = ^c; c += ^c; c -= ^c; c *= ^c; c /= ^c; c %= ^c;
300300
}
301-
)cpp"),
302-
Each("class Cls"));
301+
)cpp";
302+
EXPECT_THAT(collectPreferredTypes(code13), Each("class Cls"));
303303

304-
EXPECT_THAT(collectPreferredTypes(R"cpp(
304+
StringRef code14 = R"cpp(
305305
class Cls {};
306306
void test(Cls c) {
307307
// we assume relational ops operate on bools.
308308
c && ^c; c || ^c;
309309
}
310-
)cpp"),
311-
Each("_Bool"));
310+
)cpp";
311+
EXPECT_THAT(collectPreferredTypes(code14), Each("_Bool"));
312312

313-
EXPECT_THAT(collectPreferredTypes(R"cpp(
313+
StringRef code15 = R"cpp(
314314
class Cls {};
315315
void test(Cls c) {
316316
// we make no assumptions about the following operators, since they are
317317
// often overloaded with a non-standard meaning.
318318
c << ^c; c >> ^c; c | ^c; c & ^c;
319319
c <<= ^c; c >>= ^c; c |= ^c; c &= ^c;
320320
}
321-
)cpp"),
322-
Each("NULL TYPE"));
321+
)cpp";
322+
EXPECT_THAT(collectPreferredTypes(code15), Each("NULL TYPE"));
323323
}
324324

325325
} // namespace

0 commit comments

Comments
 (0)