You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang-tidy][libc] Fix namespace check with macro (#68134)
The name of the namespace for LLVM's libc is now provided by a macro.
The ImplementationNamespaceCheck was updated to handle this, but the
CalleeNamespaceCheck was missed. This patch updates the
CalleeNamespaceCheck to handle the macro.
// Allow calling entities defined in the namespace.
43
-
__llvm_libc::libc_api_struct{}();
53
+
LIBC_NAMESPACE::libc_api_struct{}();
44
54
45
55
// Disallow calling into global namespace for implemented entrypoints.
46
56
::libc_api_func();
47
-
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'libc_api_func' must resolve to a function declared within the '__llvm_libc' namespace
48
-
// CHECK-MESSAGES: :15:6: note: resolves to this declaration
57
+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'libc_api_func' must resolve to a function declared within the namespace defined by the 'LIBC_NAMESPACE' macro
58
+
// CHECK-MESSAGES: :25:6: note: resolves to this declaration
49
59
50
60
// Disallow indirect references to functions in global namespace.
51
61
void (*badPtr)(void) = ::libc_api_func;
52
62
badPtr();
53
-
// CHECK-MESSAGES: :[[@LINE-2]]:26: warning: 'libc_api_func' must resolve to a function declared within the '__llvm_libc' namespace
54
-
// CHECK-MESSAGES: :15:6: note: resolves to this declaration
63
+
// CHECK-MESSAGES: :[[@LINE-2]]:26: warning: 'libc_api_func' must resolve to a function declared within the namespace defined by the 'LIBC_NAMESPACE' macro
64
+
// CHECK-MESSAGES: :25:6: note: resolves to this declaration
55
65
56
66
// Allow calling into global namespace for specific functions.
57
67
::malloc();
58
68
59
69
// Disallow calling on entities that are not in the namespace, but make sure
60
70
// no crashes happen.
61
71
global_struct{}();
62
-
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'operator()' must resolve to a function declared within the '__llvm_libc' namespace
63
-
// CHECK-MESSAGES: :22:7: note: resolves to this declaration
72
+
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'operator()' must resolve to a function declared within the namespace defined by the 'LIBC_NAMESPACE' macro
73
+
// CHECK-MESSAGES: :32:7: note: resolves to this declaration
74
+
75
+
OTHER_MACRO_NAMESPACE::wrong_name_macro_func();
76
+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'wrong_name_macro_func' must resolve to a function declared within the namespace defined by the 'LIBC_NAMESPACE' macro
77
+
// CHECK-MESSAGES: :3:31: note: expanded from macro 'OTHER_MACRO_NAMESPACE'
78
+
// CHECK-MESSAGES: :5:8: note: resolves to this declaration
79
+
80
+
__llvm_libc::right_name_no_macro_func();
81
+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'right_name_no_macro_func' must resolve to a function declared within the namespace defined by the 'LIBC_NAMESPACE' macro
82
+
// CHECK-MESSAGES: :9:8: note: resolves to this declaration
0 commit comments