2018-12-14 15:29:06 +08:00
|
|
|
//===- ClangTidyForceLinker.h - clang-tidy --------------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-12-14 15:29:06 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYFORCELINKER_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYFORCELINKER_H
|
|
|
|
|
|
|
|
#include "clang/Config/config.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the CERTModule.
|
|
|
|
extern volatile int CERTModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
|
|
|
|
CERTModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the AbseilModule.
|
|
|
|
extern volatile int AbseilModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
|
|
|
|
AbseilModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the BoostModule.
|
|
|
|
extern volatile int BoostModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
|
|
|
|
BoostModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the BugproneModule.
|
|
|
|
extern volatile int BugproneModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED BugproneModuleAnchorDestination =
|
|
|
|
BugproneModuleAnchorSource;
|
|
|
|
|
[clang-tidy] Add a module for the Linux kernel.
Summary:
Now that clang is going to be able to build the Linux kernel again on
x86, and we have gen_compile_commands.py upstream for generating
compile_commands.json, clang-tidy can be used on the Linux kernel
source.
To that end, this commit adds a new clang-tidy module to be used for
checks specific to Linux kernel source. The Linux kernel follows its own
style of C, and it will be useful to separate those checks into their
own module.
This also adds an initial check that makes sure that return values from
the kernel error functions like PTR_ERR and ERR_PTR are checked. It also
makes sure that any functions that directly return values from these
functions are checked.
Subscribers: xazax.hun, gribozavr, Eugene.Zelenko, lebedev.ri, mgorny, jdoerfert, cfe-commits
Tags: #clang, #clang-tools-extra
Reviewers: aaron.ballman, alexfh, hokein, JonasToth
Differential Revision: https://reviews.llvm.org/D59963
llvm-svn: 367071
2019-07-26 06:32:50 +08:00
|
|
|
// This anchor is used to force the linker to link the LinuxKernelModule.
|
|
|
|
extern volatile int LinuxKernelModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED LinuxKernelModuleAnchorDestination =
|
|
|
|
LinuxKernelModuleAnchorSource;
|
|
|
|
|
2018-12-14 15:29:06 +08:00
|
|
|
// This anchor is used to force the linker to link the LLVMModule.
|
|
|
|
extern volatile int LLVMModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
|
|
|
|
LLVMModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
|
|
|
|
extern volatile int CppCoreGuidelinesModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
|
|
|
|
CppCoreGuidelinesModuleAnchorSource;
|
|
|
|
|
[clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage.
Summary:
Creates a new darwin ClangTidy module and adds the darwin-dispatch-once-nonstatic check that warns about dispatch_once_t variables not in static or global storage. This catches a missing static for local variables in e.g. singleton initialization behavior, and also warns on storing dispatch_once_t values in Objective-C instance variables. C/C++ struct/class instances may potentially live in static/global storage, and are ignored for this check.
The osx.API static analysis checker can find the non-static storage use of dispatch_once_t; I thought it useful to also catch this issue in clang-tidy when possible.
This is a re-land of https://reviews.llvm.org/D67567
Reviewers: thakis, gribozavr, stephanemoore
Subscribers: Eugene.Zelenko, mgorny, xazax.hun, jkorous, arphaman, kadircet, usaxena95
Tags: #clang-tools-extra, #clang, #llvm
Differential Revision: https://reviews.llvm.org/D68109
llvm-svn: 373065
2019-09-27 18:49:12 +08:00
|
|
|
// This anchor is used to force the linker to link the DarwinModule.
|
|
|
|
extern volatile int DarwinModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED DarwinModuleAnchorDestination =
|
|
|
|
DarwinModuleAnchorSource;
|
|
|
|
|
2018-12-14 15:29:06 +08:00
|
|
|
// This anchor is used to force the linker to link the FuchsiaModule.
|
|
|
|
extern volatile int FuchsiaModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
|
|
|
|
FuchsiaModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the GoogleModule.
|
|
|
|
extern volatile int GoogleModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
|
|
|
|
GoogleModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the AndroidModule.
|
|
|
|
extern volatile int AndroidModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
|
|
|
|
AndroidModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the MiscModule.
|
|
|
|
extern volatile int MiscModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
|
|
|
|
MiscModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the ModernizeModule.
|
|
|
|
extern volatile int ModernizeModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
|
|
|
|
ModernizeModuleAnchorSource;
|
|
|
|
|
2019-09-27 20:56:14 +08:00
|
|
|
#if CLANG_ENABLE_STATIC_ANALYZER && \
|
|
|
|
!defined(CLANG_TIDY_DISABLE_STATIC_ANALYZER_CHECKS)
|
2018-12-14 15:29:06 +08:00
|
|
|
// This anchor is used to force the linker to link the MPIModule.
|
|
|
|
extern volatile int MPIModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
|
|
|
|
MPIModuleAnchorSource;
|
|
|
|
#endif
|
|
|
|
|
[clang-tidy] A new OpenMP module
Summary:
Just the empty skeleton.
Previously reviewed as part of D57113.
Reviewers: JonasToth, aaron.ballman, alexfh, xazax.hun, hokein, gribozavr
Reviewed By: JonasToth, gribozavr
Subscribers: jdoerfert, mgorny, rnkovacs, guansong, arphaman, cfe-commits
Tags: #clang-tools-extra, #openmp, #clang
Differential Revision: https://reviews.llvm.org/D57571
llvm-svn: 356800
2019-03-23 03:46:01 +08:00
|
|
|
// This anchor is used to force the linker to link the OpenMPModule.
|
|
|
|
extern volatile int OpenMPModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED OpenMPModuleAnchorDestination =
|
|
|
|
OpenMPModuleAnchorSource;
|
|
|
|
|
2018-12-14 15:29:06 +08:00
|
|
|
// This anchor is used to force the linker to link the PerformanceModule.
|
|
|
|
extern volatile int PerformanceModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination =
|
|
|
|
PerformanceModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the PortabilityModule.
|
|
|
|
extern volatile int PortabilityModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED PortabilityModuleAnchorDestination =
|
|
|
|
PortabilityModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the ReadabilityModule.
|
|
|
|
extern volatile int ReadabilityModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
|
|
|
|
ReadabilityModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the ObjCModule.
|
|
|
|
extern volatile int ObjCModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
|
|
|
|
ObjCModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the HICPPModule.
|
|
|
|
extern volatile int HICPPModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
|
|
|
|
HICPPModuleAnchorSource;
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link the ZirconModule.
|
|
|
|
extern volatile int ZirconModuleAnchorSource;
|
|
|
|
static int LLVM_ATTRIBUTE_UNUSED ZirconModuleAnchorDestination =
|
|
|
|
ZirconModuleAnchorSource;
|
|
|
|
|
|
|
|
} // namespace tidy
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
#endif
|