| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 1 | //===--- ClangTidyDiagnosticConsumer.h - clang-tidy -------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| Alexander Kornienko | 6658055 | 2015-03-09 16:52:33 +0000 | [diff] [blame] | 10 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H |
| 11 | #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H |
| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 12 | |
| Alexander Kornienko | 9ff5b6f | 2014-05-05 14:54:47 +0000 | [diff] [blame] | 13 | #include "ClangTidyOptions.h" |
| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 14 | #include "clang/Basic/Diagnostic.h" |
| 15 | #include "clang/Basic/SourceManager.h" |
| 16 | #include "clang/Tooling/Refactoring.h" |
| Alexander Kornienko | 41bfe8d | 2014-01-13 10:50:51 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/DenseMap.h" |
| Samuel Benzaquen | aedd994 | 2014-10-23 17:23:20 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/StringMap.h" |
| Alexander Kornienko | 09952d2 | 2014-03-20 09:38:22 +0000 | [diff] [blame] | 19 | #include "llvm/Support/Regex.h" |
| Samuel Benzaquen | aedd994 | 2014-10-23 17:23:20 +0000 | [diff] [blame] | 20 | #include "llvm/Support/Timer.h" |
| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 21 | |
| 22 | namespace clang { |
| 23 | |
| Alexander Kornienko | ad21688 | 2014-07-14 14:10:03 +0000 | [diff] [blame] | 24 | class ASTContext; |
| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 25 | class CompilerInstance; |
| 26 | namespace ast_matchers { |
| 27 | class MatchFinder; |
| 28 | } |
| 29 | namespace tooling { |
| 30 | class CompilationDatabase; |
| 31 | } |
| 32 | |
| 33 | namespace tidy { |
| 34 | |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 35 | /// \brief A message from a clang-tidy check. |
| 36 | /// |
| 37 | /// Note that this is independent of a \c SourceManager. |
| 38 | struct ClangTidyMessage { |
| 39 | ClangTidyMessage(StringRef Message = ""); |
| 40 | ClangTidyMessage(StringRef Message, const SourceManager &Sources, |
| 41 | SourceLocation Loc); |
| 42 | std::string Message; |
| 43 | std::string FilePath; |
| 44 | unsigned FileOffset; |
| 45 | }; |
| 46 | |
| 47 | /// \brief A detected error complete with information to display diagnostic and |
| 48 | /// automatic fix. |
| 49 | /// |
| 50 | /// This is used as an intermediate format to transport Diagnostics without a |
| 51 | /// dependency on a SourceManager. |
| 52 | /// |
| 53 | /// FIXME: Make Diagnostics flexible enough to support this directly. |
| 54 | struct ClangTidyError { |
| Alexander Kornienko | 348cae8 | 2014-06-02 20:44:32 +0000 | [diff] [blame] | 55 | enum Level { |
| 56 | Warning = DiagnosticsEngine::Warning, |
| 57 | Error = DiagnosticsEngine::Error |
| 58 | }; |
| 59 | |
| Haojian Wu | f7692a2 | 2016-02-26 09:19:33 +0000 | [diff] [blame] | 60 | ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError, |
| 61 | StringRef BuildDirectory); |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 62 | |
| Alexander Kornienko | 41bfe8d | 2014-01-13 10:50:51 +0000 | [diff] [blame] | 63 | std::string CheckName; |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 64 | ClangTidyMessage Message; |
| 65 | tooling::Replacements Fix; |
| 66 | SmallVector<ClangTidyMessage, 1> Notes; |
| Alexander Kornienko | 348cae8 | 2014-06-02 20:44:32 +0000 | [diff] [blame] | 67 | |
| Haojian Wu | f7692a2 | 2016-02-26 09:19:33 +0000 | [diff] [blame] | 68 | // A build directory of the diagnostic source file. |
| 69 | // |
| 70 | // It's an absolute path which is `directory` field of the source file in |
| 71 | // compilation database. If users don't specify the compilation database |
| 72 | // directory, it is the current directory where clang-tidy runs. |
| 73 | // |
| 74 | // Note: it is empty in unittest. |
| 75 | std::string BuildDirectory; |
| 76 | |
| Alexander Kornienko | 348cae8 | 2014-06-02 20:44:32 +0000 | [diff] [blame] | 77 | Level DiagLevel; |
| Jonathan Roelofs | d60388a | 2016-01-13 17:36:41 +0000 | [diff] [blame] | 78 | bool IsWarningAsError; |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
| Alexander Kornienko | b3d331d | 2014-08-06 11:49:10 +0000 | [diff] [blame] | 81 | /// \brief Read-only set of strings represented as a list of positive and |
| 82 | /// negative globs. Positive globs add all matched strings to the set, negative |
| 83 | /// globs remove them in the order of appearance in the list. |
| 84 | class GlobList { |
| Alexander Kornienko | 09952d2 | 2014-03-20 09:38:22 +0000 | [diff] [blame] | 85 | public: |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 86 | /// \brief \p GlobList is a comma-separated list of globs (only '*' |
| 87 | /// metacharacter is supported) with optional '-' prefix to denote exclusion. |
| Alexander Kornienko | b3d331d | 2014-08-06 11:49:10 +0000 | [diff] [blame] | 88 | GlobList(StringRef Globs); |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 89 | |
| Alexander Kornienko | b3d331d | 2014-08-06 11:49:10 +0000 | [diff] [blame] | 90 | /// \brief Returns \c true if the pattern matches \p S. The result is the last |
| 91 | /// matching glob's Positive flag. |
| 92 | bool contains(StringRef S) { return contains(S, false); } |
| Alexander Kornienko | 09952d2 | 2014-03-20 09:38:22 +0000 | [diff] [blame] | 93 | |
| 94 | private: |
| Alexander Kornienko | b3d331d | 2014-08-06 11:49:10 +0000 | [diff] [blame] | 95 | bool contains(StringRef S, bool Contains); |
| Alexander Kornienko | 23fe959 | 2014-05-15 14:27:36 +0000 | [diff] [blame] | 96 | |
| 97 | bool Positive; |
| 98 | llvm::Regex Regex; |
| Alexander Kornienko | b3d331d | 2014-08-06 11:49:10 +0000 | [diff] [blame] | 99 | std::unique_ptr<GlobList> NextGlob; |
| Alexander Kornienko | 09952d2 | 2014-03-20 09:38:22 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 102 | /// \brief Contains displayed and ignored diagnostic counters for a ClangTidy |
| 103 | /// run. |
| Alexander Kornienko | 5d17454 | 2014-05-07 09:06:53 +0000 | [diff] [blame] | 104 | struct ClangTidyStats { |
| 105 | ClangTidyStats() |
| 106 | : ErrorsDisplayed(0), ErrorsIgnoredCheckFilter(0), ErrorsIgnoredNOLINT(0), |
| Alexander Kornienko | dad4acb | 2014-05-22 16:07:11 +0000 | [diff] [blame] | 107 | ErrorsIgnoredNonUserCode(0), ErrorsIgnoredLineFilter(0) {} |
| Alexander Kornienko | 5d17454 | 2014-05-07 09:06:53 +0000 | [diff] [blame] | 108 | |
| 109 | unsigned ErrorsDisplayed; |
| 110 | unsigned ErrorsIgnoredCheckFilter; |
| 111 | unsigned ErrorsIgnoredNOLINT; |
| 112 | unsigned ErrorsIgnoredNonUserCode; |
| Alexander Kornienko | dad4acb | 2014-05-22 16:07:11 +0000 | [diff] [blame] | 113 | unsigned ErrorsIgnoredLineFilter; |
| 114 | |
| 115 | unsigned errorsIgnored() const { |
| 116 | return ErrorsIgnoredNOLINT + ErrorsIgnoredCheckFilter + |
| 117 | ErrorsIgnoredNonUserCode + ErrorsIgnoredLineFilter; |
| 118 | } |
| Alexander Kornienko | 5d17454 | 2014-05-07 09:06:53 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
| Samuel Benzaquen | aedd994 | 2014-10-23 17:23:20 +0000 | [diff] [blame] | 121 | /// \brief Container for clang-tidy profiling data. |
| 122 | struct ProfileData { |
| 123 | llvm::StringMap<llvm::TimeRecord> Records; |
| 124 | }; |
| 125 | |
| Alexander Kornienko | 284c249 | 2014-12-19 15:37:02 +0000 | [diff] [blame] | 126 | /// \brief Every \c ClangTidyCheck reports errors through a \c DiagnosticsEngine |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 127 | /// provided by this context. |
| 128 | /// |
| 129 | /// A \c ClangTidyCheck always has access to the active context to report |
| 130 | /// warnings like: |
| 131 | /// \code |
| 132 | /// Context->Diag(Loc, "Single-argument constructors must be explicit") |
| 133 | /// << FixItHint::CreateInsertion(Loc, "explicit "); |
| 134 | /// \endcode |
| 135 | class ClangTidyContext { |
| 136 | public: |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 137 | /// \brief Initializes \c ClangTidyContext instance. |
| Alexander Kornienko | d53d268 | 2014-09-04 14:23:36 +0000 | [diff] [blame] | 138 | ClangTidyContext(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider); |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 139 | |
| 140 | /// \brief Report any errors detected using this method. |
| 141 | /// |
| 142 | /// This is still under heavy development and will likely change towards using |
| 143 | /// tablegen'd diagnostic IDs. |
| 144 | /// FIXME: Figure out a way to manage ID spaces. |
| Alexander Kornienko | 41bfe8d | 2014-01-13 10:50:51 +0000 | [diff] [blame] | 145 | DiagnosticBuilder diag(StringRef CheckName, SourceLocation Loc, |
| Alexander Kornienko | 54461eb | 2014-02-06 14:50:10 +0000 | [diff] [blame] | 146 | StringRef Message, |
| 147 | DiagnosticIDs::Level Level = DiagnosticIDs::Warning); |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 148 | |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 149 | /// \brief Sets the \c SourceManager of the used \c DiagnosticsEngine. |
| 150 | /// |
| 151 | /// This is called from the \c ClangTidyCheck base class. |
| 152 | void setSourceManager(SourceManager *SourceMgr); |
| 153 | |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 154 | /// \brief Should be called when starting to process new translation unit. |
| 155 | void setCurrentFile(StringRef File); |
| 156 | |
| Alexander Kornienko | 19bbeaf | 2015-05-21 14:08:56 +0000 | [diff] [blame] | 157 | /// \brief Returns the main file name of the current translation unit. |
| 158 | StringRef getCurrentFile() const { return CurrentFile; } |
| 159 | |
| Alexander Kornienko | ad21688 | 2014-07-14 14:10:03 +0000 | [diff] [blame] | 160 | /// \brief Sets ASTContext for the current translation unit. |
| 161 | void setASTContext(ASTContext *Context); |
| 162 | |
| Alexander Kornienko | 64956b5 | 2015-11-09 16:28:11 +0000 | [diff] [blame] | 163 | /// \brief Gets the language options from the AST context. |
| Alexander Kornienko | 1612fa0 | 2016-02-25 23:57:23 +0000 | [diff] [blame] | 164 | const LangOptions &getLangOpts() const { return LangOpts; } |
| Aaron Ballman | f36a425 | 2015-08-28 13:20:46 +0000 | [diff] [blame] | 165 | |
| Alexander Kornienko | 41bfe8d | 2014-01-13 10:50:51 +0000 | [diff] [blame] | 166 | /// \brief Returns the name of the clang-tidy check which produced this |
| 167 | /// diagnostic ID. |
| 168 | StringRef getCheckName(unsigned DiagnosticID) const; |
| 169 | |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 170 | /// \brief Returns check filter for the \c CurrentFile. |
| Alexander Kornienko | 64956b5 | 2015-11-09 16:28:11 +0000 | [diff] [blame] | 171 | /// |
| 172 | /// The \c CurrentFile can be changed using \c setCurrentFile. |
| Alexander Kornienko | b3d331d | 2014-08-06 11:49:10 +0000 | [diff] [blame] | 173 | GlobList &getChecksFilter(); |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 174 | |
| Aaron Ballman | c00ad6c | 2016-01-08 15:50:51 +0000 | [diff] [blame] | 175 | /// \brief Returns true if the check name is enabled for the \c CurrentFile. |
| 176 | bool isCheckEnabled(StringRef CheckName) const; |
| 177 | |
| Jonathan Roelofs | d60388a | 2016-01-13 17:36:41 +0000 | [diff] [blame] | 178 | /// \brief Returns check filter for the \c CurrentFile which |
| 179 | /// selects checks for upgrade to error. |
| 180 | GlobList &getWarningAsErrorFilter(); |
| 181 | |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 182 | /// \brief Returns global options. |
| 183 | const ClangTidyGlobalOptions &getGlobalOptions() const; |
| 184 | |
| 185 | /// \brief Returns options for \c CurrentFile. |
| Alexander Kornienko | 64956b5 | 2015-11-09 16:28:11 +0000 | [diff] [blame] | 186 | /// |
| 187 | /// The \c CurrentFile can be changed using \c setCurrentFile. |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 188 | const ClangTidyOptions &getOptions() const; |
| 189 | |
| Alexander Kornienko | 64956b5 | 2015-11-09 16:28:11 +0000 | [diff] [blame] | 190 | /// \brief Returns options for \c File. Does not change or depend on |
| 191 | /// \c CurrentFile. |
| 192 | ClangTidyOptions getOptionsForFile(StringRef File) const; |
| 193 | |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 194 | /// \brief Returns \c ClangTidyStats containing issued and ignored diagnostic |
| 195 | /// counters. |
| Alexander Kornienko | 5d17454 | 2014-05-07 09:06:53 +0000 | [diff] [blame] | 196 | const ClangTidyStats &getStats() const { return Stats; } |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 197 | |
| 198 | /// \brief Returns all collected errors. |
| Alexander Kornienko | 826b5ad | 2014-05-09 12:24:09 +0000 | [diff] [blame] | 199 | const std::vector<ClangTidyError> &getErrors() const { return Errors; } |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 200 | |
| 201 | /// \brief Clears collected errors. |
| Alexander Kornienko | c009360 | 2014-05-09 15:50:15 +0000 | [diff] [blame] | 202 | void clearErrors() { Errors.clear(); } |
| Alexander Kornienko | 09952d2 | 2014-03-20 09:38:22 +0000 | [diff] [blame] | 203 | |
| Samuel Benzaquen | aedd994 | 2014-10-23 17:23:20 +0000 | [diff] [blame] | 204 | /// \brief Set the output struct for profile data. |
| 205 | /// |
| 206 | /// Setting a non-null pointer here will enable profile collection in |
| 207 | /// clang-tidy. |
| Angel Garcia Gomez | 1669357 | 2015-10-16 11:43:49 +0000 | [diff] [blame] | 208 | void setCheckProfileData(ProfileData *Profile); |
| 209 | ProfileData *getCheckProfileData() const { return Profile; } |
| Samuel Benzaquen | aedd994 | 2014-10-23 17:23:20 +0000 | [diff] [blame] | 210 | |
| Haojian Wu | f7692a2 | 2016-02-26 09:19:33 +0000 | [diff] [blame] | 211 | /// \brief Should be called when starting to process new translation unit. |
| 212 | void setCurrentBuildDirectory(StringRef BuildDirectory) { |
| 213 | CurrentBuildDirectory = BuildDirectory; |
| 214 | } |
| 215 | |
| 216 | /// \brief Returns build directory of the current translation unit. |
| 217 | const std::string &getCurrentBuildDirectory() { |
| 218 | return CurrentBuildDirectory; |
| 219 | } |
| 220 | |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 221 | private: |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 222 | // Calls setDiagnosticsEngine() and storeError(). |
| 223 | friend class ClangTidyDiagnosticConsumer; |
| Benjamin Kramer | 8f5eb56 | 2016-03-03 08:58:12 +0000 | [diff] [blame^] | 224 | friend class ClangTidyPluginAction; |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 225 | |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 226 | /// \brief Sets the \c DiagnosticsEngine so that Diagnostics can be generated |
| 227 | /// correctly. |
| 228 | void setDiagnosticsEngine(DiagnosticsEngine *Engine); |
| 229 | |
| 230 | /// \brief Store an \p Error. |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 231 | void storeError(const ClangTidyError &Error); |
| 232 | |
| Alexander Kornienko | 826b5ad | 2014-05-09 12:24:09 +0000 | [diff] [blame] | 233 | std::vector<ClangTidyError> Errors; |
| NAKAMURA Takumi | 338eee1 | 2014-03-20 10:53:03 +0000 | [diff] [blame] | 234 | DiagnosticsEngine *DiagEngine; |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 235 | std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider; |
| 236 | |
| 237 | std::string CurrentFile; |
| Alexander Kornienko | d53d268 | 2014-09-04 14:23:36 +0000 | [diff] [blame] | 238 | ClangTidyOptions CurrentOptions; |
| Alexander Kornienko | b3d331d | 2014-08-06 11:49:10 +0000 | [diff] [blame] | 239 | std::unique_ptr<GlobList> CheckFilter; |
| Jonathan Roelofs | d60388a | 2016-01-13 17:36:41 +0000 | [diff] [blame] | 240 | std::unique_ptr<GlobList> WarningAsErrorFilter; |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 241 | |
| Aaron Ballman | f36a425 | 2015-08-28 13:20:46 +0000 | [diff] [blame] | 242 | LangOptions LangOpts; |
| 243 | |
| Alexander Kornienko | 5d17454 | 2014-05-07 09:06:53 +0000 | [diff] [blame] | 244 | ClangTidyStats Stats; |
| Alexander Kornienko | 09952d2 | 2014-03-20 09:38:22 +0000 | [diff] [blame] | 245 | |
| Haojian Wu | f7692a2 | 2016-02-26 09:19:33 +0000 | [diff] [blame] | 246 | std::string CurrentBuildDirectory; |
| 247 | |
| Alexander Kornienko | 41bfe8d | 2014-01-13 10:50:51 +0000 | [diff] [blame] | 248 | llvm::DenseMap<unsigned, std::string> CheckNamesByDiagnosticID; |
| Samuel Benzaquen | aedd994 | 2014-10-23 17:23:20 +0000 | [diff] [blame] | 249 | |
| 250 | ProfileData *Profile; |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 251 | }; |
| 252 | |
| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 253 | /// \brief A diagnostic consumer that turns each \c Diagnostic into a |
| 254 | /// \c SourceManager-independent \c ClangTidyError. |
| 255 | // |
| 256 | // FIXME: If we move away from unit-tests, this can be moved to a private |
| 257 | // implementation file. |
| 258 | class ClangTidyDiagnosticConsumer : public DiagnosticConsumer { |
| 259 | public: |
| Alexander Kornienko | 0ba86b7 | 2014-01-09 16:31:25 +0000 | [diff] [blame] | 260 | ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx); |
| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 261 | |
| 262 | // FIXME: The concept of converting between FixItHints and Replacements is |
| 263 | // more generic and should be pulled out into a more useful Diagnostics |
| 264 | // library. |
| Alexander Kornienko | cb9272f | 2014-02-27 13:14:51 +0000 | [diff] [blame] | 265 | void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, |
| Craig Topper | a3dbe84 | 2014-03-02 10:20:11 +0000 | [diff] [blame] | 266 | const Diagnostic &Info) override; |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 267 | |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 268 | /// \brief Flushes the internal diagnostics buffer to the ClangTidyContext. |
| Craig Topper | a3dbe84 | 2014-03-02 10:20:11 +0000 | [diff] [blame] | 269 | void finish() override; |
| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 270 | |
| 271 | private: |
| Alexander Kornienko | 54461eb | 2014-02-06 14:50:10 +0000 | [diff] [blame] | 272 | void finalizeLastError(); |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 273 | |
| Angel Garcia Gomez | 1669357 | 2015-10-16 11:43:49 +0000 | [diff] [blame] | 274 | void removeIncompatibleErrors(SmallVectorImpl<ClangTidyError> &Errors) const; |
| 275 | |
| Daniel Jasper | 4d871f9 | 2015-08-12 13:16:41 +0000 | [diff] [blame] | 276 | /// \brief Returns the \c HeaderFilter constructed for the options set in the |
| 277 | /// context. |
| Angel Garcia Gomez | 1669357 | 2015-10-16 11:43:49 +0000 | [diff] [blame] | 278 | llvm::Regex *getHeaderFilter(); |
| Daniel Jasper | 4d871f9 | 2015-08-12 13:16:41 +0000 | [diff] [blame] | 279 | |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 280 | /// \brief Updates \c LastErrorRelatesToUserCode and LastErrorPassesLineFilter |
| 281 | /// according to the diagnostic \p Location. |
| Alexander Kornienko | dad4acb | 2014-05-22 16:07:11 +0000 | [diff] [blame] | 282 | void checkFilters(SourceLocation Location); |
| 283 | bool passesLineFilter(StringRef FileName, unsigned LineNumber) const; |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 284 | |
| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 285 | ClangTidyContext &Context; |
| Ahmed Charles | 6a2dc5c | 2014-03-09 09:24:40 +0000 | [diff] [blame] | 286 | std::unique_ptr<DiagnosticsEngine> Diags; |
| Manuel Klimek | 814f9bd | 2013-11-14 15:49:44 +0000 | [diff] [blame] | 287 | SmallVector<ClangTidyError, 8> Errors; |
| Alexander Kornienko | a469522 | 2014-06-05 13:31:45 +0000 | [diff] [blame] | 288 | std::unique_ptr<llvm::Regex> HeaderFilter; |
| Alexander Kornienko | 54461eb | 2014-02-06 14:50:10 +0000 | [diff] [blame] | 289 | bool LastErrorRelatesToUserCode; |
| Alexander Kornienko | dad4acb | 2014-05-22 16:07:11 +0000 | [diff] [blame] | 290 | bool LastErrorPassesLineFilter; |
| Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | } // end namespace tidy |
| 294 | } // end namespace clang |
| 295 | |
| Alexander Kornienko | 6658055 | 2015-03-09 16:52:33 +0000 | [diff] [blame] | 296 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H |