diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2021-04-14 14:35:03 +0200 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2021-04-19 11:12:22 +0200 |
commit | 26bbb8700bb0ea0ce29e4158e5aa7999ab0d5386 (patch) | |
tree | 534fa5f211108edca7dd8d575799dbd2dac3e58c /clang/unittests/Frontend/CompilerInvocationTest.cpp | |
parent | 9e9f991ac0330bee8cf6e9c73fe8a7c976d7afce (diff) | |
download | llvm-26bbb8700bb0ea0ce29e4158e5aa7999ab0d5386.zip llvm-26bbb8700bb0ea0ce29e4158e5aa7999ab0d5386.tar.gz llvm-26bbb8700bb0ea0ce29e4158e5aa7999ab0d5386.tar.bz2 |
[clang] Implement CompilerInvocation copy assignment
This patch implements the copy assignment for `CompilerInvocation`.
Eventually, the deep-copy operation will be moved into a `clone()` method (D100460), but until then, this is necessary for basic ergonomics.
Depends on D100455.
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D100473
Diffstat (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp')
-rw-r--r-- | clang/unittests/Frontend/CompilerInvocationTest.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index 5062a2e..0baf17f 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -97,7 +97,7 @@ TEST(ContainsN, Two) { ASSERT_THAT(Array, ContainsN(StrEq("x"), 2)); } -// Copy constructor performs a deep copy of reference-counted pointers. +// Copy constructor/assignment perform deep copy of reference-counted pointers. TEST(CompilerInvocationTest, DeepCopyConstructor) { CompilerInvocation A; @@ -109,6 +109,17 @@ TEST(CompilerInvocationTest, DeepCopyConstructor) { ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old"); } +TEST(CompilerInvocationTest, DeepCopyAssignment) { + CompilerInvocation A; + A.getAnalyzerOpts()->Config["Key"] = "Old"; + + CompilerInvocation B; + B = A; + B.getAnalyzerOpts()->Config["Key"] = "New"; + + ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old"); +} + // Boolean option with a keypath that defaults to true. // The only flag with a negative spelling can set the keypath to false. |