David Blaikie | 69609dc | 2011-09-26 00:38:03 +0000 | [diff] [blame] | 1 | //===---- VerifyDiagnosticConsumer.cpp - Verifying Diagnostic Client ------===// |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 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 | // |
| 10 | // This is a concrete diagnostic client, which buffers the diagnostic messages. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
David Blaikie | 69609dc | 2011-09-26 00:38:03 +0000 | [diff] [blame] | 14 | #include "clang/Frontend/VerifyDiagnosticConsumer.h" |
Jordan Rose | a7d0384 | 2013-02-08 22:30:41 +0000 | [diff] [blame] | 15 | #include "clang/Basic/CharInfo.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 16 | #include "clang/Basic/FileManager.h" |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 17 | #include "clang/Frontend/FrontendDiagnostic.h" |
| 18 | #include "clang/Frontend/TextDiagnosticBuffer.h" |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 19 | #include "clang/Lex/HeaderSearch.h" |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 20 | #include "clang/Lex/Preprocessor.h" |
| 21 | #include "llvm/ADT/SmallString.h" |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 22 | #include "llvm/Support/Regex.h" |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 23 | #include "llvm/Support/raw_ostream.h" |
Anna Zaks | 2c74eed | 2011-12-15 02:58:00 +0000 | [diff] [blame] | 24 | |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 25 | using namespace clang; |
Jordan Rose | 6dae761 | 2012-07-10 02:56:15 +0000 | [diff] [blame] | 26 | typedef VerifyDiagnosticConsumer::Directive Directive; |
| 27 | typedef VerifyDiagnosticConsumer::DirectiveList DirectiveList; |
| 28 | typedef VerifyDiagnosticConsumer::ExpectedData ExpectedData; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 29 | |
David Blaikie | 69609dc | 2011-09-26 00:38:03 +0000 | [diff] [blame] | 30 | VerifyDiagnosticConsumer::VerifyDiagnosticConsumer(DiagnosticsEngine &_Diags) |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 31 | : Diags(_Diags), |
| 32 | PrimaryClient(Diags.getClient()), OwnsPrimaryClient(Diags.ownsClient()), |
| 33 | Buffer(new TextDiagnosticBuffer()), CurrentPreprocessor(0), |
Andy Gibbs | 0fea045 | 2012-10-19 12:49:32 +0000 | [diff] [blame] | 34 | LangOpts(0), SrcManager(0), ActiveSourceFiles(0), Status(HasNoDirectives) |
Douglas Gregor | 2b9b464 | 2011-09-13 01:26:44 +0000 | [diff] [blame] | 35 | { |
| 36 | Diags.takeClient(); |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 37 | if (Diags.hasSourceManager()) |
| 38 | setSourceManager(Diags.getSourceManager()); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 39 | } |
| 40 | |
David Blaikie | 69609dc | 2011-09-26 00:38:03 +0000 | [diff] [blame] | 41 | VerifyDiagnosticConsumer::~VerifyDiagnosticConsumer() { |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 42 | assert(!ActiveSourceFiles && "Incomplete parsing of source files!"); |
| 43 | assert(!CurrentPreprocessor && "CurrentPreprocessor should be invalid!"); |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 44 | SrcManager = 0; |
Douglas Gregor | 2b9b464 | 2011-09-13 01:26:44 +0000 | [diff] [blame] | 45 | CheckDiagnostics(); |
| 46 | Diags.takeClient(); |
| 47 | if (OwnsPrimaryClient) |
| 48 | delete PrimaryClient; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 49 | } |
| 50 | |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 51 | #ifndef NDEBUG |
| 52 | namespace { |
| 53 | class VerifyFileTracker : public PPCallbacks { |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 54 | VerifyDiagnosticConsumer &Verify; |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 55 | SourceManager &SM; |
| 56 | |
| 57 | public: |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 58 | VerifyFileTracker(VerifyDiagnosticConsumer &Verify, SourceManager &SM) |
| 59 | : Verify(Verify), SM(SM) { } |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 60 | |
| 61 | /// \brief Hook into the preprocessor and update the list of parsed |
| 62 | /// files when the preprocessor indicates a new file is entered. |
| 63 | virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason, |
| 64 | SrcMgr::CharacteristicKind FileType, |
| 65 | FileID PrevFID) { |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 66 | Verify.UpdateParsedFileStatus(SM, SM.getFileID(Loc), |
| 67 | VerifyDiagnosticConsumer::IsParsed); |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 68 | } |
| 69 | }; |
| 70 | } // End anonymous namespace. |
| 71 | #endif |
| 72 | |
David Blaikie | e2eefae | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 73 | // DiagnosticConsumer interface. |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 74 | |
David Blaikie | 69609dc | 2011-09-26 00:38:03 +0000 | [diff] [blame] | 75 | void VerifyDiagnosticConsumer::BeginSourceFile(const LangOptions &LangOpts, |
Douglas Gregor | 32fbe31 | 2012-01-20 16:28:04 +0000 | [diff] [blame] | 76 | const Preprocessor *PP) { |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 77 | // Attach comment handler on first invocation. |
| 78 | if (++ActiveSourceFiles == 1) { |
| 79 | if (PP) { |
| 80 | CurrentPreprocessor = PP; |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 81 | this->LangOpts = &LangOpts; |
| 82 | setSourceManager(PP->getSourceManager()); |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 83 | const_cast<Preprocessor*>(PP)->addCommentHandler(this); |
| 84 | #ifndef NDEBUG |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 85 | // Debug build tracks parsed files. |
| 86 | VerifyFileTracker *V = new VerifyFileTracker(*this, *SrcManager); |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 87 | const_cast<Preprocessor*>(PP)->addPPCallbacks(V); |
| 88 | #endif |
| 89 | } |
| 90 | } |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 91 | |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 92 | assert((!PP || CurrentPreprocessor == PP) && "Preprocessor changed!"); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 93 | PrimaryClient->BeginSourceFile(LangOpts, PP); |
| 94 | } |
| 95 | |
David Blaikie | 69609dc | 2011-09-26 00:38:03 +0000 | [diff] [blame] | 96 | void VerifyDiagnosticConsumer::EndSourceFile() { |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 97 | assert(ActiveSourceFiles && "No active source files!"); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 98 | PrimaryClient->EndSourceFile(); |
| 99 | |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 100 | // Detach comment handler once last active source file completed. |
| 101 | if (--ActiveSourceFiles == 0) { |
| 102 | if (CurrentPreprocessor) |
| 103 | const_cast<Preprocessor*>(CurrentPreprocessor)->removeCommentHandler(this); |
| 104 | |
| 105 | // Check diagnostics once last file completed. |
| 106 | CheckDiagnostics(); |
| 107 | CurrentPreprocessor = 0; |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 108 | LangOpts = 0; |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 109 | } |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 110 | } |
Daniel Dunbar | 1b39a2e | 2009-11-14 07:53:24 +0000 | [diff] [blame] | 111 | |
David Blaikie | 69609dc | 2011-09-26 00:38:03 +0000 | [diff] [blame] | 112 | void VerifyDiagnosticConsumer::HandleDiagnostic( |
David Blaikie | b578432 | 2011-09-26 01:18:08 +0000 | [diff] [blame] | 113 | DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) { |
Douglas Gregor | 6b93096 | 2013-05-03 22:58:43 +0000 | [diff] [blame] | 114 | if (Info.hasSourceManager()) { |
| 115 | // If this diagnostic is for a different source manager, ignore it. |
| 116 | if (SrcManager && &Info.getSourceManager() != SrcManager) |
| 117 | return; |
| 118 | |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 119 | setSourceManager(Info.getSourceManager()); |
Douglas Gregor | 6b93096 | 2013-05-03 22:58:43 +0000 | [diff] [blame] | 120 | } |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 121 | |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 122 | #ifndef NDEBUG |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 123 | // Debug build tracks unparsed files for possible |
| 124 | // unparsed expected-* directives. |
| 125 | if (SrcManager) { |
| 126 | SourceLocation Loc = Info.getLocation(); |
| 127 | if (Loc.isValid()) { |
| 128 | ParsedStatus PS = IsUnparsed; |
| 129 | |
| 130 | Loc = SrcManager->getExpansionLoc(Loc); |
| 131 | FileID FID = SrcManager->getFileID(Loc); |
| 132 | |
| 133 | const FileEntry *FE = SrcManager->getFileEntryForID(FID); |
| 134 | if (FE && CurrentPreprocessor && SrcManager->isLoadedFileID(FID)) { |
| 135 | // If the file is a modules header file it shall not be parsed |
| 136 | // for expected-* directives. |
| 137 | HeaderSearch &HS = CurrentPreprocessor->getHeaderSearchInfo(); |
| 138 | if (HS.findModuleForHeader(FE)) |
| 139 | PS = IsUnparsedNoDirectives; |
| 140 | } |
| 141 | |
| 142 | UpdateParsedFileStatus(*SrcManager, FID, PS); |
| 143 | } |
Axel Naumann | ac50dcf | 2011-07-25 19:18:12 +0000 | [diff] [blame] | 144 | } |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 145 | #endif |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 146 | |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 147 | // Send the diagnostic to the buffer, we will check it once we reach the end |
| 148 | // of the source file (or are destructed). |
| 149 | Buffer->HandleDiagnostic(DiagLevel, Info); |
| 150 | } |
| 151 | |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 152 | //===----------------------------------------------------------------------===// |
| 153 | // Checking diagnostics implementation. |
| 154 | //===----------------------------------------------------------------------===// |
| 155 | |
| 156 | typedef TextDiagnosticBuffer::DiagList DiagList; |
| 157 | typedef TextDiagnosticBuffer::const_iterator const_diag_iterator; |
| 158 | |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 159 | namespace { |
| 160 | |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 161 | /// StandardDirective - Directive with string matching. |
| 162 | /// |
| 163 | class StandardDirective : public Directive { |
| 164 | public: |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 165 | StandardDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, |
Jordan Rose | b8b2ca6 | 2012-07-10 02:57:26 +0000 | [diff] [blame] | 166 | StringRef Text, unsigned Min, unsigned Max) |
| 167 | : Directive(DirectiveLoc, DiagnosticLoc, Text, Min, Max) { } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 168 | |
Craig Topper | afa7cb3 | 2014-03-13 06:07:04 +0000 | [diff] [blame] | 169 | bool isValid(std::string &Error) override { |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 170 | // all strings are considered valid; even empty ones |
| 171 | return true; |
| 172 | } |
| 173 | |
Craig Topper | afa7cb3 | 2014-03-13 06:07:04 +0000 | [diff] [blame] | 174 | bool match(StringRef S) override { |
Jordan Rose | 6dae761 | 2012-07-10 02:56:15 +0000 | [diff] [blame] | 175 | return S.find(Text) != StringRef::npos; |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 176 | } |
| 177 | }; |
| 178 | |
| 179 | /// RegexDirective - Directive with regular-expression matching. |
| 180 | /// |
| 181 | class RegexDirective : public Directive { |
| 182 | public: |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 183 | RegexDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, |
Hans Wennborg | cda4b6d | 2013-12-11 23:40:50 +0000 | [diff] [blame] | 184 | StringRef Text, unsigned Min, unsigned Max, StringRef RegexStr) |
| 185 | : Directive(DirectiveLoc, DiagnosticLoc, Text, Min, Max), Regex(RegexStr) { } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 186 | |
Craig Topper | afa7cb3 | 2014-03-13 06:07:04 +0000 | [diff] [blame] | 187 | bool isValid(std::string &Error) override { |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 188 | if (Regex.isValid(Error)) |
| 189 | return true; |
| 190 | return false; |
| 191 | } |
| 192 | |
Craig Topper | afa7cb3 | 2014-03-13 06:07:04 +0000 | [diff] [blame] | 193 | bool match(StringRef S) override { |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 194 | return Regex.match(S); |
| 195 | } |
| 196 | |
| 197 | private: |
| 198 | llvm::Regex Regex; |
| 199 | }; |
| 200 | |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 201 | class ParseHelper |
| 202 | { |
| 203 | public: |
Jordan Rose | b13eb8d | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 204 | ParseHelper(StringRef S) |
| 205 | : Begin(S.begin()), End(S.end()), C(Begin), P(Begin), PEnd(NULL) { } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 206 | |
| 207 | // Return true if string literal is next. |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 208 | bool Next(StringRef S) { |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 209 | P = C; |
Benjamin Kramer | 2bd4cee | 2010-09-01 17:28:48 +0000 | [diff] [blame] | 210 | PEnd = C + S.size(); |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 211 | if (PEnd > End) |
| 212 | return false; |
Benjamin Kramer | 2bd4cee | 2010-09-01 17:28:48 +0000 | [diff] [blame] | 213 | return !memcmp(P, S.data(), S.size()); |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | // Return true if number is next. |
| 217 | // Output N only if number is next. |
| 218 | bool Next(unsigned &N) { |
| 219 | unsigned TMP = 0; |
| 220 | P = C; |
| 221 | for (; P < End && P[0] >= '0' && P[0] <= '9'; ++P) { |
| 222 | TMP *= 10; |
| 223 | TMP += P[0] - '0'; |
| 224 | } |
| 225 | if (P == C) |
| 226 | return false; |
| 227 | PEnd = P; |
| 228 | N = TMP; |
| 229 | return true; |
| 230 | } |
| 231 | |
| 232 | // Return true if string literal is found. |
| 233 | // When true, P marks begin-position of S in content. |
Andy Gibbs | ac51de6 | 2012-10-19 12:36:49 +0000 | [diff] [blame] | 234 | bool Search(StringRef S, bool EnsureStartOfWord = false) { |
| 235 | do { |
| 236 | P = std::search(C, End, S.begin(), S.end()); |
| 237 | PEnd = P + S.size(); |
| 238 | if (P == End) |
| 239 | break; |
| 240 | if (!EnsureStartOfWord |
| 241 | // Check if string literal starts a new word. |
Jordan Rose | a7d0384 | 2013-02-08 22:30:41 +0000 | [diff] [blame] | 242 | || P == Begin || isWhitespace(P[-1]) |
Alp Toker | f6a24ce | 2013-12-05 16:25:25 +0000 | [diff] [blame] | 243 | // Or it could be preceded by the start of a comment. |
Andy Gibbs | ac51de6 | 2012-10-19 12:36:49 +0000 | [diff] [blame] | 244 | || (P > (Begin + 1) && (P[-1] == '/' || P[-1] == '*') |
| 245 | && P[-2] == '/')) |
| 246 | return true; |
| 247 | // Otherwise, skip and search again. |
| 248 | } while (Advance()); |
| 249 | return false; |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Hans Wennborg | cda4b6d | 2013-12-11 23:40:50 +0000 | [diff] [blame] | 252 | // Return true if a CloseBrace that closes the OpenBrace at the current nest |
| 253 | // level is found. When true, P marks begin-position of CloseBrace. |
| 254 | bool SearchClosingBrace(StringRef OpenBrace, StringRef CloseBrace) { |
| 255 | unsigned Depth = 1; |
| 256 | P = C; |
| 257 | while (P < End) { |
| 258 | StringRef S(P, End - P); |
| 259 | if (S.startswith(OpenBrace)) { |
| 260 | ++Depth; |
| 261 | P += OpenBrace.size(); |
| 262 | } else if (S.startswith(CloseBrace)) { |
| 263 | --Depth; |
| 264 | if (Depth == 0) { |
| 265 | PEnd = P + CloseBrace.size(); |
| 266 | return true; |
| 267 | } |
| 268 | P += CloseBrace.size(); |
| 269 | } else { |
| 270 | ++P; |
| 271 | } |
| 272 | } |
| 273 | return false; |
| 274 | } |
| 275 | |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 276 | // Advance 1-past previous next/search. |
| 277 | // Behavior is undefined if previous next/search failed. |
| 278 | bool Advance() { |
| 279 | C = PEnd; |
| 280 | return C < End; |
| 281 | } |
| 282 | |
| 283 | // Skip zero or more whitespace. |
| 284 | void SkipWhitespace() { |
Jordan Rose | a7d0384 | 2013-02-08 22:30:41 +0000 | [diff] [blame] | 285 | for (; C < End && isWhitespace(*C); ++C) |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 286 | ; |
| 287 | } |
| 288 | |
| 289 | // Return true if EOF reached. |
| 290 | bool Done() { |
| 291 | return !(C < End); |
| 292 | } |
| 293 | |
| 294 | const char * const Begin; // beginning of expected content |
| 295 | const char * const End; // end of expected content (1-past) |
| 296 | const char *C; // position of next char in content |
| 297 | const char *P; |
| 298 | |
| 299 | private: |
| 300 | const char *PEnd; // previous next/search subject end (1-past) |
| 301 | }; |
| 302 | |
| 303 | } // namespace anonymous |
| 304 | |
| 305 | /// ParseDirective - Go through the comment and see if it indicates expected |
| 306 | /// diagnostics. If so, then put them in the appropriate directive list. |
| 307 | /// |
Jordan Rose | b13eb8d | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 308 | /// Returns true if any valid directives were found. |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 309 | static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM, |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 310 | Preprocessor *PP, SourceLocation Pos, |
Andy Gibbs | 0fea045 | 2012-10-19 12:49:32 +0000 | [diff] [blame] | 311 | VerifyDiagnosticConsumer::DirectiveStatus &Status) { |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 312 | DiagnosticsEngine &Diags = PP ? PP->getDiagnostics() : SM.getDiagnostics(); |
| 313 | |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 314 | // A single comment may contain multiple directives. |
Jordan Rose | b13eb8d | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 315 | bool FoundDirective = false; |
| 316 | for (ParseHelper PH(S); !PH.Done();) { |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 317 | // Search for token: expected |
Andy Gibbs | ac51de6 | 2012-10-19 12:36:49 +0000 | [diff] [blame] | 318 | if (!PH.Search("expected", true)) |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 319 | break; |
| 320 | PH.Advance(); |
| 321 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 322 | // Next token: - |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 323 | if (!PH.Next("-")) |
| 324 | continue; |
| 325 | PH.Advance(); |
| 326 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 327 | // Next token: { error | warning | note } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 328 | DirectiveList* DL = NULL; |
| 329 | if (PH.Next("error")) |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 330 | DL = ED ? &ED->Errors : NULL; |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 331 | else if (PH.Next("warning")) |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 332 | DL = ED ? &ED->Warnings : NULL; |
Tobias Grosser | 86a8567 | 2014-05-01 14:06:01 +0000 | [diff] [blame] | 333 | else if (PH.Next("remark")) |
| 334 | DL = ED ? &ED->Remarks : NULL; |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 335 | else if (PH.Next("note")) |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 336 | DL = ED ? &ED->Notes : NULL; |
Andy Gibbs | 0fea045 | 2012-10-19 12:49:32 +0000 | [diff] [blame] | 337 | else if (PH.Next("no-diagnostics")) { |
| 338 | if (Status == VerifyDiagnosticConsumer::HasOtherExpectedDirectives) |
| 339 | Diags.Report(Pos, diag::err_verify_invalid_no_diags) |
| 340 | << /*IsExpectedNoDiagnostics=*/true; |
| 341 | else |
| 342 | Status = VerifyDiagnosticConsumer::HasExpectedNoDiagnostics; |
| 343 | continue; |
| 344 | } else |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 345 | continue; |
| 346 | PH.Advance(); |
| 347 | |
Andy Gibbs | 0fea045 | 2012-10-19 12:49:32 +0000 | [diff] [blame] | 348 | if (Status == VerifyDiagnosticConsumer::HasExpectedNoDiagnostics) { |
| 349 | Diags.Report(Pos, diag::err_verify_invalid_no_diags) |
| 350 | << /*IsExpectedNoDiagnostics=*/false; |
| 351 | continue; |
| 352 | } |
| 353 | Status = VerifyDiagnosticConsumer::HasOtherExpectedDirectives; |
| 354 | |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 355 | // If a directive has been found but we're not interested |
| 356 | // in storing the directive information, return now. |
| 357 | if (!DL) |
| 358 | return true; |
| 359 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 360 | // Default directive kind. |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 361 | bool RegexKind = false; |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 362 | const char* KindStr = "string"; |
| 363 | |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 364 | // Next optional token: - |
| 365 | if (PH.Next("-re")) { |
| 366 | PH.Advance(); |
| 367 | RegexKind = true; |
| 368 | KindStr = "regex"; |
| 369 | } |
| 370 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 371 | // Next optional token: @ |
| 372 | SourceLocation ExpectedLoc; |
| 373 | if (!PH.Next("@")) { |
| 374 | ExpectedLoc = Pos; |
| 375 | } else { |
| 376 | PH.Advance(); |
| 377 | unsigned Line = 0; |
| 378 | bool FoundPlus = PH.Next("+"); |
| 379 | if (FoundPlus || PH.Next("-")) { |
| 380 | // Relative to current line. |
| 381 | PH.Advance(); |
| 382 | bool Invalid = false; |
| 383 | unsigned ExpectedLine = SM.getSpellingLineNumber(Pos, &Invalid); |
| 384 | if (!Invalid && PH.Next(Line) && (FoundPlus || Line < ExpectedLine)) { |
| 385 | if (FoundPlus) ExpectedLine += Line; |
| 386 | else ExpectedLine -= Line; |
| 387 | ExpectedLoc = SM.translateLineCol(SM.getFileID(Pos), ExpectedLine, 1); |
| 388 | } |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 389 | } else if (PH.Next(Line)) { |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 390 | // Absolute line number. |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 391 | if (Line > 0) |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 392 | ExpectedLoc = SM.translateLineCol(SM.getFileID(Pos), Line, 1); |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 393 | } else if (PP && PH.Search(":")) { |
| 394 | // Specific source file. |
| 395 | StringRef Filename(PH.C, PH.P-PH.C); |
| 396 | PH.Advance(); |
| 397 | |
| 398 | // Lookup file via Preprocessor, like a #include. |
| 399 | const DirectoryLookup *CurDir; |
Lawrence Crowl | b53e548 | 2013-06-20 21:14:14 +0000 | [diff] [blame] | 400 | const FileEntry *FE = PP->LookupFile(Pos, Filename, false, NULL, CurDir, |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 401 | NULL, NULL, 0); |
| 402 | if (!FE) { |
| 403 | Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin), |
| 404 | diag::err_verify_missing_file) << Filename << KindStr; |
| 405 | continue; |
| 406 | } |
| 407 | |
| 408 | if (SM.translateFile(FE).isInvalid()) |
| 409 | SM.createFileID(FE, Pos, SrcMgr::C_User); |
| 410 | |
| 411 | if (PH.Next(Line) && Line > 0) |
| 412 | ExpectedLoc = SM.translateFileLineCol(FE, Line, 1); |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | if (ExpectedLoc.isInvalid()) { |
| 416 | Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin), |
| 417 | diag::err_verify_missing_line) << KindStr; |
| 418 | continue; |
| 419 | } |
| 420 | PH.Advance(); |
| 421 | } |
| 422 | |
| 423 | // Skip optional whitespace. |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 424 | PH.SkipWhitespace(); |
| 425 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 426 | // Next optional token: positive integer or a '+'. |
Jordan Rose | b8b2ca6 | 2012-07-10 02:57:26 +0000 | [diff] [blame] | 427 | unsigned Min = 1; |
| 428 | unsigned Max = 1; |
| 429 | if (PH.Next(Min)) { |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 430 | PH.Advance(); |
Jordan Rose | b8b2ca6 | 2012-07-10 02:57:26 +0000 | [diff] [blame] | 431 | // A positive integer can be followed by a '+' meaning min |
| 432 | // or more, or by a '-' meaning a range from min to max. |
| 433 | if (PH.Next("+")) { |
| 434 | Max = Directive::MaxCount; |
| 435 | PH.Advance(); |
| 436 | } else if (PH.Next("-")) { |
| 437 | PH.Advance(); |
| 438 | if (!PH.Next(Max) || Max < Min) { |
| 439 | Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin), |
| 440 | diag::err_verify_invalid_range) << KindStr; |
| 441 | continue; |
| 442 | } |
| 443 | PH.Advance(); |
| 444 | } else { |
| 445 | Max = Min; |
| 446 | } |
| 447 | } else if (PH.Next("+")) { |
| 448 | // '+' on its own means "1 or more". |
| 449 | Max = Directive::MaxCount; |
Anna Zaks | a251007 | 2011-12-15 02:28:16 +0000 | [diff] [blame] | 450 | PH.Advance(); |
| 451 | } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 452 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 453 | // Skip optional whitespace. |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 454 | PH.SkipWhitespace(); |
| 455 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 456 | // Next token: {{ |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 457 | if (!PH.Next("{{")) { |
Jordan Rose | 6dae761 | 2012-07-10 02:56:15 +0000 | [diff] [blame] | 458 | Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin), |
| 459 | diag::err_verify_missing_start) << KindStr; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 460 | continue; |
| 461 | } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 462 | PH.Advance(); |
| 463 | const char* const ContentBegin = PH.C; // mark content begin |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 464 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 465 | // Search for token: }} |
Hans Wennborg | cda4b6d | 2013-12-11 23:40:50 +0000 | [diff] [blame] | 466 | if (!PH.SearchClosingBrace("{{", "}}")) { |
Jordan Rose | 6dae761 | 2012-07-10 02:56:15 +0000 | [diff] [blame] | 467 | Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin), |
| 468 | diag::err_verify_missing_end) << KindStr; |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 469 | continue; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 470 | } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 471 | const char* const ContentEnd = PH.P; // mark content end |
| 472 | PH.Advance(); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 473 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 474 | // Build directive text; convert \n to newlines. |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 475 | std::string Text; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 476 | StringRef NewlineStr = "\\n"; |
| 477 | StringRef Content(ContentBegin, ContentEnd-ContentBegin); |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 478 | size_t CPos = 0; |
| 479 | size_t FPos; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 480 | while ((FPos = Content.find(NewlineStr, CPos)) != StringRef::npos) { |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 481 | Text += Content.substr(CPos, FPos-CPos); |
| 482 | Text += '\n'; |
| 483 | CPos = FPos + NewlineStr.size(); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 484 | } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 485 | if (Text.empty()) |
| 486 | Text.assign(ContentBegin, ContentEnd); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 487 | |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 488 | // Check that regex directives contain at least one regex. |
| 489 | if (RegexKind && Text.find("{{") == StringRef::npos) { |
| 490 | Diags.Report(Pos.getLocWithOffset(ContentBegin-PH.Begin), |
| 491 | diag::err_verify_missing_regex) << Text; |
| 492 | return false; |
| 493 | } |
| 494 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 495 | // Construct new directive. |
Nico Weber | 568dacc | 2014-04-24 05:32:03 +0000 | [diff] [blame] | 496 | std::unique_ptr<Directive> D( |
| 497 | Directive::create(RegexKind, Pos, ExpectedLoc, Text, Min, Max)); |
| 498 | |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 499 | std::string Error; |
Jordan Rose | b13eb8d | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 500 | if (D->isValid(Error)) { |
Nico Weber | 568dacc | 2014-04-24 05:32:03 +0000 | [diff] [blame] | 501 | DL->push_back(D.release()); |
Jordan Rose | b13eb8d | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 502 | FoundDirective = true; |
| 503 | } else { |
Jordan Rose | 6dae761 | 2012-07-10 02:56:15 +0000 | [diff] [blame] | 504 | Diags.Report(Pos.getLocWithOffset(ContentBegin-PH.Begin), |
| 505 | diag::err_verify_invalid_content) |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 506 | << KindStr << Error; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 507 | } |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 508 | } |
Jordan Rose | b13eb8d | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 509 | |
| 510 | return FoundDirective; |
| 511 | } |
| 512 | |
| 513 | /// HandleComment - Hook into the preprocessor and extract comments containing |
| 514 | /// expected errors and warnings. |
| 515 | bool VerifyDiagnosticConsumer::HandleComment(Preprocessor &PP, |
| 516 | SourceRange Comment) { |
| 517 | SourceManager &SM = PP.getSourceManager(); |
Douglas Gregor | 6b93096 | 2013-05-03 22:58:43 +0000 | [diff] [blame] | 518 | |
| 519 | // If this comment is for a different source manager, ignore it. |
| 520 | if (SrcManager && &SM != SrcManager) |
| 521 | return false; |
| 522 | |
Jordan Rose | b13eb8d | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 523 | SourceLocation CommentBegin = Comment.getBegin(); |
| 524 | |
| 525 | const char *CommentRaw = SM.getCharacterData(CommentBegin); |
| 526 | StringRef C(CommentRaw, SM.getCharacterData(Comment.getEnd()) - CommentRaw); |
| 527 | |
| 528 | if (C.empty()) |
| 529 | return false; |
| 530 | |
| 531 | // Fold any "\<EOL>" sequences |
| 532 | size_t loc = C.find('\\'); |
| 533 | if (loc == StringRef::npos) { |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 534 | ParseDirective(C, &ED, SM, &PP, CommentBegin, Status); |
Jordan Rose | b13eb8d | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 535 | return false; |
| 536 | } |
| 537 | |
| 538 | std::string C2; |
| 539 | C2.reserve(C.size()); |
| 540 | |
| 541 | for (size_t last = 0;; loc = C.find('\\', last)) { |
| 542 | if (loc == StringRef::npos || loc == C.size()) { |
| 543 | C2 += C.substr(last); |
| 544 | break; |
| 545 | } |
| 546 | C2 += C.substr(last, loc-last); |
| 547 | last = loc + 1; |
| 548 | |
| 549 | if (C[last] == '\n' || C[last] == '\r') { |
| 550 | ++last; |
| 551 | |
| 552 | // Escape \r\n or \n\r, but not \n\n. |
| 553 | if (last < C.size()) |
| 554 | if (C[last] == '\n' || C[last] == '\r') |
| 555 | if (C[last] != C[last-1]) |
| 556 | ++last; |
| 557 | } else { |
| 558 | // This was just a normal backslash. |
| 559 | C2 += '\\'; |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | if (!C2.empty()) |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 564 | ParseDirective(C2, &ED, SM, &PP, CommentBegin, Status); |
Jordan Rose | b13eb8d | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 565 | return false; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 566 | } |
| 567 | |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 568 | #ifndef NDEBUG |
| 569 | /// \brief Lex the specified source file to determine whether it contains |
| 570 | /// any expected-* directives. As a Lexer is used rather than a full-blown |
| 571 | /// Preprocessor, directives inside skipped #if blocks will still be found. |
| 572 | /// |
| 573 | /// \return true if any directives were found. |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 574 | static bool findDirectives(SourceManager &SM, FileID FID, |
| 575 | const LangOptions &LangOpts) { |
Axel Naumann | ac50dcf | 2011-07-25 19:18:12 +0000 | [diff] [blame] | 576 | // Create a raw lexer to pull all the comments out of FID. |
| 577 | if (FID.isInvalid()) |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 578 | return false; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 579 | |
| 580 | // Create a lexer to lex all the tokens of the main file in raw mode. |
Chris Lattner | 710bb87 | 2009-11-30 04:18:44 +0000 | [diff] [blame] | 581 | const llvm::MemoryBuffer *FromFile = SM.getBuffer(FID); |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 582 | Lexer RawLex(FID, FromFile, SM, LangOpts); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 583 | |
| 584 | // Return comments as tokens, this is how we find expected diagnostics. |
| 585 | RawLex.SetCommentRetentionState(true); |
| 586 | |
| 587 | Token Tok; |
| 588 | Tok.setKind(tok::comment); |
Andy Gibbs | 0fea045 | 2012-10-19 12:49:32 +0000 | [diff] [blame] | 589 | VerifyDiagnosticConsumer::DirectiveStatus Status = |
| 590 | VerifyDiagnosticConsumer::HasNoDirectives; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 591 | while (Tok.isNot(tok::eof)) { |
Eli Friedman | 0834a4b | 2013-09-19 00:41:32 +0000 | [diff] [blame] | 592 | RawLex.LexFromRawLexer(Tok); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 593 | if (!Tok.is(tok::comment)) continue; |
| 594 | |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 595 | std::string Comment = RawLex.getSpelling(Tok, SM, LangOpts); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 596 | if (Comment.empty()) continue; |
| 597 | |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 598 | // Find first directive. |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 599 | if (ParseDirective(Comment, 0, SM, 0, Tok.getLocation(), Status)) |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 600 | return true; |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 601 | } |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 602 | return false; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 603 | } |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 604 | #endif // !NDEBUG |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 605 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 606 | /// \brief Takes a list of diagnostics that have been generated but not matched |
| 607 | /// by an expected-* directive and produces a diagnostic to the user from this. |
| 608 | static unsigned PrintUnexpected(DiagnosticsEngine &Diags, SourceManager *SourceMgr, |
| 609 | const_diag_iterator diag_begin, |
| 610 | const_diag_iterator diag_end, |
| 611 | const char *Kind) { |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 612 | if (diag_begin == diag_end) return 0; |
| 613 | |
Dylan Noblesmith | 2c1dd27 | 2012-02-05 02:13:05 +0000 | [diff] [blame] | 614 | SmallString<256> Fmt; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 615 | llvm::raw_svector_ostream OS(Fmt); |
| 616 | for (const_diag_iterator I = diag_begin, E = diag_end; I != E; ++I) { |
Daniel Dunbar | 1b39a2e | 2009-11-14 07:53:24 +0000 | [diff] [blame] | 617 | if (I->first.isInvalid() || !SourceMgr) |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 618 | OS << "\n (frontend)"; |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 619 | else { |
| 620 | OS << "\n "; |
| 621 | if (const FileEntry *File = SourceMgr->getFileEntryForID( |
| 622 | SourceMgr->getFileID(I->first))) |
| 623 | OS << " File " << File->getName(); |
| 624 | OS << " Line " << SourceMgr->getPresumedLineNumber(I->first); |
| 625 | } |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 626 | OS << ": " << I->second; |
| 627 | } |
| 628 | |
Jordan Rose | 6f524ac | 2012-07-11 16:50:36 +0000 | [diff] [blame] | 629 | Diags.Report(diag::err_verify_inconsistent_diags).setForceEmit() |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 630 | << Kind << /*Unexpected=*/true << OS.str(); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 631 | return std::distance(diag_begin, diag_end); |
| 632 | } |
| 633 | |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 634 | /// \brief Takes a list of diagnostics that were expected to have been generated |
| 635 | /// but were not and produces a diagnostic to the user from this. |
| 636 | static unsigned PrintExpected(DiagnosticsEngine &Diags, SourceManager &SourceMgr, |
| 637 | DirectiveList &DL, const char *Kind) { |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 638 | if (DL.empty()) |
| 639 | return 0; |
| 640 | |
Dylan Noblesmith | 2c1dd27 | 2012-02-05 02:13:05 +0000 | [diff] [blame] | 641 | SmallString<256> Fmt; |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 642 | llvm::raw_svector_ostream OS(Fmt); |
| 643 | for (DirectiveList::iterator I = DL.begin(), E = DL.end(); I != E; ++I) { |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 644 | Directive &D = **I; |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 645 | OS << "\n File " << SourceMgr.getFilename(D.DiagnosticLoc) |
| 646 | << " Line " << SourceMgr.getPresumedLineNumber(D.DiagnosticLoc); |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 647 | if (D.DirectiveLoc != D.DiagnosticLoc) |
| 648 | OS << " (directive at " |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 649 | << SourceMgr.getFilename(D.DirectiveLoc) << ':' |
| 650 | << SourceMgr.getPresumedLineNumber(D.DirectiveLoc) << ')'; |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 651 | OS << ": " << D.Text; |
| 652 | } |
| 653 | |
Jordan Rose | 6f524ac | 2012-07-11 16:50:36 +0000 | [diff] [blame] | 654 | Diags.Report(diag::err_verify_inconsistent_diags).setForceEmit() |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 655 | << Kind << /*Unexpected=*/false << OS.str(); |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 656 | return DL.size(); |
| 657 | } |
| 658 | |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 659 | /// \brief Determine whether two source locations come from the same file. |
| 660 | static bool IsFromSameFile(SourceManager &SM, SourceLocation DirectiveLoc, |
| 661 | SourceLocation DiagnosticLoc) { |
| 662 | while (DiagnosticLoc.isMacroID()) |
| 663 | DiagnosticLoc = SM.getImmediateMacroCallerLoc(DiagnosticLoc); |
| 664 | |
Eli Friedman | 5ba37d5 | 2013-08-22 00:27:10 +0000 | [diff] [blame] | 665 | if (SM.isWrittenInSameFile(DirectiveLoc, DiagnosticLoc)) |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 666 | return true; |
| 667 | |
| 668 | const FileEntry *DiagFile = SM.getFileEntryForID(SM.getFileID(DiagnosticLoc)); |
Eli Friedman | 5ba37d5 | 2013-08-22 00:27:10 +0000 | [diff] [blame] | 669 | if (!DiagFile && SM.isWrittenInMainFile(DirectiveLoc)) |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 670 | return true; |
| 671 | |
| 672 | return (DiagFile == SM.getFileEntryForID(SM.getFileID(DirectiveLoc))); |
| 673 | } |
| 674 | |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 675 | /// CheckLists - Compare expected to seen diagnostic lists and return the |
| 676 | /// the difference between them. |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 677 | /// |
David Blaikie | 9c902b5 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 678 | static unsigned CheckLists(DiagnosticsEngine &Diags, SourceManager &SourceMgr, |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 679 | const char *Label, |
| 680 | DirectiveList &Left, |
| 681 | const_diag_iterator d2_begin, |
| 682 | const_diag_iterator d2_end) { |
| 683 | DirectiveList LeftOnly; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 684 | DiagList Right(d2_begin, d2_end); |
| 685 | |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 686 | for (DirectiveList::iterator I = Left.begin(), E = Left.end(); I != E; ++I) { |
| 687 | Directive& D = **I; |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 688 | unsigned LineNo1 = SourceMgr.getPresumedLineNumber(D.DiagnosticLoc); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 689 | |
Jordan Rose | b8b2ca6 | 2012-07-10 02:57:26 +0000 | [diff] [blame] | 690 | for (unsigned i = 0; i < D.Max; ++i) { |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 691 | DiagList::iterator II, IE; |
| 692 | for (II = Right.begin(), IE = Right.end(); II != IE; ++II) { |
Chandler Carruth | 1aef0c5 | 2011-02-23 00:47:48 +0000 | [diff] [blame] | 693 | unsigned LineNo2 = SourceMgr.getPresumedLineNumber(II->first); |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 694 | if (LineNo1 != LineNo2) |
| 695 | continue; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 696 | |
Andy Gibbs | fcc699a | 2013-04-17 08:06:46 +0000 | [diff] [blame] | 697 | if (!IsFromSameFile(SourceMgr, D.DiagnosticLoc, II->first)) |
| 698 | continue; |
| 699 | |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 700 | const std::string &RightText = II->second; |
Jordan Rose | 6dae761 | 2012-07-10 02:56:15 +0000 | [diff] [blame] | 701 | if (D.match(RightText)) |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 702 | break; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 703 | } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 704 | if (II == IE) { |
| 705 | // Not found. |
Jordan Rose | b8b2ca6 | 2012-07-10 02:57:26 +0000 | [diff] [blame] | 706 | if (i >= D.Min) break; |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 707 | LeftOnly.push_back(*I); |
| 708 | } else { |
| 709 | // Found. The same cannot be found twice. |
| 710 | Right.erase(II); |
| 711 | } |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 712 | } |
| 713 | } |
| 714 | // Now all that's left in Right are those that were not matched. |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 715 | unsigned num = PrintExpected(Diags, SourceMgr, LeftOnly, Label); |
| 716 | num += PrintUnexpected(Diags, &SourceMgr, Right.begin(), Right.end(), Label); |
NAKAMURA Takumi | 7bfba2f | 2011-12-17 13:00:31 +0000 | [diff] [blame] | 717 | return num; |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 718 | } |
| 719 | |
| 720 | /// CheckResults - This compares the expected results to those that |
| 721 | /// were actually reported. It emits any discrepencies. Return "true" if there |
| 722 | /// were problems. Return "false" otherwise. |
| 723 | /// |
David Blaikie | 9c902b5 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 724 | static unsigned CheckResults(DiagnosticsEngine &Diags, SourceManager &SourceMgr, |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 725 | const TextDiagnosticBuffer &Buffer, |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 726 | ExpectedData &ED) { |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 727 | // We want to capture the delta between what was expected and what was |
| 728 | // seen. |
| 729 | // |
| 730 | // Expected \ Seen - set expected but not seen |
| 731 | // Seen \ Expected - set seen but not expected |
| 732 | unsigned NumProblems = 0; |
| 733 | |
| 734 | // See if there are error mismatches. |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 735 | NumProblems += CheckLists(Diags, SourceMgr, "error", ED.Errors, |
| 736 | Buffer.err_begin(), Buffer.err_end()); |
Daniel Dunbar | 1b39a2e | 2009-11-14 07:53:24 +0000 | [diff] [blame] | 737 | |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 738 | // See if there are warning mismatches. |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 739 | NumProblems += CheckLists(Diags, SourceMgr, "warning", ED.Warnings, |
| 740 | Buffer.warn_begin(), Buffer.warn_end()); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 741 | |
Tobias Grosser | 86a8567 | 2014-05-01 14:06:01 +0000 | [diff] [blame] | 742 | // See if there are remark mismatches. |
| 743 | NumProblems += CheckLists(Diags, SourceMgr, "remark", ED.Remarks, |
| 744 | Buffer.remark_begin(), Buffer.remark_end()); |
| 745 | |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 746 | // See if there are note mismatches. |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 747 | NumProblems += CheckLists(Diags, SourceMgr, "note", ED.Notes, |
| 748 | Buffer.note_begin(), Buffer.note_end()); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 749 | |
| 750 | return NumProblems; |
| 751 | } |
| 752 | |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 753 | void VerifyDiagnosticConsumer::UpdateParsedFileStatus(SourceManager &SM, |
| 754 | FileID FID, |
| 755 | ParsedStatus PS) { |
| 756 | // Check SourceManager hasn't changed. |
| 757 | setSourceManager(SM); |
| 758 | |
| 759 | #ifndef NDEBUG |
| 760 | if (FID.isInvalid()) |
| 761 | return; |
| 762 | |
| 763 | const FileEntry *FE = SM.getFileEntryForID(FID); |
| 764 | |
| 765 | if (PS == IsParsed) { |
| 766 | // Move the FileID from the unparsed set to the parsed set. |
| 767 | UnparsedFiles.erase(FID); |
| 768 | ParsedFiles.insert(std::make_pair(FID, FE)); |
| 769 | } else if (!ParsedFiles.count(FID) && !UnparsedFiles.count(FID)) { |
| 770 | // Add the FileID to the unparsed set if we haven't seen it before. |
| 771 | |
| 772 | // Check for directives. |
| 773 | bool FoundDirectives; |
| 774 | if (PS == IsUnparsedNoDirectives) |
| 775 | FoundDirectives = false; |
| 776 | else |
| 777 | FoundDirectives = !LangOpts || findDirectives(SM, FID, *LangOpts); |
| 778 | |
| 779 | // Add the FileID to the unparsed set. |
| 780 | UnparsedFiles.insert(std::make_pair(FID, |
| 781 | UnparsedFileStatus(FE, FoundDirectives))); |
| 782 | } |
| 783 | #endif |
| 784 | } |
| 785 | |
David Blaikie | 69609dc | 2011-09-26 00:38:03 +0000 | [diff] [blame] | 786 | void VerifyDiagnosticConsumer::CheckDiagnostics() { |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 787 | // Ensure any diagnostics go to the primary client. |
Douglas Gregor | 2b9b464 | 2011-09-13 01:26:44 +0000 | [diff] [blame] | 788 | bool OwnsCurClient = Diags.ownsClient(); |
David Blaikie | e2eefae | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 789 | DiagnosticConsumer *CurClient = Diags.takeClient(); |
Douglas Gregor | 2b9b464 | 2011-09-13 01:26:44 +0000 | [diff] [blame] | 790 | Diags.setClient(PrimaryClient, false); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 791 | |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 792 | #ifndef NDEBUG |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 793 | // In a debug build, scan through any files that may have been missed |
| 794 | // during parsing and issue a fatal error if directives are contained |
| 795 | // within these files. If a fatal error occurs, this suggests that |
| 796 | // this file is being parsed separately from the main file, in which |
| 797 | // case consider moving the directives to the correct place, if this |
| 798 | // is applicable. |
| 799 | if (UnparsedFiles.size() > 0) { |
| 800 | // Generate a cache of parsed FileEntry pointers for alias lookups. |
| 801 | llvm::SmallPtrSet<const FileEntry *, 8> ParsedFileCache; |
| 802 | for (ParsedFilesMap::iterator I = ParsedFiles.begin(), |
| 803 | End = ParsedFiles.end(); I != End; ++I) { |
| 804 | if (const FileEntry *FE = I->second) |
| 805 | ParsedFileCache.insert(FE); |
| 806 | } |
| 807 | |
| 808 | // Iterate through list of unparsed files. |
| 809 | for (UnparsedFilesMap::iterator I = UnparsedFiles.begin(), |
| 810 | End = UnparsedFiles.end(); I != End; ++I) { |
| 811 | const UnparsedFileStatus &Status = I->second; |
| 812 | const FileEntry *FE = Status.getFile(); |
| 813 | |
| 814 | // Skip files that have been parsed via an alias. |
| 815 | if (FE && ParsedFileCache.count(FE)) |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 816 | continue; |
| 817 | |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 818 | // Report a fatal error if this file contained directives. |
| 819 | if (Status.foundDirectives()) { |
Jordan Rose | b00073d | 2012-08-10 01:06:16 +0000 | [diff] [blame] | 820 | llvm::report_fatal_error(Twine("-verify directives found after rather" |
| 821 | " than during normal parsing of ", |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 822 | StringRef(FE ? FE->getName() : "(unknown)"))); |
| 823 | } |
Axel Naumann | 744f121 | 2011-08-24 13:36:19 +0000 | [diff] [blame] | 824 | } |
Daniel Dunbar | 1b39a2e | 2009-11-14 07:53:24 +0000 | [diff] [blame] | 825 | |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 826 | // UnparsedFiles has been processed now, so clear it. |
| 827 | UnparsedFiles.clear(); |
| 828 | } |
| 829 | #endif // !NDEBUG |
| 830 | |
| 831 | if (SrcManager) { |
Andy Gibbs | 0fea045 | 2012-10-19 12:49:32 +0000 | [diff] [blame] | 832 | // Produce an error if no expected-* directives could be found in the |
| 833 | // source file(s) processed. |
| 834 | if (Status == HasNoDirectives) { |
| 835 | Diags.Report(diag::err_verify_no_directives).setForceEmit(); |
| 836 | ++NumErrors; |
| 837 | Status = HasNoDirectivesReported; |
| 838 | } |
| 839 | |
Daniel Dunbar | 1b39a2e | 2009-11-14 07:53:24 +0000 | [diff] [blame] | 840 | // Check that the expected diagnostics occurred. |
Jordan Rose | 8c1ac0c | 2012-08-18 16:58:52 +0000 | [diff] [blame] | 841 | NumErrors += CheckResults(Diags, *SrcManager, *Buffer, ED); |
Daniel Dunbar | 1b39a2e | 2009-11-14 07:53:24 +0000 | [diff] [blame] | 842 | } else { |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 843 | NumErrors += (PrintUnexpected(Diags, 0, Buffer->err_begin(), |
| 844 | Buffer->err_end(), "error") + |
| 845 | PrintUnexpected(Diags, 0, Buffer->warn_begin(), |
| 846 | Buffer->warn_end(), "warn") + |
| 847 | PrintUnexpected(Diags, 0, Buffer->note_begin(), |
| 848 | Buffer->note_end(), "note")); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 849 | } |
| 850 | |
Douglas Gregor | 2dd19f1 | 2010-08-18 22:29:43 +0000 | [diff] [blame] | 851 | Diags.takeClient(); |
Douglas Gregor | 2b9b464 | 2011-09-13 01:26:44 +0000 | [diff] [blame] | 852 | Diags.setClient(CurClient, OwnsCurClient); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 853 | |
| 854 | // Reset the buffer, we have processed all the diagnostics in it. |
| 855 | Buffer.reset(new TextDiagnosticBuffer()); |
Nico Weber | dc493cf | 2014-04-24 05:39:55 +0000 | [diff] [blame] | 856 | ED.Reset(); |
Daniel Dunbar | 3481855 | 2009-11-14 03:23:19 +0000 | [diff] [blame] | 857 | } |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 858 | |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 859 | Directive *Directive::create(bool RegexKind, SourceLocation DirectiveLoc, |
Jordan Rose | e1572eb | 2012-07-10 02:57:03 +0000 | [diff] [blame] | 860 | SourceLocation DiagnosticLoc, StringRef Text, |
Jordan Rose | b8b2ca6 | 2012-07-10 02:57:26 +0000 | [diff] [blame] | 861 | unsigned Min, unsigned Max) { |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 862 | if (!RegexKind) |
Hans Wennborg | cda4b6d | 2013-12-11 23:40:50 +0000 | [diff] [blame] | 863 | return new StandardDirective(DirectiveLoc, DiagnosticLoc, Text, Min, Max); |
| 864 | |
| 865 | // Parse the directive into a regular expression. |
| 866 | std::string RegexStr; |
| 867 | StringRef S = Text; |
| 868 | while (!S.empty()) { |
| 869 | if (S.startswith("{{")) { |
| 870 | S = S.drop_front(2); |
| 871 | size_t RegexMatchLength = S.find("}}"); |
| 872 | assert(RegexMatchLength != StringRef::npos); |
| 873 | // Append the regex, enclosed in parentheses. |
| 874 | RegexStr += "("; |
| 875 | RegexStr.append(S.data(), RegexMatchLength); |
| 876 | RegexStr += ")"; |
| 877 | S = S.drop_front(RegexMatchLength + 2); |
| 878 | } else { |
| 879 | size_t VerbatimMatchLength = S.find("{{"); |
| 880 | if (VerbatimMatchLength == StringRef::npos) |
| 881 | VerbatimMatchLength = S.size(); |
| 882 | // Escape and append the fixed string. |
Hans Wennborg | e6a8775 | 2013-12-12 00:27:31 +0000 | [diff] [blame] | 883 | RegexStr += llvm::Regex::escape(S.substr(0, VerbatimMatchLength)); |
Hans Wennborg | cda4b6d | 2013-12-11 23:40:50 +0000 | [diff] [blame] | 884 | S = S.drop_front(VerbatimMatchLength); |
| 885 | } |
| 886 | } |
| 887 | |
Nico Weber | 568dacc | 2014-04-24 05:32:03 +0000 | [diff] [blame] | 888 | return new RegexDirective(DirectiveLoc, DiagnosticLoc, Text, Min, Max, |
| 889 | RegexStr); |
Chris Lattner | e82411b | 2010-04-28 20:02:30 +0000 | [diff] [blame] | 890 | } |