Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
4b8d5971
Commit
4b8d5971
authored
Mar 23, 2010
by
Roberto Raggi
Browse files
Recognize C++0x rvalue references.
parent
21c13328
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/TypePrettyPrinter.cpp
View file @
4b8d5971
...
...
@@ -150,8 +150,11 @@ void TypePrettyPrinter::applyPtrOperators(bool wantSpace)
if
(
op
->
isPointerType
())
{
_text
+=
QLatin1Char
(
'*'
);
outCV
(
op
);
}
else
if
(
op
->
isReferenceType
())
{
_text
+=
QLatin1Char
(
'&'
);
}
else
if
(
const
ReferenceType
*
ref
=
op
->
asReferenceType
())
{
if
(
ref
->
isRvalueReference
())
_text
+=
QLatin1String
(
"&&"
);
else
_text
+=
QLatin1Char
(
'&'
);
}
else
if
(
const
PointerToMemberType
*
memPtrTy
=
op
->
asPointerToMemberType
())
{
space
();
_text
+=
_overview
->
prettyName
(
memPtrTy
->
memberName
());
...
...
src/shared/cplusplus/AST.cpp
View file @
4b8d5971
...
...
@@ -1513,12 +1513,12 @@ unsigned QualifiedNameAST::lastToken() const
unsigned
ReferenceAST
::
firstToken
()
const
{
return
amp
_token
;
return
reference
_token
;
}
unsigned
ReferenceAST
::
lastToken
()
const
{
return
amp
_token
+
1
;
return
reference
_token
+
1
;
}
...
...
src/shared/cplusplus/AST.h
View file @
4b8d5971
...
...
@@ -2748,11 +2748,11 @@ protected:
class
CPLUSPLUS_EXPORT
ReferenceAST
:
public
PtrOperatorAST
{
public:
unsigned
amp
_token
;
unsigned
reference
_token
;
public:
ReferenceAST
()
:
amp
_token
(
0
)
:
reference
_token
(
0
)
{}
virtual
ReferenceAST
*
asReference
()
{
return
this
;
}
...
...
src/shared/cplusplus/ASTClone.cpp
View file @
4b8d5971
...
...
@@ -1032,7 +1032,7 @@ PointerAST *PointerAST::clone(MemoryPool *pool) const
ReferenceAST
*
ReferenceAST
::
clone
(
MemoryPool
*
pool
)
const
{
ReferenceAST
*
ast
=
new
(
pool
)
ReferenceAST
;
ast
->
amp_token
=
amp
_token
;
ast
->
reference_token
=
reference
_token
;
return
ast
;
}
...
...
src/shared/cplusplus/ASTMatcher.cpp
View file @
4b8d5971
...
...
@@ -1725,7 +1725,7 @@ bool ASTMatcher::match(ReferenceAST *node, ReferenceAST *pattern)
(
void
)
node
;
(
void
)
pattern
;
pattern
->
amp
_token
=
node
->
amp
_token
;
pattern
->
reference
_token
=
node
->
reference
_token
;
return
true
;
}
...
...
src/shared/cplusplus/CheckDeclarator.cpp
View file @
4b8d5971
...
...
@@ -237,9 +237,11 @@ bool CheckDeclarator::visit(PointerAST *ast)
return
false
;
}
bool
CheckDeclarator
::
visit
(
ReferenceAST
*
)
bool
CheckDeclarator
::
visit
(
ReferenceAST
*
ast
)
{
ReferenceType
*
refTy
=
control
()
->
referenceType
(
_fullySpecifiedType
);
const
bool
rvalueRef
=
(
tokenKind
(
ast
->
reference_token
)
==
T_AMPER_AMPER
);
ReferenceType
*
refTy
=
control
()
->
referenceType
(
_fullySpecifiedType
,
rvalueRef
);
FullySpecifiedType
ty
(
refTy
);
_fullySpecifiedType
=
ty
;
return
false
;
...
...
src/shared/cplusplus/Control.cpp
View file @
4b8d5971
...
...
@@ -307,9 +307,9 @@ public:
return
pointerTypes
.
intern
(
PointerType
(
elementType
));
}
ReferenceType
*
findOrInsertReferenceType
(
const
FullySpecifiedType
&
elementType
)
ReferenceType
*
findOrInsertReferenceType
(
const
FullySpecifiedType
&
elementType
,
bool
rvalueRef
)
{
return
referenceTypes
.
intern
(
ReferenceType
(
elementType
));
return
referenceTypes
.
intern
(
ReferenceType
(
elementType
,
rvalueRef
));
}
ArrayType
*
findOrInsertArrayType
(
const
FullySpecifiedType
&
elementType
,
unsigned
size
)
...
...
@@ -648,8 +648,8 @@ PointerToMemberType *Control::pointerToMemberType(const Name *memberName, const
PointerType
*
Control
::
pointerType
(
const
FullySpecifiedType
&
elementType
)
{
return
d
->
findOrInsertPointerType
(
elementType
);
}
ReferenceType
*
Control
::
referenceType
(
const
FullySpecifiedType
&
elementType
)
{
return
d
->
findOrInsertReferenceType
(
elementType
);
}
ReferenceType
*
Control
::
referenceType
(
const
FullySpecifiedType
&
elementType
,
bool
rvalueRef
)
{
return
d
->
findOrInsertReferenceType
(
elementType
,
rvalueRef
);
}
ArrayType
*
Control
::
arrayType
(
const
FullySpecifiedType
&
elementType
,
unsigned
size
)
{
return
d
->
findOrInsertArrayType
(
elementType
,
size
);
}
...
...
src/shared/cplusplus/Control.h
View file @
4b8d5971
...
...
@@ -108,7 +108,7 @@ public:
PointerType
*
pointerType
(
const
FullySpecifiedType
&
elementType
);
/// Returns a Type object of type ReferenceType.
ReferenceType
*
referenceType
(
const
FullySpecifiedType
&
elementType
);
ReferenceType
*
referenceType
(
const
FullySpecifiedType
&
elementType
,
bool
rvalueRef
=
false
);
/// Retruns a Type object of type ArrayType.
ArrayType
*
arrayType
(
const
FullySpecifiedType
&
elementType
,
unsigned
size
=
0
);
...
...
src/shared/cplusplus/CoreTypes.cpp
View file @
4b8d5971
...
...
@@ -154,8 +154,8 @@ bool PointerType::matchType0(const Type *otherType, TypeMatcher *matcher) const
FullySpecifiedType
PointerType
::
elementType
()
const
{
return
_elementType
;
}
ReferenceType
::
ReferenceType
(
const
FullySpecifiedType
&
elementType
)
:
_elementType
(
elementType
)
ReferenceType
::
ReferenceType
(
const
FullySpecifiedType
&
elementType
,
bool
rvalueRef
)
:
_elementType
(
elementType
)
,
_rvalueReference
(
rvalueRef
)
{
}
ReferenceType
::~
ReferenceType
()
...
...
@@ -166,6 +166,8 @@ bool ReferenceType::isEqualTo(const Type *other) const
const
ReferenceType
*
o
=
other
->
asReferenceType
();
if
(
!
o
)
return
false
;
else
if
(
isRvalueReference
()
!=
o
->
isRvalueReference
())
return
false
;
return
_elementType
.
isEqualTo
(
o
->
_elementType
);
}
...
...
@@ -183,6 +185,9 @@ bool ReferenceType::matchType0(const Type *otherType, TypeMatcher *matcher) cons
FullySpecifiedType
ReferenceType
::
elementType
()
const
{
return
_elementType
;
}
bool
ReferenceType
::
isRvalueReference
()
const
{
return
_rvalueReference
;
}
IntegerType
::
IntegerType
(
int
kind
)
:
_kind
(
kind
)
{
}
...
...
src/shared/cplusplus/CoreTypes.h
View file @
4b8d5971
...
...
@@ -212,10 +212,11 @@ private:
class
CPLUSPLUS_EXPORT
ReferenceType
:
public
Type
{
public:
ReferenceType
(
const
FullySpecifiedType
&
elementType
);
ReferenceType
(
const
FullySpecifiedType
&
elementType
,
bool
rvalueRef
);
virtual
~
ReferenceType
();
FullySpecifiedType
elementType
()
const
;
bool
isRvalueReference
()
const
;
virtual
bool
isEqualTo
(
const
Type
*
other
)
const
;
...
...
@@ -231,6 +232,7 @@ protected:
private:
FullySpecifiedType
_elementType
;
bool
_rvalueReference
;
};
class
CPLUSPLUS_EXPORT
ArrayType
:
public
Type
...
...
src/shared/cplusplus/Parser.cpp
View file @
4b8d5971
...
...
@@ -197,6 +197,7 @@ Parser::Parser(TranslationUnit *unit)
_tokenIndex
(
1
),
_templateArguments
(
0
),
_qtMocRunEnabled
(
false
),
_cxx0xEnabled
(
true
),
// C++0x is enabled by default
_objCEnabled
(
false
),
_inFunctionBody
(
false
),
_inObjCImplementationContext
(
false
),
...
...
@@ -213,6 +214,12 @@ bool Parser::qtMocRunEnabled() const
void
Parser
::
setQtMocRunEnabled
(
bool
onoff
)
{
_qtMocRunEnabled
=
onoff
;
}
bool
Parser
::
cxx0xEnabled
()
const
{
return
_cxx0xEnabled
;
}
void
Parser
::
isCxxOxEnabled
(
bool
onoff
)
{
_cxx0xEnabled
=
onoff
;
}
bool
Parser
::
objCEnabled
()
const
{
return
_objCEnabled
;
}
...
...
@@ -1070,9 +1077,9 @@ bool Parser::parseCvQualifiers(SpecifierListAST *&node)
bool
Parser
::
parsePtrOperator
(
PtrOperatorListAST
*&
node
)
{
DEBUG_THIS_RULE
();
if
(
LA
()
==
T_AMPER
)
{
if
(
LA
()
==
T_AMPER
||
(
_cxx0xEnabled
&&
LA
()
==
T_AMPER_AMPER
)
)
{
ReferenceAST
*
ast
=
new
(
_pool
)
ReferenceAST
;
ast
->
amp
_token
=
consumeToken
();
ast
->
reference
_token
=
consumeToken
();
node
=
new
(
_pool
)
PtrOperatorListAST
(
ast
);
return
true
;
}
else
if
(
LA
()
==
T_STAR
)
{
...
...
src/shared/cplusplus/Parser.h
View file @
4b8d5971
...
...
@@ -67,6 +67,9 @@ public:
bool
qtMocRunEnabled
()
const
;
void
setQtMocRunEnabled
(
bool
onoff
);
bool
cxx0xEnabled
()
const
;
void
isCxxOxEnabled
(
bool
onoff
);
bool
objCEnabled
()
const
;
void
setObjCEnabled
(
bool
onoff
);
...
...
@@ -312,6 +315,7 @@ private:
unsigned
_tokenIndex
;
bool
_templateArguments
:
1
;
bool
_qtMocRunEnabled
:
1
;
bool
_cxx0xEnabled
:
1
;
bool
_objCEnabled
:
1
;
bool
_inFunctionBody
:
1
;
bool
_inObjCImplementationContext
:
1
;
...
...
src/shared/cplusplus/TypeMatcher.cpp
View file @
4b8d5971
...
...
@@ -116,6 +116,9 @@ bool TypeMatcher::match(const ReferenceType *type, const ReferenceType *otherTyp
if
(
type
==
otherType
)
return
true
;
else
if
(
type
->
isRvalueReference
()
!=
otherType
->
isRvalueReference
())
return
false
;
else
if
(
!
type
->
elementType
().
match
(
otherType
->
elementType
(),
this
))
return
false
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment