Skip to content

Commit 0e9da92

Browse files
[clang-tidy] Added bugprone-unsequenced-global-accesses check
This check attempts to detect unsequenced accesses to global variables. It recurses into function calls in the same translation unit, and can handle fields on global structs/unions.
1 parent 43c35e8 commit 0e9da92

File tree

12 files changed

+1719
-0
lines changed

12 files changed

+1719
-0
lines changed

clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
#include "UnintendedCharOstreamOutputCheck.h"
9696
#include "UniquePtrArrayMismatchCheck.h"
9797
#include "UnsafeFunctionsCheck.h"
98+
#include "UnsequencedGlobalAccessesCheck.h"
9899
#include "UnusedLocalNonTrivialVariableCheck.h"
99100
#include "UnusedRaiiCheck.h"
100101
#include "UnusedReturnValueCheck.h"
@@ -128,6 +129,8 @@ class BugproneModule : public ClangTidyModule {
128129
"bugprone-chained-comparison");
129130
CheckFactories.registerCheck<ComparePointerToMemberVirtualFunctionCheck>(
130131
"bugprone-compare-pointer-to-member-virtual-function");
132+
CheckFactories.registerCheck<UnsequencedGlobalAccessesCheck>(
133+
"bugprone-unsequenced-global-accesses");
131134
CheckFactories.registerCheck<CopyConstructorInitCheck>(
132135
"bugprone-copy-constructor-init");
133136
CheckFactories.registerCheck<DanglingHandleCheck>(

clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ add_clang_library(clangTidyBugproneModule STATIC
9696
UnhandledSelfAssignmentCheck.cpp
9797
UniquePtrArrayMismatchCheck.cpp
9898
UnsafeFunctionsCheck.cpp
99+
UnsequencedGlobalAccessesCheck.cpp
99100
UnusedLocalNonTrivialVariableCheck.cpp
100101
UnusedRaiiCheck.cpp
101102
UnusedReturnValueCheck.cpp

0 commit comments

Comments
 (0)