Distinguish two lexical blocks at the same level.

llvm-svn: 96397
This commit is contained in:
Devang Patel 2010-02-16 21:41:20 +00:00
parent b154fdc974
commit 7585580ccc
2 changed files with 22 additions and 1 deletions

View File

@ -1351,10 +1351,13 @@ void CGDebugInfo::EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder) {
/// EmitRegionStart- Constructs the debug code for entering a declarative
/// region - "llvm.dbg.region.start.".
void CGDebugInfo::EmitRegionStart(llvm::Function *Fn, CGBuilderTy &Builder) {
SourceManager &SM = CGM.getContext().getSourceManager();
PresumedLoc PLoc = SM.getPresumedLoc(CurLoc);
llvm::DIDescriptor D =
DebugFactory.CreateLexicalBlock(RegionStack.empty() ?
llvm::DIDescriptor() :
llvm::DIDescriptor(RegionStack.back()));
llvm::DIDescriptor(RegionStack.back()),
PLoc.getLine(), PLoc.getColumn());
RegionStack.push_back(D.getNode());
}

View File

@ -0,0 +1,18 @@
// RUN: %clang_cc1 -emit-llvm -g < %s | grep lexical | count 5
// Test to check number of lexical scope identified in debug info.
extern int bar();
extern void foobar();
void foo(int s) {
unsigned loc = 0;
if (s) {
if (bar()) {
foobar();
}
} else {
loc = 1;
if (bar()) {
loc = 2;
}
}
}