summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp9
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.h4
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp8
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp1
4 files changed, 20 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5e60bd8f66c..6d61c52af5f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -111,6 +111,9 @@ llvm::DIDescriptor CGDebugInfo::getContextDescriptor(const Decl *Context) {
return llvm::DIDescriptor(Ty);
}
}
+
+ if (!LexicalBlockStack.empty())
+ return llvm::DIDescriptor(LexicalBlockStack.back());
return TheCU;
}
@@ -2822,6 +2825,12 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD,
getStaticDataMemberDeclaration(VD));
}
+void CGDebugInfo::EmitUsingDirectiveDecl(const UsingDirectiveDecl &UD) {
+ SourceLocation Loc = UD.getNamespaceKeyLocation();
+ llvm::DIFile Unit = getOrCreateFile(Loc);
+ DBuilder.createUsingDirective(getContextDescriptor(&UD), Unit, getLineNumber(Loc), getOrCreateNameSpace(UD.getNominatedNamespace()));
+}
+
/// getOrCreateNamesSpace - Return namespace descriptor for the given
/// namespace decl.
llvm::DINameSpace
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index fbbee0b3d2b..bcda906a027 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -34,6 +34,7 @@ namespace clang {
class ObjCInterfaceDecl;
class ClassTemplateSpecializationDecl;
class GlobalDecl;
+ class UsingDirectiveDecl;
namespace CodeGen {
class CodeGenModule;
@@ -247,6 +248,9 @@ public:
/// EmitGlobalVariable - Emit global variable's debug info.
void EmitGlobalVariable(const ValueDecl *VD, llvm::Constant *Init);
+ /// \brief Emit a C++ using directive.
+ void EmitUsingDirectiveDecl(const UsingDirectiveDecl &UD);
+
/// getOrCreateRecordType - Emit record type's standalone debug info.
llvm::DIType getOrCreateRecordType(QualType Ty, SourceLocation L);
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index a43a38360b1..75b45cc28be 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -78,14 +78,18 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
case Decl::CXXRecord: // struct/union/class X; [C++]
case Decl::Using: // using X; [C++]
case Decl::UsingShadow:
- case Decl::UsingDirective: // using namespace X; [C++]
case Decl::NamespaceAlias:
case Decl::StaticAssert: // static_assert(X, ""); [C++0x]
case Decl::Label: // __label__ x;
case Decl::Import:
// None of these decls require codegen support.
return;
-
+ case Decl::UsingDirective: { // using namespace X; [C++]
+ if (CGDebugInfo *DI = getDebugInfo()) {
+ DI->EmitUsingDirectiveDecl(cast<UsingDirectiveDecl>(D));
+ }
+ return;
+ }
case Decl::Var: {
const VarDecl &VD = cast<VarDecl>(D);
assert(VD.isLocalVarDecl() &&
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 729cdba4dee..119b90aa081 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -191,6 +191,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
// Emit debug descriptor for function end.
if (CGDebugInfo *DI = getDebugInfo()) {
DI->EmitFunctionEnd(Builder);
+ DI->setLocation(EndLoc);
}
EmitFunctionEpilog(*CurFnInfo);
OpenPOWER on IntegriCloud