]> granicus.if.org Git - clang/blobdiff - include/clang/Tooling/JSONCompilationDatabase.h
Header guard canonicalization, clang part.
[clang] / include / clang / Tooling / JSONCompilationDatabase.h
index e3f149bebc86168e43e21e1031d2891d7aa95dc1..b4edc31652f785bbe3dbe869f800e0bef1b6c13f 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_TOOLING_JSON_COMPILATION_DATABASE_H
-#define LLVM_CLANG_TOOLING_JSON_COMPILATION_DATABASE_H
+#ifndef LLVM_CLANG_TOOLING_JSONCOMPILATIONDATABASE_H
+#define LLVM_CLANG_TOOLING_JSONCOMPILATIONDATABASE_H
 
 #include "clang/Basic/LLVM.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/FileMatchTrie.h"
-#include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/YAMLParser.h"
+#include <memory>
 #include <string>
 #include <vector>
 
@@ -53,36 +53,37 @@ public:
   ///
   /// Returns NULL and sets ErrorMessage if the database could not be
   /// loaded from the given file.
-  static JSONCompilationDatabase *loadFromFile(StringRef FilePath,
-                                               std::string &ErrorMessage);
+  static std::unique_ptr<JSONCompilationDatabase>
+  loadFromFile(StringRef FilePath, std::string &ErrorMessage);
 
   /// \brief Loads a JSON compilation database from a data buffer.
   ///
   /// Returns NULL and sets ErrorMessage if the database could not be loaded.
-  static JSONCompilationDatabase *loadFromBuffer(StringRef DatabaseString,
-                                                 std::string &ErrorMessage);
+  static std::unique_ptr<JSONCompilationDatabase>
+  loadFromBuffer(StringRef DatabaseString, std::string &ErrorMessage);
 
   /// \brief Returns all compile comamnds in which the specified file was
   /// compiled.
   ///
   /// FIXME: Currently FilePath must be an absolute path inside the
   /// source directory which does not have symlinks resolved.
-  virtual std::vector<CompileCommand> getCompileCommands(
-    StringRef FilePath) const;
+  std::vector<CompileCommand>
+  getCompileCommands(StringRef FilePath) const override;
 
   /// \brief Returns the list of all files available in the compilation database.
   ///
   /// These are the 'file' entries of the JSON objects.
-  virtual std::vector<std::string> getAllFiles() const;
+  std::vector<std::string> getAllFiles() const override;
 
   /// \brief Returns all compile commands for all the files in the compilation
   /// database.
-  virtual std::vector<CompileCommand> getAllCompileCommands() const;
+  std::vector<CompileCommand> getAllCompileCommands() const override;
 
 private:
   /// \brief Constructs a JSON compilation database on a memory buffer.
-  JSONCompilationDatabase(llvm::MemoryBuffer *Database)
-    : Database(Database), YAMLStream(Database->getBuffer(), SM) {}
+  JSONCompilationDatabase(std::unique_ptr<llvm::MemoryBuffer> Database)
+      : Database(std::move(Database)),
+        YAMLStream(this->Database->getBuffer(), SM) {}
 
   /// \brief Parses the database file and creates the index.
   ///
@@ -104,7 +105,7 @@ private:
 
   FileMatchTrie MatchTrie;
 
-  OwningPtr<llvm::MemoryBuffer> Database;
+  std::unique_ptr<llvm::MemoryBuffer> Database;
   llvm::SourceMgr SM;
   llvm::yaml::Stream YAMLStream;
 };
@@ -112,4 +113,4 @@ private:
 } // end namespace tooling
 } // end namespace clang
 
-#endif // LLVM_CLANG_TOOLING_JSON_COMPILATION_DATABASE_H
+#endif