forked from qt-creator/qt-creator
C++: Match const/volatile/signed/unsigned for FullySpecifiedType
Changing a function signature from const to non-const is not recognized as a
changed, and doesn't trigger the "Apply Function Signature Changes" quickfix.
For example:
void func(Foo &var);
void func(Foo &var) {} // Add const before Foo, quickfix is not triggered
Change-Id: I71ae41765d66df69204abd085fdfcfcb2d605f4c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
07dd7d5fe2
commit
5be49c5187
@@ -216,5 +216,16 @@ void FullySpecifiedType::setFlags(unsigned flags)
|
||||
|
||||
bool FullySpecifiedType::match(const FullySpecifiedType &otherTy, Matcher *matcher) const
|
||||
{
|
||||
static const unsigned flagsMask = [](){
|
||||
FullySpecifiedType ty;
|
||||
ty.f._isConst = true;
|
||||
ty.f._isVolatile = true;
|
||||
ty.f._isSigned = true;
|
||||
ty.f._isUnsigned = true;
|
||||
return ty._flags;
|
||||
}();
|
||||
|
||||
if ((_flags & flagsMask) != (otherTy._flags & flagsMask))
|
||||
return false;
|
||||
return type()->match(otherTy.type(), matcher);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ private slots:
|
||||
void findBreakpoints3();
|
||||
|
||||
void astPathOnGeneratedTokens();
|
||||
|
||||
void typeMatcher();
|
||||
};
|
||||
|
||||
void tst_Misc::diagnosticClient_error()
|
||||
@@ -244,5 +246,30 @@ void tst_Misc::astPathOnGeneratedTokens()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_Misc::typeMatcher()
|
||||
{
|
||||
IntegerType dummyType(IntegerType::Int);
|
||||
FullySpecifiedType type1(&dummyType);
|
||||
FullySpecifiedType type2(&dummyType);
|
||||
|
||||
for (int i = 0; i < (1<<8); ++i) {
|
||||
type1.setConst (i & (1 << 0));
|
||||
type1.setVolatile(i & (1 << 1));
|
||||
type1.setSigned (i & (1 << 2));
|
||||
type1.setUnsigned(i & (1 << 3));
|
||||
|
||||
type2.setConst (i & (1 << 4));
|
||||
type2.setVolatile(i & (1 << 5));
|
||||
type2.setSigned (i & (1 << 6));
|
||||
type2.setUnsigned(i & (1 << 7));
|
||||
|
||||
const unsigned type1Specifiers = (i & 0x0f);
|
||||
const unsigned type2Specifiers = (i >> 4);
|
||||
const bool sameSpecifiers = type1Specifiers == type2Specifiers;
|
||||
QCOMPARE(type1.match(type2), sameSpecifiers);
|
||||
QCOMPARE(type2.match(type1), sameSpecifiers);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_Misc)
|
||||
#include "tst_misc.moc"
|
||||
|
||||
Reference in New Issue
Block a user