summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-11-27 17:02:01 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2019-11-27 17:05:21 +0300
commitcbfa237892e55b7129a1178c9b03f26683d643af (patch)
tree70830e078474d161abb0aaac1b500b3490eb9720 /clang/lib/CodeGen/CGExprScalar.cpp
parent9f15fcc2718f95f1dac9e6e57aa93d84e9709930 (diff)
downloadbcm5719-llvm-cbfa237892e55b7129a1178c9b03f26683d643af.tar.gz
bcm5719-llvm-cbfa237892e55b7129a1178c9b03f26683d643af.zip
Revert "[clang][CodeGen] Implicit Conversion Sanitizer: handle increment/decrement (PR44054)"
The asssertion that was added does not hold, breaks on test-suite/MultiSource/Applications/SPASS/analyze.c Will reduce the testcase and revisit. This reverts commit 9872ea4ed1de4c49300430e4f1f4dfc110a79ab9, 870f3542d3e0d06d208442bdca6482866b59171b.
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp36
1 files changed, 3 insertions, 33 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 953ced9168c..82297664064 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2419,39 +2419,9 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
// Most common case by far: integer increment.
} else if (type->isIntegerType()) {
- assert((!type->isPromotableIntegerType() ||
- (type->isSignedIntegerOrEnumerationType() ||
- CGF.getContext()
- .getPromotedIntegerType(type)
- ->isSignedIntegerOrEnumerationType())) &&
- "The following check expects that if we do promotion, at least one "
- "of the types (either base or promoted) will be signed.");
- if (CGF.SanOpts.hasOneOf(
- SanitizerKind::ImplicitIntegerArithmeticValueChange) &&
- type->isPromotableIntegerType()) {
- // While `x += 1` (for `x` with width less than int) is modeled as
- // promotion+arithmetics+demotion, and we can catch lossy demotion with
- // ease; inc/dec with width less than int can't overflow because of
- // promotion rules, so we omit promotion+demotion, which means that we can
- // not catch lossy "demotion". Because we still want to catch these cases
- // when the sanitizer is enabled, we perform the promotion, then perform
- // the increment/decrement in the wider type, and finally
- // perform the demotion. This will catch lossy demotions.
-
- QualType promotedType = CGF.getContext().getPromotedIntegerType(type);
- assert(promotedType != type && "Shouldn't promote to the same type.");
- value = EmitScalarConversion(value, type, promotedType, E->getExprLoc());
- Value *amt = llvm::ConstantInt::get(value->getType(), amount, true);
- value = Builder.CreateAdd(value, amt, isInc ? "inc" : "dec");
- // Do pass non-default ScalarConversionOpts so that sanitizer check is
- // emitted.
- value = EmitScalarConversion(value, promotedType, type, E->getExprLoc(),
- ScalarConversionOpts(CGF.SanOpts));
-
- // Note that signed integer inc/dec with width less than int can't
- // overflow because of promotion rules; we're just eliding a few steps
- // here.
- } else if (E->canOverflow() && type->isSignedIntegerOrEnumerationType()) {
+ // Note that signed integer inc/dec with width less than int can't
+ // overflow because of promotion rules; we're just eliding a few steps here.
+ if (E->canOverflow() && type->isSignedIntegerOrEnumerationType()) {
value = EmitIncDecConsiderOverflowBehavior(E, value, isInc);
} else if (E->canOverflow() && type->isUnsignedIntegerType() &&
CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow)) {
OpenPOWER on IntegriCloud