mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 23:56:49 +00:00
[clang-format] Correctly annotate pointer/reference in _Generic (#133673)
Fix #133663
This commit is contained in:
parent
bae3577002
commit
d3be29642f
@ -1417,6 +1417,10 @@ private:
|
||||
}
|
||||
} else if (Contexts.back().ContextType == Context::C11GenericSelection) {
|
||||
Tok->setType(TT_GenericSelectionColon);
|
||||
auto *Prev = Tok->getPreviousNonComment();
|
||||
assert(Prev);
|
||||
if (Prev->isPointerOrReference())
|
||||
Prev->setFinalizedType(TT_PointerOrReference);
|
||||
} else if (CurrentToken && CurrentToken->is(tok::numeric_constant)) {
|
||||
Tok->setType(TT_BitFieldColon);
|
||||
} else if (Contexts.size() == 1 &&
|
||||
|
@ -363,6 +363,10 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
|
||||
ASSERT_EQ(Tokens.size(), 20u) << Tokens;
|
||||
EXPECT_TOKEN(Tokens[14], tok::star, TT_PointerOrReference);
|
||||
|
||||
Tokens = annotate("#define foo(x) _Generic(x, bar *: 1, default: 0)");
|
||||
ASSERT_EQ(Tokens.size(), 20u) << Tokens;
|
||||
EXPECT_TOKEN(Tokens[11], tok::star, TT_PointerOrReference);
|
||||
|
||||
Tokens = annotate("Thingy kConfig = {\n"
|
||||
" 1,\n"
|
||||
" (uint16_t)(kScale * height_pixels),\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user