Issue 60915
Summary clang-tidy considers namespace scope static variables to be global variables in several checks
Labels new issue
Assignees
Reporter jmzeeman
    I don't think considering these the same as true globals is right as they have internal linkage. 

Given this code:
```
static int x;

int f(void)
{
    return x;
}
```

With for example these checks:
```
  Checks: >
    readability-identifier-naming,
 cppcoreguidelines-avoid-non-const-global-variables
  CheckOptions:    
 - { key: readability-identifier-naming.GlobalVariablePrefix, value: g_ }
    - { key: readability-identifier-naming.GlobalVariableCase, value: lower_case }
```

The output is:
```
C:\code\ivy\duo\.\test.c:1:12: warning: variable 'x' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
static int x;
 ^
C:\code\ivy\duo\.\test.c:1:12: warning: invalid case style for global variable 'x' [readability-identifier-naming]
static int x;
 ^
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to