aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/Diagnostic.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
committerDimitry Andric <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
commit9f4dbff6669c8037f3b036bcf580d14f1a4f12a5 (patch)
tree47df2c12b57214af6c31e47404b005675b8b7ffc /include/clang/Basic/Diagnostic.h
parentf73d5f23a889b93d89ddef61ac0995df40286bb8 (diff)
downloadsrc-9f4dbff6669c8037f3b036bcf580d14f1a4f12a5.tar.gz
src-9f4dbff6669c8037f3b036bcf580d14f1a4f12a5.zip
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):vendor/clang/clang-release_350-r216957
Notes
Notes: svn path=/vendor/clang/dist/; revision=274958 svn path=/vendor/clang/clang-release_350-r216957/; revision=274959; tag=vendor/clang/clang-release_350-r216957
Diffstat (limited to 'include/clang/Basic/Diagnostic.h')
-rw-r--r--include/clang/Basic/Diagnostic.h287
1 files changed, 168 insertions, 119 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index c057bdf63436..a7b2ba270d46 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -21,20 +21,23 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/Support/type_traits.h"
+#include "llvm/ADT/iterator_range.h"
#include <list>
#include <vector>
namespace clang {
- class DiagnosticConsumer;
+ class DeclContext;
class DiagnosticBuilder;
+ class DiagnosticConsumer;
+ class DiagnosticErrorTrap;
class DiagnosticOptions;
class IdentifierInfo;
- class DeclContext;
class LangOptions;
class Preprocessor;
- class DiagnosticErrorTrap;
class StoredDiagnostic;
+ namespace tok {
+ enum TokenKind : unsigned short;
+ }
/// \brief Annotates a diagnostic with some code that should be
/// inserted, removed, or replaced to fix the problem.
@@ -129,35 +132,34 @@ public:
/// the user. DiagnosticsEngine is tied to one translation unit and one
/// SourceManager.
class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
+ DiagnosticsEngine(const DiagnosticsEngine &) LLVM_DELETED_FUNCTION;
+ void operator=(const DiagnosticsEngine &) LLVM_DELETED_FUNCTION;
+
public:
/// \brief The level of the diagnostic, after it has been through mapping.
enum Level {
Ignored = DiagnosticIDs::Ignored,
Note = DiagnosticIDs::Note,
+ Remark = DiagnosticIDs::Remark,
Warning = DiagnosticIDs::Warning,
Error = DiagnosticIDs::Error,
Fatal = DiagnosticIDs::Fatal
};
- /// \brief How do we handle otherwise-unmapped extension?
- ///
- /// This is controlled by -pedantic and -pedantic-errors.
- enum ExtensionHandling {
- Ext_Ignore, Ext_Warn, Ext_Error
- };
-
enum ArgumentKind {
ak_std_string, ///< std::string
ak_c_string, ///< const char *
ak_sint, ///< int
ak_uint, ///< unsigned
+ ak_tokenkind, ///< enum TokenKind : unsigned
ak_identifierinfo, ///< IdentifierInfo
ak_qualtype, ///< QualType
ak_declarationname, ///< DeclarationName
ak_nameddecl, ///< NamedDecl *
ak_nestednamespec, ///< NestedNameSpecifier *
ak_declcontext, ///< DeclContext *
- ak_qualtype_pair ///< pair<QualType, QualType>
+ ak_qualtype_pair, ///< pair<QualType, QualType>
+ ak_attr ///< Attr *
};
/// \brief Represents on argument value, which is a union discriminated
@@ -181,7 +183,7 @@ private:
// 0 -> no limit.
unsigned ConstexprBacktraceLimit; // Cap on depth of constexpr evaluation
// backtrace stack, 0 -> no limit.
- ExtensionHandling ExtBehavior; // Map extensions onto warnings or errors?
+ diag::Severity ExtBehavior; // Map extensions to warnings or errors?
IntrusiveRefCntPtr<DiagnosticIDs> Diags;
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
DiagnosticConsumer *Client;
@@ -191,7 +193,7 @@ private:
/// \brief Mapping information for diagnostics.
///
/// Mapping info is packed into four bits per diagnostic. The low three
- /// bits are the mapping (an instance of diag::Mapping), or zero if unset.
+ /// bits are the mapping (an instance of diag::Severity), or zero if unset.
/// The high bit is set when the mapping was established as a user mapping.
/// If the high bit is clear, then the low bits are set to the default
/// value, and should be mapped with -pedantic, -Werror, etc.
@@ -200,19 +202,18 @@ private:
/// the state so that we know what is the diagnostic state at any given
/// source location.
class DiagState {
- llvm::DenseMap<unsigned, DiagnosticMappingInfo> DiagMap;
+ llvm::DenseMap<unsigned, DiagnosticMapping> DiagMap;
public:
- typedef llvm::DenseMap<unsigned, DiagnosticMappingInfo>::iterator
- iterator;
- typedef llvm::DenseMap<unsigned, DiagnosticMappingInfo>::const_iterator
- const_iterator;
+ typedef llvm::DenseMap<unsigned, DiagnosticMapping>::iterator iterator;
+ typedef llvm::DenseMap<unsigned, DiagnosticMapping>::const_iterator
+ const_iterator;
- void setMappingInfo(diag::kind Diag, DiagnosticMappingInfo Info) {
+ void setMapping(diag::kind Diag, DiagnosticMapping Info) {
DiagMap[Diag] = Info;
}
- DiagnosticMappingInfo &getOrAddMappingInfo(diag::kind Diag);
+ DiagnosticMapping &getOrAddMapping(diag::kind Diag);
const_iterator begin() const { return DiagMap.begin(); }
const_iterator end() const { return DiagMap.end(); }
@@ -308,17 +309,15 @@ private:
///
/// This takes the modifiers and argument that was present in the diagnostic.
///
- /// The PrevArgs array (whose length is NumPrevArgs) indicates the previous
- /// arguments formatted for this diagnostic. Implementations of this function
- /// can use this information to avoid redundancy across arguments.
+ /// The PrevArgs array indicates the previous arguments formatted for this
+ /// diagnostic. Implementations of this function can use this information to
+ /// avoid redundancy across arguments.
///
/// This is a hack to avoid a layering violation between libbasic and libsema.
typedef void (*ArgToStringFnTy)(
ArgumentKind Kind, intptr_t Val,
- const char *Modifier, unsigned ModifierLen,
- const char *Argument, unsigned ArgumentLen,
- const ArgumentValue *PrevArgs,
- unsigned NumPrevArgs,
+ StringRef Modifier, StringRef Argument,
+ ArrayRef<ArgumentValue> PrevArgs,
SmallVectorImpl<char> &Output,
void *Cookie,
ArrayRef<intptr_t> QualTypeVals);
@@ -336,11 +335,18 @@ private:
/// \brief Second string argument for the delayed diagnostic.
std::string DelayedDiagArg2;
+ /// \brief Optional flag value.
+ ///
+ /// Some flags accept values, for instance: -Wframe-larger-than=<value> and
+ /// -Rpass=<value>. The content of this string is emitted after the flag name
+ /// and '='.
+ std::string FlagValue;
+
public:
explicit DiagnosticsEngine(
const IntrusiveRefCntPtr<DiagnosticIDs> &Diags,
DiagnosticOptions *DiagOpts,
- DiagnosticConsumer *client = 0,
+ DiagnosticConsumer *client = nullptr,
bool ShouldOwnClient = true);
~DiagnosticsEngine();
@@ -351,6 +357,14 @@ public:
/// \brief Retrieve the diagnostic options.
DiagnosticOptions &getDiagnosticOptions() const { return *DiagOpts; }
+ typedef llvm::iterator_range<DiagState::const_iterator> diag_mapping_range;
+
+ /// \brief Get the current set of diagnostic mappings.
+ diag_mapping_range getDiagnosticMappings() const {
+ const DiagState &DS = *GetCurDiagState();
+ return diag_mapping_range(DS.begin(), DS.end());
+ }
+
DiagnosticConsumer *getClient() { return Client; }
const DiagnosticConsumer *getClient() const { return Client; }
@@ -364,7 +378,7 @@ public:
return Client;
}
- bool hasSourceManager() const { return SourceMgr != 0; }
+ bool hasSourceManager() const { return SourceMgr != nullptr; }
SourceManager &getSourceManager() const {
assert(SourceMgr && "SourceManager not set!");
return *SourceMgr;
@@ -501,10 +515,8 @@ public:
/// mapped onto ignore/warning/error.
///
/// This corresponds to the GCC -pedantic and -pedantic-errors option.
- void setExtensionHandlingBehavior(ExtensionHandling H) {
- ExtBehavior = H;
- }
- ExtensionHandling getExtensionHandlingBehavior() const { return ExtBehavior; }
+ void setExtensionHandlingBehavior(diag::Severity H) { ExtBehavior = H; }
+ diag::Severity getExtensionHandlingBehavior() const { return ExtBehavior; }
/// \brief Counter bumped when an __extension__ block is/ encountered.
///
@@ -522,8 +534,7 @@ public:
///
/// \param Loc The source location that this change of diagnostic state should
/// take affect. It can be null if we are setting the latest state.
- void setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
- SourceLocation Loc);
+ void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc);
/// \brief Change an entire diagnostic group (e.g. "unknown-pragmas") to
/// have the specified mapping.
@@ -531,15 +542,14 @@ public:
/// \returns true (and ignores the request) if "Group" was unknown, false
/// otherwise.
///
+ /// \param Flavor The flavor of group to affect. -Rfoo does not affect the
+ /// state of the -Wfoo group and vice versa.
+ ///
/// \param Loc The source location that this change of diagnostic state should
/// take affect. It can be null if we are setting the state from command-line.
- bool setDiagnosticGroupMapping(StringRef Group, diag::Mapping Map,
- SourceLocation Loc = SourceLocation());
-
- /// \brief Set the warning-as-error flag for the given diagnostic.
- ///
- /// This function always only operates on the current diagnostic state.
- void setDiagnosticWarningAsError(diag::kind Diag, bool Enabled);
+ bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group,
+ diag::Severity Map,
+ SourceLocation Loc = SourceLocation());
/// \brief Set the warning-as-error flag for the given diagnostic group.
///
@@ -548,11 +558,6 @@ public:
/// \returns True if the given group is unknown, false otherwise.
bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled);
- /// \brief Set the error-as-fatal flag for the given diagnostic.
- ///
- /// This function always only operates on the current diagnostic state.
- void setDiagnosticErrorAsFatal(diag::kind Diag, bool Enabled);
-
/// \brief Set the error-as-fatal flag for the given diagnostic group.
///
/// This function always only operates on the current diagnostic state.
@@ -560,12 +565,13 @@ public:
/// \returns True if the given group is unknown, false otherwise.
bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled);
- /// \brief Add the specified mapping to all diagnostics.
+ /// \brief Add the specified mapping to all diagnostics of the specified
+ /// flavor.
///
/// Mainly to be used by -Wno-everything to disable all warnings but allow
/// subsequent -W options to enable specific warnings.
- void setMappingToAllDiagnostics(diag::Mapping Map,
- SourceLocation Loc = SourceLocation());
+ void setSeverityForAll(diag::Flavor Flavor, diag::Severity Map,
+ SourceLocation Loc = SourceLocation());
bool hasErrorOccurred() const { return ErrorOccurred; }
@@ -587,25 +593,29 @@ public:
this->NumWarnings = NumWarnings;
}
- /// \brief Return an ID for a diagnostic with the specified message and level.
+ /// \brief Return an ID for a diagnostic with the specified format string and
+ /// level.
///
/// If this is the first request for this diagnostic, it is registered and
/// created, otherwise the existing ID is returned.
- unsigned getCustomDiagID(Level L, StringRef Message) {
- return Diags->getCustomDiagID((DiagnosticIDs::Level)L, Message);
+ ///
+ /// \param FormatString A fixed diagnostic format string that will be hashed
+ /// and mapped to a unique DiagID.
+ template <unsigned N>
+ unsigned getCustomDiagID(Level L, const char (&FormatString)[N]) {
+ return Diags->getCustomDiagID((DiagnosticIDs::Level)L,
+ StringRef(FormatString, N - 1));
}
/// \brief Converts a diagnostic argument (as an intptr_t) into the string
/// that represents it.
void ConvertArgToString(ArgumentKind Kind, intptr_t Val,
- const char *Modifier, unsigned ModLen,
- const char *Argument, unsigned ArgLen,
- const ArgumentValue *PrevArgs, unsigned NumPrevArgs,
+ StringRef Modifier, StringRef Argument,
+ ArrayRef<ArgumentValue> PrevArgs,
SmallVectorImpl<char> &Output,
ArrayRef<intptr_t> QualTypeVals) const {
- ArgToStringFn(Kind, Val, Modifier, ModLen, Argument, ArgLen,
- PrevArgs, NumPrevArgs, Output, ArgToStringCookie,
- QualTypeVals);
+ ArgToStringFn(Kind, Val, Modifier, Argument, PrevArgs, Output,
+ ArgToStringCookie, QualTypeVals);
}
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie) {
@@ -627,10 +637,27 @@ public:
// DiagnosticsEngine classification and reporting interfaces.
//
+ /// \brief Determine whether the diagnostic is known to be ignored.
+ ///
+ /// This can be used to opportunistically avoid expensive checks when it's
+ /// known for certain that the diagnostic has been suppressed at the
+ /// specified location \p Loc.
+ ///
+ /// \param Loc The source location we are interested in finding out the
+ /// diagnostic state. Can be null in order to query the latest state.
+ bool isIgnored(unsigned DiagID, SourceLocation Loc) const {
+ return Diags->getDiagnosticSeverity(DiagID, Loc, *this) ==
+ diag::Severity::Ignored;
+ }
+
/// \brief Based on the way the client configured the DiagnosticsEngine
/// object, classify the specified diagnostic ID into a Level, consumable by
/// the DiagnosticConsumer.
///
+ /// To preserve invariant assumptions, this function should not be used to
+ /// influence parse or semantic analysis actions. Instead consider using
+ /// \c isIgnored().
+ ///
/// \param Loc The source location we are interested in finding out the
/// diagnostic state. Can be null in order to query the latest state.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const {
@@ -680,6 +707,9 @@ public:
/// \brief Clear out the current diagnostic.
void Clear() { CurDiagID = ~0U; }
+ /// \brief Return the value associated with this diagnostic flag.
+ StringRef getFlagValue() const { return FlagValue; }
+
private:
/// \brief Report the delayed diagnostic.
void ReportDelayed();
@@ -711,20 +741,10 @@ private:
/// diagnostic with more than that almost certainly has to be simplified
/// anyway.
MaxArguments = 10,
-
- /// \brief The maximum number of ranges we can hold.
- MaxRanges = 10,
-
- /// \brief The maximum number of ranges we can hold.
- MaxFixItHints = 10
};
/// \brief The number of entries in Arguments.
signed char NumDiagArgs;
- /// \brief The number of ranges in the DiagRanges array.
- unsigned char NumDiagRanges;
- /// \brief The number of hints in the DiagFixItHints array.
- unsigned char NumDiagFixItHints;
/// \brief Specifies whether an argument is in DiagArgumentsStr or
/// in DiagArguments.
@@ -747,25 +767,25 @@ private:
intptr_t DiagArgumentsVal[MaxArguments];
/// \brief The list of ranges added to this diagnostic.
- CharSourceRange DiagRanges[MaxRanges];
+ SmallVector<CharSourceRange, 8> DiagRanges;
/// \brief If valid, provides a hint with some code to insert, remove,
/// or modify at a particular position.
- FixItHint DiagFixItHints[MaxFixItHints];
+ SmallVector<FixItHint, 8> DiagFixItHints;
- DiagnosticMappingInfo makeMappingInfo(diag::Mapping Map, SourceLocation L) {
+ DiagnosticMapping makeUserMapping(diag::Severity Map, SourceLocation L) {
bool isPragma = L.isValid();
- DiagnosticMappingInfo MappingInfo = DiagnosticMappingInfo::Make(
- Map, /*IsUser=*/true, isPragma);
+ DiagnosticMapping Mapping =
+ DiagnosticMapping::Make(Map, /*IsUser=*/true, isPragma);
// If this is a pragma mapping, then set the diagnostic mapping flags so
// that we override command line options.
if (isPragma) {
- MappingInfo.setNoWarningAsError(true);
- MappingInfo.setNoErrorAsFatal(true);
+ Mapping.setNoWarningAsError(true);
+ Mapping.setNoErrorAsFatal(true);
}
- return MappingInfo;
+ return Mapping;
}
/// \brief Used to report a diagnostic that is finally fully formed.
@@ -848,7 +868,7 @@ public:
/// for example.
class DiagnosticBuilder {
mutable DiagnosticsEngine *DiagObj;
- mutable unsigned NumArgs, NumRanges, NumFixits;
+ mutable unsigned NumArgs;
/// \brief Status variable indicating if this diagnostic is still active.
///
@@ -863,15 +883,15 @@ class DiagnosticBuilder {
void operator=(const DiagnosticBuilder &) LLVM_DELETED_FUNCTION;
friend class DiagnosticsEngine;
-
+
DiagnosticBuilder()
- : DiagObj(0), NumArgs(0), NumRanges(0), NumFixits(0), IsActive(false),
- IsForceEmit(false) { }
+ : DiagObj(nullptr), NumArgs(0), IsActive(false), IsForceEmit(false) {}
explicit DiagnosticBuilder(DiagnosticsEngine *diagObj)
- : DiagObj(diagObj), NumArgs(0), NumRanges(0), NumFixits(0), IsActive(true),
- IsForceEmit(false) {
+ : DiagObj(diagObj), NumArgs(0), IsActive(true), IsForceEmit(false) {
assert(diagObj && "DiagnosticBuilder requires a valid DiagnosticsEngine!");
+ diagObj->DiagRanges.clear();
+ diagObj->DiagFixItHints.clear();
}
friend class PartialDiagnostic;
@@ -879,13 +899,11 @@ class DiagnosticBuilder {
protected:
void FlushCounts() {
DiagObj->NumDiagArgs = NumArgs;
- DiagObj->NumDiagRanges = NumRanges;
- DiagObj->NumDiagFixItHints = NumFixits;
}
/// \brief Clear out the current diagnostic.
void Clear() const {
- DiagObj = 0;
+ DiagObj = nullptr;
IsActive = false;
IsForceEmit = false;
}
@@ -927,8 +945,6 @@ public:
IsForceEmit = D.IsForceEmit;
D.Clear();
NumArgs = D.NumArgs;
- NumRanges = D.NumRanges;
- NumFixits = D.NumFixits;
}
/// \brief Retrieve an empty diagnostic builder.
@@ -974,27 +990,32 @@ public:
void AddSourceRange(const CharSourceRange &R) const {
assert(isActive() && "Clients must not add to cleared diagnostic!");
- assert(NumRanges < DiagnosticsEngine::MaxRanges &&
- "Too many arguments to diagnostic!");
- DiagObj->DiagRanges[NumRanges++] = R;
+ DiagObj->DiagRanges.push_back(R);
}
void AddFixItHint(const FixItHint &Hint) const {
assert(isActive() && "Clients must not add to cleared diagnostic!");
- assert(NumFixits < DiagnosticsEngine::MaxFixItHints &&
- "Too many arguments to diagnostic!");
- DiagObj->DiagFixItHints[NumFixits++] = Hint;
+ DiagObj->DiagFixItHints.push_back(Hint);
}
- bool hasMaxRanges() const {
- return NumRanges == DiagnosticsEngine::MaxRanges;
- }
+ void addFlagValue(StringRef V) const { DiagObj->FlagValue = V; }
+};
- bool hasMaxFixItHints() const {
- return NumFixits == DiagnosticsEngine::MaxFixItHints;
- }
+struct AddFlagValue {
+ explicit AddFlagValue(StringRef V) : Val(V) {}
+ StringRef Val;
};
+/// \brief Register a value for the flag in the current diagnostic. This
+/// value will be shown as the suffix "=value" after the flag name. It is
+/// useful in cases where the diagnostic flag accepts values (e.g.,
+/// -Rpass or -Wframe-larger-than).
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ const AddFlagValue V) {
+ DB.addFlagValue(V.Val);
+ return DB;
+}
+
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
StringRef S) {
DB.AddString(S);
@@ -1013,7 +1034,13 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, int I) {
return DB;
}
-inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,bool I) {
+// We use enable_if here to prevent that this overload is selected for
+// pointers or other arguments that are implicitly convertible to bool.
+template <typename T>
+inline
+typename std::enable_if<std::is_same<T, bool>::value,
+ const DiagnosticBuilder &>::type
+operator<<(const DiagnosticBuilder &DB, T I) {
DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
return DB;
}
@@ -1025,6 +1052,12 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
}
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ tok::TokenKind I) {
+ DB.AddTaggedVal(static_cast<unsigned>(I), DiagnosticsEngine::ak_tokenkind);
+ return DB;
+}
+
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const IdentifierInfo *II) {
DB.AddTaggedVal(reinterpret_cast<intptr_t>(II),
DiagnosticsEngine::ak_identifierinfo);
@@ -1037,14 +1070,14 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
// match.
template<typename T>
inline
-typename llvm::enable_if<llvm::is_same<T, DeclContext>,
- const DiagnosticBuilder &>::type
+typename std::enable_if<std::is_same<T, DeclContext>::value,
+ const DiagnosticBuilder &>::type
operator<<(const DiagnosticBuilder &DB, T *DC) {
DB.AddTaggedVal(reinterpret_cast<intptr_t>(DC),
DiagnosticsEngine::ak_declcontext);
return DB;
}
-
+
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const SourceRange &R) {
DB.AddSourceRange(CharSourceRange::getTokenRange(R));
@@ -1052,11 +1085,18 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
}
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ ArrayRef<SourceRange> Ranges) {
+ for (const SourceRange &R: Ranges)
+ DB.AddSourceRange(CharSourceRange::getTokenRange(R));
+ return DB;
+}
+
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const CharSourceRange &R) {
DB.AddSourceRange(R);
return DB;
}
-
+
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const FixItHint &Hint) {
if (!Hint.isNull())
@@ -1065,12 +1105,14 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
}
inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
- unsigned DiagID){
+ unsigned DiagID) {
assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
CurDiagLoc = Loc;
CurDiagID = DiagID;
+ FlagValue.clear();
return DiagnosticBuilder(this);
}
+
inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) {
return Report(SourceLocation(), DiagID);
}
@@ -1159,22 +1201,22 @@ public:
/// \brief Return the number of source ranges associated with this diagnostic.
unsigned getNumRanges() const {
- return DiagObj->NumDiagRanges;
+ return DiagObj->DiagRanges.size();
}
/// \pre Idx < getNumRanges()
const CharSourceRange &getRange(unsigned Idx) const {
- assert(Idx < DiagObj->NumDiagRanges && "Invalid diagnostic range index!");
+ assert(Idx < getNumRanges() && "Invalid diagnostic range index!");
return DiagObj->DiagRanges[Idx];
}
/// \brief Return an array reference for this diagnostic's ranges.
ArrayRef<CharSourceRange> getRanges() const {
- return llvm::makeArrayRef(DiagObj->DiagRanges, DiagObj->NumDiagRanges);
+ return DiagObj->DiagRanges;
}
unsigned getNumFixItHints() const {
- return DiagObj->NumDiagFixItHints;
+ return DiagObj->DiagFixItHints.size();
}
const FixItHint &getFixItHint(unsigned Idx) const {
@@ -1182,8 +1224,8 @@ public:
return DiagObj->DiagFixItHints[Idx];
}
- const FixItHint *getFixItHints() const {
- return getNumFixItHints()? DiagObj->DiagFixItHints : 0;
+ ArrayRef<FixItHint> getFixItHints() const {
+ return DiagObj->DiagFixItHints;
}
/// \brief Format this diagnostic into a string, substituting the
@@ -1279,7 +1321,7 @@ public:
/// \param PP The preprocessor object being used for the source; this is
/// optional, e.g., it may not be present when processing AST source files.
virtual void BeginSourceFile(const LangOptions &LangOpts,
- const Preprocessor *PP = 0) {}
+ const Preprocessor *PP = nullptr) {}
/// \brief Callback to inform the diagnostic client that processing
/// of a source file has ended.
@@ -1312,7 +1354,7 @@ public:
class IgnoringDiagConsumer : public DiagnosticConsumer {
virtual void anchor();
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const Diagnostic &Info) {
+ const Diagnostic &Info) override {
// Just ignore it.
}
};
@@ -1328,11 +1370,11 @@ public:
virtual ~ForwardingDiagnosticConsumer();
- virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const Diagnostic &Info);
- virtual void clear();
+ void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+ const Diagnostic &Info) override;
+ void clear() override;
- virtual bool IncludeInDiagnosticCounts() const;
+ bool IncludeInDiagnosticCounts() const override;
};
// Struct used for sending info about how a type should be printed.
@@ -1351,6 +1393,13 @@ struct TemplateDiffTypes {
/// attribute. The character itself will be not be printed.
const char ToggleHighlight = 127;
+
+/// ProcessWarningOptions - Initialize the diagnostic client and process the
+/// warning options specified on the command line.
+void ProcessWarningOptions(DiagnosticsEngine &Diags,
+ const DiagnosticOptions &Opts,
+ bool ReportDiags = true);
+
} // end namespace clang
#endif