clang-tools 24.0.0git
AvoidPragmaCommentCheck.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMACOMMENTCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMACOMMENTCHECK_H
11
12#include "../ClangTidyCheck.h"
13
15
16/// Finds uses of ``#pragma comment`` and for ``lib`` or ``linker`` comments
17/// suggests using the build system for improved portability.
18///
19/// Only the "lib" pragma comment type is implemented on Linux, the rest are
20/// Windows-only and should be caught by "-Wunknown-pragmas" on Linux.
21///
22/// For the user-facing documentation see:
23/// https://clang.llvm.org/extra/clang-tidy/checks/portability/avoid-pragma-comment.html
25public:
26 AvoidPragmaCommentCheck(StringRef Name, ClangTidyContext *Context)
27 : ClangTidyCheck(Name, Context) {}
28 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
29 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
30 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
31 return LangOpts.CPlusPlus || LangOpts.C99;
32 }
33};
34
35} // namespace clang::tidy::portability
36
37#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMACOMMENTCHECK_H
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
AvoidPragmaCommentCheck(StringRef Name, ClangTidyContext *Context)