summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r--src/shared/cplusplus/CPlusPlusForwardDeclarations.h3
-rw-r--r--src/shared/cplusplus/Symbol.cpp56
-rw-r--r--src/shared/cplusplus/Symbol.h15
-rw-r--r--src/shared/cplusplus/TranslationUnit.cpp6
-rw-r--r--src/shared/cplusplus/TranslationUnit.h2
5 files changed, 81 insertions, 1 deletions
diff --git a/src/shared/cplusplus/CPlusPlusForwardDeclarations.h b/src/shared/cplusplus/CPlusPlusForwardDeclarations.h
index d04147ad87..29d30428c7 100644
--- a/src/shared/cplusplus/CPlusPlusForwardDeclarations.h
+++ b/src/shared/cplusplus/CPlusPlusForwardDeclarations.h
@@ -49,7 +49,7 @@
#ifndef CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H
#define CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H
-#ifdef HAVE_QT
+#ifndef CPLUSPLUS_WITH_NO_QT
# include <QtCore/qglobal.h>
# define CPLUSPLUS_BEGIN_HEADER
# define CPLUSPLUS_END_HEADER
@@ -58,6 +58,7 @@
# else
# define CPLUSPLUS_EXPORT Q_DECL_IMPORT
# endif
+# define CPLUSPLUS_WITH_NAMESPACE
#else
# define CPLUSPLUS_BEGIN_HEADER
# define CPLUSPLUS_END_HEADER
diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp
index a012cca8ad..cecb468428 100644
--- a/src/shared/cplusplus/Symbol.cpp
+++ b/src/shared/cplusplus/Symbol.cpp
@@ -55,6 +55,7 @@
#include "MemoryPool.h"
#include "SymbolVisitor.h"
#include "NameVisitor.h"
+#include "Scope.h"
#include <cstddef>
#include <cassert>
@@ -313,6 +314,61 @@ void Symbol::setScope(Scope *scope)
_scope = scope;
}
+Scope *Symbol::enclosingNamespaceScope() const
+{
+ if (! _scope)
+ return 0;
+
+ else if (_scope->isNamespaceScope())
+ return _scope;
+
+ return _scope->enclosingNamespaceScope();
+}
+
+Scope *Symbol::enclosingClassScope() const
+{
+ if (! _scope)
+ return 0;
+
+ else if (_scope->isClassScope())
+ return _scope;
+
+ return _scope->enclosingClassScope();
+}
+
+Scope *Symbol::enclosingEnumScope() const
+{
+ if (! _scope)
+ return 0;
+
+ else if (_scope->isEnumScope())
+ return _scope;
+
+ return _scope->enclosingEnumScope();
+}
+
+Scope *Symbol::enclosingFunctionScope() const
+{
+ if (! _scope)
+ return 0;
+
+ else if (_scope->isFunctionScope())
+ return _scope;
+
+ return _scope->enclosingFunctionScope();
+}
+
+Scope *Symbol::enclosingBlockScope() const
+{
+ if (! _scope)
+ return 0;
+
+ else if (_scope->isBlockScope())
+ return _scope;
+
+ return _scope->enclosingBlockScope();
+}
+
unsigned Symbol::index() const
{ return _index; }
diff --git a/src/shared/cplusplus/Symbol.h b/src/shared/cplusplus/Symbol.h
index c5cc484f10..12c4822241 100644
--- a/src/shared/cplusplus/Symbol.h
+++ b/src/shared/cplusplus/Symbol.h
@@ -248,6 +248,21 @@ public:
bool isGenerated() const;
+ /// Returns the eclosing namespace scope.
+ Scope *enclosingNamespaceScope() const;
+
+ /// Returns the enclosing class scope.
+ Scope *enclosingClassScope() const;
+
+ /// Returns the enclosing enum scope.
+ Scope *enclosingEnumScope() const;
+
+ /// Returns the enclosing function scope.
+ Scope *enclosingFunctionScope() const;
+
+ /// Returns the enclosing Block scope.
+ Scope *enclosingBlockScope() const;
+
void setScope(Scope *scope); // ### make me private
void setSourceLocation(unsigned sourceLocation); // ### make me private
diff --git a/src/shared/cplusplus/TranslationUnit.cpp b/src/shared/cplusplus/TranslationUnit.cpp
index d6afcb3e2f..2f2024dc2d 100644
--- a/src/shared/cplusplus/TranslationUnit.cpp
+++ b/src/shared/cplusplus/TranslationUnit.cpp
@@ -465,6 +465,12 @@ void TranslationUnit::fatal(unsigned index, const char *format, ...)
exit(EXIT_FAILURE);
}
+unsigned TranslationUnit::findPreviousLineOffset(unsigned tokenIndex) const
+{
+ unsigned lineOffset = _lineOffsets[findLineNumber(_tokens->at(tokenIndex).offset)];
+ return lineOffset;
+}
+
void TranslationUnit::showErrorLine(unsigned index, unsigned column, FILE *out)
{
unsigned lineOffset = _lineOffsets[findLineNumber(_tokens->at(index).offset)];
diff --git a/src/shared/cplusplus/TranslationUnit.h b/src/shared/cplusplus/TranslationUnit.h
index b4830e525d..609e9b7309 100644
--- a/src/shared/cplusplus/TranslationUnit.h
+++ b/src/shared/cplusplus/TranslationUnit.h
@@ -142,6 +142,8 @@ public:
unsigned line,
StringLiteral *fileName);
+ unsigned findPreviousLineOffset(unsigned tokenIndex) const;
+
public:
struct PPLine {
unsigned offset;