[clang] 5b6dbde - [CodeGen] bugfix: ApplyDebugLocation goes out of scope before intended
usama hameed via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 24 15:32:31 PST 2023
Author: usama hameed
Date: 2023-01-24T15:31:07-08:00
New Revision: 5b6dbdecba0b033e6a64593062cf87cd6c8a66ee
URL: https://github.com/llvm/llvm-project/commit/5b6dbdecba0b033e6a64593062cf87cd6c8a66ee
DIFF: https://github.com/llvm/llvm-project/commit/5b6dbdecba0b033e6a64593062cf87cd6c8a66ee.diff
LOG: [CodeGen] bugfix: ApplyDebugLocation goes out of scope before intended
rdar://103570533
Differential Revision: https://reviews.llvm.org/D142243
Added:
clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
Modified:
clang/lib/CodeGen/CodeGenFunction.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 55464e1b1636b..8cbe2a5407440 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -361,17 +361,18 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
bool HasOnlyLifetimeMarkers =
HasCleanups && EHStack.containsOnlyLifetimeMarkers(PrologueCleanupDepth);
bool EmitRetDbgLoc = !HasCleanups || HasOnlyLifetimeMarkers;
+
+ std::optional<ApplyDebugLocation> OAL;
if (HasCleanups) {
// Make sure the line table doesn't jump back into the body for
// the ret after it's been at EndLoc.
- std::optional<ApplyDebugLocation> AL;
if (CGDebugInfo *DI = getDebugInfo()) {
if (OnlySimpleReturnStmts)
DI->EmitLocation(Builder, EndLoc);
else
// We may not have a valid end location. Try to apply it anyway, and
// fall back to an artificial location if needed.
- AL = ApplyDebugLocation::CreateDefaultArtificial(*this, EndLoc);
+ OAL = ApplyDebugLocation::CreateDefaultArtificial(*this, EndLoc);
}
PopCleanupBlocks(PrologueCleanupDepth);
diff --git a/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m b/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
new file mode 100644
index 0000000000000..531f99990fdf9
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-arc-ubsan-debugging.m
@@ -0,0 +1,14 @@
+// RUN: %clang -x objective-c -target arm64-apple-macos12.0 -fobjc-arc -std=gnu99 -O0 -fsanitize=undefined -fsanitize=nullability -c %s -v -g
+
+ at interface NSString
+ at end
+
+struct A {
+ NSString *a;
+};
+
+NSString* _Nonnull foo()
+{
+ struct A a;
+ return 0;
+}
More information about the cfe-commits
mailing list