summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-12-17 18:02:04 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-12-17 18:02:04 +0000
commit06b2c54db9132bc7b6e599c2a3252ea7f2a8b33b (patch)
tree1f82c3bcffe8b94b88453af46106a2aae3c897b5 /clang/lib/CodeGen/CGDebugInfo.cpp
parente4c9cf04f5be0547938e5442caa10a3f56073a8f (diff)
downloadbcm5719-llvm-06b2c54db9132bc7b6e599c2a3252ea7f2a8b33b.tar.gz
bcm5719-llvm-06b2c54db9132bc7b6e599c2a3252ea7f2a8b33b.zip
Revert "DebugInfo: Generalize debug info location handling"
Fails an ASan bootstrap - I'll try to reproduce locally & sort that out before recommitting. This reverts commit r224385. llvm-svn: 224441
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp61
1 files changed, 40 insertions, 21 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 7452ac98114..5bf460f2b82 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -52,35 +52,54 @@ CGDebugInfo::~CGDebugInfo() {
"Region stack mismatch, stack not empty!");
}
-ArtificialLocation::ArtificialLocation(CodeGenFunction &CGF)
- : ApplyDebugLocation(CGF) {
- if (auto *DI = CGF.getDebugInfo()) {
- // Construct a location that has a valid scope, but no line info.
- assert(!DI->LexicalBlockStack.empty());
- llvm::DIDescriptor Scope(DI->LexicalBlockStack.back());
- CGF.Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(0, 0, Scope));
+SaveAndRestoreLocation::SaveAndRestoreLocation(CodeGenFunction &CGF,
+ CGBuilderTy &B)
+ : DI(CGF.getDebugInfo()), Builder(B) {
+ if (DI) {
+ SavedLoc = DI->getLocation();
+ DI->CurLoc = SourceLocation();
}
}
-ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,
- SourceLocation TemporaryLocation,
- bool ForceColumnInfo)
- : CGF(CGF) {
- if (auto *DI = CGF.getDebugInfo()) {
- OriginalLocation = CGF.Builder.getCurrentDebugLocation();
- if (TemporaryLocation.isInvalid())
- CGF.Builder.SetCurrentDebugLocation(llvm::DebugLoc());
- else
- DI->EmitLocation(CGF.Builder, TemporaryLocation, ForceColumnInfo);
+SaveAndRestoreLocation::~SaveAndRestoreLocation() {
+ if (DI)
+ DI->EmitLocation(Builder, SavedLoc);
+}
+
+NoLocation::NoLocation(CodeGenFunction &CGF, CGBuilderTy &B)
+ : SaveAndRestoreLocation(CGF, B) {
+ if (DI)
+ Builder.SetCurrentDebugLocation(llvm::DebugLoc());
+}
+
+NoLocation::~NoLocation() {
+ if (DI)
+ assert(Builder.getCurrentDebugLocation().isUnknown());
+}
+
+ArtificialLocation::ArtificialLocation(CodeGenFunction &CGF, CGBuilderTy &B)
+ : SaveAndRestoreLocation(CGF, B) {
+ if (DI)
+ Builder.SetCurrentDebugLocation(llvm::DebugLoc());
+}
+
+void ArtificialLocation::Emit() {
+ if (DI) {
+ // Sync the Builder.
+ DI->EmitLocation(Builder, SavedLoc);
+ DI->CurLoc = SourceLocation();
+ // Construct a location that has a valid scope, but no line info.
+ assert(!DI->LexicalBlockStack.empty());
+ llvm::DIDescriptor Scope(DI->LexicalBlockStack.back());
+ Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(0, 0, Scope));
}
}
-ApplyDebugLocation::~ApplyDebugLocation() {
- CGF.Builder.SetCurrentDebugLocation(OriginalLocation);
+ArtificialLocation::~ArtificialLocation() {
+ if (DI)
+ assert(Builder.getCurrentDebugLocation().getLine() == 0);
}
-/// ArtificialLocation - An RAII object that temporarily switches to
-/// an artificial debug location that has a valid scope, but no line
void CGDebugInfo::setLocation(SourceLocation Loc) {
// If the new location isn't valid return.
if (Loc.isInvalid())
OpenPOWER on IntegriCloud