Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Rename the clang-tidy safety module to be hicpp, for the High-Integri…
Browse files Browse the repository at this point in the history
…ty C++ coding standard from PRQA.

This commit renames all of the safety functionality to be hicpp, adds an appropriate LICENSE.TXT, and updates the documentation accordingly.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@298229 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
AaronBallman committed Mar 19, 2017
1 parent 3360740 commit f4a5bb6
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 45 deletions.
1 change: 1 addition & 0 deletions LICENSE.TXT
Expand Up @@ -60,3 +60,4 @@ licenses, and/or restrictions:
Program Directory
------- ---------
clang-tidy clang-tidy/cert
clang-tidy clang-tidy/hicpp
8 changes: 4 additions & 4 deletions clang-tidy/CMakeLists.txt
Expand Up @@ -26,17 +26,17 @@ add_clang_library(clangTidy
clangToolingCore
)

add_subdirectory(tool)
add_subdirectory(plugin)
add_subdirectory(boost)
add_subdirectory(cert)
add_subdirectory(llvm)
add_subdirectory(cppcoreguidelines)
add_subdirectory(google)
add_subdirectory(hicpp)
add_subdirectory(llvm)
add_subdirectory(misc)
add_subdirectory(modernize)
add_subdirectory(mpi)
add_subdirectory(performance)
add_subdirectory(plugin)
add_subdirectory(readability)
add_subdirectory(safety)
add_subdirectory(tool)
add_subdirectory(utils)
@@ -1,8 +1,8 @@
set(LLVM_LINK_COMPONENTS support)

add_clang_library(clangTidySafetyModule
add_clang_library(clangTidyHICPPModule
NoAssemblerCheck.cpp
SafetyTidyModule.cpp
HICPPTidyModule.cpp

LINK_LIBS
clangAST
Expand Down
@@ -1,4 +1,4 @@
//===------- SafetyTidyModule.cpp - clang-tidy ----------------------------===//
//===------- HICPPTidyModule.cpp - clang-tidy -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -14,25 +14,25 @@

namespace clang {
namespace tidy {
namespace safety {
namespace hicpp {

class SafetyModule : public ClangTidyModule {
class HICPPModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<NoAssemblerCheck>(
"safety-no-assembler");
"hicpp-no-assembler");
}
};

// Register the SafetyModule using this statically initialized variable.
static ClangTidyModuleRegistry::Add<SafetyModule>
X("safety-module", "Adds safety-critical checks.");
// Register the HICPPModule using this statically initialized variable.
static ClangTidyModuleRegistry::Add<HICPPModule>
X("hicpp-module", "Adds High-Integrity C++ checks.");

} // namespace safety
} // namespace hicpp

// This anchor is used to force the linker to link in the generated object file
// and thus register the SafetyModule.
volatile int SafetyModuleAnchorSource = 0;
// and thus register the HICPPModule.
volatile int HICPPModuleAnchorSource = 0;

} // namespace tidy
} // namespace clang
12 changes: 12 additions & 0 deletions clang-tidy/hicpp/LICENSE.TXT
@@ -0,0 +1,12 @@
------------------------------------------------------------------------------
clang-tidy High-Integrity C++ Files
------------------------------------------------------------------------------
All clang-tidy files are licensed under the LLVM license with the following
additions:

Any file referencing a High-Integrity C++ Coding guideline:

HIC++ Coding Standard as created by PRQA.

Please see http://www.codingstandard.com/section/conditions-of-use/ for more
information.
Expand Up @@ -23,7 +23,7 @@ const internal::VariadicDynCastAllOfMatcher<Decl, FileScopeAsmDecl>

namespace clang {
namespace tidy {
namespace safety {
namespace hicpp {

void NoAssemblerCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(asmStmt().bind("asm-stmt"), this);
Expand All @@ -46,6 +46,6 @@ void NoAssemblerCheck::check(const MatchFinder::MatchResult &Result) {
diag(ASMLocation, "do not use inline assembler in safety-critical code");
}

} // namespace safety
} // namespace hicpp
} // namespace tidy
} // namespace clang
Expand Up @@ -7,19 +7,19 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SAFETY_NO_ASSEMBLER_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SAFETY_NO_ASSEMBLER_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_NO_ASSEMBLER_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_NO_ASSEMBLER_H

#include "../ClangTidy.h"

namespace clang {
namespace tidy {
namespace safety {
namespace hicpp {

/// Find assembler statements. No fix is offered.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/safety-no-assembler.html
/// http://clang.llvm.org/extra/clang-tidy/checks/hicpp-no-assembler.html
class NoAssemblerCheck : public ClangTidyCheck {
public:
NoAssemblerCheck(StringRef Name, ClangTidyContext *Context)
Expand All @@ -28,8 +28,8 @@ class NoAssemblerCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace safety
} // namespace hicpp
} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SAFETY_NO_ASSEMBLER_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_NO_ASSEMBLER_H
2 changes: 1 addition & 1 deletion clang-tidy/tool/CMakeLists.txt
Expand Up @@ -17,13 +17,13 @@ target_link_libraries(clang-tidy
clangTidyCERTModule
clangTidyCppCoreGuidelinesModule
clangTidyGoogleModule
clangTidyHICPPModule
clangTidyLLVMModule
clangTidyMiscModule
clangTidyModernizeModule
clangTidyMPIModule
clangTidyPerformanceModule
clangTidyReadabilityModule
clangTidySafetyModule
clangTooling
)

Expand Down
8 changes: 4 additions & 4 deletions clang-tidy/tool/ClangTidyMain.cpp
Expand Up @@ -496,10 +496,10 @@ extern volatile int ReadabilityModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
ReadabilityModuleAnchorSource;

// This anchor is used to force the linker to link the SafetyModule.
extern volatile int SafetyModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED SafetyModuleAnchorDestination =
SafetyModuleAnchorSource;
// This anchor is used to force the linker to link the HICPPModule.
extern volatile int HICPPModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
HICPPModuleAnchorSource;

} // namespace tidy
} // namespace clang
Expand Down
10 changes: 10 additions & 0 deletions docs/clang-tidy/checks/hicpp-no-assembler.rst
@@ -0,0 +1,10 @@
.. title:: clang-tidy - hicpp-no-assembler

hicpp-no-assembler
===================

Check for assembler statements. No fix is offered.

Inline assembler is forbidden by the `High Intergrity C++ Coding Standard
<http://www.codingstandard.com/section/7-5-the-asm-declaration/>`_
as it restricts the portability of code.
2 changes: 1 addition & 1 deletion docs/clang-tidy/checks/list.rst
Expand Up @@ -53,6 +53,7 @@ Clang-Tidy Checks
google-runtime-memset
google-runtime-operator
google-runtime-references
hicpp-no-assembler
llvm-header-guard
llvm-include-order
llvm-namespace-comment
Expand Down Expand Up @@ -155,4 +156,3 @@ Clang-Tidy Checks
readability-simplify-boolean-expr
readability-static-definition-in-anonymous-namespace
readability-uniqueptr-delete-release
safety-no-assembler
10 changes: 0 additions & 10 deletions docs/clang-tidy/checks/safety-no-assembler.rst

This file was deleted.

@@ -1,13 +1,12 @@
// RUN: %check_clang_tidy %s safety-no-assembler %t
// RUN: %check_clang_tidy %s hicpp-no-assembler %t

__asm__(".symver foo, bar@v");
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not use inline assembler in safety-critical code [safety-no-assembler]
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]

static int s asm("spam");
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not use inline assembler in safety-critical code [safety-no-assembler]
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]

void f() {
__asm("mov al, 2");
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [safety-no-assembler]
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]
}

0 comments on commit f4a5bb6

Please sign in to comment.