[clang-tools-extra] c814f4c - [clangd] Do not highlight keywords in semantic highlighting
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 28 04:04:31 PDT 2019
Author: Ilya Biryukov
Date: 2019-10-28T12:03:09+01:00
New Revision: c814f4c4592cf0a6049a56b09442369d8e6eb9d7
URL: https://github.com/llvm/llvm-project/commit/c814f4c4592cf0a6049a56b09442369d8e6eb9d7
DIFF: https://github.com/llvm/llvm-project/commit/c814f4c4592cf0a6049a56b09442369d8e6eb9d7.diff
LOG: [clangd] Do not highlight keywords in semantic highlighting
Summary:
Editors are good at highlightings the keywords themselves.
Note that this only affects highlightings of builtin types spelled out
as keywords in the source code. Highlightings of typedefs to builtin
types are unchanged.
Reviewers: hokein
Reviewed By: hokein
Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69431
Added:
Modified:
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/test/semantic-highlighting.test
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 61074852e369..464cbc4fcf85 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -49,7 +49,7 @@ llvm::Optional<HighlightingKind> kindForDecl(const NamedDecl *D) {
return HighlightingKind::Typedef;
}
// We highlight class decls, constructor decls and destructor decls as
- // `Class` type. The destructor decls are handled in `VisitTypeLoc` (we
+ // `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we
// will visit a TypeLoc where the underlying Type is a CXXRecordDecl).
if (auto *RD = llvm::dyn_cast<RecordDecl>(D)) {
// We don't want to highlight lambdas like classes.
@@ -214,25 +214,27 @@ class HighlightingTokenCollector
return true;
}
- bool WalkUpFromTagTypeLoc(TagTypeLoc L) {
+ bool VisitTagTypeLoc(TagTypeLoc L) {
if (L.isDefinition())
return true; // Definition will be highligthed by VisitNamedDecl.
- return RecursiveASTVisitor::WalkUpFromTagTypeLoc(L);
+ if (auto K = kindForType(L.getTypePtr()))
+ addToken(L.getBeginLoc(), *K);
+ return true;
}
- bool WalkUpFromElaboratedTypeLoc(ElaboratedTypeLoc L) {
- // Avoid highlighting 'struct' or 'enum' keywords.
+ bool VisitDecltypeTypeLoc(DecltypeTypeLoc L) {
+ if (auto K = kindForType(L.getTypePtr()))
+ addToken(L.getBeginLoc(), *K);
return true;
}
- bool WalkUpFromDependentNameTypeLoc(DependentNameTypeLoc L) {
+ bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
addToken(L.getNameLoc(), HighlightingKind::DependentType);
return true;
}
- bool VisitTypeLoc(TypeLoc TL) {
- if (auto K = kindForType(TL.getTypePtr()))
- addToken(TL.getBeginLoc(), *K);
+ bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
+ addToken(TL.getBeginLoc(), HighlightingKind::TemplateParameter);
return true;
}
diff --git a/clang-tools-extra/clangd/test/semantic-highlighting.test b/clang-tools-extra/clangd/test/semantic-highlighting.test
index 38cb186946fa..7d9b381e2842 100644
--- a/clang-tools-extra/clangd/test/semantic-highlighting.test
+++ b/clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -67,7 +67,7 @@
# CHECK-NEXT: "lines": [
# CHECK-NEXT: {
# CHECK-NEXT: "line": 0,
-# CHECK-NEXT: "tokens": "AAAAAAADABAAAAAEAAEAAA=="
+# CHECK-NEXT: "tokens": "AAAABAABAAA="
# CHECK-NEXT: }
# CHECK-NEXT: ],
# CHECK-NEXT: "textDocument": {
@@ -82,11 +82,11 @@
# CHECK-NEXT: "lines": [
# CHECK-NEXT: {
# CHECK-NEXT: "line": 0,
-# CHECK-NEXT: "tokens": "AAAAAAADABAAAAAEAAEAAA=="
+# CHECK-NEXT: "tokens": "AAAABAABAAA="
# CHECK-NEXT: }
# CHECK-NEXT: {
# CHECK-NEXT: "line": 1,
-# CHECK-NEXT: "tokens": "AAAAAAADABAAAAAEAAEAAA=="
+# CHECK-NEXT: "tokens": "AAAABAABAAA="
# CHECK-NEXT: }
# CHECK-NEXT: ],
# CHECK-NEXT: "textDocument": {
@@ -101,7 +101,7 @@
# CHECK-NEXT: "lines": [
# CHECK-NEXT: {
# CHECK-NEXT: "line": 1,
-# CHECK-NEXT: "tokens": "AAAAAAADABAAAAAEAAEAAA=="
+# CHECK-NEXT: "tokens": "AAAABAABAAA="
# CHECK-NEXT: }
# CHECK-NEXT: ],
# CHECK-NEXT: "textDocument": {
diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index a20fea32d81c..9d33b523f69b 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -153,26 +153,26 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
const char *TestCases[] = {
R"cpp(
struct $Class[[AS]] {
- $Primitive[[double]] $Field[[SomeMember]];
+ double $Field[[SomeMember]];
};
struct {
} $Variable[[S]];
- $Primitive[[void]] $Function[[foo]]($Primitive[[int]] $Parameter[[A]], $Class[[AS]] $Parameter[[As]]) {
+ void $Function[[foo]](int $Parameter[[A]], $Class[[AS]] $Parameter[[As]]) {
$Primitive[[auto]] $LocalVariable[[VeryLongVariableName]] = 12312;
$Class[[AS]] $LocalVariable[[AA]];
$Primitive[[auto]] $LocalVariable[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
- auto $LocalVariable[[FN]] = [ $LocalVariable[[AA]]]($Primitive[[int]] $Parameter[[A]]) -> $Primitive[[void]] {};
+ auto $LocalVariable[[FN]] = [ $LocalVariable[[AA]]](int $Parameter[[A]]) -> void {};
$LocalVariable[[FN]](12312);
}
)cpp",
R"cpp(
- $Primitive[[void]] $Function[[foo]]($Primitive[[int]]);
- $Primitive[[void]] $Function[[Gah]]();
- $Primitive[[void]] $Function[[foo]]() {
+ void $Function[[foo]](int);
+ void $Function[[Gah]]();
+ void $Function[[foo]]() {
auto $LocalVariable[[Bou]] = $Function[[Gah]];
}
struct $Class[[A]] {
- $Primitive[[void]] $Method[[abc]]();
+ void $Method[[abc]]();
};
)cpp",
R"cpp(
@@ -186,17 +186,17 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
struct $Class[[C]] : $Namespace[[abc]]::$Class[[A]]<$TemplateParameter[[T]]> {
typename $TemplateParameter[[T]]::$DependentType[[A]]* $Field[[D]];
};
- $Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Variable[[AA]];
- typedef $Namespace[[abc]]::$Class[[A]]<$Primitive[[int]]> $Class[[AAA]];
+ $Namespace[[abc]]::$Class[[A]]<int> $Variable[[AA]];
+ typedef $Namespace[[abc]]::$Class[[A]]<int> $Class[[AAA]];
struct $Class[[B]] {
$Class[[B]]();
~$Class[[B]]();
- $Primitive[[void]] operator<<($Class[[B]]);
+ void operator<<($Class[[B]]);
$Class[[AAA]] $Field[[AA]];
};
$Class[[B]]::$Class[[B]]() {}
$Class[[B]]::~$Class[[B]]() {}
- $Primitive[[void]] $Function[[f]] () {
+ void $Function[[f]] () {
$Class[[B]] $LocalVariable[[BB]] = $Class[[B]]();
$LocalVariable[[BB]].~$Class[[B]]();
$Class[[B]]();
@@ -214,7 +214,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
$Enum[[E]] $Field[[EEE]];
$Enum[[EE]] $Field[[EEEE]];
};
- $Primitive[[int]] $Variable[[I]] = $EnumConstant[[Hi]];
+ int $Variable[[I]] = $EnumConstant[[Hi]];
$Enum[[E]] $Variable[[L]] = $Enum[[E]]::$EnumConstant[[B]];
)cpp",
R"cpp(
@@ -242,14 +242,14 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
)cpp",
R"cpp(
struct $Class[[D]] {
- $Primitive[[double]] $Field[[C]];
+ double $Field[[C]];
};
struct $Class[[A]] {
- $Primitive[[double]] $Field[[B]];
+ double $Field[[B]];
$Class[[D]] $Field[[E]];
- static $Primitive[[double]] $StaticField[[S]];
- static $Primitive[[void]] $StaticMethod[[bar]]() {}
- $Primitive[[void]] $Method[[foo]]() {
+ static double $StaticField[[S]];
+ static void $StaticMethod[[bar]]() {}
+ void $Method[[foo]]() {
$Field[[B]] = 123;
this->$Field[[B]] = 156;
this->$Method[[foo]]();
@@ -258,7 +258,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
$StaticField[[S]] = 90.1;
}
};
- $Primitive[[void]] $Function[[foo]]() {
+ void $Function[[foo]]() {
$Class[[A]] $LocalVariable[[AA]];
$LocalVariable[[AA]].$Field[[B]] += 2;
$LocalVariable[[AA]].$Method[[foo]]();
@@ -268,15 +268,15 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
)cpp",
R"cpp(
struct $Class[[AA]] {
- $Primitive[[int]] $Field[[A]];
+ int $Field[[A]];
}
- $Primitive[[int]] $Variable[[B]];
+ int $Variable[[B]];
$Class[[AA]] $Variable[[A]]{$Variable[[B]]};
)cpp",
R"cpp(
namespace $Namespace[[a]] {
struct $Class[[A]] {};
- typedef $Primitive[[char]] $Primitive[[C]];
+ typedef char $Primitive[[C]];
}
typedef $Namespace[[a]]::$Class[[A]] $Class[[B]];
using $Class[[BB]] = $Namespace[[a]]::$Class[[A]];
@@ -287,10 +287,10 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
$Enum[[CC]] $Function[[f]]($Class[[B]]);
$Enum[[CD]] $Function[[f]]($Class[[BB]]);
typedef $Namespace[[a]]::$Primitive[[C]] $Primitive[[PC]];
- typedef $Primitive[[float]] $Primitive[[F]];
+ typedef float $Primitive[[F]];
)cpp",
R"cpp(
- template<typename $TemplateParameter[[T]], typename = $Primitive[[void]]>
+ template<typename $TemplateParameter[[T]], typename = void>
class $Class[[A]] {
$TemplateParameter[[T]] $Field[[AA]];
$TemplateParameter[[T]] $Method[[foo]]();
@@ -302,7 +302,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
template<class $TemplateParameter[[TT]], class $TemplateParameter[[GG]]>
class $Class[[BB]] {};
template<class $TemplateParameter[[T]]>
- class $Class[[BB]]<$TemplateParameter[[T]], $Primitive[[int]]> {};
+ class $Class[[BB]]<$TemplateParameter[[T]], int> {};
template<class $TemplateParameter[[T]]>
class $Class[[BB]]<$TemplateParameter[[T]], $TemplateParameter[[T]]*> {};
@@ -313,13 +313,13 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
class $Class[[Foo]] {};
template<typename $TemplateParameter[[T]]>
- $Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] ...);
+ void $Function[[foo]]($TemplateParameter[[T]] ...);
)cpp",
R"cpp(
template <class $TemplateParameter[[T]]>
struct $Class[[Tmpl]] {$TemplateParameter[[T]] $Field[[x]] = 0;};
- extern template struct $Class[[Tmpl]]<$Primitive[[float]]>;
- template struct $Class[[Tmpl]]<$Primitive[[double]]>;
+ extern template struct $Class[[Tmpl]]<float>;
+ template struct $Class[[Tmpl]]<double>;
)cpp",
// This test is to guard against highlightings disappearing when using
// conversion operators as their behaviour in the clang AST
diff er from
@@ -328,14 +328,14 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
class $Class[[Foo]] {};
struct $Class[[Bar]] {
explicit operator $Class[[Foo]]*() const;
- explicit operator $Primitive[[int]]() const;
+ explicit operator int() const;
operator $Class[[Foo]]();
};
- $Primitive[[void]] $Function[[f]]() {
+ void $Function[[f]]() {
$Class[[Bar]] $LocalVariable[[B]];
$Class[[Foo]] $LocalVariable[[F]] = $LocalVariable[[B]];
$Class[[Foo]] *$LocalVariable[[FP]] = ($Class[[Foo]]*)$LocalVariable[[B]];
- $Primitive[[int]] $LocalVariable[[I]] = ($Primitive[[int]])$LocalVariable[[B]];
+ int $LocalVariable[[I]] = (int)$LocalVariable[[B]];
}
)cpp"
R"cpp(
@@ -355,7 +355,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
class $Class[[Bar]] {
$Class[[Foo]] $Field[[Fo]];
$Enum[[En]] $Field[[E]];
- $Primitive[[int]] $Field[[I]];
+ int $Field[[I]];
$Class[[Bar]] ($Class[[Foo]] $Parameter[[F]],
$Enum[[En]] $Parameter[[E]])
: $Field[[Fo]] ($Parameter[[F]]), $Field[[E]] ($Parameter[[E]]),
@@ -377,7 +377,7 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
$Enum[[auto]] &$Variable[[AER]] = $Variable[[AE]];
$Primitive[[auto]] $Variable[[Form]] = 10.2 + 2 * 4;
$Primitive[[decltype]]($Variable[[Form]]) $Variable[[F]] = 10;
- auto $Variable[[Fun]] = []()->$Primitive[[void]]{};
+ auto $Variable[[Fun]] = []()->void{};
)cpp",
R"cpp(
class $Class[[G]] {};
@@ -385,22 +385,22 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
class $Class[[GP]] {};
template<$Class[[G]] &$TemplateParameter[[U]]>
class $Class[[GR]] {};
- template<$Primitive[[int]] *$TemplateParameter[[U]]>
+ template<int *$TemplateParameter[[U]]>
class $Class[[IP]] {
- $Primitive[[void]] $Method[[f]]() {
+ void $Method[[f]]() {
*$TemplateParameter[[U]] += 5;
}
};
- template<$Primitive[[unsigned]] $TemplateParameter[[U]] = 2>
+ template<unsigned $TemplateParameter[[U]] = 2>
class $Class[[Foo]] {
- $Primitive[[void]] $Method[[f]]() {
- for($Primitive[[int]] $LocalVariable[[I]] = 0;
+ void $Method[[f]]() {
+ for(int $LocalVariable[[I]] = 0;
$LocalVariable[[I]] < $TemplateParameter[[U]];) {}
}
};
$Class[[G]] $Variable[[L]];
- $Primitive[[void]] $Function[[f]]() {
+ void $Function[[f]]() {
$Class[[Foo]]<123> $LocalVariable[[F]];
$Class[[GP]]<&$Variable[[L]]> $LocalVariable[[LL]];
$Class[[GR]]<$Variable[[L]]> $LocalVariable[[LLL]];
@@ -408,24 +408,24 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
)cpp",
R"cpp(
template<typename $TemplateParameter[[T]],
- $Primitive[[void]] (T::*$TemplateParameter[[method]])($Primitive[[int]])>
+ void (T::*$TemplateParameter[[method]])(int)>
struct $Class[[G]] {
- $Primitive[[void]] $Method[[foo]](
+ void $Method[[foo]](
$TemplateParameter[[T]] *$Parameter[[O]]) {
($Parameter[[O]]->*$TemplateParameter[[method]])(10);
}
};
struct $Class[[F]] {
- $Primitive[[void]] $Method[[f]]($Primitive[[int]]);
+ void $Method[[f]](int);
};
- template<$Primitive[[void]] (*$TemplateParameter[[Func]])()>
+ template<void (*$TemplateParameter[[Func]])()>
struct $Class[[A]] {
- $Primitive[[void]] $Method[[f]]() {
+ void $Method[[f]]() {
(*$TemplateParameter[[Func]])();
}
};
- $Primitive[[void]] $Function[[foo]]() {
+ void $Function[[foo]]() {
$Class[[F]] $LocalVariable[[FF]];
$Class[[G]]<$Class[[F]], &$Class[[F]]::$Method[[f]]> $LocalVariable[[GG]];
$LocalVariable[[GG]].$Method[[foo]](&$LocalVariable[[FF]]);
@@ -449,21 +449,21 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
#define $Macro[[SOME_NAME]] variable
#define $Macro[[SOME_NAME_SET]] variable2 = 123
#define $Macro[[INC_VAR]](X) X += 2
- $Primitive[[void]] $Function[[foo]]() {
+ void $Function[[foo]]() {
$Macro[[DEF_VAR]]($LocalVariable[[X]], 123);
$Macro[[DEF_VAR_REV]](908, $LocalVariable[[XY]]);
- $Primitive[[int]] $Macro[[CPY]]( $LocalVariable[[XX]] );
+ int $Macro[[CPY]]( $LocalVariable[[XX]] );
$Macro[[DEF_VAR_TYPE]]($Class[[A]], $LocalVariable[[AA]]);
- $Primitive[[double]] $Macro[[SOME_NAME]];
- $Primitive[[int]] $Macro[[SOME_NAME_SET]];
+ double $Macro[[SOME_NAME]];
+ int $Macro[[SOME_NAME_SET]];
$LocalVariable[[variable]] = 20.1;
- $Macro[[MACRO_CONCAT]](var, 2, $Primitive[[float]]);
+ $Macro[[MACRO_CONCAT]](var, 2, float);
$Macro[[DEF_VAR_T]]($Class[[A]], $Macro[[CPY]](
$Macro[[CPY]]($LocalVariable[[Nested]])),
$Macro[[CPY]]($Class[[A]]()));
$Macro[[INC_VAR]]($LocalVariable[[variable]]);
}
- $Primitive[[void]] $Macro[[SOME_NAME]]();
+ void $Macro[[SOME_NAME]]();
$Macro[[DEF_VAR]]($Variable[[XYZ]], 567);
$Macro[[DEF_VAR_REV]](756, $Variable[[AB]]);
@@ -477,10 +477,10 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
#define $Macro[[fail]](expr) expr
#define $Macro[[assert]](COND) if (!(COND)) { fail("assertion failed" #COND); }
// Preamble ends.
- $Primitive[[int]] $Variable[[x]];
- $Primitive[[int]] $Variable[[y]];
- $Primitive[[int]] $Function[[f]]();
- $Primitive[[void]] $Function[[foo]]() {
+ int $Variable[[x]];
+ int $Variable[[y]];
+ int $Function[[f]]();
+ void $Function[[foo]]() {
$Macro[[assert]]($Variable[[x]] != $Variable[[y]]);
$Macro[[assert]]($Variable[[x]] != $Function[[f]]());
}
@@ -501,12 +501,12 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
)cpp",
R"cpp(
struct $Class[[S]] {
- $Primitive[[float]] $Field[[Value]];
+ float $Field[[Value]];
$Class[[S]] *$Field[[Next]];
};
$Class[[S]] $Variable[[Global]][2] = {$Class[[S]](), $Class[[S]]()};
- $Primitive[[void]] $Function[[f]]($Class[[S]] $Parameter[[P]]) {
- $Primitive[[int]] $LocalVariable[[A]][2] = {1,2};
+ void $Function[[f]]($Class[[S]] $Parameter[[P]]) {
+ int $LocalVariable[[A]][2] = {1,2};
auto [$Variable[[B1]], $Variable[[B2]]] = $LocalVariable[[A]];
auto [$Variable[[G1]], $Variable[[G2]]] = $Variable[[Global]];
$Class[[auto]] [$Variable[[P1]], $Variable[[P2]]] = $Parameter[[P]];
@@ -519,25 +519,25 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
class $Class[[A]] {
using $TemplateParameter[[TemplateParam1]] = $TemplateParameter[[T]];
typedef $TemplateParameter[[T]] $TemplateParameter[[TemplateParam2]];
- using $Primitive[[IntType]] = $Primitive[[int]];
+ using $Primitive[[IntType]] = int;
using $Typedef[[Pointer]] = $TemplateParameter[[T]] *;
using $Typedef[[LVReference]] = $TemplateParameter[[T]] &;
using $Typedef[[RVReference]] = $TemplateParameter[[T]]&&;
using $Typedef[[Array]] = $TemplateParameter[[T]]*[3];
- using $Typedef[[MemberPointer]] = $Primitive[[int]] (A::*)($Primitive[[int]]);
+ using $Typedef[[MemberPointer]] = int (A::*)(int);
// Use various previously defined typedefs in a function type.
- $Primitive[[void]] $Method[[func]](
+ void $Method[[func]](
$Typedef[[Pointer]], $Typedef[[LVReference]], $Typedef[[RVReference]],
$Typedef[[Array]], $Typedef[[MemberPointer]]);
};
)cpp",
R"cpp(
template <class $TemplateParameter[[T]]>
- $Primitive[[void]] $Function[[phase1]]($TemplateParameter[[T]]);
+ void $Function[[phase1]]($TemplateParameter[[T]]);
template <class $TemplateParameter[[T]]>
- $Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
+ void $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
$Function[[phase1]]($Parameter[[P]]);
$DependentName[[phase2]]($Parameter[[P]]);
}
@@ -545,42 +545,42 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
R"cpp(
class $Class[[A]] {
template <class $TemplateParameter[[T]]>
- $Primitive[[void]] $Method[[bar]]($TemplateParameter[[T]]);
+ void $Method[[bar]]($TemplateParameter[[T]]);
};
template <class $TemplateParameter[[U]]>
- $Primitive[[void]] $Function[[foo]]($TemplateParameter[[U]] $Parameter[[P]]) {
+ void $Function[[foo]]($TemplateParameter[[U]] $Parameter[[P]]) {
$Class[[A]]().$Method[[bar]]($Parameter[[P]]);
}
)cpp",
R"cpp(
struct $Class[[A]] {
template <class $TemplateParameter[[T]]>
- static $Primitive[[void]] $StaticMethod[[foo]]($TemplateParameter[[T]]);
+ static void $StaticMethod[[foo]]($TemplateParameter[[T]]);
};
template <class $TemplateParameter[[T]]>
struct $Class[[B]] {
- $Primitive[[void]] $Method[[bar]]() {
+ void $Method[[bar]]() {
$Class[[A]]::$StaticMethod[[foo]]($TemplateParameter[[T]]());
}
};
)cpp",
R"cpp(
template <class $TemplateParameter[[T]]>
- $Primitive[[void]] $Function[[foo]](typename $TemplateParameter[[T]]::$DependentType[[Type]]
+ void $Function[[foo]](typename $TemplateParameter[[T]]::$DependentType[[Type]]
= $TemplateParameter[[T]]::$DependentName[[val]]);
)cpp",
R"cpp(
template <class $TemplateParameter[[T]]>
- $Primitive[[void]] $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
+ void $Function[[foo]]($TemplateParameter[[T]] $Parameter[[P]]) {
$Parameter[[P]].$DependentName[[Field]];
}
)cpp",
R"cpp(
template <class $TemplateParameter[[T]]>
class $Class[[A]] {
- $Primitive[[int]] $Method[[foo]]() {
+ int $Method[[foo]]() {
return $TemplateParameter[[T]]::$DependentName[[Field]];
}
};
diff --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp b/clang-tools-extra/clangd/unittests/TweakTests.cpp
index ac39e06de3fb..f68dff131d9d 100644
--- a/clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -442,20 +442,15 @@ TWEAK_TEST(AnnotateHighlightings);
TEST_F(AnnotateHighlightingsTest, Test) {
EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
EXPECT_AVAILABLE("[[int a; int b;]]");
- EXPECT_EQ("/* storage.type.primitive.cpp */void "
- "/* entity.name.function.cpp */f() {}",
- apply("void ^f() {}"));
+ EXPECT_EQ("void /* entity.name.function.cpp */f() {}", apply("void ^f() {}"));
EXPECT_EQ(apply("[[void f1(); void f2();]]"),
- "/* storage.type.primitive.cpp */void "
- "/* entity.name.function.cpp */f1(); "
- "/* storage.type.primitive.cpp */void "
- "/* entity.name.function.cpp */f2();");
+ "void /* entity.name.function.cpp */f1(); "
+ "void /* entity.name.function.cpp */f2();");
EXPECT_EQ(apply("void f1(); void f2() {^}"),
"void f1(); "
- "/* storage.type.primitive.cpp */void "
- "/* entity.name.function.cpp */f2() {}");
+ "void /* entity.name.function.cpp */f2() {}");
}
TWEAK_TEST(ExpandMacro);
More information about the cfe-commits
mailing list