Clang: Remove pointer arguments from output argument

Non constant pointers are used many times as non output arguments, so you
get misleading information.

Task-number: QTCREATORBUG-18591
Change-Id: Ic5f987db44ad63a0b1a38fd59cd807db5f2acc8f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Marco Bubke
2017-07-20 17:06:36 +02:00
parent 15793d3318
commit 9b5d6546b8
3 changed files with 16 additions and 6 deletions

View File

@@ -76,7 +76,7 @@ bool Type::isReferencingConstant() const
bool Type::isOutputArgument() const bool Type::isOutputArgument() const
{ {
return (isPointer() || isLValueReference()) && !pointeeType().isConstant(); return isLValueReference() && !pointeeType().isConstant();
} }
bool Type::isBuiltinType() const bool Type::isBuiltinType() const

View File

@@ -482,12 +482,12 @@ void f25()
NonConstPointerArgument(x); NonConstPointerArgument(x);
} }
void ConstPointerArgument(const int *argument); void PointerToConstArgument(const int *argument);
void ConstPointerArgument(int *const argument);
void f26() void f26()
{ {
int *x; int *x;
PointerToConstArgument(x);
ConstPointerArgument(x); ConstPointerArgument(x);
} }

View File

@@ -998,7 +998,17 @@ TEST_F(HighlightingMarks, NonConstPointerArgument)
infos[1]; infos[1];
ASSERT_THAT(infos[2], ASSERT_THAT(infos[2],
HasTwoTypes(HighlightingType::LocalVariable, HighlightingType::OutputArgument)); HasOnlyType(HighlightingType::LocalVariable));
}
TEST_F(HighlightingMarks, PointerToConstArgument)
{
const auto infos = translationUnit.highlightingMarksInRange(sourceRange(490, 31));
infos[1];
ASSERT_THAT(infos[2],
HasOnlyType(HighlightingType::LocalVariable));
} }
TEST_F(HighlightingMarks, ConstPointerArgument) TEST_F(HighlightingMarks, ConstPointerArgument)
@@ -1048,7 +1058,7 @@ TEST_F(HighlightingMarks, NonConstPointerArgumentAsExpression)
infos[1]; infos[1];
ASSERT_THAT(infos[3], ASSERT_THAT(infos[3],
HasTwoTypes(HighlightingType::LocalVariable, HighlightingType::OutputArgument)); HasOnlyType(HighlightingType::LocalVariable));
} }
TEST_F(HighlightingMarks, NonConstPointerArgumentAsInstanceWithMember) TEST_F(HighlightingMarks, NonConstPointerArgumentAsInstanceWithMember)