diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-09-01 03:07:18 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-09-01 03:07:18 +0000 | 
| commit | 01a430134fb5ba09a5562b2a694838e3d02aee4c (patch) | |
| tree | 823a8b67cd7d0937092a4a0b78835a268987d048 /clang/tools | |
| parent | 110ed64fbbcbf27bfce6dac31c06585438c4a3d1 (diff) | |
| download | bcm5719-llvm-01a430134fb5ba09a5562b2a694838e3d02aee4c.tar.gz bcm5719-llvm-01a430134fb5ba09a5562b2a694838e3d02aee4c.zip | |
Implement libclang support for using directives (cursor + visitation +
suppressing USRs). Also, fix up the source location information for
using directives so that the declaration location refers to the
namespace name.
llvm-svn: 112693
Diffstat (limited to 'clang/tools')
| -rw-r--r-- | clang/tools/libclang/CIndex.cpp | 15 | ||||
| -rw-r--r-- | clang/tools/libclang/CIndexUSRs.cpp | 6 | ||||
| -rw-r--r-- | clang/tools/libclang/CXCursor.cpp | 1 | 
3 files changed, 19 insertions, 3 deletions
| diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 230631bad9a..d8491863244 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -317,7 +317,8 @@ public:    bool VisitLinkageSpecDecl(LinkageSpecDecl *D);    bool VisitNamespaceDecl(NamespaceDecl *D);    bool VisitNamespaceAliasDecl(NamespaceAliasDecl *D); -  +  bool VisitUsingDirectiveDecl(UsingDirectiveDecl *D); +      // Name visitor    bool VisitDeclarationNameInfo(DeclarationNameInfo Name); @@ -871,6 +872,13 @@ bool CursorVisitor::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {                                        D->getTargetNameLoc(), TU));  } +bool CursorVisitor::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { +  // FIXME: Visit nested-name-specifier + +  return Visit(MakeCursorNamespaceRef(D->getNominatedNamespaceAsWritten(), +                                      D->getIdentLocation(), TU)); +} +  bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {    switch (Name.getName().getNameKind()) {    case clang::DeclarationName::Identifier: @@ -2022,6 +2030,9 @@ static CXString getDeclSpelling(Decl *D) {      // ObjCCategoryImplDecl returns the category name.      return createCXString(CIMP->getIdentifier()->getNameStart()); +  if (isa<UsingDirectiveDecl>(D)) +    return createCXString(""); +      llvm::SmallString<1024> S;    llvm::raw_svector_ostream os(S);    ND->printName(os); @@ -2219,6 +2230,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {      return createCXString("ClassTemplatePartialSpecialization");    case CXCursor_NamespaceAlias:      return createCXString("NamespaceAlias"); +  case CXCursor_UsingDirective: +    return createCXString("UsingDirective");    }    llvm_unreachable("Unhandled CXCursorKind"); diff --git a/clang/tools/libclang/CIndexUSRs.cpp b/clang/tools/libclang/CIndexUSRs.cpp index 9ef851aeaa2..5628aef056a 100644 --- a/clang/tools/libclang/CIndexUSRs.cpp +++ b/clang/tools/libclang/CIndexUSRs.cpp @@ -82,9 +82,11 @@ public:    void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);    void VisitLinkageSpecDecl(LinkageSpecDecl *D) {      IgnoreResults = true; -    return;    } - +  void VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { +    IgnoreResults = true; +  } +      /// Generate the string component containing the location of the    ///  declaration.    bool GenLoc(const Decl *D); diff --git a/clang/tools/libclang/CXCursor.cpp b/clang/tools/libclang/CXCursor.cpp index 3edbc4d1ef9..75806ffa8d7 100644 --- a/clang/tools/libclang/CXCursor.cpp +++ b/clang/tools/libclang/CXCursor.cpp @@ -69,6 +69,7 @@ static CXCursorKind GetCursorKind(Decl *D) {      case Decl::ClassTemplate:      return CXCursor_ClassTemplate;      case Decl::ClassTemplatePartialSpecialization:        return CXCursor_ClassTemplatePartialSpecialization; +    case Decl::UsingDirective:     return CXCursor_UsingDirective;      default:        if (TagDecl *TD = dyn_cast<TagDecl>(D)) { | 

