aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Tooling/CompilationDatabase.h
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2012-04-17 16:54:26 +0000
committerManuel Klimek <klimek@google.com>2012-04-17 16:54:26 +0000
commitc661f1467a84a0a3a83a396b067188b647844ee9 (patch)
treede35f100469618d2467a4c1c3b8f09eef8ae1307 /include/clang/Tooling/CompilationDatabase.h
parent82a9478fcb06ac0d4d2241c05efee91d0eeda580 (diff)
Switches the JSONCompilationDatabase to use the YAML parser.
This will allow us to delete the JSON parser from llvm. The biggest change is a general change of strategy - instead of storing StringRef's to the values for the command line and directory in the input buffer, we store ScalarNode*'s. The reason is that the YAML parser's getRawValue on ScalarNodes returns a string that includes the quotes in case of double quoted strings. For the same reason we're removing the JSON parsing part of the command line parsing - this means an extra copy for a command line when it is requested (and only when it is requested). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154929 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Tooling/CompilationDatabase.h')
-rw-r--r--include/clang/Tooling/CompilationDatabase.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/include/clang/Tooling/CompilationDatabase.h b/include/clang/Tooling/CompilationDatabase.h
index 3430320b51..60e9a080dc 100644
--- a/include/clang/Tooling/CompilationDatabase.h
+++ b/include/clang/Tooling/CompilationDatabase.h
@@ -34,13 +34,11 @@
#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 <string>
#include <vector>
-namespace llvm {
-class MemoryBuffer;
-} // end namespace llvm
-
namespace clang {
namespace tooling {
@@ -139,7 +137,7 @@ public:
private:
/// \brief Constructs a JSON compilation database on a memory buffer.
JSONCompilationDatabase(llvm::MemoryBuffer *Database)
- : Database(Database) {}
+ : Database(Database), YAMLStream(Database->getBuffer(), SM) {}
/// \brief Parses the database file and creates the index.
///
@@ -147,14 +145,17 @@ private:
/// failed.
bool parse(std::string &ErrorMessage);
- // Tuple (directory, commandline) where 'commandline' is a JSON escaped bash
- // escaped command line.
- typedef std::pair<StringRef, StringRef> CompileCommandRef;
+ // Tuple (directory, commandline) where 'commandline' pointing to the
+ // corresponding nodes in the YAML stream.
+ typedef std::pair<llvm::yaml::ScalarNode*,
+ llvm::yaml::ScalarNode*> CompileCommandRef;
// Maps file paths to the compile command lines for that file.
llvm::StringMap< std::vector<CompileCommandRef> > IndexByFile;
llvm::OwningPtr<llvm::MemoryBuffer> Database;
+ llvm::SourceMgr SM;
+ llvm::yaml::Stream YAMLStream;
};
} // end namespace tooling