Luca Versari | 99fddff | 2022-05-25 10:22:32 -0700 | [diff] [blame] | 1 | // Part of the Crubit project, under the Apache License v2.0 with LLVM |
| 2 | // Exceptions. See /LICENSE for license information. |
| 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | |
| 5 | // Tests for various types of expressions. |
| 6 | |
| 7 | #include "gmock/gmock.h" |
| 8 | #include "gtest/gtest.h" |
| 9 | #include "lifetime_analysis/test/lifetime_analysis_test.h" |
| 10 | |
| 11 | namespace clang { |
| 12 | namespace tidy { |
| 13 | namespace lifetimes { |
| 14 | namespace { |
| 15 | |
| 16 | TEST_F(LifetimeAnalysisTest, IncrementAndDecrement) { |
| 17 | EXPECT_THAT(GetLifetimes(R"( |
| 18 | int* prefix_inc(int* p) { |
| 19 | return ++p; |
| 20 | } |
| 21 | int* prefix_dec(int* p) { |
| 22 | return --p; |
| 23 | } |
| 24 | int* postfix_inc(int* p) { |
| 25 | return p++; |
| 26 | } |
| 27 | int* postfix_dec(int* p) { |
| 28 | return p--; |
| 29 | } |
| 30 | )"), |
| 31 | LifetimesAre({{"prefix_inc", "a -> a"}, |
| 32 | {"prefix_dec", "a -> a"}, |
| 33 | {"postfix_inc", "a -> a"}, |
| 34 | {"postfix_dec", "a -> a"}})); |
| 35 | } |
| 36 | |
| 37 | } // namespace |
| 38 | } // namespace lifetimes |
| 39 | } // namespace tidy |
| 40 | } // namespace clang |