Clang: Add clang query

Clang query is mechanism to use AST matcher to search for code. Think
about regular expression but in the context of AST. So you get a semantic
search tool for C++.

Change-Id: I72e882c5b53a0c52f352a3664847c4c3e4f6fc2e
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tim Jenssen
2016-11-15 15:38:12 +01:00
parent 96187594b5
commit 9c7ff5199f
99 changed files with 4603 additions and 246 deletions

View File

@@ -25,6 +25,7 @@
#pragma once
#include "clangtool.h"
#include "findusrforcursoraction.h"
#include "symbollocationfinderaction.h"
#include "sourcefilecallbacks.h"
@@ -42,42 +43,13 @@
#pragma GCC diagnostic pop
#endif
#include <string>
#include <vector>
namespace ClangBackEnd {
struct FileContent
{
FileContent(const std::string &directory,
const std::string &fileName,
const std::string &content,
const std::vector<std::string> &commandLine)
: directory(directory),
fileName(fileName),
filePath(directory + nativeSeperator + fileName),
content(content),
commandLine(commandLine)
{}
std::string directory;
std::string fileName;
std::string filePath;
std::string content;
std::vector<std::string> commandLine;
};
class SymbolFinder
class SymbolFinder : public ClangTool
{
public:
SymbolFinder(uint line, uint column);
void addFile(std::string &&directory,
std::string &&fileName,
std::string &&content,
std::vector<std::string> &&commandLine);
void findSymbol();
Utils::SmallString takeSymbolName();
@@ -90,7 +62,7 @@ private:
USRFindingAction usrFindingAction;
SymbolLocationFinderAction symbolLocationFinderAction;
SourceFileCallbacks sourceFileCallbacks;
std::vector<FileContent> fileContents;
ClangBackEnd::SourceLocationsContainer sourceLocations_;
};