summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2018-08-24 23:30:57 +0000
committerAdrian Prantl <aprantl@apple.com>2018-08-24 23:30:57 +0000
commit4ddd0596350d102693839349ba4d741a5bbae427 (patch)
tree38a3bed540300c1b19c8ef5da0a49132df2a41b5 /llvm/lib/IR
parent2b1dc39d1885b1dc014e76977488bbc6eae57cb6 (diff)
downloadbcm5719-llvm-4ddd0596350d102693839349ba4d741a5bbae427.tar.gz
bcm5719-llvm-4ddd0596350d102693839349ba4d741a5bbae427.zip
Prevent DILocation::getMergedLocation() from creating invalid metadata.
The function's new implementation from r340583 had a bug in it that could cause an invalid scope to be generated when merging two DILocations with no common ancestor scope. This patch detects this situation and picks the scope of the first location. This is not perfect, because the scope is misleading, but on the other hand, this will be a line 0 location. rdar://problem/43687474 Differential Revision: https://reviews.llvm.org/D51238 llvm-svn: 340672
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 0ceded07679..7a6160244ec 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -102,6 +102,11 @@ const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
L = L->getInlinedAt();
}
}
+
+ // If the two locations are irreconsilable, just pick one. This is misleading,
+ // but on the other hand, it's a "line 0" location.
+ if (!S || !isa<DILocalScope>(S))
+ S = LocA->getScope();
return DILocation::get(Result->getContext(), 0, 0, S, L);
}
OpenPOWER on IntegriCloud