aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Analysis/FlowSensitive/TransferTest.cpp')
-rw-r--r--clang/unittests/Analysis/FlowSensitive/TransferTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index d7a51b0..97ec321 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3208,6 +3208,32 @@ TEST(TransferTest, ResultObjectLocationForStmtExpr) {
});
}
+TEST(TransferTest, ResultObjectLocationForBuiltinBitCastExpr) {
+ std::string Code = R"(
+ struct S { int i; };
+ void target(int i) {
+ S s = __builtin_bit_cast(S, i);
+ // [[p]]
+ }
+ )";
+ using ast_matchers::explicitCastExpr;
+ using ast_matchers::match;
+ using ast_matchers::selectFirst;
+ using ast_matchers::traverse;
+ runDataflow(
+ Code,
+ [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
+ ASTContext &ASTCtx) {
+ const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+ auto *BuiltinBitCast = selectFirst<BuiltinBitCastExpr>(
+ "cast", match(explicitCastExpr().bind("cast"), ASTCtx));
+
+ EXPECT_EQ(&Env.getResultObjectLocation(*BuiltinBitCast),
+ &getLocForDecl<RecordStorageLocation>(ASTCtx, Env, "s"));
+ });
+}
+
TEST(TransferTest, ResultObjectLocationPropagatesThroughConditionalOperator) {
std::string Code = R"(
struct A {