diff options
author | Marco Bubke <marco.bubke@qt.io> | 2017-07-24 14:55:51 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2017-08-29 16:37:09 +0000 |
commit | f0e00a8c25ff123ad23dc295ecede5736a476685 (patch) | |
tree | a308c4cad8c2f39a5e5db9790ee1f495f94aa085 /src/tools/clangrefactoringbackend/source/findcursorusr.h | |
parent | 8640ef19278139ddee27b93eda1e57b9b51bddfa (diff) | |
download | qt-creator-f0e00a8c25ff123ad23dc295ecede5736a476685.tar.gz |
Clang: Add symbols collector
Change-Id: I64c25eef8eaa6cc6c3ff09d41866972b6c7248d0
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/tools/clangrefactoringbackend/source/findcursorusr.h')
-rw-r--r-- | src/tools/clangrefactoringbackend/source/findcursorusr.h | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/tools/clangrefactoringbackend/source/findcursorusr.h b/src/tools/clangrefactoringbackend/source/findcursorusr.h index 0c228c67e8..549086cd3a 100644 --- a/src/tools/clangrefactoringbackend/source/findcursorusr.h +++ b/src/tools/clangrefactoringbackend/source/findcursorusr.h @@ -25,26 +25,12 @@ #pragma once -#if defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-parameter" -#elif defined(_MSC_VER) -# pragma warning(push) -# pragma warning( disable : 4100 ) -#endif - #include <clang/AST/AST.h> #include <clang/AST/ASTContext.h> #include <clang/AST/RecursiveASTVisitor.h> #include <clang/Index/USRGeneration.h> #include <llvm/ADT/SmallVector.h> -#if defined(__GNUC__) -# pragma GCC diagnostic pop -#elif defined(_MSC_VER) -# pragma warning(pop) -#endif - #include <vector> namespace ClangBackEnd { @@ -54,8 +40,8 @@ class FindNamedDeclarationASTVisitor : public clang::RecursiveASTVisitor<FindNam public: explicit FindNamedDeclarationASTVisitor(const clang::SourceManager &sourceManager, const clang::SourceLocation cursorSourceLocation) - : sourceManager(sourceManager), - cursorSourceLocation(cursorSourceLocation) + : m_sourceManager(sourceManager), + m_cursorSourceLocation(cursorSourceLocation) { } @@ -96,7 +82,7 @@ public: std::vector<const clang::NamedDecl*> takeNamedDecl() { - return std::move(namedDeclarations); + return std::move(m_namedDeclarations); } private: @@ -138,7 +124,7 @@ private: bool isValid = isValidLocationWithCursorInside(startLocation, endLocation); if (isValid) - namedDeclarations.push_back(declaration); + m_namedDeclarations.push_back(declaration); return !isValid; } @@ -153,20 +139,20 @@ private: bool isCursorLocationBetween(const clang::SourceLocation startLocation, const clang::SourceLocation endLocation) { - return cursorSourceLocation == startLocation - || cursorSourceLocation == endLocation - || (sourceManager.isBeforeInTranslationUnit(startLocation, cursorSourceLocation) - && sourceManager.isBeforeInTranslationUnit(cursorSourceLocation, endLocation)); + return m_cursorSourceLocation == startLocation + || m_cursorSourceLocation == endLocation + || (m_sourceManager.isBeforeInTranslationUnit(startLocation, m_cursorSourceLocation) + && m_sourceManager.isBeforeInTranslationUnit(m_cursorSourceLocation, endLocation)); } - std::vector<const clang::NamedDecl*> namedDeclarations; - const clang::SourceManager &sourceManager; - const clang::SourceLocation cursorSourceLocation; + std::vector<const clang::NamedDecl*> m_namedDeclarations; + const clang::SourceManager &m_sourceManager; + const clang::SourceLocation m_cursorSourceLocation; }; inline std::vector<const clang::NamedDecl *> namedDeclarationsAt(const clang::ASTContext &Context, - const clang::SourceLocation cursorSourceLocation) + const clang::SourceLocation cursorSourceLocation) { const auto &sourceManager = Context.getSourceManager(); const auto currentFile = sourceManager.getFilename(cursorSourceLocation); |