forked from qt-creator/qt-creator
ClangBackEnd: Fix mis-detection of operator<
Inside the body of a function template, clang reports a different cursor type for operators in some cases. Make sure we don't mistake such operator< or operator> as opening or closing a template, respectively. Fixes: QTCREATORBUG-25596 Change-Id: Ifc357e199ea13e44ac501613639e667c333d48e3 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -599,6 +599,7 @@ void TokenInfo::punctuationOrOperatorKind()
|
|||||||
|
|
||||||
if (m_types.mainHighlightingType == HighlightingType::Punctuation
|
if (m_types.mainHighlightingType == HighlightingType::Punctuation
|
||||||
&& m_types.mixinHighlightingTypes.empty()
|
&& m_types.mixinHighlightingTypes.empty()
|
||||||
|
&& kind != CXCursor_OverloadedDeclRef
|
||||||
&& kind != CXCursor_InclusionDirective
|
&& kind != CXCursor_InclusionDirective
|
||||||
&& kind != CXCursor_PreprocessingDirective) {
|
&& kind != CXCursor_PreprocessingDirective) {
|
||||||
const ClangString spelling = m_token->spelling();
|
const ClangString spelling = m_token->spelling();
|
||||||
|
@@ -771,3 +771,20 @@ void func(T v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<std::pair<int, int>> pv;
|
static std::vector<std::pair<int, int>> pv;
|
||||||
|
|
||||||
|
template <class T, long S>
|
||||||
|
struct vecn
|
||||||
|
{
|
||||||
|
T v[S];
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, long S>
|
||||||
|
static inline constexpr vecn<T, S> operator<(vecn<T, S> a, vecn<T, S> b)
|
||||||
|
{
|
||||||
|
vecn<T, S> x = vecn<T, S>{};
|
||||||
|
for(long i = 0; i < S; ++i)
|
||||||
|
{
|
||||||
|
x[i] = a[i] < b[i];
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
@@ -1801,6 +1801,12 @@ TEST_F(TokenProcessor, NestedTemplate)
|
|||||||
HighlightingType::DoubleAngleBracketClose));
|
HighlightingType::DoubleAngleBracketClose));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TokenProcessor, OperatorInTemplate)
|
||||||
|
{
|
||||||
|
const auto infos = translationUnit.tokenInfosInRange(sourceRange(787, 28));
|
||||||
|
ASSERT_THAT(infos[9], HasOnlyType(HighlightingType::Punctuation));
|
||||||
|
}
|
||||||
|
|
||||||
Data *TokenProcessor::d;
|
Data *TokenProcessor::d;
|
||||||
|
|
||||||
void TokenProcessor::SetUpTestCase()
|
void TokenProcessor::SetUpTestCase()
|
||||||
|
Reference in New Issue
Block a user