Skip to content

Commit 3bcdc0d

Browse files
committed
Add more flexible string comparisons in tests' synthetic field
callbacks.
1 parent 5ee040b commit 3bcdc0d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

clang/unittests/Analysis/FlowSensitive/RecordOpsTest.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ TEST(RecordOpsTest, CopyRecord) {
6464
runDataflow(
6565
Code,
6666
[](QualType Ty) -> llvm::StringMap<QualType> {
67-
if (Ty.getAsString() != "S")
67+
std::string TypeAsString = Ty.getAsString();
68+
if (TypeAsString != "S" && TypeAsString != "struct S")
6869
return {};
6970
QualType IntTy =
7071
getFieldNamed(Ty->getAsRecordDecl(), "outer_int")->getType();
@@ -123,7 +124,8 @@ TEST(RecordOpsTest, RecordsEqual) {
123124
runDataflow(
124125
Code,
125126
[](QualType Ty) -> llvm::StringMap<QualType> {
126-
if (Ty.getAsString() != "S")
127+
std::string TypeAsString = Ty.getAsString();
128+
if (TypeAsString != "S" && TypeAsString != "struct S")
127129
return {};
128130
QualType IntTy =
129131
getFieldNamed(Ty->getAsRecordDecl(), "outer_int")->getType();
@@ -213,9 +215,10 @@ TEST(RecordOpsTest, CopyRecordBetweenDerivedAndBase) {
213215
)";
214216
auto SyntheticFieldCallback = [](QualType Ty) -> llvm::StringMap<QualType> {
215217
CXXRecordDecl *ADecl = nullptr;
216-
if (Ty.getAsString() == "A" || Ty.getAsString() == "struct A")
218+
std::string TypeAsString = Ty.getAsString();
219+
if (TypeAsString == "A" || TypeAsString == "struct A")
217220
ADecl = Ty->getAsCXXRecordDecl();
218-
else if (Ty.getAsString() == "B" || Ty.getAsString() == "struct B")
221+
else if (TypeAsString == "B" || TypeAsString == "struct B")
219222
ADecl = Ty->getAsCXXRecordDecl()
220223
->bases_begin()
221224
->getType()

0 commit comments

Comments
 (0)