diff options
author | Vitaly Buka <vitalybuka@google.com> | 2024-08-03 10:41:32 -0700 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2024-08-03 10:41:32 -0700 |
commit | 44bdf8db938f38005dcf1d8f82709db8cc8a401d (patch) | |
tree | 47ee1b60b853a8fbbe0888ba7f5e4e290882b67f | |
parent | f26dfea1bf5da060aa895fa107575a228d5b0702 (diff) | |
parent | 242e8b94cf68a9666830ef60463400f9a1cc2d2f (diff) | |
download | llvm-users/vitalybuka/spr/main.asan-optimize-initialization-order-checking.zip llvm-users/vitalybuka/spr/main.asan-optimize-initialization-order-checking.tar.gz llvm-users/vitalybuka/spr/main.asan-optimize-initialization-order-checking.tar.bz2 |
[𝘀𝗽𝗿] changes introduced through rebaseusers/vitalybuka/spr/main.asan-optimize-initialization-order-checking
Created using spr 1.3.4
[skip ci]
-rw-r--r-- | .github/workflows/release-binaries.yml | 6 | ||||
-rw-r--r-- | clang/lib/AST/Interp/Compiler.cpp | 16 | ||||
-rw-r--r-- | clang/test/AST/Interp/eval-order.cpp | 5 |
3 files changed, 20 insertions, 7 deletions
diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index b1b046d..7cc8b7a 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -57,6 +57,12 @@ jobs: release-binary-filename: ${{ steps.vars.outputs.release-binary-filename }} steps: + # It's good practice to use setup-python, but this is also required on macos-14 + # due to https://github.com/actions/runner-images/issues/10385 + - uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f + with: + python-version: '3.12' + - name: Checkout LLVM uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp index ada22b5..d9db1c7 100644 --- a/clang/lib/AST/Interp/Compiler.cpp +++ b/clang/lib/AST/Interp/Compiler.cpp @@ -733,8 +733,8 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) { } // Typecheck the args. - std::optional<PrimType> LT = classify(LHS->getType()); - std::optional<PrimType> RT = classify(RHS->getType()); + std::optional<PrimType> LT = classify(LHS); + std::optional<PrimType> RT = classify(RHS); std::optional<PrimType> T = classify(BO->getType()); // Special case for C++'s three-way/spaceship operator <=>, which @@ -769,8 +769,16 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) { return this->VisitPointerArithBinOp(BO); } - if (!visit(LHS) || !visit(RHS)) - return false; + // Assignmentes require us to evalute the RHS first. + if (BO->getOpcode() == BO_Assign) { + if (!visit(RHS) || !visit(LHS)) + return false; + if (!this->emitFlip(*LT, *RT, BO)) + return false; + } else { + if (!visit(LHS) || !visit(RHS)) + return false; + } // For languages such as C, cast the result of one // of our comparision opcodes to T (which is usually int). diff --git a/clang/test/AST/Interp/eval-order.cpp b/clang/test/AST/Interp/eval-order.cpp index d9cfd0b..c78c506 100644 --- a/clang/test/AST/Interp/eval-order.cpp +++ b/clang/test/AST/Interp/eval-order.cpp @@ -45,7 +45,7 @@ namespace EvalOrder { } template <typename T> constexpr T &&b(T &&v) { if (!done_a) - throw "wrong"; // expected-note 4{{not valid}} + throw "wrong"; // expected-note 3{{not valid}} done_b = true; return (T &&)v; } @@ -78,8 +78,7 @@ namespace EvalOrder { SEQ(A(f)(B(1), B(2), B(3))); // Rule 5: b = a, b @= a - SEQ(B(lvalue<int>().get()) = A(0)); // expected-error {{not an integral constant expression}} FIXME \ - // expected-note 2{{in call to}} + SEQ(B(lvalue<int>().get()) = A(0)); SEQ(B(lvalue<UserDefined>().get()) = A(ud)); // expected-error {{not an integral constant expression}} FIXME \ // expected-note 2{{in call to}} SEQ(B(lvalue<int>().get()) += A(0)); |