diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2017-10-08 20:53:36 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2017-10-08 20:53:36 +0000 |
commit | 8a1d633fe2cb6fb5f708d3b90b324f3688900a29 (patch) | |
tree | f669294293c4a7163394e486f290267e25c67825 | |
parent | 3c51ae5bd9b33d90fe23f4578fc8e6bb7d05764e (diff) | |
download | bcm5719-llvm-8a1d633fe2cb6fb5f708d3b90b324f3688900a29.tar.gz bcm5719-llvm-8a1d633fe2cb6fb5f708d3b90b324f3688900a29.zip |
Make SourceLocation, QualType and friends have constexpr constructors.
No functionality change intended.
llvm-svn: 315194
-rw-r--r-- | clang/include/clang/AST/CharUnits.h | 4 | ||||
-rw-r--r-- | clang/include/clang/AST/Type.h | 6 | ||||
-rw-r--r-- | clang/include/clang/Basic/SourceLocation.h | 24 |
3 files changed, 16 insertions, 18 deletions
diff --git a/clang/include/clang/AST/CharUnits.h b/clang/include/clang/AST/CharUnits.h index 564c8ec9b9e..ddead6046a1 100644 --- a/clang/include/clang/AST/CharUnits.h +++ b/clang/include/clang/AST/CharUnits.h @@ -40,14 +40,14 @@ namespace clang { typedef int64_t QuantityType; private: - QuantityType Quantity; + QuantityType Quantity = 0; explicit CharUnits(QuantityType C) : Quantity(C) {} public: /// CharUnits - A default constructor. - CharUnits() : Quantity(0) {} + CharUnits() = default; /// Zero - Construct a CharUnits quantity of zero. static CharUnits Zero() { diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 52a1ff8bd2b..2b94772fa37 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -162,8 +162,6 @@ public: FastMask = (1 << FastWidth) - 1 }; - Qualifiers() : Mask(0) {} - /// Returns the common set of qualifiers while removing them from /// the given sets. static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R) { @@ -539,7 +537,7 @@ private: // bits: |0 1 2|3|4 .. 5|6 .. 8|9 ... 31| // |C R V|U|GCAttr|Lifetime|AddressSpace| - uint32_t Mask; + uint32_t Mask = 0; static const uint32_t UMask = 0x8; static const uint32_t UShift = 3; @@ -634,7 +632,7 @@ class QualType { friend class QualifierCollector; public: - QualType() {} + QualType() = default; QualType(const Type *Ptr, unsigned Quals) : Value(Ptr, Quals) {} diff --git a/clang/include/clang/Basic/SourceLocation.h b/clang/include/clang/Basic/SourceLocation.h index 991cb786951..7418b50f9d8 100644 --- a/clang/include/clang/Basic/SourceLocation.h +++ b/clang/include/clang/Basic/SourceLocation.h @@ -39,10 +39,9 @@ class SourceManager; class FileID { /// \brief A mostly-opaque identifier, where 0 is "invalid", >0 is /// this module, and <-1 is something loaded from another module. - int ID; -public: - FileID() : ID(0) {} + int ID = 0; +public: bool isValid() const { return ID != 0; } bool isInvalid() const { return ID == 0; } @@ -86,17 +85,15 @@ private: /// /// It is important that this type remains small. It is currently 32 bits wide. class SourceLocation { - unsigned ID; + unsigned ID = 0; friend class SourceManager; friend class ASTReader; friend class ASTWriter; enum : unsigned { MacroIDBit = 1U << 31 }; -public: - - SourceLocation() : ID(0) {} +public: bool isFileID() const { return (ID & MacroIDBit) == 0; } bool isMacroID() const { return (ID & MacroIDBit) != 0; } @@ -198,8 +195,9 @@ inline bool operator<(const SourceLocation &LHS, const SourceLocation &RHS) { class SourceRange { SourceLocation B; SourceLocation E; + public: - SourceRange(): B(SourceLocation()), E(SourceLocation()) {} + SourceRange() = default; SourceRange(SourceLocation loc) : B(loc), E(loc) {} SourceRange(SourceLocation begin, SourceLocation end) : B(begin), E(end) {} @@ -230,9 +228,10 @@ public: /// range. class CharSourceRange { SourceRange Range; - bool IsTokenRange; + bool IsTokenRange = false; + public: - CharSourceRange() : IsTokenRange(false) {} + CharSourceRange() = default; CharSourceRange(SourceRange R, bool ITR) : Range(R), IsTokenRange(ITR) {} static CharSourceRange getTokenRange(SourceRange R) { @@ -330,10 +329,11 @@ class FileEntry; /// /// This is useful for argument passing to functions that expect both objects. class FullSourceLoc : public SourceLocation { - const SourceManager *SrcMgr; + const SourceManager *SrcMgr = nullptr; + public: /// \brief Creates a FullSourceLoc where isValid() returns \c false. - explicit FullSourceLoc() : SrcMgr(nullptr) {} + FullSourceLoc() = default; explicit FullSourceLoc(SourceLocation Loc, const SourceManager &SM) : SourceLocation(Loc), SrcMgr(&SM) {} |