]> granicus.if.org Git - clang/commitdiff
Revert "Visit function/method bodies and issue callback for parameters and local
authorDaniel Dunbar <daniel@zuster.org>
Thu, 3 Sep 2009 05:59:50 +0000 (05:59 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 3 Sep 2009 05:59:50 +0000 (05:59 +0000)
variables.", this is breaking x86_64-apple-darwin10 and Linux tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80896 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang-c/Index.h
include/clang/Frontend/ASTUnit.h
lib/Frontend/ASTUnit.cpp
tools/CIndex/CIndex.cpp
tools/CIndex/CIndex.exports
tools/c-index-test/c-index-test.c

index f85c9d416069b3780aacd25588a26d0bb26e474f..9efa791e89f2d75b61b3493bf1089ef65a5a06eb 100644 (file)
@@ -95,8 +95,6 @@ CXTranslationUnit clang_createTranslationUnit(
   CXIndex, const char *ast_filename
 );
 
-const char *clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
-
 /*
    Usage: clang_loadTranslationUnit(). Will load the toplevel declarations
    within a translation unit, issuing a 'callback' for each one.
index deb4436152b79b4c91325e93f8fbf1d92e2e353e..5eb7f494d736989c854825164f3c2a7a2310b5c7 100644 (file)
@@ -28,7 +28,6 @@ namespace clang {
   class Preprocessor;
   class ASTContext;
   class Decl;
-  class PCHReader;
 
 /// \brief Utility class for loading a ASTContext from a PCH file.
 ///
@@ -40,7 +39,6 @@ class ASTUnit {
   llvm::OwningPtr<TargetInfo>       Target;
   llvm::OwningPtr<Preprocessor>     PP;
   llvm::OwningPtr<ASTContext>       Ctx;
-  llvm::OwningPtr<PCHReader>        Reader;
 
   ASTUnit(const ASTUnit&); // do not implement
   ASTUnit &operator=(const ASTUnit &); // do not implement
@@ -61,8 +59,6 @@ public:
   const Diagnostic &getDiagnostic() const { return *Diags.get(); }
         Diagnostic &getDiagnostic()       { return *Diags.get(); }
 
-  const std::string &getOriginalSourceFileName();
-
   /// \brief Create a ASTUnit from a PCH file.
   ///
   /// \param Filename PCH filename
index 38452ed9d4442965b14ed5e9807ee5bfe9eecce1..8143263ca2f94ee881104424774e048a26fbf154 100644 (file)
@@ -77,9 +77,6 @@ public:
 
 } // anonymous namespace
 
-const std::string &ASTUnit::getOriginalSourceFileName() {
-  return Reader->getOriginalSourceFile();
-}
 
 ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
                                   FileManager &FileMgr,
@@ -104,11 +101,10 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
   std::string Predefines;
   unsigned Counter;
 
-  llvm::OwningPtr<PCHReader>        Reader;
+  llvm::OwningPtr<PCHReader> Reader;
   llvm::OwningPtr<ExternalASTSource> Source;
 
   Reader.reset(new PCHReader(SourceMgr, FileMgr, Diags));
-  AST->Reader.reset(Reader.get());
   Reader->setListener(new PCHInfoCollector(LangInfo, HeaderInfo, TargetTriple,
                                            Predefines, Counter));
 
index a0b49c41691ba639a15318d639c31276ccd31fa4..82f7fb8e2b61df3eb85f9823e8eb60608d137118 100644 (file)
@@ -67,9 +67,6 @@ public:
         break;
     }
   }
-  void VisitVarDecl(VarDecl *ND) {
-    Call(CXCursor_VarDecl, ND);
-  }
   void VisitFunctionDecl(FunctionDecl *ND) {
     Call(ND->isThisDeclarationADefinition() ? CXCursor_FunctionDefn
                                             : CXCursor_FunctionDecl, ND);
@@ -98,9 +95,6 @@ class CDeclVisitor : public DeclVisitor<CDeclVisitor> {
   CXClientData CData;
   
   void Call(enum CXCursorKind CK, NamedDecl *ND) {
-    // Disable the callback when the context is equal to the visiting decl.
-    if (CDecl == ND)
-      return;
     CXCursor C = { CK, ND };
     Callback(CDecl, C, CData);
   }
@@ -135,28 +129,17 @@ public:
   void VisitFieldDecl(FieldDecl *ND) {
     Call(CXCursor_FieldDecl, ND);
   }
-  void VisitVarDecl(VarDecl *ND) {
-    Call(CXCursor_VarDecl, ND);
-  }
-  void VisitParmVarDecl(ParmVarDecl *ND) {
-    Call(CXCursor_ParmDecl, ND);
-  }
   void VisitObjCPropertyDecl(ObjCPropertyDecl *ND) {
     Call(CXCursor_ObjCPropertyDecl, ND);
   }
   void VisitObjCIvarDecl(ObjCIvarDecl *ND) {
     Call(CXCursor_ObjCIvarDecl, ND);
   }
-  void VisitFunctionDecl(FunctionDecl *ND) {
-    if (ND->isThisDeclarationADefinition()) {
-      VisitDeclContext(dyn_cast<DeclContext>(ND));
-    }
-  }
   void VisitObjCMethodDecl(ObjCMethodDecl *ND) {
     if (ND->getBody()) {
       Call(ND->isInstanceMethod() ? CXCursor_ObjCInstanceMethodDefn
                                   : CXCursor_ObjCClassMethodDefn, ND);
-      VisitDeclContext(dyn_cast<DeclContext>(ND));
+      // FIXME: load body.
     } else
       Call(ND->isInstanceMethod() ? CXCursor_ObjCInstanceMethodDecl
                                   : CXCursor_ObjCClassMethodDecl, ND);
@@ -184,12 +167,6 @@ CXTranslationUnit clang_createTranslationUnit(
   return ASTUnit::LoadFromPCHFile(astName, CXXIdx->getFileManager(), &ErrMsg);
 }
 
-const char *clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) 
-{
-  assert(CTUnit && "Passed null CXTranslationUnit");
-  ASTUnit *CXXUnit = static_cast<ASTUnit *>(CTUnit);
-  return CXXUnit->getOriginalSourceFileName().c_str();
-}
 
 void clang_loadTranslationUnit(CXTranslationUnit CTUnit, 
                                CXTranslationUnitIterator callback,
index 7c9660b4d0dc4dc15233388dd3dc8393924b360f..3f87a82b3a14fca0ca1586dc397a6ab477da30d5 100644 (file)
@@ -19,4 +19,3 @@ _clang_isReference
 _clang_isDefinition
 _clang_getCursorSpelling
 _clang_getCursorKindSpelling
-_clang_getTranslationUnitSpelling
index 8df2fc261dc28c8c27dd208cab1630c6f02538ad..2d2be158d0686c1c5ae69178cc3a7a2a87d9e818 100644 (file)
@@ -3,27 +3,25 @@
 #include "clang-c/Index.h"
 #include <stdio.h>
 
-static void PrintCursor(CXCursor Cursor) {
-  printf("%s => %s", clang_getCursorKindSpelling(Cursor.kind),
-                     clang_getCursorSpelling(Cursor));
-  printf(" (%s,%d:%d)\n", clang_getCursorSource(Cursor),
-                          clang_getCursorLine(Cursor),
-                          clang_getCursorColumn(Cursor));
-}
-
 static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter) 
 {
-  printf("%s: ", clang_getDeclSpelling(Dcl));
-  if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter))
-    PrintCursor(Cursor);
+  if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
+    printf("%s => %s", clang_getCursorKindSpelling(Cursor.kind),
+                       clang_getCursorSpelling(Cursor));
+    printf(" (%s,%d:%d)\n", clang_getCursorSource(Cursor),
+                            clang_getCursorLine(Cursor),
+                            clang_getCursorColumn(Cursor));
+  }
 }
-
 static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor,
                                    CXClientData Filter) 
 {
-  printf("%s: ", clang_getTranslationUnitSpelling(Unit));
   if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
-    PrintCursor(Cursor);
+    printf("%s => %s", clang_getCursorKindSpelling(Cursor.kind),
+                       clang_getCursorSpelling(Cursor));
+    printf(" (%s,%d:%d)\n", clang_getCursorSource(Cursor),
+                            clang_getCursorLine(Cursor),
+                            clang_getCursorColumn(Cursor));
 
     clang_loadDeclaration(Cursor.decl, DeclVisitor, 0);
   }