aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Names.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Names.h')
-rw-r--r--src/libs/3rdparty/cplusplus/Names.h138
1 files changed, 94 insertions, 44 deletions
diff --git a/src/libs/3rdparty/cplusplus/Names.h b/src/libs/3rdparty/cplusplus/Names.h
index cea93911c6..ede94eb781 100644
--- a/src/libs/3rdparty/cplusplus/Names.h
+++ b/src/libs/3rdparty/cplusplus/Names.h
@@ -23,6 +23,7 @@
#include "CPlusPlusForwardDeclarations.h"
#include "Name.h"
#include "FullySpecifiedType.h"
+#include <functional>
#include <vector>
namespace CPlusPlus {
@@ -35,17 +36,17 @@ public:
virtual ~QualifiedNameId();
- virtual const Identifier *identifier() const;
+ const Identifier *identifier() const override;
const Name *base() const;
const Name *name() const;
- virtual const QualifiedNameId *asQualifiedNameId() const
+ const QualifiedNameId *asQualifiedNameId() const override
{ return this; }
protected:
- virtual void accept0(NameVisitor *visitor) const;
- virtual bool match0(const Name *otherName, Matcher *matcher) const;
+ void accept0(NameVisitor *visitor) const override;
+ bool match0(const Name *otherName, Matcher *matcher) const override;
private:
const Name *_base;
@@ -58,21 +59,72 @@ public:
DestructorNameId(const Name *name);
virtual ~DestructorNameId();
- virtual const Name *name() const;
+ const Name *name() const;
- virtual const Identifier *identifier() const;
+ const Identifier *identifier() const override;
- virtual const DestructorNameId *asDestructorNameId() const
+ const DestructorNameId *asDestructorNameId() const override
{ return this; }
protected:
- virtual void accept0(NameVisitor *visitor) const;
- virtual bool match0(const Name *otherName, Matcher *matcher) const;
+ void accept0(NameVisitor *visitor) const override;
+ bool match0(const Name *otherName, Matcher *matcher) const override;
private:
const Name *_name;
};
+class CPLUSPLUS_EXPORT TemplateArgument
+{
+public:
+ TemplateArgument()
+ : _expressionTy(nullptr)
+ , _numericLiteral(nullptr)
+ {}
+
+ TemplateArgument(const FullySpecifiedType &type, const NumericLiteral *numericLiteral = nullptr)
+ : _expressionTy(type)
+ , _numericLiteral(numericLiteral)
+ {}
+
+ bool hasType() const { return _expressionTy.isValid(); }
+
+ bool hasNumericLiteral() const { return _numericLiteral != nullptr; }
+
+ const FullySpecifiedType &type() const { return _expressionTy; }
+ FullySpecifiedType &type() { return _expressionTy; }
+
+ const NumericLiteral *numericLiteral() const { return _numericLiteral; }
+ void setNumericLiteral(const NumericLiteral *l) { _numericLiteral = l; }
+
+ bool operator==(const TemplateArgument &other) const
+ {
+ return _expressionTy == other._expressionTy && _numericLiteral == other._numericLiteral;
+ }
+ bool operator!=(const TemplateArgument &other) const
+ {
+ return _expressionTy != other._expressionTy || _numericLiteral != other._numericLiteral;
+ }
+ bool operator<(const TemplateArgument &other) const
+ {
+ if (_expressionTy == other._expressionTy) {
+ return _numericLiteral < other._numericLiteral;
+ }
+ return _expressionTy < other._expressionTy;
+ }
+
+ bool match(const TemplateArgument &otherTy, Matcher *matcher = nullptr) const;
+
+ size_t hash() const
+ {
+ return _expressionTy.hash() ^ std::hash<const NumericLiteral *>()(_numericLiteral);
+ }
+
+private:
+ FullySpecifiedType _expressionTy;
+ const NumericLiteral *_numericLiteral = nullptr;
+};
+
class CPLUSPLUS_EXPORT TemplateNameId: public Name
{
public:
@@ -85,33 +137,36 @@ public:
virtual ~TemplateNameId();
- virtual const Identifier *identifier() const;
+ const Identifier *identifier() const override;
// ### find a better name
int templateArgumentCount() const;
- const FullySpecifiedType &templateArgumentAt(int index) const;
+ const TemplateArgument &templateArgumentAt(int index) const;
- virtual const TemplateNameId *asTemplateNameId() const
+ const TemplateNameId *asTemplateNameId() const override
{ return this; }
- typedef std::vector<FullySpecifiedType>::const_iterator TemplateArgumentIterator;
+ typedef std::vector<TemplateArgument>::const_iterator TemplateArgumentIterator;
TemplateArgumentIterator firstTemplateArgument() const { return _templateArguments.begin(); }
TemplateArgumentIterator lastTemplateArgument() const { return _templateArguments.end(); }
bool isSpecialization() const { return _isSpecialization; }
- // Comparator needed to distinguish between two different TemplateNameId(e.g.:used in std::map)
- struct Compare {
+ // Comparator needed to distinguish between two different TemplateNameId(e.g.:used in std::unordered_map)
+ struct Equals {
bool operator()(const TemplateNameId *name, const TemplateNameId *other) const;
};
+ struct Hash {
+ size_t operator()(const TemplateNameId *name) const;
+ };
protected:
- virtual void accept0(NameVisitor *visitor) const;
- virtual bool match0(const Name *otherName, Matcher *matcher) const;
+ void accept0(NameVisitor *visitor) const override;
+ bool match0(const Name *otherName, Matcher *matcher) const override;
private:
const Identifier *_identifier;
- std::vector<FullySpecifiedType> _templateArguments;
+ std::vector<TemplateArgument> _templateArguments;
// now TemplateNameId can be a specialization or an instantiation
bool _isSpecialization;
};
@@ -125,7 +180,7 @@ public:
! = < > += -= *= /= %=
^= &= |= << >> >>= <<= == !=
<= >= && || ++ -- , ->* ->
- () []
+ () [] <=>
*/
enum Kind {
InvalidOp,
@@ -170,7 +225,8 @@ public:
ArrowStarOp,
ArrowOp,
FunctionCallOp,
- ArrayAccessOp
+ ArrayAccessOp,
+ SpaceShipOp
};
public:
@@ -179,14 +235,12 @@ public:
Kind kind() const;
- virtual const Identifier *identifier() const;
-
- virtual const OperatorNameId *asOperatorNameId() const
- { return this; }
+ const Identifier *identifier() const override { return nullptr; }
+ const OperatorNameId *asOperatorNameId() const override { return this; }
protected:
- virtual void accept0(NameVisitor *visitor) const;
- virtual bool match0(const Name *otherName, Matcher *matcher) const;
+ void accept0(NameVisitor *visitor) const override;
+ bool match0(const Name *otherName, Matcher *matcher) const override;
private:
Kind _kind;
@@ -198,16 +252,13 @@ public:
ConversionNameId(const FullySpecifiedType &type);
virtual ~ConversionNameId();
- FullySpecifiedType type() const;
-
- virtual const Identifier *identifier() const;
-
- virtual const ConversionNameId *asConversionNameId() const
- { return this; }
+ FullySpecifiedType type() const { return _type; }
+ const Identifier *identifier() const override { return nullptr; }
+ const ConversionNameId *asConversionNameId() const override { return this; }
protected:
- virtual void accept0(NameVisitor *visitor) const;
- virtual bool match0(const Name *otherName, Matcher *matcher) const;
+ void accept0(NameVisitor *visitor) const override;
+ bool match0(const Name *otherName, Matcher *matcher) const override;
private:
FullySpecifiedType _type;
@@ -222,13 +273,13 @@ public:
virtual ~SelectorNameId();
- virtual const Identifier *identifier() const;
+ const Identifier *identifier() const override;
int nameCount() const;
const Name *nameAt(int index) const;
bool hasArguments() const;
- virtual const SelectorNameId *asSelectorNameId() const
+ const SelectorNameId *asSelectorNameId() const override
{ return this; }
typedef std::vector<const Name *>::const_iterator NameIterator;
@@ -237,15 +288,15 @@ public:
NameIterator lastName() const { return _names.end(); }
protected:
- virtual void accept0(NameVisitor *visitor) const;
- virtual bool match0(const Name *otherName, Matcher *matcher) const;
+ void accept0(NameVisitor *visitor) const override;
+ bool match0(const Name *otherName, Matcher *matcher) const override;
private:
std::vector<const Name *> _names;
bool _hasArguments;
};
-class CPLUSPLUS_EXPORT AnonymousNameId: public Name
+class CPLUSPLUS_EXPORT AnonymousNameId final : public Name
{
public:
AnonymousNameId(int classTokenIndex);
@@ -253,14 +304,13 @@ public:
int classTokenIndex() const;
- virtual const Identifier *identifier() const;
+ const Identifier *identifier() const override { return nullptr; }
- virtual const AnonymousNameId *asAnonymousNameId() const
- { return this; }
+ const AnonymousNameId *asAnonymousNameId() const override { return this; }
protected:
- virtual void accept0(NameVisitor *visitor) const;
- virtual bool match0(const Name *otherName, Matcher *matcher) const;
+ void accept0(NameVisitor *visitor) const override;
+ bool match0(const Name *otherName, Matcher *matcher) const override;
private:
int _classTokenIndex;