clang-tags
C/C++ source code indexing tool based on libclang
 All Classes Functions Variables Typedefs Groups Pages
translationUnit.hxx
1 #pragma once
2 
3 #include <clang-c/Index.h>
4 #include <memory>
5 
6 #include "unsavedFiles.hxx"
7 
8 namespace LibClang {
13  // Forward declarations
14  class Index;
15  class SourceLocation;
16  class Cursor;
17 
27  public:
34  void reparse ();
35 
45  void reparse (UnsavedFiles & unsaved);
46 
57  SourceLocation getLocation (const char* fileName, unsigned int offset);
58 
66  Cursor cursor () const;
67 
75  unsigned int numDiagnostics ();
76 
86  std::string diagnostic (unsigned int i);
87 
88  // TODO Make this method private
89  const CXTranslationUnit & raw () const;
90 
91  private:
92  TranslationUnit (CXTranslationUnit tu);
93 
94  struct TranslationUnit_ {
95  CXTranslationUnit translationUnit_;
96  TranslationUnit_ (CXTranslationUnit tu) : translationUnit_ (tu) {}
97  ~TranslationUnit_ () { clang_disposeTranslationUnit (translationUnit_); }
98  };
99  std::shared_ptr<TranslationUnit_> translationUnit_;
100 
101  // Friend declaration
102  friend class Index;
103  friend class Cursor;
104  };
105 
107 }