File tree Expand file tree Collapse file tree 6 files changed +110
-3
lines changed Expand file tree Collapse file tree 6 files changed +110
-3
lines changed Original file line number Diff line number Diff line change @@ -246,10 +246,11 @@ std::optional<std::string_view> SymbolFormatter::getSymbolCached(
246
246
247
247
std::optional<std::string_view>
248
248
SymbolFormatter::getContextSymbol (const clang::DeclContext &declContext) {
249
- if (auto namespaceDecl = llvm::dyn_cast<clang::NamespaceDecl>(&declContext)) {
249
+ if (auto *namespaceDecl =
250
+ llvm::dyn_cast<clang::NamespaceDecl>(&declContext)) {
250
251
return this ->getNamespaceSymbol (*namespaceDecl);
251
252
}
252
- if (auto tagDecl = llvm::dyn_cast<clang::TagDecl>(&declContext)) {
253
+ if (auto * tagDecl = llvm::dyn_cast<clang::TagDecl>(&declContext)) {
253
254
return this ->getTagSymbol (*tagDecl);
254
255
}
255
256
if (llvm::isa<clang::TranslationUnitDecl>(declContext)
@@ -264,16 +265,22 @@ SymbolFormatter::getContextSymbol(const clang::DeclContext &declContext) {
264
265
return std::string (this ->scratchBuffer );
265
266
});
266
267
}
268
+ if (auto *functionDecl = llvm::dyn_cast<clang::FunctionDecl>(&declContext)) {
269
+ // TODO: Strictly speaking, we should return some information marking
270
+ // the symbol as local, but it shouldn't be possible to create spurious
271
+ // references, so this is OK for now.
272
+ return this ->getFunctionSymbol (*functionDecl);
273
+ }
267
274
// TODO: Handle all cases of DeclContext here:
268
275
// Done
269
276
// - TranslationUnitDecl
270
277
// - ExternCContext
271
278
// - NamespaceDecl
272
279
// - TagDecl
280
+ // - FunctionDecl
273
281
// Pending:
274
282
// - OMPDeclareReductionDecl
275
283
// - OMPDeclareMapperDecl
276
- // - FunctionDecl
277
284
// - ObjCMethodDecl
278
285
// - ObjCContainerDecl
279
286
// - LinkageSpecDecl
Original file line number Diff line number Diff line change
1
+ void f () {
2
+ struct C {
3
+ int plain_field;
4
+
5
+ void g () {};
6
+ };
7
+
8
+ (void )C ().plain_field ;
9
+ C ().g ();
10
+
11
+ int x = 0 ;
12
+ (void )(2 * x);
13
+ }
Original file line number Diff line number Diff line change
1
+ void f () {
2
+ // ^^^^ definition [..] `<file>/body.cc`/
3
+ // ^ definition [..] f(49f6e7a06ebc5aa8).
4
+ struct C {
5
+ // ^ definition [..] f(49f6e7a06ebc5aa8).C#
6
+ int plain_field;
7
+ // ^^^^^^^^^^^ definition [..] f(49f6e7a06ebc5aa8).C#plain_field.
8
+
9
+ void g () {};
10
+ // ^ definition [..] f(49f6e7a06ebc5aa8).C#g(49f6e7a06ebc5aa8).
11
+ };
12
+
13
+ (void )C ().plain_field ;
14
+ // ^ reference [..] f(49f6e7a06ebc5aa8).C#
15
+ // ^^^^^^^^^^^ reference [..] f(49f6e7a06ebc5aa8).C#plain_field.
16
+ C ().g ();
17
+ // ^ reference [..] f(49f6e7a06ebc5aa8).C#
18
+ // ^ reference [..] f(49f6e7a06ebc5aa8).C#g(49f6e7a06ebc5aa8).
19
+
20
+ int x = 0 ;
21
+ // ^ definition local 0
22
+ (void )(2 * x);
23
+ // ^ reference local 0
24
+ }
Original file line number Diff line number Diff line change
1
+ template <typename T>
2
+ void f () {
3
+ struct C {
4
+ int plain_field;
5
+ T dependent_field;
6
+
7
+ void g () {};
8
+ };
9
+
10
+ (void )C ().plain_field ;
11
+ (void )C ().dependent_field ;
12
+ C ().g ();
13
+
14
+ int x = 0 ;
15
+ (void )(2 * x);
16
+
17
+ // The following are not allowed:
18
+ // - Templated function-local classes
19
+ // - Templates inside function-local classes
20
+ }
Original file line number Diff line number Diff line change
1
+ template <typename T>
2
+ // ^^^^^^^^ definition [..] `<file>/template_body.cc`/
3
+ // ^ definition local 0
4
+ void f () {
5
+ // ^ definition [..] f(49f6e7a06ebc5aa8).
6
+ struct C {
7
+ // ^ definition [..] f(49f6e7a06ebc5aa8).C#
8
+ int plain_field;
9
+ // ^^^^^^^^^^^ definition [..] f(49f6e7a06ebc5aa8).C#plain_field.
10
+ T dependent_field;
11
+ // ^ reference local 0
12
+ // ^^^^^^^^^^^^^^^ definition [..] f(49f6e7a06ebc5aa8).C#dependent_field.
13
+
14
+ void g () {};
15
+ // ^ definition [..] f(49f6e7a06ebc5aa8).C#g(49f6e7a06ebc5aa8).
16
+ };
17
+
18
+ (void )C ().plain_field ;
19
+ // ^ reference [..] f(49f6e7a06ebc5aa8).C#
20
+ (void )C ().dependent_field ;
21
+ // ^ reference [..] f(49f6e7a06ebc5aa8).C#
22
+ C ().g ();
23
+ // ^ reference [..] f(49f6e7a06ebc5aa8).C#
24
+
25
+ int x = 0 ;
26
+ // ^ definition local 1
27
+ (void )(2 * x);
28
+ // ^ reference local 1
29
+
30
+ // The following are not allowed:
31
+ // - Templated function-local classes
32
+ // - Templates inside function-local classes
33
+ }
Original file line number Diff line number Diff line change 157
157
// documentation
158
158
// | No documentation available.
159
159
class fC {
160
+ // ^^ definition [..] f(49f6e7a06ebc5aa8).fC#
161
+ // documentation
162
+ // | No documentation available.
160
163
void fCf () {
164
+ // ^^^ definition [..] f(49f6e7a06ebc5aa8).fC#fCf(49f6e7a06ebc5aa8).
165
+ // documentation
166
+ // | No documentation available.
161
167
class fCfC { };
168
+ // ^^^^ definition [..] f(49f6e7a06ebc5aa8).fC#fCf(49f6e7a06ebc5aa8).fCfC#
169
+ // documentation
170
+ // | No documentation available.
162
171
}
163
172
};
164
173
}
332
341
};
333
342
return ignore_first (" " , L{});
334
343
// ^^^^^^^^^^^^ reference local 3
344
+ // ^ reference [..] trailing_return_type(693bfa61ed1914d5).$anonymous_type_4#`operator()`(dc97d1a1ce4cdab3).
335
345
// ^ reference [..] L#
336
346
}
You can’t perform that action at this time.
0 commit comments