File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -50,9 +50,18 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {
50
50
stack.push_back (decl);
51
51
52
52
ClangDeclRefFinder refFinder ([&](const clang::DeclRefExpr *DRE) {
53
- const clang::ValueDecl *D = DRE->getDecl ();
54
- if (!D->hasLinkage () || D->isExternallyVisible ())
55
- return ;
53
+ const clang::Decl *D = DRE->getDecl ();
54
+ // Check that this is a file-level declaration and not inside a function.
55
+ // If it's a member of a file-level decl, like a C++ static member variable,
56
+ // we want to add the entire file-level declaration because Clang doesn't
57
+ // expect to see members directly here.
58
+ for (auto *DC = D->getDeclContext ();; DC = DC->getParent ()) {
59
+ if (DC->isFunctionOrMethod ())
60
+ return ;
61
+ if (DC->isFileContext ())
62
+ break ;
63
+ D = cast<const clang::Decl>(DC);
64
+ }
56
65
if (!GlobalClangDecls.insert (D->getCanonicalDecl ()).second )
57
66
return ;
58
67
stack.push_back (D);
Original file line number Diff line number Diff line change 2
2
3
3
void overloaded (void ) __attribute__((overloadable ));
4
4
void overloaded (int ) __attribute__((overloadable ));
5
+
6
+ extern void use (const char * );
7
+
8
+ static inline void test_my_log () {
9
+ __attribute__((internal_linkage )) static const char fmt [] = "foobar" ;
10
+ use (fmt );
11
+ }
Original file line number Diff line number Diff line change @@ -9,4 +9,6 @@ func testOverloaded() {
9
9
overloaded ( )
10
10
// CHECK: call void @_Z10overloadedi(i32{{( signext)?}} 42)
11
11
overloaded ( 42 )
12
+ // CHECK: call void @{{.*}}test_my_log
13
+ test_my_log ( )
12
14
} // CHECK: {{^}$}}
You can’t perform that action at this time.
0 commit comments