summaryrefslogtreecommitdiffstats
path: root/include/clang
diff options
context:
space:
mode:
authorEugene Zelenko <eugene.zelenko@gmail.com>2018-02-16 23:40:07 +0000
committerEugene Zelenko <eugene.zelenko@gmail.com>2018-02-16 23:40:07 +0000
commit53d982bea4e15405c228fd90afc486c36d71feed (patch)
tree4a4ce5ae8875d3783abf5947334045a5220be375 /include/clang
parent4735edbbaf28ced185e76223b39ab4f0141186e3 (diff)
[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/Basic/Diagnostic.h247
-rw-r--r--include/clang/Basic/DiagnosticOptions.h15
-rw-r--r--include/clang/Basic/LangOptions.h55
-rw-r--r--include/clang/Basic/PartialDiagnostic.h60
-rw-r--r--include/clang/Basic/PlistSupport.h19
-rw-r--r--include/clang/Basic/SourceLocation.h67
6 files changed, 293 insertions, 170 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index a40a78d841..8bf0fd1140 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -1,4 +1,4 @@
-//===--- Diagnostic.h - C Language Family Diagnostic Handling ---*- C++ -*-===//
+//===- Diagnostic.h - C Language Family Diagnostic Handling -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,10 +6,10 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-///
+//
/// \file
/// \brief Defines the Diagnostic-related interfaces.
-///
+//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H
@@ -22,12 +22,13 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
-#include <algorithm>
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Compiler.h"
#include <cassert>
#include <cstdint>
+#include <limits>
#include <list>
#include <map>
#include <memory>
@@ -44,13 +45,14 @@ class DiagnosticConsumer;
class IdentifierInfo;
class LangOptions;
class Preprocessor;
+class SourceManager;
class StoredDiagnostic;
namespace tok {
- enum TokenKind : unsigned short;
+enum TokenKind : unsigned short;
-} // end namespace tok
+} // namespace tok
/// \brief Annotates a diagnostic with some code that should be
/// inserted, removed, or replaced to fix the problem.
@@ -75,11 +77,11 @@ public:
/// string.
std::string CodeToInsert;
- bool BeforePreviousInsertions;
+ bool BeforePreviousInsertions = false;
/// \brief Empty code modification hint, indicating that no code
/// modification is known.
- FixItHint() : BeforePreviousInsertions(false) { }
+ FixItHint() = default;
bool isNull() const {
return !RemoveRange.isValid();
@@ -157,43 +159,86 @@ public:
};
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_attr ///< Attr *
+ /// std::string
+ ak_std_string,
+
+ /// const char *
+ ak_c_string,
+
+ /// int
+ ak_sint,
+
+ /// unsigned
+ ak_uint,
+
+ /// enum TokenKind : unsigned
+ ak_tokenkind,
+
+ /// IdentifierInfo
+ ak_identifierinfo,
+
+ /// QualType
+ ak_qualtype,
+
+ /// DeclarationName
+ ak_declarationname,
+
+ /// NamedDecl *
+ ak_nameddecl,
+
+ /// NestedNameSpecifier *
+ ak_nestednamespec,
+
+ /// DeclContext *
+ ak_declcontext,
+
+ /// pair<QualType, QualType>
+ ak_qualtype_pair,
+
+ /// Attr *
+ ak_attr
};
/// \brief Represents on argument value, which is a union discriminated
/// by ArgumentKind, with a value.
- typedef std::pair<ArgumentKind, intptr_t> ArgumentValue;
+ using ArgumentValue = std::pair<ArgumentKind, intptr_t>;
private:
- unsigned char AllExtensionsSilenced; // Used by __extension__
- bool SuppressAfterFatalError; // Suppress diagnostics after a fatal error?
- bool SuppressAllDiagnostics; // Suppress all diagnostics.
- bool ElideType; // Elide common types of templates.
- bool PrintTemplateTree; // Print a tree when comparing templates.
- bool ShowColors; // Color printing is enabled.
- OverloadsShown ShowOverloads; // Which overload candidates to show.
- unsigned ErrorLimit; // Cap of # errors emitted, 0 -> no limit.
- unsigned TemplateBacktraceLimit; // Cap on depth of template backtrace stack,
- // 0 -> no limit.
- unsigned ConstexprBacktraceLimit; // Cap on depth of constexpr evaluation
- // backtrace stack, 0 -> no limit.
+ // Used by __extension__
+ unsigned char AllExtensionsSilenced = 0;
+
+ // Suppress diagnostics after a fatal error?
+ bool SuppressAfterFatalError = true;
+
+ // Suppress all diagnostics.
+ bool SuppressAllDiagnostics = false;
+
+ // Elide common types of templates.
+ bool ElideType = true;
+
+ // Print a tree when comparing templates.
+ bool PrintTemplateTree = false;
+
+ // Color printing is enabled.
+ bool ShowColors = false;
+
+ // Which overload candidates to show.
+ OverloadsShown ShowOverloads = Ovl_All;
+
+ // Cap of # errors emitted, 0 -> no limit.
+ unsigned ErrorLimit = 0;
+
+ // Cap on depth of template backtrace stack, 0 -> no limit.
+ unsigned TemplateBacktraceLimit = 0;
+
+ // Cap on depth of constexpr evaluation backtrace stack, 0 -> no limit.
+ unsigned ConstexprBacktraceLimit = 0;
+
IntrusiveRefCntPtr<DiagnosticIDs> Diags;
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
- DiagnosticConsumer *Client;
+ DiagnosticConsumer *Client = nullptr;
std::unique_ptr<DiagnosticConsumer> Owner;
- SourceManager *SourceMgr;
+ SourceManager *SourceMgr = nullptr;
/// \brief Mapping information for diagnostics.
///
@@ -211,25 +256,38 @@ private:
public:
// "Global" configuration state that can actually vary between modules.
- unsigned IgnoreAllWarnings : 1; // Ignore all warnings: -w
- unsigned EnableAllWarnings : 1; // Enable all warnings.
- unsigned WarningsAsErrors : 1; // Treat warnings like errors.
- unsigned ErrorsAsFatal : 1; // Treat errors like fatal errors.
- unsigned SuppressSystemWarnings : 1; // Suppress warnings in system headers.
- diag::Severity ExtBehavior; // Map extensions to warnings or errors?
+
+ // Ignore all warnings: -w
+ unsigned IgnoreAllWarnings : 1;
+
+ // Enable all warnings.
+ unsigned EnableAllWarnings : 1;
+
+ // Treat warnings like errors.
+ unsigned WarningsAsErrors : 1;
+
+ // Treat errors like fatal errors.
+ unsigned ErrorsAsFatal : 1;
+
+ // Suppress warnings in system headers.
+ unsigned SuppressSystemWarnings : 1;
+
+ // Map extensions to warnings or errors?
+ diag::Severity ExtBehavior = diag::Severity::Ignored;
DiagState()
: IgnoreAllWarnings(false), EnableAllWarnings(false),
WarningsAsErrors(false), ErrorsAsFatal(false),
- SuppressSystemWarnings(false), ExtBehavior(diag::Severity::Ignored) {}
+ SuppressSystemWarnings(false) {}
- typedef llvm::DenseMap<unsigned, DiagnosticMapping>::iterator iterator;
- typedef llvm::DenseMap<unsigned, DiagnosticMapping>::const_iterator
- const_iterator;
+ using iterator = llvm::DenseMap<unsigned, DiagnosticMapping>::iterator;
+ using const_iterator =
+ llvm::DenseMap<unsigned, DiagnosticMapping>::const_iterator;
void setMapping(diag::kind Diag, DiagnosticMapping Info) {
DiagMap[Diag] = Info;
}
+
DiagnosticMapping lookupMapping(diag::kind Diag) const {
return DiagMap.lookup(Diag);
}
@@ -249,12 +307,16 @@ private:
public:
/// Add an initial diagnostic state.
void appendFirst(DiagState *State);
+
/// Add a new latest state point.
void append(SourceManager &SrcMgr, SourceLocation Loc, DiagState *State);
+
/// Look up the diagnostic state at a given source location.
DiagState *lookup(SourceManager &SrcMgr, SourceLocation Loc) const;
+
/// Determine whether this map is empty.
bool empty() const { return Files.empty(); }
+
/// Clear out this map.
void clear() {
Files.clear();
@@ -268,10 +330,14 @@ private:
/// Grab the most-recently-added state point.
DiagState *getCurDiagState() const { return CurDiagState; }
+
/// Get the location at which a diagnostic state was last added.
SourceLocation getCurDiagStateLoc() const { return CurDiagStateLoc; }
private:
+ friend class ASTReader;
+ friend class ASTWriter;
+
/// \brief Represents a point in source where the diagnostic state was
/// modified because of a pragma.
///
@@ -280,8 +346,9 @@ private:
struct DiagStatePoint {
DiagState *State;
unsigned Offset;
+
DiagStatePoint(DiagState *State, unsigned Offset)
- : State(State), Offset(Offset) { }
+ : State(State), Offset(Offset) {}
};
/// Description of the diagnostic states and state transitions for a
@@ -291,11 +358,14 @@ private:
/// as looking up the DecomposedIncludedLoc for the FileID in the Files
/// map would give us this, but we cache it here for performance.
File *Parent = nullptr;
+
/// The offset of this file within its parent.
unsigned ParentOffset = 0;
+
/// Whether this file has any local (not imported from an AST file)
/// diagnostic state transitions.
bool HasLocalTransitions = false;
+
/// The points within the file where the state changes. There will always
/// be at least one of these (the state on entry to the file).
llvm::SmallVector<DiagStatePoint, 4> StateTransitions;
@@ -308,16 +378,15 @@ private:
/// The initial diagnostic state.
DiagState *FirstDiagState;
+
/// The current diagnostic state.
DiagState *CurDiagState;
+
/// The location at which the current diagnostic state was established.
SourceLocation CurDiagStateLoc;
/// Get the diagnostic state information for a file.
File *getFile(SourceManager &SrcMgr, FileID ID) const;
-
- friend class ASTReader;
- friend class ASTWriter;
};
DiagStateMap DiagStatesByLoc;
@@ -363,8 +432,11 @@ private:
/// diagnostic that they follow.
DiagnosticIDs::Level LastDiagLevel;
- unsigned NumWarnings; ///< Number of warnings reported
- unsigned NumErrors; ///< Number of errors reported
+ /// Number of warnings reported
+ unsigned NumWarnings;
+
+ /// Number of errors reported
+ unsigned NumErrors;
/// \brief A function pointer that converts an opaque diagnostic
/// argument to a strings.
@@ -376,14 +448,15 @@ private:
/// avoid redundancy across arguments.
///
/// This is a hack to avoid a layering violation between libbasic and libsema.
- typedef void (*ArgToStringFnTy)(
+ using ArgToStringFnTy = void (*)(
ArgumentKind Kind, intptr_t Val,
StringRef Modifier, StringRef Argument,
ArrayRef<ArgumentValue> PrevArgs,
SmallVectorImpl<char> &Output,
void *Cookie,
ArrayRef<intptr_t> QualTypeVals);
- void *ArgToStringCookie;
+
+ void *ArgToStringCookie = nullptr;
ArgToStringFnTy ArgToStringFn;
/// \brief ID of the "delayed" diagnostic, which is a (typically
@@ -425,7 +498,7 @@ public:
/// \brief Retrieve the diagnostic options.
DiagnosticOptions &getDiagnosticOptions() const { return *DiagOpts; }
- typedef llvm::iterator_range<DiagState::const_iterator> diag_mapping_range;
+ using diag_mapping_range = llvm::iterator_range<DiagState::const_iterator>;
/// \brief Get the current set of diagnostic mappings.
diag_mapping_range getDiagnosticMappings() const {
@@ -444,10 +517,12 @@ public:
std::unique_ptr<DiagnosticConsumer> takeClient() { return std::move(Owner); }
bool hasSourceManager() const { return SourceMgr != nullptr; }
+
SourceManager &getSourceManager() const {
assert(SourceMgr && "SourceManager not set!");
return *SourceMgr;
}
+
void setSourceManager(SourceManager *SrcMgr) {
assert(DiagStatesByLoc.empty() &&
"Leftover diag state from a different SourceManager.");
@@ -773,7 +848,9 @@ public:
void Report(const StoredDiagnostic &storedDiag);
/// \brief Determine whethere there is already a diagnostic in flight.
- bool isDiagnosticInFlight() const { return CurDiagID != ~0U; }
+ bool isDiagnosticInFlight() const {
+ return CurDiagID != std::numeric_limits<unsigned>::max();
+ }
/// \brief Set the "delayed" diagnostic that will be emitted once
/// the current diagnostic completes.
@@ -800,33 +877,34 @@ public:
StringRef Arg2 = "");
/// \brief Clear out the current diagnostic.
- void Clear() { CurDiagID = ~0U; }
+ void Clear() { CurDiagID = std::numeric_limits<unsigned>::max(); }
/// \brief Return the value associated with this diagnostic flag.
StringRef getFlagValue() const { return FlagValue; }
private:
- /// \brief Report the delayed diagnostic.
- void ReportDelayed();
-
// This is private state used by DiagnosticBuilder. We put it here instead of
// in DiagnosticBuilder in order to keep DiagnosticBuilder a small lightweight
// object. This implementation choice means that we can only have one
// diagnostic "in flight" at a time, but this seems to be a reasonable
// tradeoff to keep these objects small. Assertions verify that only one
// diagnostic is in flight at a time.
- friend class DiagnosticIDs;
- friend class DiagnosticBuilder;
friend class Diagnostic;
- friend class PartialDiagnostic;
+ friend class DiagnosticBuilder;
friend class DiagnosticErrorTrap;
+ friend class DiagnosticIDs;
+ friend class PartialDiagnostic;
+ /// \brief Report the delayed diagnostic.
+ void ReportDelayed();
+
/// \brief The location of the current diagnostic that is in flight.
SourceLocation CurDiagLoc;
/// \brief The ID of the current diagnostic that is in flight.
///
- /// This is set to ~0U when there is no diagnostic in flight.
+ /// This is set to std::numeric_limits<unsigned>::max() when there is no
+ /// diagnostic in flight.
unsigned CurDiagID;
enum {
@@ -893,6 +971,9 @@ private:
/// @name Diagnostic Emission
/// @{
protected:
+ friend class ASTReader;
+ friend class ASTWriter;
+
// Sema requires access to the following functions because the current design
// of SFINAE requires it to use its own SemaDiagnosticBuilder, which needs to
// access us directly to ensure we minimize the emitted code for the common
@@ -909,9 +990,6 @@ protected:
SourceLocation getCurrentDiagLoc() const { return CurDiagLoc; }
/// @}
-
- friend class ASTReader;
- friend class ASTWriter;
};
/// \brief RAII class that determines when any errors have occurred
@@ -924,7 +1002,7 @@ class DiagnosticErrorTrap {
public:
explicit DiagnosticErrorTrap(DiagnosticsEngine &Diag)
- : Diag(Diag) { reset(); }
+ : Diag(Diag) { reset(); }
/// \brief Determine whether any errors have occurred since this
/// object instance was created.
@@ -962,6 +1040,9 @@ public:
/// the common fields to registers, eliminating increments of the NumArgs field,
/// for example.
class DiagnosticBuilder {
+ friend class DiagnosticsEngine;
+ friend class PartialDiagnostic;
+
mutable DiagnosticsEngine *DiagObj = nullptr;
mutable unsigned NumArgs = 0;
@@ -976,8 +1057,6 @@ class DiagnosticBuilder {
/// call to ForceEmit.
mutable bool IsForceEmit = false;
- friend class DiagnosticsEngine;
-
DiagnosticBuilder() = default;
explicit DiagnosticBuilder(DiagnosticsEngine *diagObj)
@@ -987,8 +1066,6 @@ class DiagnosticBuilder {
diagObj->DiagFixItHints.clear();
}
- friend class PartialDiagnostic;
-
protected:
void FlushCounts() {
DiagObj->NumDiagArgs = NumArgs;
@@ -1049,7 +1126,7 @@ public:
/// \brief Retrieve an empty diagnostic builder.
static DiagnosticBuilder getEmpty() {
- return DiagnosticBuilder();
+ return {};
}
/// \brief Forces the diagnostic to be emitted.
@@ -1098,8 +1175,9 @@ public:
};
struct AddFlagValue {
- explicit AddFlagValue(StringRef V) : Val(V) {}
StringRef Val;
+
+ explicit AddFlagValue(StringRef V) : Val(V) {}
};
/// \brief Register a value for the flag in the current diagnostic. This
@@ -1208,14 +1286,15 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
/// A nullability kind paired with a bit indicating whether it used a
/// context-sensitive keyword.
-typedef std::pair<NullabilityKind, bool> DiagNullabilityKind;
+using DiagNullabilityKind = std::pair<NullabilityKind, bool>;
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
DiagNullabilityKind nullability);
inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
unsigned DiagID) {
- assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
+ assert(CurDiagID == std::numeric_limits<unsigned>::max() &&
+ "Multiple diagnostics in flight at once!");
CurDiagLoc = Loc;
CurDiagID = DiagID;
FlagValue.clear();
@@ -1240,7 +1319,7 @@ class Diagnostic {
public:
explicit Diagnostic(const DiagnosticsEngine *DO) : DiagObj(DO) {}
Diagnostic(const DiagnosticsEngine *DO, StringRef storedDiagMessage)
- : DiagObj(DO), StoredDiagMessage(storedDiagMessage) {}
+ : DiagObj(DO), StoredDiagMessage(storedDiagMessage) {}
const DiagnosticsEngine *getDiags() const { return DiagObj; }
unsigned getID() const { return DiagObj->CurDiagID; }
@@ -1382,7 +1461,8 @@ public:
void setLocation(FullSourceLoc Loc) { this->Loc = Loc; }
- typedef std::vector<CharSourceRange>::const_iterator range_iterator;
+ using range_iterator = std::vector<CharSourceRange>::const_iterator;
+
range_iterator range_begin() const { return Ranges.begin(); }
range_iterator range_end() const { return Ranges.end(); }
unsigned range_size() const { return Ranges.size(); }
@@ -1391,7 +1471,8 @@ public:
return llvm::makeArrayRef(Ranges);
}
- typedef std::vector<FixItHint>::const_iterator fixit_iterator;
+ using fixit_iterator = std::vector<FixItHint>::const_iterator;
+
fixit_iterator fixit_begin() const { return FixIts.begin(); }
fixit_iterator fixit_end() const { return FixIts.end(); }
unsigned fixit_size() const { return FixIts.size(); }
@@ -1410,7 +1491,6 @@ protected:
public:
DiagnosticConsumer() = default;
-
virtual ~DiagnosticConsumer();
unsigned getNumErrors() const { return NumErrors; }
@@ -1476,7 +1556,6 @@ class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
public:
ForwardingDiagnosticConsumer(DiagnosticConsumer &Target) : Target(Target) {}
-
~ForwardingDiagnosticConsumer() override;
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
@@ -1494,6 +1573,7 @@ struct TemplateDiffTypes {
unsigned PrintFromType : 1;
unsigned ElideType : 1;
unsigned ShowColors : 1;
+
// The printer sets this variable to true if the template diff was used.
unsigned TemplateDiffUsed : 1;
};
@@ -1502,13 +1582,12 @@ 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
+} // namespace clang
#endif // LLVM_CLANG_BASIC_DIAGNOSTIC_H
diff --git a/include/clang/Basic/DiagnosticOptions.h b/include/clang/Basic/DiagnosticOptions.h
index 3844eb63f0..404d0c5aef 100644
--- a/include/clang/Basic/DiagnosticOptions.h
+++ b/include/clang/Basic/DiagnosticOptions.h
@@ -1,4 +1,4 @@
-//===--- DiagnosticOptions.h ------------------------------------*- C++ -*-===//
+//===- DiagnosticOptions.h --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -21,8 +21,11 @@ namespace clang {
/// \brief Specifies which overload candidates to display when overload
/// resolution fails.
enum OverloadsShown : unsigned {
- Ovl_All, ///< Show all overloads.
- Ovl_Best ///< Show just the "best" overload candidates.
+ /// Show all overloads.
+ Ovl_All,
+
+ /// Show just the "best" overload candidates.
+ Ovl_Best
};
/// \brief A bitmask representing the diagnostic levels used by
@@ -119,8 +122,8 @@ public:
}
};
-typedef DiagnosticOptions::TextDiagnosticFormat TextDiagnosticFormat;
+using TextDiagnosticFormat = DiagnosticOptions::TextDiagnosticFormat;
-} // end namespace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h
index f7a43adefa..b16392d4d7 100644
--- a/include/clang/Basic/LangOptions.h
+++ b/include/clang/Basic/LangOptions.h
@@ -1,4 +1,4 @@
-//===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===//
+//===- LangOptions.h - C Language Family Language Options -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,10 +6,10 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-///
+//
/// \file
/// \brief Defines the clang::LangOptions interface.
-///
+//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H
@@ -20,6 +20,8 @@
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Basic/Visibility.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
#include <string>
#include <vector>
@@ -47,22 +49,32 @@ protected:
/// enabled, which controls the dialect of C or C++ that is accepted.
class LangOptions : public LangOptionsBase {
public:
- typedef clang::Visibility Visibility;
+ using Visibility = clang::Visibility;
enum GCMode { NonGC, GCOnly, HybridGC };
enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq };
enum SignedOverflowBehaviorTy {
- SOB_Undefined, // Default C standard behavior.
- SOB_Defined, // -fwrapv
- SOB_Trapping // -ftrapv
+ // Default C standard behavior.
+ SOB_Undefined,
+
+ // -fwrapv
+ SOB_Defined,
+
+ // -ftrapv
+ SOB_Trapping
};
// FIXME: Unify with TUKind.
enum CompilingModuleKind {
- CMK_None, ///< Not compiling a module interface at all.
- CMK_ModuleMap, ///< Compiling a module from a module map.
- CMK_ModuleInterface ///< Compiling a C++ modules TS module interface unit.
+ /// Not compiling a module interface at all.
+ CMK_None,
+
+ /// Compiling a module from a module map.
+ CMK_ModuleMap,
+
+ /// Compiling a C++ modules TS module interface unit.
+ CMK_ModuleInterface
};
enum PragmaMSPointersToMembersKind {
@@ -91,9 +103,14 @@ public:
};
enum FPContractModeKind {
- FPC_Off, // Form fused FP ops only where result will not be affected.
- FPC_On, // Form fused FP ops according to FP_CONTRACT rules.
- FPC_Fast // Aggressively fuse FP ops (E.g. FMA).
+ // Form fused FP ops only where result will not be affected.
+ FPC_Off,
+
+ // Form fused FP ops according to FP_CONTRACT rules.
+ FPC_On,
+
+ // Aggressively fuse FP ops (E.g. FMA).
+ FPC_Fast
};
public:
@@ -152,7 +169,7 @@ public:
/// \brief Indicates whether the front-end is explicitly told that the
/// input is a header file (i.e. -x c-header).
- bool IsHeaderFile;
+ bool IsHeaderFile = false;
LangOptions();
@@ -219,15 +236,19 @@ public:
bool allowFPContractWithinStatement() const {
return fp_contract == LangOptions::FPC_On;
}
+
bool allowFPContractAcrossStatement() const {
return fp_contract == LangOptions::FPC_Fast;
}
+
void setAllowFPContractWithinStatement() {
fp_contract = LangOptions::FPC_On;
}
+
void setAllowFPContractAcrossStatement() {
fp_contract = LangOptions::FPC_Fast;
}
+
void setDisallowFPContract() { fp_contract = LangOptions::FPC_Off; }
/// Used to serialize this.
@@ -242,13 +263,15 @@ private:
enum TranslationUnitKind {
/// \brief The translation unit is a complete translation unit.
TU_Complete,
+
/// \brief The translation unit is a prefix to a translation unit, and is
/// not complete.
TU_Prefix,
+
/// \brief The translation unit is a module.
TU_Module
};
-} // end namespace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_BASIC_LANGOPTIONS_H
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h
index b2f14afe56..dffeaee8e2 100644
--- a/include/clang/Basic/PartialDiagnostic.h
+++ b/include/clang/Basic/PartialDiagnostic.h
@@ -1,4 +1,4 @@
-//===--- PartialDiagnostic.h - Diagnostic "closures" ------------*- C++ -*-===//
+//===- PartialDiagnostic.h - Diagnostic "closures" --------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,25 +6,32 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-///
+//
/// \file
/// \brief Implements a partial diagnostic that can be emitted anwyhere
/// in a DiagnosticBuilder stream.
-///
+//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_BASIC_PARTIALDIAGNOSTIC_H
#define LLVM_CLANG_BASIC_PARTIALDIAGNOSTIC_H
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include <cassert>
+#include <cstdint>
+#include <string>
+#include <type_traits>
+#include <utility>
namespace clang {
+class DeclContext;
+class IdentifierInfo;
+
class PartialDiagnostic {
public:
enum {
@@ -36,8 +43,6 @@ public:
};
struct Storage {
- Storage() : NumDiagArgs(0) { }
-
enum {
/// \brief The maximum number of arguments we can hold. We
/// currently only support up to 10 arguments (%0-%9).
@@ -48,7 +53,7 @@ public:
};
/// \brief The number of entries in Arguments.
- unsigned char NumDiagArgs;
+ unsigned char NumDiagArgs = 0;
/// \brief Specifies for each argument whether it is in DiagArgumentsStr
/// or in DiagArguments.
@@ -71,6 +76,8 @@ public:
/// \brief If valid, provides a hint with some code to insert, remove, or
/// modify at a particular position.
SmallVector<FixItHint, 6> FixItHints;
+
+ Storage() = default;
};
/// \brief An allocator for Storage objects, which uses a small cache to
@@ -114,13 +121,13 @@ private:
// in the new location.
/// \brief The diagnostic ID.
- mutable unsigned DiagID;
+ mutable unsigned DiagID = 0;
/// \brief Storage for args and ranges.
- mutable Storage *DiagStorage;
+ mutable Storage *DiagStorage = nullptr;
/// \brief Allocator used to allocate storage for this diagnostic.
- StorageAllocator *Allocator;
+ StorageAllocator *Allocator = nullptr;
/// \brief Retrieve storage for this particular diagnostic.
Storage *getStorage() const {
@@ -176,17 +183,16 @@ private:
public:
struct NullDiagnostic {};
+
/// \brief Create a null partial diagnostic, which cannot carry a payload,
/// and only exists to be swapped with a real partial diagnostic.
- PartialDiagnostic(NullDiagnostic)
- : DiagID(0), DiagStorage(nullptr), Allocator(nullptr) { }
+ PartialDiagnostic(NullDiagnostic) {}
PartialDiagnostic(unsigned DiagID, StorageAllocator &Allocator)
- : DiagID(DiagID), DiagStorage(nullptr), Allocator(&Allocator) { }
+ : DiagID(DiagID), Allocator(&Allocator) {}
PartialDiagnostic(const PartialDiagnostic &Other)
- : DiagID(Other.DiagID), DiagStorage(nullptr), Allocator(Other.Allocator)
- {
+ : DiagID(Other.DiagID), Allocator(Other.Allocator) {
if (Other.DiagStorage) {
DiagStorage = getStorage();
*DiagStorage = *Other.DiagStorage;
@@ -194,22 +200,20 @@ public:
}
PartialDiagnostic(PartialDiagnostic &&Other)
- : DiagID(Other.DiagID), DiagStorage(Other.DiagStorage),
- Allocator(Other.Allocator) {
+ : DiagID(Other.DiagID), DiagStorage(Other.DiagStorage),
+ Allocator(Other.Allocator) {
Other.DiagStorage = nullptr;
}
PartialDiagnostic(const PartialDiagnostic &Other, Storage *DiagStorage)
- : DiagID(Other.DiagID), DiagStorage(DiagStorage),
- Allocator(reinterpret_cast<StorageAllocator *>(~uintptr_t(0)))
- {
+ : DiagID(Other.DiagID), DiagStorage(DiagStorage),
+ Allocator(reinterpret_cast<StorageAllocator *>(~uintptr_t(0))) {
if (Other.DiagStorage)
*this->DiagStorage = *Other.DiagStorage;
}
PartialDiagnostic(const Diagnostic &Other, StorageAllocator &Allocator)
- : DiagID(Other.getID()), DiagStorage(nullptr), Allocator(&Allocator)
- {
+ : DiagID(Other.getID()), Allocator(&Allocator) {
// Copy arguments.
for (unsigned I = 0, N = Other.getNumArgs(); I != N; ++I) {
if (Other.getArgKind(I) == DiagnosticsEngine::ak_std_string)
@@ -402,7 +406,6 @@ public:
PD.AddFixItHint(Hint);
return PD;
}
-
};
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
@@ -413,7 +416,8 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
/// \brief A partial diagnostic along with the source location where this
/// diagnostic occurs.
-typedef std::pair<SourceLocation, PartialDiagnostic> PartialDiagnosticAt;
+using PartialDiagnosticAt = std::pair<SourceLocation, PartialDiagnostic>;
+
+} // namespace clang
-} // end namespace clang
-#endif
+#endif // LLVM_CLANG_BASIC_PARTIALDIAGNOSTIC_H
diff --git a/include/clang/Basic/PlistSupport.h b/include/clang/Basic/PlistSupport.h
index 61de82450c..be92bbfde1 100644
--- a/include/clang/Basic/PlistSupport.h
+++ b/include/clang/Basic/PlistSupport.h
@@ -1,4 +1,4 @@
-//===---------- PlistSupport.h - Plist Output Utilities ---------*- C++ -*-===//
+//===- PlistSupport.h - Plist Output Utilities ------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,12 +10,20 @@
#ifndef LLVM_CLANG_BASIC_PLISTSUPPORT_H
#define LLVM_CLANG_BASIC_PLISTSUPPORT_H
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/raw_ostream.h"
+#include <cassert>
+#include <cstdint>
namespace clang {
namespace markup {
-typedef llvm::DenseMap<FileID, unsigned> FIDMap;
+
+using FIDMap = llvm::DenseMap<FileID, unsigned>;
inline void AddFID(FIDMap &FIDs, SmallVectorImpl<FileID> &V,
const SourceManager &SM, SourceLocation L) {
@@ -112,7 +120,8 @@ inline void EmitRange(raw_ostream &o, const SourceManager &SM,
EmitLocation(o, SM, R.getEnd(), FM, indent + 1);
Indent(o, indent) << "</array>\n";
}
-}
-}
-#endif
+} // namespace markup
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_PLISTSUPPORT_H
diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h
index 7418b50f9d..a83f95e7ae 100644
--- a/include/clang/Basic/SourceLocation.h
+++ b/include/clang/Basic/SourceLocation.h
@@ -1,4 +1,4 @@
-//===--- SourceLocation.h - Compact identifier for Source Files -*- C++ -*-===//
+//===- SourceLocation.h - Compact identifier for Source Files ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,28 +6,29 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-///
+//
/// \file
/// \brief Defines the clang::SourceLocation class and associated facilities.
-///
+//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_BASIC_SOURCELOCATION_H
#define LLVM_CLANG_BASIC_SOURCELOCATION_H
#include "clang/Basic/LLVM.h"
-#include "llvm/Support/Compiler.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/PointerLikeTypeTraits.h"
#include <cassert>
-#include <functional>
+#include <cstdint>
#include <string>
#include <utility>
namespace llvm {
- class MemoryBuffer;
- template <typename T> struct DenseMapInfo;
- template <typename T> struct isPodLike;
-}
+
+template <typename T> struct DenseMapInfo;
+template <typename T> struct isPodLike;
+
+} // namespace llvm
namespace clang {
@@ -56,19 +57,19 @@ public:
unsigned getHashValue() const { return static_cast<unsigned>(ID); }
private:
- friend class SourceManager;
friend class ASTWriter;
friend class ASTReader;
+ friend class SourceManager;
static FileID get(int V) {
FileID F;
F.ID = V;
return F;
}
+
int getOpaqueValue() const { return ID; }
};
-
/// \brief Encodes a location in the source. The SourceManager can decode this
/// to get at the full include stack, line and column information.
///
@@ -85,10 +86,12 @@ private:
///
/// It is important that this type remains small. It is currently 32 bits wide.
class SourceLocation {
- unsigned ID = 0;
- friend class SourceManager;
friend class ASTReader;
friend class ASTWriter;
+ friend class SourceManager;
+
+ unsigned ID = 0;
+
enum : unsigned {
MacroIDBit = 1U << 31
};
@@ -124,8 +127,8 @@ private:
L.ID = MacroIDBit | ID;
return L;
}
-public:
+public:
/// \brief Return a source location with the specified offset from this
/// SourceLocation.
SourceLocation getLocWithOffset(int Offset) const {
@@ -245,6 +248,7 @@ public:
static CharSourceRange getTokenRange(SourceLocation B, SourceLocation E) {
return getTokenRange(SourceRange(B, E));
}
+
static CharSourceRange getCharRange(SourceLocation B, SourceLocation E) {
return getCharRange(SourceRange(B, E));
}
@@ -274,12 +278,12 @@ public:
///
/// You can get a PresumedLoc from a SourceLocation with SourceManager.
class PresumedLoc {
- const char *Filename;
+ const char *Filename = nullptr;
unsigned Line, Col;
SourceLocation IncludeLoc;
public:
- PresumedLoc() : Filename(nullptr) {}
+ PresumedLoc() = default;
PresumedLoc(const char *FN, unsigned Ln, unsigned Co, SourceLocation IL)
: Filename(FN), Line(Ln), Col(Co), IncludeLoc(IL) {}
@@ -336,7 +340,7 @@ public:
FullSourceLoc() = default;
explicit FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
- : SourceLocation(Loc), SrcMgr(&SM) {}
+ : SourceLocation(Loc), SrcMgr(&SM) {}
bool hasManager() const {
bool hasSrcMgr = SrcMgr != nullptr;
@@ -415,32 +419,31 @@ public:
/// This is useful for debugging.
void dump() const;
- friend inline bool
+ friend bool
operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS) {
return LHS.getRawEncoding() == RHS.getRawEncoding() &&
LHS.SrcMgr == RHS.SrcMgr;
}
- friend inline bool
+ friend bool
operator!=(const FullSourceLoc &LHS, const FullSourceLoc &RHS) {
return !(LHS == RHS);
}
-
};
-
-
-} // end namespace clang
+} // namespace clang
namespace llvm {
+
/// Define DenseMapInfo so that FileID's can be used as keys in DenseMap and
/// DenseSets.
template <>
struct DenseMapInfo<clang::FileID> {
- static inline clang::FileID getEmptyKey() {
- return clang::FileID();
+ static clang::FileID getEmptyKey() {
+ return {};
}
- static inline clang::FileID getTombstoneKey() {
+
+ static clang::FileID getTombstoneKey() {
return clang::FileID::getSentinel();
}
@@ -461,15 +464,17 @@ namespace llvm {
// Teach SmallPtrSet how to handle SourceLocation.
template<>
struct PointerLikeTypeTraits<clang::SourceLocation> {
- static inline void *getAsVoidPointer(clang::SourceLocation L) {
+ enum { NumLowBitsAvailable = 0 };
+
+ static void *getAsVoidPointer(clang::SourceLocation L) {
return L.getPtrEncoding();
}
- static inline clang::SourceLocation getFromVoidPointer(void *P) {
+
+ static clang::SourceLocation getFromVoidPointer(void *P) {
return clang::SourceLocation::getFromRawEncoding((unsigned)(uintptr_t)P);
}
- enum { NumLowBitsAvailable = 0 };
};
-} // end namespace llvm
+} // namespace llvm
-#endif
+#endif // LLVM_CLANG_BASIC_SOURCELOCATION_H