Clang Project

clang_source_code/include/clang/Basic/Diagnostic.h
1//===- Diagnostic.h - C Language Family Diagnostic Handling -----*- C++ -*-===//
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/// \file
10/// Defines the Diagnostic-related interfaces.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H
15#define LLVM_CLANG_BASIC_DIAGNOSTIC_H
16
17#include "clang/Basic/DiagnosticIDs.h"
18#include "clang/Basic/DiagnosticOptions.h"
19#include "clang/Basic/SourceLocation.h"
20#include "clang/Basic/Specifiers.h"
21#include "llvm/ADT/ArrayRef.h"
22#include "llvm/ADT/DenseMap.h"
23#include "llvm/ADT/IntrusiveRefCntPtr.h"
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/ADT/StringRef.h"
26#include "llvm/ADT/iterator_range.h"
27#include "llvm/Support/Compiler.h"
28#include <cassert>
29#include <cstdint>
30#include <limits>
31#include <list>
32#include <map>
33#include <memory>
34#include <string>
35#include <type_traits>
36#include <utility>
37#include <vector>
38
39namespace clang {
40
41class DeclContext;
42class DiagnosticBuilder;
43class DiagnosticConsumer;
44class IdentifierInfo;
45class LangOptions;
46class Preprocessor;
47class SourceManager;
48class StoredDiagnostic;
49
50namespace tok {
51
52enum TokenKind : unsigned short;
53
54// namespace tok
55
56/// Annotates a diagnostic with some code that should be
57/// inserted, removed, or replaced to fix the problem.
58///
59/// This kind of hint should be used when we are certain that the
60/// introduction, removal, or modification of a particular (small!)
61/// amount of code will correct a compilation error. The compiler
62/// should also provide full recovery from such errors, such that
63/// suppressing the diagnostic output can still result in successful
64/// compilation.
65class FixItHint {
66public:
67  /// Code that should be replaced to correct the error. Empty for an
68  /// insertion hint.
69  CharSourceRange RemoveRange;
70
71  /// Code in the specific range that should be inserted in the insertion
72  /// location.
73  CharSourceRange InsertFromRange;
74
75  /// The actual code to insert at the insertion location, as a
76  /// string.
77  std::string CodeToInsert;
78
79  bool BeforePreviousInsertions = false;
80
81  /// Empty code modification hint, indicating that no code
82  /// modification is known.
83  FixItHint() = default;
84
85  bool isNull() const {
86    return !RemoveRange.isValid();
87  }
88
89  /// Create a code modification hint that inserts the given
90  /// code string at a specific location.
91  static FixItHint CreateInsertion(SourceLocation InsertionLoc,
92                                   StringRef Code,
93                                   bool BeforePreviousInsertions = false) {
94    FixItHint Hint;
95    Hint.RemoveRange =
96      CharSourceRange::getCharRange(InsertionLocInsertionLoc);
97    Hint.CodeToInsert = Code;
98    Hint.BeforePreviousInsertions = BeforePreviousInsertions;
99    return Hint;
100  }
101
102  /// Create a code modification hint that inserts the given
103  /// code from \p FromRange at a specific location.
104  static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc,
105                                            CharSourceRange FromRange,
106                                        bool BeforePreviousInsertions = false) {
107    FixItHint Hint;
108    Hint.RemoveRange =
109      CharSourceRange::getCharRange(InsertionLocInsertionLoc);
110    Hint.InsertFromRange = FromRange;
111    Hint.BeforePreviousInsertions = BeforePreviousInsertions;
112    return Hint;
113  }
114
115  /// Create a code modification hint that removes the given
116  /// source range.
117  static FixItHint CreateRemoval(CharSourceRange RemoveRange) {
118    FixItHint Hint;
119    Hint.RemoveRange = RemoveRange;
120    return Hint;
121  }
122  static FixItHint CreateRemoval(SourceRange RemoveRange) {
123    return CreateRemoval(CharSourceRange::getTokenRange(RemoveRange));
124  }
125
126  /// Create a code modification hint that replaces the given
127  /// source range with the given code string.
128  static FixItHint CreateReplacement(CharSourceRange RemoveRange,
129                                     StringRef Code) {
130    FixItHint Hint;
131    Hint.RemoveRange = RemoveRange;
132    Hint.CodeToInsert = Code;
133    return Hint;
134  }
135
136  static FixItHint CreateReplacement(SourceRange RemoveRange,
137                                     StringRef Code) {
138    return CreateReplacement(CharSourceRange::getTokenRange(RemoveRange), Code);
139  }
140};
141
142/// Concrete class used by the front-end to report problems and issues.
143///
144/// This massages the diagnostics (e.g. handling things like "report warnings
145/// as errors" and passes them off to the DiagnosticConsumer for reporting to
146/// the user. DiagnosticsEngine is tied to one translation unit and one
147/// SourceManager.
148class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
149public:
150  /// The level of the diagnostic, after it has been through mapping.
151  enum Level {
152    Ignored = DiagnosticIDs::Ignored,
153    Note = DiagnosticIDs::Note,
154    Remark = DiagnosticIDs::Remark,
155    Warning = DiagnosticIDs::Warning,
156    Error = DiagnosticIDs::Error,
157    Fatal = DiagnosticIDs::Fatal
158  };
159
160  enum ArgumentKind {
161    /// std::string
162    ak_std_string,
163
164    /// const char *
165    ak_c_string,
166
167    /// int
168    ak_sint,
169
170    /// unsigned
171    ak_uint,
172
173    /// enum TokenKind : unsigned
174    ak_tokenkind,
175
176    /// IdentifierInfo
177    ak_identifierinfo,
178
179    /// Qualifiers
180    ak_qual,
181
182    /// QualType
183    ak_qualtype,
184
185    /// DeclarationName
186    ak_declarationname,
187
188    /// NamedDecl *
189    ak_nameddecl,
190
191    /// NestedNameSpecifier *
192    ak_nestednamespec,
193
194    /// DeclContext *
195    ak_declcontext,
196
197    /// pair<QualType, QualType>
198    ak_qualtype_pair,
199
200    /// Attr *
201    ak_attr
202  };
203
204  /// Represents on argument value, which is a union discriminated
205  /// by ArgumentKind, with a value.
206  using ArgumentValue = std::pair<ArgumentKindintptr_t>;
207
208private:
209  // Used by __extension__
210  unsigned char AllExtensionsSilenced = 0;
211
212  // Treat fatal errors like errors.
213  bool FatalsAsError = false;
214
215  // Suppress all diagnostics.
216  bool SuppressAllDiagnostics = false;
217
218  // Elide common types of templates.
219  bool ElideType = true;
220
221  // Print a tree when comparing templates.
222  bool PrintTemplateTree = false;
223
224  // Color printing is enabled.
225  bool ShowColors = false;
226
227  // Which overload candidates to show.
228  OverloadsShown ShowOverloads = Ovl_All;
229
230  // Cap of # errors emitted, 0 -> no limit.
231  unsigned ErrorLimit = 0;
232
233  // Cap on depth of template backtrace stack, 0 -> no limit.
234  unsigned TemplateBacktraceLimit = 0;
235
236  // Cap on depth of constexpr evaluation backtrace stack, 0 -> no limit.
237  unsigned ConstexprBacktraceLimit = 0;
238
239  IntrusiveRefCntPtr<DiagnosticIDsDiags;
240  IntrusiveRefCntPtr<DiagnosticOptionsDiagOpts;
241  DiagnosticConsumer *Client = nullptr;
242  std::unique_ptr<DiagnosticConsumerOwner;
243  SourceManager *SourceMgr = nullptr;
244
245  /// Mapping information for diagnostics.
246  ///
247  /// Mapping info is packed into four bits per diagnostic.  The low three
248  /// bits are the mapping (an instance of diag::Severity), or zero if unset.
249  /// The high bit is set when the mapping was established as a user mapping.
250  /// If the high bit is clear, then the low bits are set to the default
251  /// value, and should be mapped with -pedantic, -Werror, etc.
252  ///
253  /// A new DiagState is created and kept around when diagnostic pragmas modify
254  /// the state so that we know what is the diagnostic state at any given
255  /// source location.
256  class DiagState {
257    llvm::DenseMap<unsigned, DiagnosticMapping> DiagMap;
258
259  public:
260    // "Global" configuration state that can actually vary between modules.
261
262    // Ignore all warnings: -w
263    unsigned IgnoreAllWarnings : 1;
264
265    // Enable all warnings.
266    unsigned EnableAllWarnings : 1;
267
268    // Treat warnings like errors.
269    unsigned WarningsAsErrors : 1;
270
271    // Treat errors like fatal errors.
272    unsigned ErrorsAsFatal : 1;
273
274    // Suppress warnings in system headers.
275    unsigned SuppressSystemWarnings : 1;
276
277    // Map extensions to warnings or errors?
278    diag::Severity ExtBehavior = diag::Severity::Ignored;
279
280    DiagState()
281        : IgnoreAllWarnings(false), EnableAllWarnings(false),
282          WarningsAsErrors(false), ErrorsAsFatal(false),
283          SuppressSystemWarnings(false) {}
284
285    using iterator = llvm::DenseMap<unsigned, DiagnosticMapping>::iterator;
286    using const_iterator =
287        llvm::DenseMap<unsigned, DiagnosticMapping>::const_iterator;
288
289    void setMapping(diag::kind DiagDiagnosticMapping Info) {
290      DiagMap[Diag] = Info;
291    }
292
293    DiagnosticMapping lookupMapping(diag::kind Diagconst {
294      return DiagMap.lookup(Diag);
295    }
296
297    DiagnosticMapping &getOrAddMapping(diag::kind Diag);
298
299    const_iterator begin() const { return DiagMap.begin(); }
300    const_iterator end() const { return DiagMap.end(); }
301  };
302
303  /// Keeps and automatically disposes all DiagStates that we create.
304  std::list<DiagStateDiagStates;
305
306  /// A mapping from files to the diagnostic states for those files. Lazily
307  /// built on demand for files in which the diagnostic state has not changed.
308  class DiagStateMap {
309  public:
310    /// Add an initial diagnostic state.
311    void appendFirst(DiagState *State);
312
313    /// Add a new latest state point.
314    void append(SourceManager &SrcMgrSourceLocation LocDiagState *State);
315
316    /// Look up the diagnostic state at a given source location.
317    DiagState *lookup(SourceManager &SrcMgrSourceLocation Locconst;
318
319    /// Determine whether this map is empty.
320    bool empty() const { return Files.empty(); }
321
322    /// Clear out this map.
323    void clear() {
324      Files.clear();
325      FirstDiagState = CurDiagState = nullptr;
326      CurDiagStateLoc = SourceLocation();
327    }
328
329    /// Produce a debugging dump of the diagnostic state.
330    LLVM_DUMP_METHOD void dump(SourceManager &SrcMgr,
331                               StringRef DiagName = StringRef()) const;
332
333    /// Grab the most-recently-added state point.
334    DiagState *getCurDiagState() const { return CurDiagState; }
335
336    /// Get the location at which a diagnostic state was last added.
337    SourceLocation getCurDiagStateLoc() const { return CurDiagStateLoc; }
338
339  private:
340    friend class ASTReader;
341    friend class ASTWriter;
342
343    /// Represents a point in source where the diagnostic state was
344    /// modified because of a pragma.
345    ///
346    /// 'Loc' can be null if the point represents the diagnostic state
347    /// modifications done through the command-line.
348    struct DiagStatePoint {
349      DiagState *State;
350      unsigned Offset;
351
352      DiagStatePoint(DiagState *Stateunsigned Offset)
353          : State(State), Offset(Offset) {}
354    };
355
356    /// Description of the diagnostic states and state transitions for a
357    /// particular FileID.
358    struct File {
359      /// The diagnostic state for the parent file. This is strictly redundant,
360      /// as looking up the DecomposedIncludedLoc for the FileID in the Files
361      /// map would give us this, but we cache it here for performance.
362      File *Parent = nullptr;
363
364      /// The offset of this file within its parent.
365      unsigned ParentOffset = 0;
366
367      /// Whether this file has any local (not imported from an AST file)
368      /// diagnostic state transitions.
369      bool HasLocalTransitions = false;
370
371      /// The points within the file where the state changes. There will always
372      /// be at least one of these (the state on entry to the file).
373      llvm::SmallVector<DiagStatePoint4StateTransitions;
374
375      DiagState *lookup(unsigned Offsetconst;
376    };
377
378    /// The diagnostic states for each file.
379    mutable std::map<FileIDFileFiles;
380
381    /// The initial diagnostic state.
382    DiagState *FirstDiagState;
383
384    /// The current diagnostic state.
385    DiagState *CurDiagState;
386
387    /// The location at which the current diagnostic state was established.
388    SourceLocation CurDiagStateLoc;
389
390    /// Get the diagnostic state information for a file.
391    File *getFile(SourceManager &SrcMgrFileID IDconst;
392  };
393
394  DiagStateMap DiagStatesByLoc;
395
396  /// Keeps the DiagState that was active during each diagnostic 'push'
397  /// so we can get back at it when we 'pop'.
398  std::vector<DiagState *> DiagStateOnPushStack;
399
400  DiagState *GetCurDiagState() const {
401    return DiagStatesByLoc.getCurDiagState();
402  }
403
404  void PushDiagStatePoint(DiagState *StateSourceLocation L);
405
406  /// Finds the DiagStatePoint that contains the diagnostic state of
407  /// the given source location.
408  DiagState *GetDiagStateForLoc(SourceLocation Locconst {
409    return SourceMgr ? DiagStatesByLoc.lookup(*SourceMgrLoc)
410                     : DiagStatesByLoc.getCurDiagState();
411  }
412
413  /// Sticky flag set to \c true when an error is emitted.
414  bool ErrorOccurred;
415
416  /// Sticky flag set to \c true when an "uncompilable error" occurs.
417  /// I.e. an error that was not upgraded from a warning by -Werror.
418  bool UncompilableErrorOccurred;
419
420  /// Sticky flag set to \c true when a fatal error is emitted.
421  bool FatalErrorOccurred;
422
423  /// Indicates that an unrecoverable error has occurred.
424  bool UnrecoverableErrorOccurred;
425
426  /// Counts for DiagnosticErrorTrap to check whether an error occurred
427  /// during a parsing section, e.g. during parsing a function.
428  unsigned TrapNumErrorsOccurred;
429  unsigned TrapNumUnrecoverableErrorsOccurred;
430
431  /// The level of the last diagnostic emitted.
432  ///
433  /// This is used to emit continuation diagnostics with the same level as the
434  /// diagnostic that they follow.
435  DiagnosticIDs::Level LastDiagLevel;
436
437  /// Number of warnings reported
438  unsigned NumWarnings;
439
440  /// Number of errors reported
441  unsigned NumErrors;
442
443  /// A function pointer that converts an opaque diagnostic
444  /// argument to a strings.
445  ///
446  /// This takes the modifiers and argument that was present in the diagnostic.
447  ///
448  /// The PrevArgs array indicates the previous arguments formatted for this
449  /// diagnostic.  Implementations of this function can use this information to
450  /// avoid redundancy across arguments.
451  ///
452  /// This is a hack to avoid a layering violation between libbasic and libsema.
453  using ArgToStringFnTy = void (*)(
454      ArgumentKind Kindintptr_t Val,
455      StringRef ModifierStringRef Argument,
456      ArrayRef<ArgumentValuePrevArgs,
457      SmallVectorImpl<char> &Output,
458      void *Cookie,
459      ArrayRef<intptr_tQualTypeVals);
460
461  void *ArgToStringCookie = nullptr;
462  ArgToStringFnTy ArgToStringFn;
463
464  /// ID of the "delayed" diagnostic, which is a (typically
465  /// fatal) diagnostic that had to be delayed because it was found
466  /// while emitting another diagnostic.
467  unsigned DelayedDiagID;
468
469  /// First string argument for the delayed diagnostic.
470  std::string DelayedDiagArg1;
471
472  /// Second string argument for the delayed diagnostic.
473  std::string DelayedDiagArg2;
474
475  /// Optional flag value.
476  ///
477  /// Some flags accept values, for instance: -Wframe-larger-than=<value> and
478  /// -Rpass=<value>. The content of this string is emitted after the flag name
479  /// and '='.
480  std::string FlagValue;
481
482public:
483  explicit DiagnosticsEngine(IntrusiveRefCntPtr<DiagnosticIDsDiags,
484                             IntrusiveRefCntPtr<DiagnosticOptionsDiagOpts,
485                             DiagnosticConsumer *client = nullptr,
486                             bool ShouldOwnClient = true);
487  DiagnosticsEngine(const DiagnosticsEngine &) = delete;
488  DiagnosticsEngine &operator=(const DiagnosticsEngine &) = delete;
489  ~DiagnosticsEngine();
490
491  LLVM_DUMP_METHOD void dump() const;
492  LLVM_DUMP_METHOD void dump(StringRef DiagName) const;
493
494  const IntrusiveRefCntPtr<DiagnosticIDs> &getDiagnosticIDs() const {
495    return Diags;
496  }
497
498  /// Retrieve the diagnostic options.
499  DiagnosticOptions &getDiagnosticOptions() const { return *DiagOpts; }
500
501  using diag_mapping_range = llvm::iterator_range<DiagState::const_iterator>;
502
503  /// Get the current set of diagnostic mappings.
504  diag_mapping_range getDiagnosticMappings() const {
505    const DiagState &DS = *GetCurDiagState();
506    return diag_mapping_range(DS.begin(), DS.end());
507  }
508
509  DiagnosticConsumer *getClient() { return Client; }
510  const DiagnosticConsumer *getClient() const { return Client; }
511
512  /// Determine whether this \c DiagnosticsEngine object own its client.
513  bool ownsClient() const { return Owner != nullptr; }
514
515  /// Return the current diagnostic client along with ownership of that
516  /// client.
517  std::unique_ptr<DiagnosticConsumertakeClient() { return std::move(Owner); }
518
519  bool hasSourceManager() const { return SourceMgr != nullptr; }
520
521  SourceManager &getSourceManager() const {
522     (0) . __assert_fail ("SourceMgr && \"SourceManager not set!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 522, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(SourceMgr && "SourceManager not set!");
523    return *SourceMgr;
524  }
525
526  void setSourceManager(SourceManager *SrcMgr) {
527     (0) . __assert_fail ("DiagStatesByLoc.empty() && \"Leftover diag state from a different SourceManager.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 528, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(DiagStatesByLoc.empty() &&
528 (0) . __assert_fail ("DiagStatesByLoc.empty() && \"Leftover diag state from a different SourceManager.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 528, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Leftover diag state from a different SourceManager.");
529    SourceMgr = SrcMgr;
530  }
531
532  //===--------------------------------------------------------------------===//
533  //  DiagnosticsEngine characterization methods, used by a client to customize
534  //  how diagnostics are emitted.
535  //
536
537  /// Copies the current DiagMappings and pushes the new copy
538  /// onto the top of the stack.
539  void pushMappings(SourceLocation Loc);
540
541  /// Pops the current DiagMappings off the top of the stack,
542  /// causing the new top of the stack to be the active mappings.
543  ///
544  /// \returns \c true if the pop happens, \c false if there is only one
545  /// DiagMapping on the stack.
546  bool popMappings(SourceLocation Loc);
547
548  /// Set the diagnostic client associated with this diagnostic object.
549  ///
550  /// \param ShouldOwnClient true if the diagnostic object should take
551  /// ownership of \c client.
552  void setClient(DiagnosticConsumer *clientbool ShouldOwnClient = true);
553
554  /// Specify a limit for the number of errors we should
555  /// emit before giving up.
556  ///
557  /// Zero disables the limit.
558  void setErrorLimit(unsigned Limit) { ErrorLimit = Limit; }
559
560  /// Specify the maximum number of template instantiation
561  /// notes to emit along with a given diagnostic.
562  void setTemplateBacktraceLimit(unsigned Limit) {
563    TemplateBacktraceLimit = Limit;
564  }
565
566  /// Retrieve the maximum number of template instantiation
567  /// notes to emit along with a given diagnostic.
568  unsigned getTemplateBacktraceLimit() const {
569    return TemplateBacktraceLimit;
570  }
571
572  /// Specify the maximum number of constexpr evaluation
573  /// notes to emit along with a given diagnostic.
574  void setConstexprBacktraceLimit(unsigned Limit) {
575    ConstexprBacktraceLimit = Limit;
576  }
577
578  /// Retrieve the maximum number of constexpr evaluation
579  /// notes to emit along with a given diagnostic.
580  unsigned getConstexprBacktraceLimit() const {
581    return ConstexprBacktraceLimit;
582  }
583
584  /// When set to true, any unmapped warnings are ignored.
585  ///
586  /// If this and WarningsAsErrors are both set, then this one wins.
587  void setIgnoreAllWarnings(bool Val) {
588    GetCurDiagState()->IgnoreAllWarnings = Val;
589  }
590  bool getIgnoreAllWarnings() const {
591    return GetCurDiagState()->IgnoreAllWarnings;
592  }
593
594  /// When set to true, any unmapped ignored warnings are no longer
595  /// ignored.
596  ///
597  /// If this and IgnoreAllWarnings are both set, then that one wins.
598  void setEnableAllWarnings(bool Val) {
599    GetCurDiagState()->EnableAllWarnings = Val;
600  }
601  bool getEnableAllWarnings() const {
602    return GetCurDiagState()->EnableAllWarnings;
603  }
604
605  /// When set to true, any warnings reported are issued as errors.
606  void setWarningsAsErrors(bool Val) {
607    GetCurDiagState()->WarningsAsErrors = Val;
608  }
609  bool getWarningsAsErrors() const {
610    return GetCurDiagState()->WarningsAsErrors;
611  }
612
613  /// When set to true, any error reported is made a fatal error.
614  void setErrorsAsFatal(bool Val) { GetCurDiagState()->ErrorsAsFatal = Val; }
615  bool getErrorsAsFatal() const { return GetCurDiagState()->ErrorsAsFatal; }
616
617  /// \brief When set to true, any fatal error reported is made an error.
618  ///
619  /// This setting takes precedence over the setErrorsAsFatal setting above.
620  void setFatalsAsError(bool Val) { FatalsAsError = Val; }
621  bool getFatalsAsError() const { return FatalsAsError; }
622
623  /// When set to true mask warnings that come from system headers.
624  void setSuppressSystemWarnings(bool Val) {
625    GetCurDiagState()->SuppressSystemWarnings = Val;
626  }
627  bool getSuppressSystemWarnings() const {
628    return GetCurDiagState()->SuppressSystemWarnings;
629  }
630
631  /// Suppress all diagnostics, to silence the front end when we
632  /// know that we don't want any more diagnostics to be passed along to the
633  /// client
634  void setSuppressAllDiagnostics(bool Val = true) {
635    SuppressAllDiagnostics = Val;
636  }
637  bool getSuppressAllDiagnostics() const { return SuppressAllDiagnostics; }
638
639  /// Set type eliding, to skip outputting same types occurring in
640  /// template types.
641  void setElideType(bool Val = true) { ElideType = Val; }
642  bool getElideType() { return ElideType; }
643
644  /// Set tree printing, to outputting the template difference in a
645  /// tree format.
646  void setPrintTemplateTree(bool Val = false) { PrintTemplateTree = Val; }
647  bool getPrintTemplateTree() { return PrintTemplateTree; }
648
649  /// Set color printing, so the type diffing will inject color markers
650  /// into the output.
651  void setShowColors(bool Val = false) { ShowColors = Val; }
652  bool getShowColors() { return ShowColors; }
653
654  /// Specify which overload candidates to show when overload resolution
655  /// fails.
656  ///
657  /// By default, we show all candidates.
658  void setShowOverloads(OverloadsShown Val) {
659    ShowOverloads = Val;
660  }
661  OverloadsShown getShowOverloads() const { return ShowOverloads; }
662
663  /// Pretend that the last diagnostic issued was ignored, so any
664  /// subsequent notes will be suppressed, or restore a prior ignoring
665  /// state after ignoring some diagnostics and their notes, possibly in
666  /// the middle of another diagnostic.
667  ///
668  /// This can be used by clients who suppress diagnostics themselves.
669  void setLastDiagnosticIgnored(bool Ignored = true) {
670    if (LastDiagLevel == DiagnosticIDs::Fatal)
671      FatalErrorOccurred = true;
672    LastDiagLevel = Ignored ? DiagnosticIDs::Ignored : DiagnosticIDs::Warning;
673  }
674
675  /// Determine whether the previous diagnostic was ignored. This can
676  /// be used by clients that want to determine whether notes attached to a
677  /// diagnostic will be suppressed.
678  bool isLastDiagnosticIgnored() const {
679    return LastDiagLevel == DiagnosticIDs::Ignored;
680  }
681
682  /// Controls whether otherwise-unmapped extension diagnostics are
683  /// mapped onto ignore/warning/error.
684  ///
685  /// This corresponds to the GCC -pedantic and -pedantic-errors option.
686  void setExtensionHandlingBehavior(diag::Severity H) {
687    GetCurDiagState()->ExtBehavior = H;
688  }
689  diag::Severity getExtensionHandlingBehavior() const {
690    return GetCurDiagState()->ExtBehavior;
691  }
692
693  /// Counter bumped when an __extension__  block is/ encountered.
694  ///
695  /// When non-zero, all extension diagnostics are entirely silenced, no
696  /// matter how they are mapped.
697  void IncrementAllExtensionsSilenced() { ++AllExtensionsSilenced; }
698  void DecrementAllExtensionsSilenced() { --AllExtensionsSilenced; }
699  bool hasAllExtensionsSilenced() { return AllExtensionsSilenced != 0; }
700
701  /// This allows the client to specify that certain warnings are
702  /// ignored.
703  ///
704  /// Notes can never be mapped, errors can only be mapped to fatal, and
705  /// WARNINGs and EXTENSIONs can be mapped arbitrarily.
706  ///
707  /// \param Loc The source location that this change of diagnostic state should
708  /// take affect. It can be null if we are setting the latest state.
709  void setSeverity(diag::kind Diagdiag::Severity MapSourceLocation Loc);
710
711  /// Change an entire diagnostic group (e.g. "unknown-pragmas") to
712  /// have the specified mapping.
713  ///
714  /// \returns true (and ignores the request) if "Group" was unknown, false
715  /// otherwise.
716  ///
717  /// \param Flavor The flavor of group to affect. -Rfoo does not affect the
718  /// state of the -Wfoo group and vice versa.
719  ///
720  /// \param Loc The source location that this change of diagnostic state should
721  /// take affect. It can be null if we are setting the state from command-line.
722  bool setSeverityForGroup(diag::Flavor FlavorStringRef Group,
723                           diag::Severity Map,
724                           SourceLocation Loc = SourceLocation());
725
726  /// Set the warning-as-error flag for the given diagnostic group.
727  ///
728  /// This function always only operates on the current diagnostic state.
729  ///
730  /// \returns True if the given group is unknown, false otherwise.
731  bool setDiagnosticGroupWarningAsError(StringRef Groupbool Enabled);
732
733  /// Set the error-as-fatal flag for the given diagnostic group.
734  ///
735  /// This function always only operates on the current diagnostic state.
736  ///
737  /// \returns True if the given group is unknown, false otherwise.
738  bool setDiagnosticGroupErrorAsFatal(StringRef Groupbool Enabled);
739
740  /// Add the specified mapping to all diagnostics of the specified
741  /// flavor.
742  ///
743  /// Mainly to be used by -Wno-everything to disable all warnings but allow
744  /// subsequent -W options to enable specific warnings.
745  void setSeverityForAll(diag::Flavor Flavordiag::Severity Map,
746                         SourceLocation Loc = SourceLocation());
747
748  bool hasErrorOccurred() const { return ErrorOccurred; }
749
750  /// Errors that actually prevent compilation, not those that are
751  /// upgraded from a warning by -Werror.
752  bool hasUncompilableErrorOccurred() const {
753    return UncompilableErrorOccurred;
754  }
755  bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
756
757  /// Determine whether any kind of unrecoverable error has occurred.
758  bool hasUnrecoverableErrorOccurred() const {
759    return FatalErrorOccurred || UnrecoverableErrorOccurred;
760  }
761
762  unsigned getNumWarnings() const { return NumWarnings; }
763
764  void setNumWarnings(unsigned NumWarnings) {
765    this->NumWarnings = NumWarnings;
766  }
767
768  /// Return an ID for a diagnostic with the specified format string and
769  /// level.
770  ///
771  /// If this is the first request for this diagnostic, it is registered and
772  /// created, otherwise the existing ID is returned.
773  ///
774  /// \param FormatString A fixed diagnostic format string that will be hashed
775  /// and mapped to a unique DiagID.
776  template <unsigned N>
777  unsigned getCustomDiagID(Level Lconst char (&FormatString)[N]) {
778    return Diags->getCustomDiagID((DiagnosticIDs::Level)L,
779                                  StringRef(FormatString, N - 1));
780  }
781
782  /// Converts a diagnostic argument (as an intptr_t) into the string
783  /// that represents it.
784  void ConvertArgToString(ArgumentKind Kindintptr_t Val,
785                          StringRef ModifierStringRef Argument,
786                          ArrayRef<ArgumentValuePrevArgs,
787                          SmallVectorImpl<char> &Output,
788                          ArrayRef<intptr_tQualTypeValsconst {
789    ArgToStringFn(Kind, Val, Modifier, Argument, PrevArgs, Output,
790                  ArgToStringCookie, QualTypeVals);
791  }
792
793  void SetArgToStringFn(ArgToStringFnTy Fnvoid *Cookie) {
794    ArgToStringFn = Fn;
795    ArgToStringCookie = Cookie;
796  }
797
798  /// Note that the prior diagnostic was emitted by some other
799  /// \c DiagnosticsEngine, and we may be attaching a note to that diagnostic.
800  void notePriorDiagnosticFrom(const DiagnosticsEngine &Other) {
801    LastDiagLevel = Other.LastDiagLevel;
802  }
803
804  /// Reset the state of the diagnostic object to its initial
805  /// configuration.
806  void Reset();
807
808  //===--------------------------------------------------------------------===//
809  // DiagnosticsEngine classification and reporting interfaces.
810  //
811
812  /// Determine whether the diagnostic is known to be ignored.
813  ///
814  /// This can be used to opportunistically avoid expensive checks when it's
815  /// known for certain that the diagnostic has been suppressed at the
816  /// specified location \p Loc.
817  ///
818  /// \param Loc The source location we are interested in finding out the
819  /// diagnostic state. Can be null in order to query the latest state.
820  bool isIgnored(unsigned DiagIDSourceLocation Locconst {
821    return Diags->getDiagnosticSeverity(DiagID, Loc, *this) ==
822           diag::Severity::Ignored;
823  }
824
825  /// Based on the way the client configured the DiagnosticsEngine
826  /// object, classify the specified diagnostic ID into a Level, consumable by
827  /// the DiagnosticConsumer.
828  ///
829  /// To preserve invariant assumptions, this function should not be used to
830  /// influence parse or semantic analysis actions. Instead consider using
831  /// \c isIgnored().
832  ///
833  /// \param Loc The source location we are interested in finding out the
834  /// diagnostic state. Can be null in order to query the latest state.
835  Level getDiagnosticLevel(unsigned DiagIDSourceLocation Locconst {
836    return (Level)Diags->getDiagnosticLevel(DiagID, Loc, *this);
837  }
838
839  /// Issue the message to the client.
840  ///
841  /// This actually returns an instance of DiagnosticBuilder which emits the
842  /// diagnostics (through @c ProcessDiag) when it is destroyed.
843  ///
844  /// \param DiagID A member of the @c diag::kind enum.
845  /// \param Loc Represents the source location associated with the diagnostic,
846  /// which can be an invalid location if no position information is available.
847  inline DiagnosticBuilder Report(SourceLocation Locunsigned DiagID);
848  inline DiagnosticBuilder Report(unsigned DiagID);
849
850  void Report(const StoredDiagnostic &storedDiag);
851
852  /// Determine whethere there is already a diagnostic in flight.
853  bool isDiagnosticInFlight() const {
854    return CurDiagID != std::numeric_limits<unsigned>::max();
855  }
856
857  /// Set the "delayed" diagnostic that will be emitted once
858  /// the current diagnostic completes.
859  ///
860  ///  If a diagnostic is already in-flight but the front end must
861  ///  report a problem (e.g., with an inconsistent file system
862  ///  state), this routine sets a "delayed" diagnostic that will be
863  ///  emitted after the current diagnostic completes. This should
864  ///  only be used for fatal errors detected at inconvenient
865  ///  times. If emitting a delayed diagnostic causes a second delayed
866  ///  diagnostic to be introduced, that second delayed diagnostic
867  ///  will be ignored.
868  ///
869  /// \param DiagID The ID of the diagnostic being delayed.
870  ///
871  /// \param Arg1 A string argument that will be provided to the
872  /// diagnostic. A copy of this string will be stored in the
873  /// DiagnosticsEngine object itself.
874  ///
875  /// \param Arg2 A string argument that will be provided to the
876  /// diagnostic. A copy of this string will be stored in the
877  /// DiagnosticsEngine object itself.
878  void SetDelayedDiagnostic(unsigned DiagIDStringRef Arg1 = "",
879                            StringRef Arg2 = "");
880
881  /// Clear out the current diagnostic.
882  void Clear() { CurDiagID = std::numeric_limits<unsigned>::max(); }
883
884  /// Return the value associated with this diagnostic flag.
885  StringRef getFlagValue() const { return FlagValue; }
886
887private:
888  // This is private state used by DiagnosticBuilder.  We put it here instead of
889  // in DiagnosticBuilder in order to keep DiagnosticBuilder a small lightweight
890  // object.  This implementation choice means that we can only have one
891  // diagnostic "in flight" at a time, but this seems to be a reasonable
892  // tradeoff to keep these objects small.  Assertions verify that only one
893  // diagnostic is in flight at a time.
894  friend class Diagnostic;
895  friend class DiagnosticBuilder;
896  friend class DiagnosticErrorTrap;
897  friend class DiagnosticIDs;
898  friend class PartialDiagnostic;
899
900  /// Report the delayed diagnostic.
901  void ReportDelayed();
902
903  /// The location of the current diagnostic that is in flight.
904  SourceLocation CurDiagLoc;
905
906  /// The ID of the current diagnostic that is in flight.
907  ///
908  /// This is set to std::numeric_limits<unsigned>::max() when there is no
909  /// diagnostic in flight.
910  unsigned CurDiagID;
911
912  enum {
913    /// The maximum number of arguments we can hold.
914    ///
915    /// We currently only support up to 10 arguments (%0-%9).  A single
916    /// diagnostic with more than that almost certainly has to be simplified
917    /// anyway.
918    MaxArguments = 10,
919  };
920
921  /// The number of entries in Arguments.
922  signed char NumDiagArgs;
923
924  /// Specifies whether an argument is in DiagArgumentsStr or
925  /// in DiagArguments.
926  ///
927  /// This is an array of ArgumentKind::ArgumentKind enum values, one for each
928  /// argument.
929  unsigned char DiagArgumentsKind[MaxArguments];
930
931  /// Holds the values of each string argument for the current
932  /// diagnostic.
933  ///
934  /// This is only used when the corresponding ArgumentKind is ak_std_string.
935  std::string DiagArgumentsStr[MaxArguments];
936
937  /// The values for the various substitution positions.
938  ///
939  /// This is used when the argument is not an std::string.  The specific
940  /// value is mangled into an intptr_t and the interpretation depends on
941  /// exactly what sort of argument kind it is.
942  intptr_t DiagArgumentsVal[MaxArguments];
943
944  /// The list of ranges added to this diagnostic.
945  SmallVector<CharSourceRange8DiagRanges;
946
947  /// If valid, provides a hint with some code to insert, remove,
948  /// or modify at a particular position.
949  SmallVector<FixItHint8DiagFixItHints;
950
951  DiagnosticMapping makeUserMapping(diag::Severity MapSourceLocation L) {
952    bool isPragma = L.isValid();
953    DiagnosticMapping Mapping =
954        DiagnosticMapping::Make(Map/*IsUser=*/trueisPragma);
955
956    // If this is a pragma mapping, then set the diagnostic mapping flags so
957    // that we override command line options.
958    if (isPragma) {
959      Mapping.setNoWarningAsError(true);
960      Mapping.setNoErrorAsFatal(true);
961    }
962
963    return Mapping;
964  }
965
966  /// Used to report a diagnostic that is finally fully formed.
967  ///
968  /// \returns true if the diagnostic was emitted, false if it was suppressed.
969  bool ProcessDiag() {
970    return Diags->ProcessDiag(*this);
971  }
972
973  /// @name Diagnostic Emission
974  /// @{
975protected:
976  friend class ASTReader;
977  friend class ASTWriter;
978
979  // Sema requires access to the following functions because the current design
980  // of SFINAE requires it to use its own SemaDiagnosticBuilder, which needs to
981  // access us directly to ensure we minimize the emitted code for the common
982  // Sema::Diag() patterns.
983  friend class Sema;
984
985  /// Emit the current diagnostic and clear the diagnostic state.
986  ///
987  /// \param Force Emit the diagnostic regardless of suppression settings.
988  bool EmitCurrentDiagnostic(bool Force = false);
989
990  unsigned getCurrentDiagID() const { return CurDiagID; }
991
992  SourceLocation getCurrentDiagLoc() const { return CurDiagLoc; }
993
994  /// @}
995};
996
997/// RAII class that determines when any errors have occurred
998/// between the time the instance was created and the time it was
999/// queried.
1000class DiagnosticErrorTrap {
1001  DiagnosticsEngine &Diag;
1002  unsigned NumErrors;
1003  unsigned NumUnrecoverableErrors;
1004
1005public:
1006  explicit DiagnosticErrorTrap(DiagnosticsEngine &Diag)
1007      : Diag(Diag) { reset(); }
1008
1009  /// Determine whether any errors have occurred since this
1010  /// object instance was created.
1011  bool hasErrorOccurred() const {
1012    return Diag.TrapNumErrorsOccurred > NumErrors;
1013  }
1014
1015  /// Determine whether any unrecoverable errors have occurred since this
1016  /// object instance was created.
1017  bool hasUnrecoverableErrorOccurred() const {
1018    return Diag.TrapNumUnrecoverableErrorsOccurred > NumUnrecoverableErrors;
1019  }
1020
1021  /// Set to initial state of "no errors occurred".
1022  void reset() {
1023    NumErrors = Diag.TrapNumErrorsOccurred;
1024    NumUnrecoverableErrors = Diag.TrapNumUnrecoverableErrorsOccurred;
1025  }
1026};
1027
1028//===----------------------------------------------------------------------===//
1029// DiagnosticBuilder
1030//===----------------------------------------------------------------------===//
1031
1032/// A little helper class used to produce diagnostics.
1033///
1034/// This is constructed by the DiagnosticsEngine::Report method, and
1035/// allows insertion of extra information (arguments and source ranges) into
1036/// the currently "in flight" diagnostic.  When the temporary for the builder
1037/// is destroyed, the diagnostic is issued.
1038///
1039/// Note that many of these will be created as temporary objects (many call
1040/// sites), so we want them to be small and we never want their address taken.
1041/// This ensures that compilers with somewhat reasonable optimizers will promote
1042/// the common fields to registers, eliminating increments of the NumArgs field,
1043/// for example.
1044class DiagnosticBuilder {
1045  friend class DiagnosticsEngine;
1046  friend class PartialDiagnostic;
1047
1048  mutable DiagnosticsEngine *DiagObj = nullptr;
1049  mutable unsigned NumArgs = 0;
1050
1051  /// Status variable indicating if this diagnostic is still active.
1052  ///
1053  // NOTE: This field is redundant with DiagObj (IsActive iff (DiagObj == 0)),
1054  // but LLVM is not currently smart enough to eliminate the null check that
1055  // Emit() would end up with if we used that as our status variable.
1056  mutable bool IsActive = false;
1057
1058  /// Flag indicating that this diagnostic is being emitted via a
1059  /// call to ForceEmit.
1060  mutable bool IsForceEmit = false;
1061
1062  DiagnosticBuilder() = default;
1063
1064  explicit DiagnosticBuilder(DiagnosticsEngine *diagObj)
1065      : DiagObj(diagObj), IsActive(true) {
1066     (0) . __assert_fail ("diagObj && \"DiagnosticBuilder requires a valid DiagnosticsEngine!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1066, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(diagObj && "DiagnosticBuilder requires a valid DiagnosticsEngine!");
1067    diagObj->DiagRanges.clear();
1068    diagObj->DiagFixItHints.clear();
1069  }
1070
1071protected:
1072  void FlushCounts() {
1073    DiagObj->NumDiagArgs = NumArgs;
1074  }
1075
1076  /// Clear out the current diagnostic.
1077  void Clear() const {
1078    DiagObj = nullptr;
1079    IsActive = false;
1080    IsForceEmit = false;
1081  }
1082
1083  /// Determine whether this diagnostic is still active.
1084  bool isActive() const { return IsActive; }
1085
1086  /// Force the diagnostic builder to emit the diagnostic now.
1087  ///
1088  /// Once this function has been called, the DiagnosticBuilder object
1089  /// should not be used again before it is destroyed.
1090  ///
1091  /// \returns true if a diagnostic was emitted, false if the
1092  /// diagnostic was suppressed.
1093  bool Emit() {
1094    // If this diagnostic is inactive, then its soul was stolen by the copy ctor
1095    // (or by a subclass, as in SemaDiagnosticBuilder).
1096    if (!isActive()) return false;
1097
1098    // When emitting diagnostics, we set the final argument count into
1099    // the DiagnosticsEngine object.
1100    FlushCounts();
1101
1102    // Process the diagnostic.
1103    bool Result = DiagObj->EmitCurrentDiagnostic(IsForceEmit);
1104
1105    // This diagnostic is dead.
1106    Clear();
1107
1108    return Result;
1109  }
1110
1111public:
1112  /// Copy constructor.  When copied, this "takes" the diagnostic info from the
1113  /// input and neuters it.
1114  DiagnosticBuilder(const DiagnosticBuilder &D) {
1115    DiagObj = D.DiagObj;
1116    IsActive = D.IsActive;
1117    IsForceEmit = D.IsForceEmit;
1118    D.Clear();
1119    NumArgs = D.NumArgs;
1120  }
1121
1122  DiagnosticBuilder &operator=(const DiagnosticBuilder &) = delete;
1123
1124  /// Emits the diagnostic.
1125  ~DiagnosticBuilder() {
1126    Emit();
1127  }
1128
1129  /// Retrieve an empty diagnostic builder.
1130  static DiagnosticBuilder getEmpty() {
1131    return {};
1132  }
1133
1134  /// Forces the diagnostic to be emitted.
1135  const DiagnosticBuilder &setForceEmit() const {
1136    IsForceEmit = true;
1137    return *this;
1138  }
1139
1140  /// Conversion of DiagnosticBuilder to bool always returns \c true.
1141  ///
1142  /// This allows is to be used in boolean error contexts (where \c true is
1143  /// used to indicate that an error has occurred), like:
1144  /// \code
1145  /// return Diag(...);
1146  /// \endcode
1147  operator bool() const { return true; }
1148
1149  void AddString(StringRef Sconst {
1150     (0) . __assert_fail ("isActive() && \"Clients must not add to cleared diagnostic!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1150, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isActive() && "Clients must not add to cleared diagnostic!");
1151     (0) . __assert_fail ("NumArgs < DiagnosticsEngine..MaxArguments && \"Too many arguments to diagnostic!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1152, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(NumArgs < DiagnosticsEngine::MaxArguments &&
1152 (0) . __assert_fail ("NumArgs < DiagnosticsEngine..MaxArguments && \"Too many arguments to diagnostic!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1152, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Too many arguments to diagnostic!");
1153    DiagObj->DiagArgumentsKind[NumArgs] = DiagnosticsEngine::ak_std_string;
1154    DiagObj->DiagArgumentsStr[NumArgs++] = S;
1155  }
1156
1157  void AddTaggedVal(intptr_t VDiagnosticsEngine::ArgumentKind Kindconst {
1158     (0) . __assert_fail ("isActive() && \"Clients must not add to cleared diagnostic!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1158, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isActive() && "Clients must not add to cleared diagnostic!");
1159     (0) . __assert_fail ("NumArgs < DiagnosticsEngine..MaxArguments && \"Too many arguments to diagnostic!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1160, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(NumArgs < DiagnosticsEngine::MaxArguments &&
1160 (0) . __assert_fail ("NumArgs < DiagnosticsEngine..MaxArguments && \"Too many arguments to diagnostic!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1160, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Too many arguments to diagnostic!");
1161    DiagObj->DiagArgumentsKind[NumArgs] = Kind;
1162    DiagObj->DiagArgumentsVal[NumArgs++] = V;
1163  }
1164
1165  void AddSourceRange(const CharSourceRange &Rconst {
1166     (0) . __assert_fail ("isActive() && \"Clients must not add to cleared diagnostic!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1166, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isActive() && "Clients must not add to cleared diagnostic!");
1167    DiagObj->DiagRanges.push_back(R);
1168  }
1169
1170  void AddFixItHint(const FixItHint &Hintconst {
1171     (0) . __assert_fail ("isActive() && \"Clients must not add to cleared diagnostic!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1171, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isActive() && "Clients must not add to cleared diagnostic!");
1172    if (!Hint.isNull())
1173      DiagObj->DiagFixItHints.push_back(Hint);
1174  }
1175
1176  void addFlagValue(StringRef Vconst { DiagObj->FlagValue = V; }
1177};
1178
1179struct AddFlagValue {
1180  StringRef Val;
1181
1182  explicit AddFlagValue(StringRef V) : Val(V) {}
1183};
1184
1185/// Register a value for the flag in the current diagnostic. This
1186/// value will be shown as the suffix "=value" after the flag name. It is
1187/// useful in cases where the diagnostic flag accepts values (e.g.,
1188/// -Rpass or -Wframe-larger-than).
1189inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1190                                           const AddFlagValue V) {
1191  DB.addFlagValue(V.Val);
1192  return DB;
1193}
1194
1195inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1196                                           StringRef S) {
1197  DB.AddString(S);
1198  return DB;
1199}
1200
1201inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1202                                           const char *Str) {
1203  DB.AddTaggedVal(reinterpret_cast<intptr_t>(Str),
1204                  DiagnosticsEngine::ak_c_string);
1205  return DB;
1206}
1207
1208inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DBint I) {
1209  DB.AddTaggedVal(IDiagnosticsEngine::ak_sint);
1210  return DB;
1211}
1212
1213// We use enable_if here to prevent that this overload is selected for
1214// pointers or other arguments that are implicitly convertible to bool.
1215template <typename T>
1216inline
1217typename std::enable_if<std::is_same<T, bool>::value,
1218                        const DiagnosticBuilder &>::type
1219operator<<(const DiagnosticBuilder &DB, T I) {
1220  DB.AddTaggedVal(IDiagnosticsEngine::ak_sint);
1221  return DB;
1222}
1223
1224inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1225                                           unsigned I) {
1226  DB.AddTaggedVal(IDiagnosticsEngine::ak_uint);
1227  return DB;
1228}
1229
1230inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1231                                           tok::TokenKind I) {
1232  DB.AddTaggedVal(static_cast<unsigned>(I), DiagnosticsEngine::ak_tokenkind);
1233  return DB;
1234}
1235
1236inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1237                                           const IdentifierInfo *II) {
1238  DB.AddTaggedVal(reinterpret_cast<intptr_t>(II),
1239                  DiagnosticsEngine::ak_identifierinfo);
1240  return DB;
1241}
1242
1243// Adds a DeclContext to the diagnostic. The enable_if template magic is here
1244// so that we only match those arguments that are (statically) DeclContexts;
1245// other arguments that derive from DeclContext (e.g., RecordDecls) will not
1246// match.
1247template <typename T>
1248inline typename std::enable_if<
1249    std::is_same<typename std::remove_const<T>::type, DeclContext>::value,
1250    const DiagnosticBuilder &>::type
1251operator<<(const DiagnosticBuilder &DB, T *DC) {
1252  DB.AddTaggedVal(reinterpret_cast<intptr_t>(DC),
1253                  DiagnosticsEngine::ak_declcontext);
1254  return DB;
1255}
1256
1257inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1258                                           SourceRange R) {
1259  DB.AddSourceRange(CharSourceRange::getTokenRange(R));
1260  return DB;
1261}
1262
1263inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1264                                           ArrayRef<SourceRangeRanges) {
1265  for (SourceRange R : Ranges)
1266    DB.AddSourceRange(CharSourceRange::getTokenRange(R));
1267  return DB;
1268}
1269
1270inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1271                                           const CharSourceRange &R) {
1272  DB.AddSourceRange(R);
1273  return DB;
1274}
1275
1276inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1277                                           const FixItHint &Hint) {
1278  DB.AddFixItHint(Hint);
1279  return DB;
1280}
1281
1282inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1283                                           ArrayRef<FixItHintHints) {
1284  for (const FixItHint &Hint : Hints)
1285    DB.AddFixItHint(Hint);
1286  return DB;
1287}
1288
1289/// A nullability kind paired with a bit indicating whether it used a
1290/// context-sensitive keyword.
1291using DiagNullabilityKind = std::pair<NullabilityKindbool>;
1292
1293const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1294                                    DiagNullabilityKind nullability);
1295
1296inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
1297                                                   unsigned DiagID) {
1298   (0) . __assert_fail ("CurDiagID == std..numeric_limits..max() && \"Multiple diagnostics in flight at once!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1299, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(CurDiagID == std::numeric_limits<unsigned>::max() &&
1299 (0) . __assert_fail ("CurDiagID == std..numeric_limits..max() && \"Multiple diagnostics in flight at once!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1299, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">         "Multiple diagnostics in flight at once!");
1300  CurDiagLoc = Loc;
1301  CurDiagID = DiagID;
1302  FlagValue.clear();
1303  return DiagnosticBuilder(this);
1304}
1305
1306inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) {
1307  return Report(SourceLocation(), DiagID);
1308}
1309
1310//===----------------------------------------------------------------------===//
1311// Diagnostic
1312//===----------------------------------------------------------------------===//
1313
1314/// A little helper class (which is basically a smart pointer that forwards
1315/// info from DiagnosticsEngine) that allows clients to enquire about the
1316/// currently in-flight diagnostic.
1317class Diagnostic {
1318  const DiagnosticsEngine *DiagObj;
1319  StringRef StoredDiagMessage;
1320
1321public:
1322  explicit Diagnostic(const DiagnosticsEngine *DO) : DiagObj(DO) {}
1323  Diagnostic(const DiagnosticsEngine *DOStringRef storedDiagMessage)
1324      : DiagObj(DO), StoredDiagMessage(storedDiagMessage) {}
1325
1326  const DiagnosticsEngine *getDiags() const { return DiagObj; }
1327  unsigned getID() const { return DiagObj->CurDiagID; }
1328  const SourceLocation &getLocation() const { return DiagObj->CurDiagLoc; }
1329  bool hasSourceManager() const { return DiagObj->hasSourceManager(); }
1330  SourceManager &getSourceManager() const { return DiagObj->getSourceManager();}
1331
1332  unsigned getNumArgs() const { return DiagObj->NumDiagArgs; }
1333
1334  /// Return the kind of the specified index.
1335  ///
1336  /// Based on the kind of argument, the accessors below can be used to get
1337  /// the value.
1338  ///
1339  /// \pre Idx < getNumArgs()
1340  DiagnosticsEngine::ArgumentKind getArgKind(unsigned Idxconst {
1341     (0) . __assert_fail ("Idx < getNumArgs() && \"Argument index out of range!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1341, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Idx < getNumArgs() && "Argument index out of range!");
1342    return (DiagnosticsEngine::ArgumentKind)DiagObj->DiagArgumentsKind[Idx];
1343  }
1344
1345  /// Return the provided argument string specified by \p Idx.
1346  /// \pre getArgKind(Idx) == DiagnosticsEngine::ak_std_string
1347  const std::string &getArgStdStr(unsigned Idxconst {
1348     (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_std_string && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1349, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getArgKind(Idx) == DiagnosticsEngine::ak_std_string &&
1349 (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_std_string && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1349, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "invalid argument accessor!");
1350    return DiagObj->DiagArgumentsStr[Idx];
1351  }
1352
1353  /// Return the specified C string argument.
1354  /// \pre getArgKind(Idx) == DiagnosticsEngine::ak_c_string
1355  const char *getArgCStr(unsigned Idxconst {
1356     (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_c_string && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1357, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getArgKind(Idx) == DiagnosticsEngine::ak_c_string &&
1357 (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_c_string && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1357, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "invalid argument accessor!");
1358    return reinterpret_cast<const char*>(DiagObj->DiagArgumentsVal[Idx]);
1359  }
1360
1361  /// Return the specified signed integer argument.
1362  /// \pre getArgKind(Idx) == DiagnosticsEngine::ak_sint
1363  int getArgSInt(unsigned Idxconst {
1364     (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_sint && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1365, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getArgKind(Idx) == DiagnosticsEngine::ak_sint &&
1365 (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_sint && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1365, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "invalid argument accessor!");
1366    return (int)DiagObj->DiagArgumentsVal[Idx];
1367  }
1368
1369  /// Return the specified unsigned integer argument.
1370  /// \pre getArgKind(Idx) == DiagnosticsEngine::ak_uint
1371  unsigned getArgUInt(unsigned Idxconst {
1372     (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_uint && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1373, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getArgKind(Idx) == DiagnosticsEngine::ak_uint &&
1373 (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_uint && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1373, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "invalid argument accessor!");
1374    return (unsigned)DiagObj->DiagArgumentsVal[Idx];
1375  }
1376
1377  /// Return the specified IdentifierInfo argument.
1378  /// \pre getArgKind(Idx) == DiagnosticsEngine::ak_identifierinfo
1379  const IdentifierInfo *getArgIdentifier(unsigned Idxconst {
1380     (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_identifierinfo && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1381, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getArgKind(Idx) == DiagnosticsEngine::ak_identifierinfo &&
1381 (0) . __assert_fail ("getArgKind(Idx) == DiagnosticsEngine..ak_identifierinfo && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1381, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "invalid argument accessor!");
1382    return reinterpret_cast<IdentifierInfo*>(DiagObj->DiagArgumentsVal[Idx]);
1383  }
1384
1385  /// Return the specified non-string argument in an opaque form.
1386  /// \pre getArgKind(Idx) != DiagnosticsEngine::ak_std_string
1387  intptr_t getRawArg(unsigned Idxconst {
1388     (0) . __assert_fail ("getArgKind(Idx) != DiagnosticsEngine..ak_std_string && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1389, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getArgKind(Idx) != DiagnosticsEngine::ak_std_string &&
1389 (0) . __assert_fail ("getArgKind(Idx) != DiagnosticsEngine..ak_std_string && \"invalid argument accessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1389, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "invalid argument accessor!");
1390    return DiagObj->DiagArgumentsVal[Idx];
1391  }
1392
1393  /// Return the number of source ranges associated with this diagnostic.
1394  unsigned getNumRanges() const {
1395    return DiagObj->DiagRanges.size();
1396  }
1397
1398  /// \pre Idx < getNumRanges()
1399  const CharSourceRange &getRange(unsigned Idxconst {
1400     (0) . __assert_fail ("Idx < getNumRanges() && \"Invalid diagnostic range index!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1400, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Idx < getNumRanges() && "Invalid diagnostic range index!");
1401    return DiagObj->DiagRanges[Idx];
1402  }
1403
1404  /// Return an array reference for this diagnostic's ranges.
1405  ArrayRef<CharSourceRangegetRanges() const {
1406    return DiagObj->DiagRanges;
1407  }
1408
1409  unsigned getNumFixItHints() const {
1410    return DiagObj->DiagFixItHints.size();
1411  }
1412
1413  const FixItHint &getFixItHint(unsigned Idxconst {
1414     (0) . __assert_fail ("Idx < getNumFixItHints() && \"Invalid index!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/Diagnostic.h", 1414, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Idx < getNumFixItHints() && "Invalid index!");
1415    return DiagObj->DiagFixItHints[Idx];
1416  }
1417
1418  ArrayRef<FixItHintgetFixItHints() const {
1419    return DiagObj->DiagFixItHints;
1420  }
1421
1422  /// Format this diagnostic into a string, substituting the
1423  /// formal arguments into the %0 slots.
1424  ///
1425  /// The result is appended onto the \p OutStr array.
1426  void FormatDiagnostic(SmallVectorImpl<char> &OutStrconst;
1427
1428  /// Format the given format-string into the output buffer using the
1429  /// arguments stored in this diagnostic.
1430  void FormatDiagnostic(const char *DiagStrconst char *DiagEnd,
1431                        SmallVectorImpl<char> &OutStrconst;
1432};
1433
1434/**
1435 * Represents a diagnostic in a form that can be retained until its
1436 * corresponding source manager is destroyed.
1437 */
1438class StoredDiagnostic {
1439  unsigned ID;
1440  DiagnosticsEngine::Level Level;
1441  FullSourceLoc Loc;
1442  std::string Message;
1443  std::vector<CharSourceRangeRanges;
1444  std::vector<FixItHintFixIts;
1445
1446public:
1447  StoredDiagnostic() = default;
1448  StoredDiagnostic(DiagnosticsEngine::Level Levelconst Diagnostic &Info);
1449  StoredDiagnostic(DiagnosticsEngine::Level Levelunsigned ID,
1450                   StringRef Message);
1451  StoredDiagnostic(DiagnosticsEngine::Level Levelunsigned ID,
1452                   StringRef MessageFullSourceLoc Loc,
1453                   ArrayRef<CharSourceRangeRanges,
1454                   ArrayRef<FixItHintFixits);
1455
1456  /// Evaluates true when this object stores a diagnostic.
1457  explicit operator bool() const { return !Message.empty(); }
1458
1459  unsigned getID() const { return ID; }
1460  DiagnosticsEngine::Level getLevel() const { return Level; }
1461  const FullSourceLoc &getLocation() const { return Loc; }
1462  StringRef getMessage() const { return Message; }
1463
1464  void setLocation(FullSourceLoc Loc) { this->Loc = Loc; }
1465
1466  using range_iterator = std::vector<CharSourceRange>::const_iterator;
1467
1468  range_iterator range_begin() const { return Ranges.begin(); }
1469  range_iterator range_end() const { return Ranges.end(); }
1470  unsigned range_size() const { return Ranges.size(); }
1471
1472  ArrayRef<CharSourceRangegetRanges() const {
1473    return llvm::makeArrayRef(Ranges);
1474  }
1475
1476  using fixit_iterator = std::vector<FixItHint>::const_iterator;
1477
1478  fixit_iterator fixit_begin() const { return FixIts.begin(); }
1479  fixit_iterator fixit_end() const { return FixIts.end(); }
1480  unsigned fixit_size() const { return FixIts.size(); }
1481
1482  ArrayRef<FixItHintgetFixIts() const {
1483    return llvm::makeArrayRef(FixIts);
1484  }
1485};
1486
1487/// Abstract interface, implemented by clients of the front-end, which
1488/// formats and prints fully processed diagnostics.
1489class DiagnosticConsumer {
1490protected:
1491  unsigned NumWarnings = 0;       ///< Number of warnings reported
1492  unsigned NumErrors = 0;         ///< Number of errors reported
1493
1494public:
1495  DiagnosticConsumer() = default;
1496  virtual ~DiagnosticConsumer();
1497
1498  unsigned getNumErrors() const { return NumErrors; }
1499  unsigned getNumWarnings() const { return NumWarnings; }
1500  virtual void clear() { NumWarnings = NumErrors = 0; }
1501
1502  /// Callback to inform the diagnostic client that processing
1503  /// of a source file is beginning.
1504  ///
1505  /// Note that diagnostics may be emitted outside the processing of a source
1506  /// file, for example during the parsing of command line options. However,
1507  /// diagnostics with source range information are required to only be emitted
1508  /// in between BeginSourceFile() and EndSourceFile().
1509  ///
1510  /// \param LangOpts The language options for the source file being processed.
1511  /// \param PP The preprocessor object being used for the source; this is
1512  /// optional, e.g., it may not be present when processing AST source files.
1513  virtual void BeginSourceFile(const LangOptions &LangOpts,
1514                               const Preprocessor *PP = nullptr) {}
1515
1516  /// Callback to inform the diagnostic client that processing
1517  /// of a source file has ended.
1518  ///
1519  /// The diagnostic client should assume that any objects made available via
1520  /// BeginSourceFile() are inaccessible.
1521  virtual void EndSourceFile() {}
1522
1523  /// Callback to inform the diagnostic client that processing of all
1524  /// source files has ended.
1525  virtual void finish() {}
1526
1527  /// Indicates whether the diagnostics handled by this
1528  /// DiagnosticConsumer should be included in the number of diagnostics
1529  /// reported by DiagnosticsEngine.
1530  ///
1531  /// The default implementation returns true.
1532  virtual bool IncludeInDiagnosticCounts() const;
1533
1534  /// Handle this diagnostic, reporting it to the user or
1535  /// capturing it to a log as needed.
1536  ///
1537  /// The default implementation just keeps track of the total number of
1538  /// warnings and errors.
1539  virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
1540                                const Diagnostic &Info);
1541};
1542
1543/// A diagnostic client that ignores all diagnostics.
1544class IgnoringDiagConsumer : public DiagnosticConsumer {
1545  virtual void anchor();
1546
1547  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
1548                        const Diagnostic &Info) override {
1549    // Just ignore it.
1550  }
1551};
1552
1553/// Diagnostic consumer that forwards diagnostics along to an
1554/// existing, already-initialized diagnostic consumer.
1555///
1556class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
1557  DiagnosticConsumer &Target;
1558
1559public:
1560  ForwardingDiagnosticConsumer(DiagnosticConsumer &Target) : Target(Target) {}
1561  ~ForwardingDiagnosticConsumer() override;
1562
1563  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
1564                        const Diagnostic &Info) override;
1565  void clear() override;
1566
1567  bool IncludeInDiagnosticCounts() const override;
1568};
1569
1570// Struct used for sending info about how a type should be printed.
1571struct TemplateDiffTypes {
1572  intptr_t FromType;
1573  intptr_t ToType;
1574  unsigned PrintTree : 1;
1575  unsigned PrintFromType : 1;
1576  unsigned ElideType : 1;
1577  unsigned ShowColors : 1;
1578
1579  // The printer sets this variable to true if the template diff was used.
1580  unsigned TemplateDiffUsed : 1;
1581};
1582
1583/// Special character that the diagnostic printer will use to toggle the bold
1584/// attribute.  The character itself will be not be printed.
1585const char ToggleHighlight = 127;
1586
1587/// ProcessWarningOptions - Initialize the diagnostic client and process the
1588/// warning options specified on the command line.
1589void ProcessWarningOptions(DiagnosticsEngine &Diags,
1590                           const DiagnosticOptions &Opts,
1591                           bool ReportDiags = true);
1592
1593// namespace clang
1594
1595#endif // LLVM_CLANG_BASIC_DIAGNOSTIC_H
1596
clang::FixItHint::RemoveRange
clang::FixItHint::InsertFromRange
clang::FixItHint::CodeToInsert
clang::FixItHint::BeforePreviousInsertions
clang::FixItHint::isNull
clang::FixItHint::CreateInsertion
clang::FixItHint::CreateInsertionFromRange
clang::FixItHint::CreateRemoval
clang::FixItHint::CreateRemoval
clang::FixItHint::CreateReplacement
clang::FixItHint::CreateReplacement
clang::DiagnosticsEngine::Level
clang::DiagnosticsEngine::ArgumentKind
clang::DiagnosticsEngine::AllExtensionsSilenced
clang::DiagnosticsEngine::FatalsAsError
clang::DiagnosticsEngine::SuppressAllDiagnostics
clang::DiagnosticsEngine::ElideType
clang::DiagnosticsEngine::PrintTemplateTree
clang::DiagnosticsEngine::ShowColors
clang::DiagnosticsEngine::ShowOverloads
clang::DiagnosticsEngine::ErrorLimit
clang::DiagnosticsEngine::TemplateBacktraceLimit
clang::DiagnosticsEngine::ConstexprBacktraceLimit
clang::DiagnosticsEngine::Diags
clang::DiagnosticsEngine::DiagOpts
clang::DiagnosticsEngine::Client
clang::DiagnosticsEngine::Owner
clang::DiagnosticsEngine::SourceMgr
clang::DiagnosticsEngine::DiagState
clang::DiagnosticsEngine::DiagState::DiagMap
clang::DiagnosticsEngine::DiagState::IgnoreAllWarnings
clang::DiagnosticsEngine::DiagState::EnableAllWarnings
clang::DiagnosticsEngine::DiagState::WarningsAsErrors
clang::DiagnosticsEngine::DiagState::ErrorsAsFatal
clang::DiagnosticsEngine::DiagState::SuppressSystemWarnings
clang::DiagnosticsEngine::DiagState::ExtBehavior
clang::DiagnosticsEngine::DiagState::setMapping
clang::DiagnosticsEngine::DiagState::lookupMapping
clang::DiagnosticsEngine::DiagState::getOrAddMapping
clang::DiagnosticsEngine::DiagState::begin
clang::DiagnosticsEngine::DiagState::end
clang::DiagnosticsEngine::DiagStates
clang::DiagnosticsEngine::DiagStateMap
clang::DiagnosticsEngine::DiagStateMap::appendFirst
clang::DiagnosticsEngine::DiagStateMap::append
clang::DiagnosticsEngine::DiagStateMap::lookup
clang::DiagnosticsEngine::DiagStateMap::empty
clang::DiagnosticsEngine::DiagStateMap::clear
clang::DiagnosticsEngine::DiagStateMap::dump
clang::DiagnosticsEngine::DiagStateMap::getCurDiagState
clang::DiagnosticsEngine::DiagStateMap::getCurDiagStateLoc
clang::DiagnosticsEngine::DiagStateMap::DiagStatePoint
clang::DiagnosticsEngine::DiagStateMap::DiagStatePoint::State
clang::DiagnosticsEngine::DiagStateMap::DiagStatePoint::Offset
clang::DiagnosticsEngine::DiagStateMap::File
clang::DiagnosticsEngine::DiagStateMap::File::Parent
clang::DiagnosticsEngine::DiagStateMap::File::ParentOffset
clang::DiagnosticsEngine::DiagStateMap::File::HasLocalTransitions
clang::DiagnosticsEngine::DiagStateMap::File::StateTransitions
clang::DiagnosticsEngine::DiagStateMap::File::lookup
clang::DiagnosticsEngine::DiagStateMap::Files
clang::DiagnosticsEngine::DiagStateMap::FirstDiagState
clang::DiagnosticsEngine::DiagStateMap::CurDiagState
clang::DiagnosticsEngine::DiagStateMap::CurDiagStateLoc
clang::DiagnosticsEngine::DiagStateMap::getFile
clang::DiagnosticsEngine::DiagStatesByLoc
clang::DiagnosticsEngine::DiagStateOnPushStack
clang::DiagnosticsEngine::GetCurDiagState
clang::DiagnosticsEngine::PushDiagStatePoint
clang::DiagnosticsEngine::GetDiagStateForLoc
clang::DiagnosticsEngine::ErrorOccurred
clang::DiagnosticsEngine::UncompilableErrorOccurred
clang::DiagnosticsEngine::FatalErrorOccurred
clang::DiagnosticsEngine::UnrecoverableErrorOccurred
clang::DiagnosticsEngine::TrapNumErrorsOccurred
clang::DiagnosticsEngine::TrapNumUnrecoverableErrorsOccurred
clang::DiagnosticsEngine::LastDiagLevel
clang::DiagnosticsEngine::NumWarnings
clang::DiagnosticsEngine::NumErrors
clang::DiagnosticsEngine::ArgToStringCookie
clang::DiagnosticsEngine::ArgToStringFn
clang::DiagnosticsEngine::DelayedDiagID
clang::DiagnosticsEngine::DelayedDiagArg1
clang::DiagnosticsEngine::DelayedDiagArg2
clang::DiagnosticsEngine::FlagValue
clang::DiagnosticsEngine::dump
clang::DiagnosticsEngine::dump
clang::DiagnosticsEngine::getDiagnosticIDs
clang::DiagnosticsEngine::getDiagnosticOptions
clang::DiagnosticsEngine::getDiagnosticMappings
clang::DiagnosticsEngine::getClient
clang::DiagnosticsEngine::getClient
clang::DiagnosticsEngine::ownsClient
clang::DiagnosticsEngine::takeClient
clang::DiagnosticsEngine::hasSourceManager
clang::DiagnosticsEngine::getSourceManager
clang::DiagnosticsEngine::setSourceManager
clang::DiagnosticsEngine::pushMappings
clang::DiagnosticsEngine::popMappings
clang::DiagnosticsEngine::setClient
clang::DiagnosticsEngine::setErrorLimit
clang::DiagnosticsEngine::setTemplateBacktraceLimit
clang::DiagnosticsEngine::getTemplateBacktraceLimit
clang::DiagnosticsEngine::setConstexprBacktraceLimit
clang::DiagnosticsEngine::getConstexprBacktraceLimit
clang::DiagnosticsEngine::setIgnoreAllWarnings
clang::DiagnosticsEngine::getIgnoreAllWarnings
clang::DiagnosticsEngine::setEnableAllWarnings
clang::DiagnosticsEngine::getEnableAllWarnings
clang::DiagnosticsEngine::setWarningsAsErrors
clang::DiagnosticsEngine::getWarningsAsErrors
clang::DiagnosticsEngine::setErrorsAsFatal
clang::DiagnosticsEngine::getErrorsAsFatal
clang::DiagnosticsEngine::setFatalsAsError
clang::DiagnosticsEngine::getFatalsAsError
clang::DiagnosticsEngine::setSuppressSystemWarnings
clang::DiagnosticsEngine::getSuppressSystemWarnings
clang::DiagnosticsEngine::setSuppressAllDiagnostics
clang::DiagnosticsEngine::getSuppressAllDiagnostics
clang::DiagnosticsEngine::setElideType
clang::DiagnosticsEngine::getElideType
clang::DiagnosticsEngine::setPrintTemplateTree
clang::DiagnosticsEngine::getPrintTemplateTree
clang::DiagnosticsEngine::setShowColors
clang::DiagnosticsEngine::getShowColors
clang::DiagnosticsEngine::setShowOverloads
clang::DiagnosticsEngine::getShowOverloads
clang::DiagnosticsEngine::setLastDiagnosticIgnored
clang::DiagnosticsEngine::isLastDiagnosticIgnored
clang::DiagnosticsEngine::setExtensionHandlingBehavior
clang::DiagnosticsEngine::getExtensionHandlingBehavior
clang::DiagnosticsEngine::IncrementAllExtensionsSilenced
clang::DiagnosticsEngine::DecrementAllExtensionsSilenced
clang::DiagnosticsEngine::hasAllExtensionsSilenced
clang::DiagnosticsEngine::setSeverity
clang::DiagnosticsEngine::setSeverityForGroup
clang::DiagnosticsEngine::setDiagnosticGroupWarningAsError
clang::DiagnosticsEngine::setDiagnosticGroupErrorAsFatal
clang::DiagnosticsEngine::setSeverityForAll
clang::DiagnosticsEngine::hasErrorOccurred
clang::DiagnosticsEngine::hasUncompilableErrorOccurred
clang::DiagnosticsEngine::hasFatalErrorOccurred
clang::DiagnosticsEngine::hasUnrecoverableErrorOccurred
clang::DiagnosticsEngine::getNumWarnings
clang::DiagnosticsEngine::setNumWarnings
clang::DiagnosticsEngine::getCustomDiagID
clang::DiagnosticsEngine::ConvertArgToString
clang::DiagnosticsEngine::SetArgToStringFn
clang::DiagnosticsEngine::notePriorDiagnosticFrom
clang::DiagnosticsEngine::Reset
clang::DiagnosticsEngine::isIgnored
clang::DiagnosticsEngine::getDiagnosticLevel
clang::DiagnosticsEngine::Report
clang::DiagnosticsEngine::Report
clang::DiagnosticsEngine::Report
clang::DiagnosticsEngine::isDiagnosticInFlight
clang::DiagnosticsEngine::SetDelayedDiagnostic
clang::DiagnosticsEngine::Clear
clang::DiagnosticsEngine::getFlagValue
clang::DiagnosticsEngine::ReportDelayed
clang::DiagnosticsEngine::CurDiagLoc
clang::DiagnosticsEngine::CurDiagID
clang::DiagnosticsEngine::NumDiagArgs
clang::DiagnosticsEngine::DiagArgumentsKind
clang::DiagnosticsEngine::DiagArgumentsStr
clang::DiagnosticsEngine::DiagArgumentsVal
clang::DiagnosticsEngine::DiagRanges
clang::DiagnosticsEngine::DiagFixItHints
clang::DiagnosticsEngine::makeUserMapping
clang::DiagnosticsEngine::ProcessDiag
clang::DiagnosticsEngine::EmitCurrentDiagnostic
clang::DiagnosticsEngine::getCurrentDiagID
clang::DiagnosticsEngine::getCurrentDiagLoc
clang::DiagnosticErrorTrap::Diag
clang::DiagnosticErrorTrap::NumErrors
clang::DiagnosticErrorTrap::NumUnrecoverableErrors
clang::DiagnosticErrorTrap::hasErrorOccurred
clang::DiagnosticErrorTrap::hasUnrecoverableErrorOccurred
clang::DiagnosticErrorTrap::reset
clang::DiagnosticBuilder::DiagObj
clang::DiagnosticBuilder::NumArgs
clang::DiagnosticBuilder::IsActive
clang::DiagnosticBuilder::IsForceEmit
clang::DiagnosticBuilder::FlushCounts
clang::DiagnosticBuilder::Clear
clang::DiagnosticBuilder::isActive
clang::DiagnosticBuilder::Emit
clang::DiagnosticBuilder::getEmpty
clang::DiagnosticBuilder::setForceEmit
clang::DiagnosticBuilder::AddString
clang::DiagnosticBuilder::AddTaggedVal
clang::DiagnosticBuilder::AddSourceRange
clang::DiagnosticBuilder::AddFixItHint
clang::DiagnosticBuilder::addFlagValue
clang::AddFlagValue::Val
clang::DiagnosticsEngine::Report
clang::DiagnosticsEngine::Report
clang::Diagnostic::DiagObj
clang::Diagnostic::StoredDiagMessage
clang::Diagnostic::getDiags
clang::Diagnostic::getID
clang::Diagnostic::getLocation
clang::Diagnostic::hasSourceManager
clang::Diagnostic::getSourceManager
clang::Diagnostic::getNumArgs
clang::Diagnostic::getArgKind
clang::Diagnostic::getArgStdStr
clang::Diagnostic::getArgCStr
clang::Diagnostic::getArgSInt
clang::Diagnostic::getArgUInt
clang::Diagnostic::getArgIdentifier
clang::Diagnostic::getRawArg
clang::Diagnostic::getNumRanges
clang::Diagnostic::getRange
clang::Diagnostic::getRanges
clang::Diagnostic::getNumFixItHints
clang::Diagnostic::getFixItHint
clang::Diagnostic::getFixItHints
clang::Diagnostic::FormatDiagnostic
clang::Diagnostic::FormatDiagnostic
clang::StoredDiagnostic::ID
clang::StoredDiagnostic::Level
clang::StoredDiagnostic::Loc
clang::StoredDiagnostic::Message
clang::StoredDiagnostic::Ranges
clang::StoredDiagnostic::FixIts
clang::StoredDiagnostic::getID
clang::StoredDiagnostic::getLevel
clang::StoredDiagnostic::getLocation
clang::StoredDiagnostic::getMessage
clang::StoredDiagnostic::setLocation
clang::StoredDiagnostic::range_begin
clang::StoredDiagnostic::range_end
clang::StoredDiagnostic::range_size
clang::StoredDiagnostic::getRanges
clang::StoredDiagnostic::fixit_begin
clang::StoredDiagnostic::fixit_end
clang::StoredDiagnostic::fixit_size
clang::StoredDiagnostic::getFixIts
clang::DiagnosticConsumer::NumWarnings
clang::DiagnosticConsumer::NumErrors
clang::DiagnosticConsumer::getNumErrors
clang::DiagnosticConsumer::getNumWarnings
clang::DiagnosticConsumer::clear
clang::DiagnosticConsumer::BeginSourceFile
clang::DiagnosticConsumer::EndSourceFile
clang::DiagnosticConsumer::finish
clang::DiagnosticConsumer::IncludeInDiagnosticCounts
clang::DiagnosticConsumer::HandleDiagnostic
clang::IgnoringDiagConsumer::anchor
clang::IgnoringDiagConsumer::HandleDiagnostic
clang::ForwardingDiagnosticConsumer::Target
clang::ForwardingDiagnosticConsumer::HandleDiagnostic
clang::ForwardingDiagnosticConsumer::clear
clang::ForwardingDiagnosticConsumer::IncludeInDiagnosticCounts
clang::TemplateDiffTypes::FromType
clang::TemplateDiffTypes::ToType
clang::TemplateDiffTypes::PrintTree
clang::TemplateDiffTypes::PrintFromType
clang::TemplateDiffTypes::ElideType
clang::TemplateDiffTypes::ShowColors
clang::TemplateDiffTypes::TemplateDiffUsed