Index: clang/include/clang/AST/DeclObjC.h =================================================================== --- clang/include/clang/AST/DeclObjC.h +++ clang/include/clang/AST/DeclObjC.h @@ -637,8 +637,8 @@ : private llvm::TrailingObjects { /// Stores the components of a SourceRange as a POD. struct PODSourceRange { - unsigned Begin; - unsigned End; + PODSourceLocation Begin; + PODSourceLocation End; }; union { @@ -697,11 +697,11 @@ } SourceLocation getLAngleLoc() const { - return SourceLocation::getFromRawEncoding(Brackets.Begin); + return SourceLocation::getFromPOD(Brackets.Begin); } SourceLocation getRAngleLoc() const { - return SourceLocation::getFromRawEncoding(Brackets.End); + return SourceLocation::getFromPOD(Brackets.End); } SourceRange getSourceRange() const { Index: clang/include/clang/AST/DeclarationName.h =================================================================== --- clang/include/clang/AST/DeclarationName.h +++ clang/include/clang/AST/DeclarationName.h @@ -660,13 +660,13 @@ // The location (if any) of the operator keyword is stored elsewhere. struct CXXOpName { - unsigned BeginOpNameLoc; - unsigned EndOpNameLoc; + PODSourceLocation BeginOpNameLoc; + PODSourceLocation EndOpNameLoc; }; // The location (if any) of the operator keyword is stored elsewhere. struct CXXLitOpName { - unsigned OpNameLoc; + PODSourceLocation OpNameLoc; }; // struct {} CXXUsingDirective; @@ -750,8 +750,8 @@ if (Name.getNameKind() != DeclarationName::CXXOperatorName) return SourceRange(); return SourceRange( - SourceLocation::getFromRawEncoding(LocInfo.CXXOperatorName.BeginOpNameLoc), - SourceLocation::getFromRawEncoding(LocInfo.CXXOperatorName.EndOpNameLoc) + SourceLocation::getFromPOD(LocInfo.CXXOperatorName.BeginOpNameLoc), + SourceLocation::getFromPOD(LocInfo.CXXOperatorName.EndOpNameLoc) ); } @@ -759,8 +759,8 @@ /// (without the operator keyword). Assumes it is a C++ operator. void setCXXOperatorNameRange(SourceRange R) { assert(Name.getNameKind() == DeclarationName::CXXOperatorName); - LocInfo.CXXOperatorName.BeginOpNameLoc = R.getBegin().getRawEncoding(); - LocInfo.CXXOperatorName.EndOpNameLoc = R.getEnd().getRawEncoding(); + LocInfo.CXXOperatorName.BeginOpNameLoc = R.getBegin().getPOD(); + LocInfo.CXXOperatorName.EndOpNameLoc = R.getEnd().getPOD(); } /// getCXXLiteralOperatorNameLoc - Returns the location of the literal @@ -770,7 +770,7 @@ if (Name.getNameKind() != DeclarationName::CXXLiteralOperatorName) return SourceLocation(); return SourceLocation:: - getFromRawEncoding(LocInfo.CXXLiteralOperatorName.OpNameLoc); + getFromPOD(LocInfo.CXXLiteralOperatorName.OpNameLoc); } /// setCXXLiteralOperatorNameLoc - Sets the location of the literal @@ -778,7 +778,7 @@ /// Assumes it is a literal operator. void setCXXLiteralOperatorNameLoc(SourceLocation Loc) { assert(Name.getNameKind() == DeclarationName::CXXLiteralOperatorName); - LocInfo.CXXLiteralOperatorName.OpNameLoc = Loc.getRawEncoding(); + LocInfo.CXXLiteralOperatorName.OpNameLoc = Loc.getPOD(); } /// Determine whether this name involves a template parameter. Index: clang/include/clang/AST/DependentDiagnostic.h =================================================================== --- clang/include/clang/AST/DependentDiagnostic.h +++ clang/include/clang/AST/DependentDiagnostic.h @@ -48,7 +48,7 @@ QualType BaseObjectType, const PartialDiagnostic &PDiag) { DependentDiagnostic *DD = Create(Context, Parent, PDiag); - DD->AccessData.Loc = Loc.getRawEncoding(); + DD->AccessData.Loc = Loc.getPOD(); DD->AccessData.IsMember = IsMemberAccess; DD->AccessData.Access = AS; DD->AccessData.TargetDecl = TargetDecl; @@ -73,7 +73,7 @@ SourceLocation getAccessLoc() const { assert(getKind() == Access); - return SourceLocation::getFromRawEncoding(AccessData.Loc); + return SourceLocation::getFromPOD(AccessData.Loc); } NamedDecl *getAccessTarget() const { @@ -112,7 +112,7 @@ PartialDiagnostic Diag; struct { - unsigned Loc; + PODSourceLocation Loc; unsigned Access : 2; unsigned IsMember : 1; NamedDecl *TargetDecl; Index: clang/include/clang/AST/Expr.h =================================================================== --- clang/include/clang/AST/Expr.h +++ clang/include/clang/AST/Expr.h @@ -4657,10 +4657,10 @@ uintptr_t NameOrField; /// The location of the '.' in the designated initializer. - unsigned DotLoc; + PODSourceLocation DotLoc; /// The location of the field name in the designated initializer. - unsigned FieldLoc; + PODSourceLocation FieldLoc; }; /// An array or GNU array-range designator, e.g., "[9]" or "[10..15]". @@ -4669,12 +4669,12 @@ /// initializer expression's list of subexpressions. unsigned Index; /// The location of the '[' starting the array range designator. - unsigned LBracketLoc; + PODSourceLocation LBracketLoc; /// The location of the ellipsis separating the start and end /// indices. Only valid for GNU array-range designators. - unsigned EllipsisLoc; + PODSourceLocation EllipsisLoc; /// The location of the ']' terminating the array range designator. - unsigned RBracketLoc; + PODSourceLocation RBracketLoc; }; /// Represents a single C99 designator. @@ -4707,8 +4707,8 @@ SourceLocation FieldLoc) : Kind(FieldDesignator) { Field.NameOrField = reinterpret_cast(FieldName) | 0x01; - Field.DotLoc = DotLoc.getRawEncoding(); - Field.FieldLoc = FieldLoc.getRawEncoding(); + Field.DotLoc = DotLoc.getPOD(); + Field.FieldLoc = FieldLoc.getPOD(); } /// Initializes an array designator. @@ -4716,9 +4716,9 @@ SourceLocation RBracketLoc) : Kind(ArrayDesignator) { ArrayOrRange.Index = Index; - ArrayOrRange.LBracketLoc = LBracketLoc.getRawEncoding(); - ArrayOrRange.EllipsisLoc = SourceLocation().getRawEncoding(); - ArrayOrRange.RBracketLoc = RBracketLoc.getRawEncoding(); + ArrayOrRange.LBracketLoc = LBracketLoc.getPOD(); + ArrayOrRange.EllipsisLoc = SourceLocation().getPOD(); + ArrayOrRange.RBracketLoc = RBracketLoc.getPOD(); } /// Initializes a GNU array-range designator. @@ -4726,9 +4726,9 @@ SourceLocation EllipsisLoc, SourceLocation RBracketLoc) : Kind(ArrayRangeDesignator) { ArrayOrRange.Index = Index; - ArrayOrRange.LBracketLoc = LBracketLoc.getRawEncoding(); - ArrayOrRange.EllipsisLoc = EllipsisLoc.getRawEncoding(); - ArrayOrRange.RBracketLoc = RBracketLoc.getRawEncoding(); + ArrayOrRange.LBracketLoc = LBracketLoc.getPOD(); + ArrayOrRange.EllipsisLoc = EllipsisLoc.getPOD(); + ArrayOrRange.RBracketLoc = RBracketLoc.getPOD(); } bool isFieldDesignator() const { return Kind == FieldDesignator; } @@ -4752,30 +4752,30 @@ SourceLocation getDotLoc() const { assert(Kind == FieldDesignator && "Only valid on a field designator"); - return SourceLocation::getFromRawEncoding(Field.DotLoc); + return SourceLocation::getFromPOD(Field.DotLoc); } SourceLocation getFieldLoc() const { assert(Kind == FieldDesignator && "Only valid on a field designator"); - return SourceLocation::getFromRawEncoding(Field.FieldLoc); + return SourceLocation::getFromPOD(Field.FieldLoc); } SourceLocation getLBracketLoc() const { assert((Kind == ArrayDesignator || Kind == ArrayRangeDesignator) && "Only valid on an array or array-range designator"); - return SourceLocation::getFromRawEncoding(ArrayOrRange.LBracketLoc); + return SourceLocation::getFromPOD(ArrayOrRange.LBracketLoc); } SourceLocation getRBracketLoc() const { assert((Kind == ArrayDesignator || Kind == ArrayRangeDesignator) && "Only valid on an array or array-range designator"); - return SourceLocation::getFromRawEncoding(ArrayOrRange.RBracketLoc); + return SourceLocation::getFromPOD(ArrayOrRange.RBracketLoc); } SourceLocation getEllipsisLoc() const { assert(Kind == ArrayRangeDesignator && "Only valid on an array-range designator"); - return SourceLocation::getFromRawEncoding(ArrayOrRange.EllipsisLoc); + return SourceLocation::getFromPOD(ArrayOrRange.EllipsisLoc); } unsigned getFirstExprIndex() const { Index: clang/include/clang/AST/TemplateBase.h =================================================================== --- clang/include/clang/AST/TemplateBase.h +++ clang/include/clang/AST/TemplateBase.h @@ -396,8 +396,8 @@ // but template arguments get canonicalized too quickly. NestedNameSpecifier *Qualifier; void *QualifierLocData; - unsigned TemplateNameLoc; - unsigned EllipsisLoc; + PODSourceLocation TemplateNameLoc; + PODSourceLocation EllipsisLoc; }; union { @@ -407,7 +407,7 @@ }; public: - constexpr TemplateArgumentLocInfo() : Template({nullptr, nullptr, 0, 0}) {} + constexpr TemplateArgumentLocInfo() : Template({nullptr, nullptr, {}, {}}) {} TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {} @@ -418,8 +418,8 @@ SourceLocation EllipsisLoc) { Template.Qualifier = QualifierLoc.getNestedNameSpecifier(); Template.QualifierLocData = QualifierLoc.getOpaqueData(); - Template.TemplateNameLoc = TemplateNameLoc.getRawEncoding(); - Template.EllipsisLoc = EllipsisLoc.getRawEncoding(); + Template.TemplateNameLoc = TemplateNameLoc.getPOD(); + Template.EllipsisLoc = EllipsisLoc.getPOD(); } TypeSourceInfo *getAsTypeSourceInfo() const { @@ -436,11 +436,11 @@ } SourceLocation getTemplateNameLoc() const { - return SourceLocation::getFromRawEncoding(Template.TemplateNameLoc); + return SourceLocation::getFromPOD(Template.TemplateNameLoc); } SourceLocation getTemplateEllipsisLoc() const { - return SourceLocation::getFromRawEncoding(Template.EllipsisLoc); + return SourceLocation::getFromPOD(Template.EllipsisLoc); } }; Index: clang/include/clang/Basic/SourceLocation.h =================================================================== --- clang/include/clang/Basic/SourceLocation.h +++ clang/include/clang/Basic/SourceLocation.h @@ -70,6 +70,42 @@ int getOpaqueValue() const { return ID; } }; +/// Encodes a location in the source. This class is used in cases when a POD +/// type is required and SourceLocation cannot be used (e.g. in unions). +/// +/// The default constructor of PODSourceLocation leaves it in an uninitialized +/// state. +/// +/// \see SourceLocation +class PODSourceLocation { + friend class SourceLocation; + unsigned ID; +public: + /// Set the value to "Invalid location" + void clear() { ID = 0; } + + bool isValid() const { return ID != 0; } + bool isInvalid() const { return ID == 0; } + + friend bool operator==(const PODSourceLocation &LHS, + const PODSourceLocation &RHS) { + return LHS.ID == RHS.ID; + } + + friend bool operator<(const PODSourceLocation &LHS, + const PODSourceLocation &RHS) { + return LHS.ID < RHS.ID; + } + + friend bool operator!=(const PODSourceLocation &LHS, + const PODSourceLocation &RHS) { + return !(LHS == RHS); + } +}; + +static_assert(std::is_pod::value, + "PODSourceLocation must be a POD type"); + /// Encodes a location in the source. The SourceManager can decode this /// to get at the full include stack, line and column information. /// @@ -138,11 +174,28 @@ return L; } + /// Return a POD object containing the same information as SourceLocation + PODSourceLocation getPOD() const { + PODSourceLocation Loc; + Loc.ID = ID; + return Loc; + } + + /// Turn a PODSourceLocation into a SourceLocation. + /// + /// \see getPOD. + static SourceLocation getFromPOD(PODSourceLocation Encoding) { + SourceLocation X; + X.ID = Encoding.ID; + return X; + } + /// When a SourceLocation itself cannot be used, this returns /// an (opaque) 32-bit integer encoding for it. /// - /// This should only be passed to SourceLocation::getFromRawEncoding, it - /// should not be inspected directly. + /// This should only be used when PODSourceLocation cannot be used (e.g. C + /// API boundary). The return value should not be inspected directly, it + /// should be passed to SourceLocation::getFromRawEncoding. unsigned getRawEncoding() const { return ID; } /// Turn a raw encoding of a SourceLocation object into @@ -190,7 +243,7 @@ }; inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) { - return LHS.getRawEncoding() == RHS.getRawEncoding(); + return LHS.getPOD() == RHS.getPOD(); } inline bool operator!=(const SourceLocation &LHS, const SourceLocation &RHS) { @@ -198,7 +251,7 @@ } inline bool operator<(const SourceLocation &LHS, const SourceLocation &RHS) { - return LHS.getRawEncoding() < RHS.getRawEncoding(); + return LHS.getPOD() < RHS.getPOD(); } /// A trivial tuple used to represent a source range. @@ -437,7 +490,7 @@ friend bool operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS) { - return LHS.getRawEncoding() == RHS.getRawEncoding() && + return LHS.getPOD() == RHS.getPOD() && LHS.SrcMgr == RHS.SrcMgr; } @@ -504,7 +557,7 @@ } static clang::SourceLocation getFromVoidPointer(void *P) { - return clang::SourceLocation::getFromRawEncoding((unsigned)(uintptr_t)P); + return clang::SourceLocation::getFromPtrEncoding(P); } }; Index: clang/include/clang/Basic/SourceManager.h =================================================================== --- clang/include/clang/Basic/SourceManager.h +++ clang/include/clang/Basic/SourceManager.h @@ -254,7 +254,7 @@ /// The location of the \#include that brought in this file. /// /// This is an invalid SLOC for the main file (top of the \#include chain). - unsigned IncludeLoc; // Really a SourceLocation + PODSourceLocation IncludeLoc; /// Number of FileIDs (files and macros) that were created during /// preprocessing of this \#include, including this SLocEntry. @@ -278,7 +278,7 @@ static FileInfo get(SourceLocation IL, const ContentCache *Con, CharacteristicKind FileCharacter, StringRef Filename) { FileInfo X; - X.IncludeLoc = IL.getRawEncoding(); + X.IncludeLoc = IL.getPOD(); X.NumCreatedFIDs = 0; X.HasLineDirectives = false; X.ContentAndKind.setPointer(Con); @@ -288,7 +288,7 @@ } SourceLocation getIncludeLoc() const { - return SourceLocation::getFromRawEncoding(IncludeLoc); + return SourceLocation::getFromPOD(IncludeLoc); } const ContentCache *getContentCache() const { @@ -318,10 +318,8 @@ /// the token was ultimately expanded, and the SpellingLoc - where the actual /// character data for the token came from. class ExpansionInfo { - // Really these are all SourceLocations. - /// Where the spelling for the token can be found. - unsigned SpellingLoc; + PODSourceLocation SpellingLoc; /// In a macro expansion, ExpansionLocStart and ExpansionLocEnd /// indicate the start and end of the expansion. In object-like macros, @@ -329,24 +327,24 @@ /// will be the identifier and the end will be the ')'. Finally, in /// macro-argument instantiations, the end will be 'SourceLocation()', an /// invalid location. - unsigned ExpansionLocStart, ExpansionLocEnd; + PODSourceLocation ExpansionLocStart, ExpansionLocEnd; /// Whether the expansion range is a token range. bool ExpansionIsTokenRange; public: SourceLocation getSpellingLoc() const { - SourceLocation SpellLoc = SourceLocation::getFromRawEncoding(SpellingLoc); + SourceLocation SpellLoc = SourceLocation::getFromPOD(SpellingLoc); return SpellLoc.isInvalid() ? getExpansionLocStart() : SpellLoc; } SourceLocation getExpansionLocStart() const { - return SourceLocation::getFromRawEncoding(ExpansionLocStart); + return SourceLocation::getFromPOD(ExpansionLocStart); } SourceLocation getExpansionLocEnd() const { SourceLocation EndLoc = - SourceLocation::getFromRawEncoding(ExpansionLocEnd); + SourceLocation::getFromPOD(ExpansionLocEnd); return EndLoc.isInvalid() ? getExpansionLocStart() : EndLoc; } @@ -363,12 +361,12 @@ bool isMacroArgExpansion() const { // Note that this needs to return false for default constructed objects. return getExpansionLocStart().isValid() && - SourceLocation::getFromRawEncoding(ExpansionLocEnd).isInvalid(); + SourceLocation::getFromPOD(ExpansionLocEnd).isInvalid(); } bool isMacroBodyExpansion() const { return getExpansionLocStart().isValid() && - SourceLocation::getFromRawEncoding(ExpansionLocEnd).isValid(); + SourceLocation::getFromPOD(ExpansionLocEnd).isValid(); } bool isFunctionMacroExpansion() const { @@ -386,9 +384,9 @@ SourceLocation Start, SourceLocation End, bool ExpansionIsTokenRange = true) { ExpansionInfo X; - X.SpellingLoc = SpellingLoc.getRawEncoding(); - X.ExpansionLocStart = Start.getRawEncoding(); - X.ExpansionLocEnd = End.getRawEncoding(); + X.SpellingLoc = SpellingLoc.getPOD(); + X.ExpansionLocStart = Start.getPOD(); + X.ExpansionLocEnd = End.getPOD(); X.ExpansionIsTokenRange = ExpansionIsTokenRange; return X; } Index: clang/include/clang/Lex/Token.h =================================================================== --- clang/include/clang/Lex/Token.h +++ clang/include/clang/Lex/Token.h @@ -33,7 +33,7 @@ /// information about the SourceRange of the tokens and the type object. class Token { /// The location of the token. This is actually a SourceLocation. - unsigned Loc; + PODSourceLocation Loc; // Conceptually these next two fields could be in a union. However, this // causes gcc 4.2 to pessimize LexTokenInternal, a very performance critical @@ -43,7 +43,10 @@ /// UintData - This holds either the length of the token text, when /// a normal token, or the end of the SourceRange when an annotation /// token. - unsigned UintData; + union { + PODSourceLocation Loc; + unsigned Len; + } UintData; /// PtrData - This is a union of four different pointer types, which depends /// on what type of token this is: @@ -124,26 +127,27 @@ /// Return a source location identifier for the specified /// offset in the current file. SourceLocation getLocation() const { - return SourceLocation::getFromRawEncoding(Loc); + return SourceLocation::getFromPOD(Loc); } unsigned getLength() const { assert(!isAnnotation() && "Annotation tokens have no length field"); - return UintData; + return UintData.Len; } - void setLocation(SourceLocation L) { Loc = L.getRawEncoding(); } + void setLocation(SourceLocation L) { Loc = L.getPOD(); } void setLength(unsigned Len) { assert(!isAnnotation() && "Annotation tokens have no length field"); - UintData = Len; + UintData.Len = Len; } SourceLocation getAnnotationEndLoc() const { assert(isAnnotation() && "Used AnnotEndLocID on non-annotation token"); - return SourceLocation::getFromRawEncoding(UintData ? UintData : Loc); + return SourceLocation::getFromPOD(UintData.Loc.isValid() ? UintData.Loc + : Loc); } void setAnnotationEndLoc(SourceLocation L) { assert(isAnnotation() && "Used AnnotEndLocID on non-annotation token"); - UintData = L.getRawEncoding(); + UintData.Loc = L.getPOD(); } SourceLocation getLastLoc() const { @@ -172,8 +176,8 @@ Kind = tok::unknown; Flags = 0; PtrData = nullptr; - UintData = 0; - Loc = SourceLocation().getRawEncoding(); + UintData.Len = 0; + Loc = SourceLocation().getPOD(); } IdentifierInfo *getIdentifierInfo() const { Index: clang/include/clang/Sema/DeclSpec.h =================================================================== --- clang/include/clang/Sema/DeclSpec.h +++ clang/include/clang/Sema/DeclSpec.h @@ -961,7 +961,7 @@ /// Different operators have different numbers of tokens in their name, /// up to three. Any remaining source locations in this array will be /// set to an invalid value for operators with fewer than three tokens. - unsigned SymbolLocations[3]; + PODSourceLocation SymbolLocations[3]; }; /// Anonymous union that holds extra data associated with the @@ -1178,19 +1178,19 @@ unsigned TypeQuals : 5; /// The location of the const-qualifier, if any. - unsigned ConstQualLoc; + PODSourceLocation ConstQualLoc; /// The location of the volatile-qualifier, if any. - unsigned VolatileQualLoc; + PODSourceLocation VolatileQualLoc; /// The location of the restrict-qualifier, if any. - unsigned RestrictQualLoc; + PODSourceLocation RestrictQualLoc; /// The location of the _Atomic-qualifier, if any. - unsigned AtomicQualLoc; + PODSourceLocation AtomicQualLoc; /// The location of the __unaligned-qualifier, if any. - unsigned UnalignedQualLoc; + PODSourceLocation UnalignedQualLoc; void destroy() { } @@ -1285,13 +1285,13 @@ unsigned HasTrailingReturnType : 1; /// The location of the left parenthesis in the source. - unsigned LParenLoc; + PODSourceLocation LParenLoc; /// When isVariadic is true, the location of the ellipsis in the source. - unsigned EllipsisLoc; + PODSourceLocation EllipsisLoc; /// The location of the right parenthesis in the source. - unsigned RParenLoc; + PODSourceLocation RParenLoc; /// NumParams - This is the number of formal parameters specified by the /// declarator. @@ -1305,17 +1305,17 @@ /// The location of the ref-qualifier, if any. /// /// If this is an invalid location, there is no ref-qualifier. - unsigned RefQualifierLoc; + PODSourceLocation RefQualifierLoc; /// The location of the 'mutable' qualifer in a lambda-declarator, if /// any. - unsigned MutableLoc; + PODSourceLocation MutableLoc; /// The beginning location of the exception specification, if any. - unsigned ExceptionSpecLocBeg; + PODSourceLocation ExceptionSpecLocBeg; /// The end location of the exception specification, if any. - unsigned ExceptionSpecLocEnd; + PODSourceLocation ExceptionSpecLocEnd; /// Params - This is a pointer to a new[]'d array of ParamInfo objects that /// describe the parameters specified by this function declarator. null if @@ -1399,23 +1399,23 @@ bool isKNRPrototype() const { return !hasPrototype && NumParams != 0; } SourceLocation getLParenLoc() const { - return SourceLocation::getFromRawEncoding(LParenLoc); + return SourceLocation::getFromPOD(LParenLoc); } SourceLocation getEllipsisLoc() const { - return SourceLocation::getFromRawEncoding(EllipsisLoc); + return SourceLocation::getFromPOD(EllipsisLoc); } SourceLocation getRParenLoc() const { - return SourceLocation::getFromRawEncoding(RParenLoc); + return SourceLocation::getFromPOD(RParenLoc); } SourceLocation getExceptionSpecLocBeg() const { - return SourceLocation::getFromRawEncoding(ExceptionSpecLocBeg); + return SourceLocation::getFromPOD(ExceptionSpecLocBeg); } SourceLocation getExceptionSpecLocEnd() const { - return SourceLocation::getFromRawEncoding(ExceptionSpecLocEnd); + return SourceLocation::getFromPOD(ExceptionSpecLocEnd); } SourceRange getExceptionSpecRange() const { @@ -1424,7 +1424,7 @@ /// Retrieve the location of the ref-qualifier, if any. SourceLocation getRefQualifierLoc() const { - return SourceLocation::getFromRawEncoding(RefQualifierLoc); + return SourceLocation::getFromPOD(RefQualifierLoc); } /// Retrieve the location of the 'const' qualifier. @@ -1447,7 +1447,7 @@ /// Retrieve the location of the 'mutable' qualifier, if any. SourceLocation getMutableLoc() const { - return SourceLocation::getFromRawEncoding(MutableLoc); + return SourceLocation::getFromPOD(MutableLoc); } /// Determine whether this function declaration contains a @@ -1562,11 +1562,11 @@ I.Kind = Pointer; I.Loc = Loc; I.Ptr.TypeQuals = TypeQuals; - I.Ptr.ConstQualLoc = ConstQualLoc.getRawEncoding(); - I.Ptr.VolatileQualLoc = VolatileQualLoc.getRawEncoding(); - I.Ptr.RestrictQualLoc = RestrictQualLoc.getRawEncoding(); - I.Ptr.AtomicQualLoc = AtomicQualLoc.getRawEncoding(); - I.Ptr.UnalignedQualLoc = UnalignedQualLoc.getRawEncoding(); + I.Ptr.ConstQualLoc = ConstQualLoc.getPOD(); + I.Ptr.VolatileQualLoc = VolatileQualLoc.getPOD(); + I.Ptr.RestrictQualLoc = RestrictQualLoc.getPOD(); + I.Ptr.AtomicQualLoc = AtomicQualLoc.getPOD(); + I.Ptr.UnalignedQualLoc = UnalignedQualLoc.getPOD(); return I; } Index: clang/include/clang/Sema/Designator.h =================================================================== --- clang/include/clang/Sema/Designator.h +++ clang/include/clang/Sema/Designator.h @@ -43,18 +43,18 @@ struct FieldDesignatorInfo { const IdentifierInfo *II; - unsigned DotLoc; - unsigned NameLoc; + PODSourceLocation DotLoc; + PODSourceLocation NameLoc; }; struct ArrayDesignatorInfo { Expr *Index; - unsigned LBracketLoc; - mutable unsigned RBracketLoc; + PODSourceLocation LBracketLoc; + mutable PODSourceLocation RBracketLoc; }; struct ArrayRangeDesignatorInfo { Expr *Start, *End; - unsigned LBracketLoc, EllipsisLoc; - mutable unsigned RBracketLoc; + PODSourceLocation LBracketLoc, EllipsisLoc; + mutable PODSourceLocation RBracketLoc; }; union { @@ -77,12 +77,12 @@ SourceLocation getDotLoc() const { assert(isFieldDesignator() && "Invalid accessor"); - return SourceLocation::getFromRawEncoding(FieldInfo.DotLoc); + return SourceLocation::getFromPOD(FieldInfo.DotLoc); } SourceLocation getFieldLoc() const { assert(isFieldDesignator() && "Invalid accessor"); - return SourceLocation::getFromRawEncoding(FieldInfo.NameLoc); + return SourceLocation::getFromPOD(FieldInfo.NameLoc); } Expr *getArrayIndex() const { @@ -103,23 +103,23 @@ assert((isArrayDesignator() || isArrayRangeDesignator()) && "Invalid accessor"); if (isArrayDesignator()) - return SourceLocation::getFromRawEncoding(ArrayInfo.LBracketLoc); + return SourceLocation::getFromPOD(ArrayInfo.LBracketLoc); else - return SourceLocation::getFromRawEncoding(ArrayRangeInfo.LBracketLoc); + return SourceLocation::getFromPOD(ArrayRangeInfo.LBracketLoc); } SourceLocation getRBracketLoc() const { assert((isArrayDesignator() || isArrayRangeDesignator()) && "Invalid accessor"); if (isArrayDesignator()) - return SourceLocation::getFromRawEncoding(ArrayInfo.RBracketLoc); + return SourceLocation::getFromPOD(ArrayInfo.RBracketLoc); else - return SourceLocation::getFromRawEncoding(ArrayRangeInfo.RBracketLoc); + return SourceLocation::getFromPOD(ArrayRangeInfo.RBracketLoc); } SourceLocation getEllipsisLoc() const { assert(isArrayRangeDesignator() && "Invalid accessor"); - return SourceLocation::getFromRawEncoding(ArrayRangeInfo.EllipsisLoc); + return SourceLocation::getFromPOD(ArrayRangeInfo.EllipsisLoc); } static Designator getField(const IdentifierInfo *II, SourceLocation DotLoc, @@ -127,8 +127,8 @@ Designator D; D.Kind = FieldDesignator; D.FieldInfo.II = II; - D.FieldInfo.DotLoc = DotLoc.getRawEncoding(); - D.FieldInfo.NameLoc = NameLoc.getRawEncoding(); + D.FieldInfo.DotLoc = DotLoc.getPOD(); + D.FieldInfo.NameLoc = NameLoc.getPOD(); return D; } @@ -137,8 +137,8 @@ Designator D; D.Kind = ArrayDesignator; D.ArrayInfo.Index = Index; - D.ArrayInfo.LBracketLoc = LBracketLoc.getRawEncoding(); - D.ArrayInfo.RBracketLoc = 0; + D.ArrayInfo.LBracketLoc = LBracketLoc.getPOD(); + D.ArrayInfo.RBracketLoc.clear(); return D; } @@ -150,9 +150,9 @@ D.Kind = ArrayRangeDesignator; D.ArrayRangeInfo.Start = Start; D.ArrayRangeInfo.End = End; - D.ArrayRangeInfo.LBracketLoc = LBracketLoc.getRawEncoding(); - D.ArrayRangeInfo.EllipsisLoc = EllipsisLoc.getRawEncoding(); - D.ArrayRangeInfo.RBracketLoc = 0; + D.ArrayRangeInfo.LBracketLoc = LBracketLoc.getPOD(); + D.ArrayRangeInfo.EllipsisLoc = EllipsisLoc.getPOD(); + D.ArrayRangeInfo.RBracketLoc.clear(); return D; } @@ -160,9 +160,9 @@ assert((isArrayDesignator() || isArrayRangeDesignator()) && "Invalid accessor"); if (isArrayDesignator()) - ArrayInfo.RBracketLoc = RBracketLoc.getRawEncoding(); + ArrayInfo.RBracketLoc = RBracketLoc.getPOD(); else - ArrayRangeInfo.RBracketLoc = RBracketLoc.getRawEncoding(); + ArrayRangeInfo.RBracketLoc = RBracketLoc.getPOD(); } /// ClearExprs - Null out any expression references, which prevents Index: clang/include/clang/Sema/Initialization.h =================================================================== --- clang/include/clang/Sema/Initialization.h +++ clang/include/clang/Sema/Initialization.h @@ -145,7 +145,7 @@ /// location of the 'return', 'throw', or 'new' keyword, /// respectively. When Kind == EK_Temporary, the location where /// the temporary is being created. - unsigned Location; + PODSourceLocation Location; /// Whether the entity being initialized may end up using the /// named return value optimization (NRVO). @@ -171,7 +171,7 @@ IdentifierInfo *VarID; /// The source location at which the capture occurs. - unsigned Location; + PODSourceLocation Location; }; union { @@ -217,7 +217,7 @@ InitializedEntity(EntityKind Kind, SourceLocation Loc, QualType Type, bool NRVO = false) : Kind(Kind), Type(Type) { - LocAndNRVO.Location = Loc.getRawEncoding(); + LocAndNRVO.Location = Loc.getPOD(); LocAndNRVO.NRVO = NRVO; } @@ -235,7 +235,7 @@ InitializedEntity(IdentifierInfo *VarID, QualType FieldType, SourceLocation Loc) : Kind(EK_LambdaCapture), Type(FieldType) { Capture.VarID = VarID; - Capture.Location = Loc.getRawEncoding(); + Capture.Location = Loc.getPOD(); } public: @@ -482,14 +482,14 @@ /// the result of a function call. SourceLocation getReturnLoc() const { assert(getKind() == EK_Result && "No 'return' location!"); - return SourceLocation::getFromRawEncoding(LocAndNRVO.Location); + return SourceLocation::getFromPOD(LocAndNRVO.Location); } /// Determine the location of the 'throw' keyword when initializing /// an exception object. SourceLocation getThrowLoc() const { assert(getKind() == EK_Exception && "No 'throw' location!"); - return SourceLocation::getFromRawEncoding(LocAndNRVO.Location); + return SourceLocation::getFromPOD(LocAndNRVO.Location); } /// If this is an array, vector, or complex number element, get the @@ -518,7 +518,7 @@ /// field from a captured variable in a lambda. SourceLocation getCaptureLoc() const { assert(getKind() == EK_LambdaCapture && "Not a lambda capture!"); - return SourceLocation::getFromRawEncoding(Capture.Location); + return SourceLocation::getFromPOD(Capture.Location); } void setParameterCFAudited() { Index: clang/include/clang/Serialization/ASTBitCodes.h =================================================================== --- clang/include/clang/Serialization/ASTBitCodes.h +++ clang/include/clang/Serialization/ASTBitCodes.h @@ -175,65 +175,65 @@ /// Source range/offset of a preprocessed entity. struct PPEntityOffset { - /// Raw source location of beginning of range. - unsigned Begin; + /// Source location of beginning of range. + PODSourceLocation Begin; - /// Raw source location of end of range. - unsigned End; + /// Source location of end of range. + PODSourceLocation End; /// Offset in the AST file. uint32_t BitOffset; PPEntityOffset(SourceRange R, uint32_t BitOffset) - : Begin(R.getBegin().getRawEncoding()), - End(R.getEnd().getRawEncoding()), BitOffset(BitOffset) {} + : Begin(R.getBegin().getPOD()), + End(R.getEnd().getPOD()), BitOffset(BitOffset) {} SourceLocation getBegin() const { - return SourceLocation::getFromRawEncoding(Begin); + return SourceLocation::getFromPOD(Begin); } SourceLocation getEnd() const { - return SourceLocation::getFromRawEncoding(End); + return SourceLocation::getFromPOD(End); } }; /// Source range of a skipped preprocessor region struct PPSkippedRange { - /// Raw source location of beginning of range. - unsigned Begin; - /// Raw source location of end of range. - unsigned End; + /// Source location of beginning of range. + PODSourceLocation Begin; + /// Source location of end of range. + PODSourceLocation End; PPSkippedRange(SourceRange R) - : Begin(R.getBegin().getRawEncoding()), - End(R.getEnd().getRawEncoding()) { } + : Begin(R.getBegin().getPOD()), + End(R.getEnd().getPOD()) { } SourceLocation getBegin() const { - return SourceLocation::getFromRawEncoding(Begin); + return SourceLocation::getFromPOD(Begin); } SourceLocation getEnd() const { - return SourceLocation::getFromRawEncoding(End); + return SourceLocation::getFromPOD(End); } }; /// Source range/offset of a preprocessed entity. struct DeclOffset { - /// Raw source location. - unsigned Loc = 0; + /// Source location. + PODSourceLocation Loc = {}; /// Offset in the AST file. uint32_t BitOffset = 0; DeclOffset() = default; DeclOffset(SourceLocation Loc, uint32_t BitOffset) - : Loc(Loc.getRawEncoding()), BitOffset(BitOffset) {} + : Loc(Loc.getPOD()), BitOffset(BitOffset) {} void setLocation(SourceLocation L) { - Loc = L.getRawEncoding(); + Loc = L.getPOD(); } SourceLocation getLocation() const { - return SourceLocation::getFromRawEncoding(Loc); + return SourceLocation::getFromPOD(Loc); } }; Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -5361,8 +5361,8 @@ DName = DeclarationNames.getCXXOperatorName(DTN->getOperator()); // DNInfo work in progress: FIXME: source locations? DeclarationNameLoc DNLoc; - DNLoc.CXXOperatorName.BeginOpNameLoc = SourceLocation().getRawEncoding(); - DNLoc.CXXOperatorName.EndOpNameLoc = SourceLocation().getRawEncoding(); + DNLoc.CXXOperatorName.BeginOpNameLoc = SourceLocation().getPOD(); + DNLoc.CXXOperatorName.EndOpNameLoc = SourceLocation().getPOD(); return DeclarationNameInfo(DName, NameLoc, DNLoc); } } Index: clang/lib/AST/DeclObjC.cpp =================================================================== --- clang/lib/AST/DeclObjC.cpp +++ clang/lib/AST/DeclObjC.cpp @@ -1425,8 +1425,8 @@ ArrayRef typeParams, SourceLocation rAngleLoc) : NumParams(typeParams.size()) { - Brackets.Begin = lAngleLoc.getRawEncoding(); - Brackets.End = rAngleLoc.getRawEncoding(); + Brackets.Begin = lAngleLoc.getPOD(); + Brackets.End = rAngleLoc.getPOD(); std::copy(typeParams.begin(), typeParams.end(), begin()); } Index: clang/lib/AST/DeclarationName.cpp =================================================================== --- clang/lib/AST/DeclarationName.cpp +++ clang/lib/AST/DeclarationName.cpp @@ -382,11 +382,11 @@ NamedType.TInfo = nullptr; break; case DeclarationName::CXXOperatorName: - CXXOperatorName.BeginOpNameLoc = SourceLocation().getRawEncoding(); - CXXOperatorName.EndOpNameLoc = SourceLocation().getRawEncoding(); + CXXOperatorName.BeginOpNameLoc = SourceLocation().getPOD(); + CXXOperatorName.EndOpNameLoc = SourceLocation().getPOD(); break; case DeclarationName::CXXLiteralOperatorName: - CXXLiteralOperatorName.OpNameLoc = SourceLocation().getRawEncoding(); + CXXLiteralOperatorName.OpNameLoc = SourceLocation().getPOD(); break; case DeclarationName::ObjCZeroArgSelector: case DeclarationName::ObjCOneArgSelector: @@ -492,13 +492,13 @@ return NameLoc; case DeclarationName::CXXOperatorName: { - unsigned raw = LocInfo.CXXOperatorName.EndOpNameLoc; - return SourceLocation::getFromRawEncoding(raw); + PODSourceLocation raw = LocInfo.CXXOperatorName.EndOpNameLoc; + return SourceLocation::getFromPOD(raw); } case DeclarationName::CXXLiteralOperatorName: { - unsigned raw = LocInfo.CXXLiteralOperatorName.OpNameLoc; - return SourceLocation::getFromRawEncoding(raw); + PODSourceLocation raw = LocInfo.CXXLiteralOperatorName.OpNameLoc; + return SourceLocation::getFromPOD(raw); } case DeclarationName::CXXConstructorName: Index: clang/lib/AST/Expr.cpp =================================================================== --- clang/lib/AST/Expr.cpp +++ clang/lib/AST/Expr.cpp @@ -4338,12 +4338,12 @@ Designator &First = *DIE->getDesignator(0); if (First.isFieldDesignator()) { if (GNUSyntax) - StartLoc = SourceLocation::getFromRawEncoding(First.Field.FieldLoc); + StartLoc = SourceLocation::getFromPOD(First.Field.FieldLoc); else - StartLoc = SourceLocation::getFromRawEncoding(First.Field.DotLoc); + StartLoc = SourceLocation::getFromPOD(First.Field.DotLoc); } else StartLoc = - SourceLocation::getFromRawEncoding(First.ArrayOrRange.LBracketLoc); + SourceLocation::getFromPOD(First.ArrayOrRange.LBracketLoc); return StartLoc; } Index: clang/lib/AST/NestedNameSpecifier.cpp =================================================================== --- clang/lib/AST/NestedNameSpecifier.cpp +++ clang/lib/AST/NestedNameSpecifier.cpp @@ -405,9 +405,9 @@ /// Load a (possibly unaligned) source location from a given address /// and offset. static SourceLocation LoadSourceLocation(void *Data, unsigned Offset) { - unsigned Raw; - memcpy(&Raw, static_cast(Data) + Offset, sizeof(unsigned)); - return SourceLocation::getFromRawEncoding(Raw); + PODSourceLocation Raw; + memcpy(&Raw, static_cast(Data) + Offset, sizeof(PODSourceLocation)); + return SourceLocation::getFromPOD(Raw); } /// Load a (possibly unaligned) pointer from a given address and @@ -497,9 +497,9 @@ /// Save a source location to the given buffer. static void SaveSourceLocation(SourceLocation Loc, char *&Buffer, unsigned &BufferSize, unsigned &BufferCapacity) { - unsigned Raw = Loc.getRawEncoding(); + PODSourceLocation Raw = Loc.getPOD(); Append(reinterpret_cast(&Raw), - reinterpret_cast(&Raw) + sizeof(unsigned), + reinterpret_cast(&Raw) + sizeof(PODSourceLocation), Buffer, BufferSize, BufferCapacity); } Index: clang/lib/Lex/ModuleMap.cpp =================================================================== --- clang/lib/Lex/ModuleMap.cpp +++ clang/lib/Lex/ModuleMap.cpp @@ -1344,7 +1344,7 @@ RSquare } Kind; - unsigned Location; + PODSourceLocation Location; unsigned StringLength; union { // If Kind != IntegerLiteral. @@ -1356,7 +1356,7 @@ void clear() { Kind = EndOfFile; - Location = 0; + Location.clear(); StringLength = 0; StringData = nullptr; } @@ -1364,7 +1364,7 @@ bool is(TokenKind K) const { return Kind == K; } SourceLocation getLocation() const { - return SourceLocation::getFromRawEncoding(Location); + return SourceLocation::getFromPOD(Location); } uint64_t getInteger() const { @@ -1485,7 +1485,7 @@ Tok.clear(); Token LToken; L.LexFromRawLexer(LToken); - Tok.Location = LToken.getLocation().getRawEncoding(); + Tok.Location = LToken.getLocation().getPOD(); switch (LToken.getKind()) { case tok::raw_identifier: { StringRef RI = LToken.getRawIdentifier(); Index: clang/lib/Parse/ParseDeclCXX.cpp =================================================================== --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -2407,7 +2407,7 @@ const char *Name = (RefQualifierIsLValueRef ? "& " : "&& "); FixItHint Insertion = FixItHint::CreateInsertion(VS.getFirstLocation(), Name); Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef; - Function.RefQualifierLoc = RefQualifierLoc.getRawEncoding(); + Function.RefQualifierLoc = RefQualifierLoc.getPOD(); Diag(RefQualifierLoc, diag::err_declspec_after_virtspec) << (RefQualifierIsLValueRef ? "&" : "&&") Index: clang/lib/Sema/DeclSpec.cpp =================================================================== --- clang/lib/Sema/DeclSpec.cpp +++ clang/lib/Sema/DeclSpec.cpp @@ -183,18 +183,18 @@ I.Fun.hasPrototype = hasProto; I.Fun.isVariadic = EllipsisLoc.isValid(); I.Fun.isAmbiguous = isAmbiguous; - I.Fun.LParenLoc = LParenLoc.getRawEncoding(); - I.Fun.EllipsisLoc = EllipsisLoc.getRawEncoding(); - I.Fun.RParenLoc = RParenLoc.getRawEncoding(); + I.Fun.LParenLoc = LParenLoc.getPOD(); + I.Fun.EllipsisLoc = EllipsisLoc.getPOD(); + I.Fun.RParenLoc = RParenLoc.getPOD(); I.Fun.DeleteParams = false; I.Fun.NumParams = NumParams; I.Fun.Params = nullptr; I.Fun.RefQualifierIsLValueRef = RefQualifierIsLvalueRef; - I.Fun.RefQualifierLoc = RefQualifierLoc.getRawEncoding(); - I.Fun.MutableLoc = MutableLoc.getRawEncoding(); + I.Fun.RefQualifierLoc = RefQualifierLoc.getPOD(); + I.Fun.MutableLoc = MutableLoc.getPOD(); I.Fun.ExceptionSpecType = ESpecType; - I.Fun.ExceptionSpecLocBeg = ESpecRange.getBegin().getRawEncoding(); - I.Fun.ExceptionSpecLocEnd = ESpecRange.getEnd().getRawEncoding(); + I.Fun.ExceptionSpecLocBeg = ESpecRange.getBegin().getPOD(); + I.Fun.ExceptionSpecLocEnd = ESpecRange.getEnd().getPOD(); I.Fun.NumExceptionsOrDecls = 0; I.Fun.Exceptions = nullptr; I.Fun.NoexceptExpr = nullptr; @@ -1373,7 +1373,7 @@ EndLocation = OperatorLoc; OperatorFunctionId.Operator = Op; for (unsigned I = 0; I != 3; ++I) { - OperatorFunctionId.SymbolLocations[I] = SymbolLocations[I].getRawEncoding(); + OperatorFunctionId.SymbolLocations[I] = SymbolLocations[I].getPOD(); if (SymbolLocations[I].isValid()) EndLocation = SymbolLocations[I]; Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -434,8 +434,8 @@ if (isa(*Res) || isa(*Res) || (AllowDeducedTemplate && getAsTypeTemplateDecl(*Res))) { if (!IIDecl || - (*Res)->getLocation().getRawEncoding() < - IIDecl->getLocation().getRawEncoding()) + (*Res)->getLocation().getPOD() < + IIDecl->getLocation().getPOD()) IIDecl = *Res; } } @@ -5179,7 +5179,7 @@ NameInfo.getInfo().CXXOperatorName.BeginOpNameLoc = Name.OperatorFunctionId.SymbolLocations[0]; NameInfo.getInfo().CXXOperatorName.EndOpNameLoc - = Name.EndLocation.getRawEncoding(); + = Name.EndLocation.getPOD(); return NameInfo; case UnqualifiedIdKind::IK_LiteralOperatorId: Index: clang/lib/Sema/SemaLambda.cpp =================================================================== --- clang/lib/Sema/SemaLambda.cpp +++ clang/lib/Sema/SemaLambda.cpp @@ -387,9 +387,9 @@ = Context.DeclarationNames.getCXXOperatorName(OO_Call); DeclarationNameLoc MethodNameLoc; MethodNameLoc.CXXOperatorName.BeginOpNameLoc - = IntroducerRange.getBegin().getRawEncoding(); + = IntroducerRange.getBegin().getPOD(); MethodNameLoc.CXXOperatorName.EndOpNameLoc - = IntroducerRange.getEnd().getRawEncoding(); + = IntroducerRange.getEnd().getPOD(); CXXMethodDecl *Method = CXXMethodDecl::Create( Context, Class, EndLoc, DeclarationNameInfo(MethodName, IntroducerRange.getBegin(), Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -2855,11 +2855,11 @@ diag::warn_qual_return_type, PTI.TypeQuals, SourceLocation(), - SourceLocation::getFromRawEncoding(PTI.ConstQualLoc), - SourceLocation::getFromRawEncoding(PTI.VolatileQualLoc), - SourceLocation::getFromRawEncoding(PTI.RestrictQualLoc), - SourceLocation::getFromRawEncoding(PTI.AtomicQualLoc), - SourceLocation::getFromRawEncoding(PTI.UnalignedQualLoc)); + SourceLocation::getFromPOD(PTI.ConstQualLoc), + SourceLocation::getFromPOD(PTI.VolatileQualLoc), + SourceLocation::getFromPOD(PTI.RestrictQualLoc), + SourceLocation::getFromPOD(PTI.AtomicQualLoc), + SourceLocation::getFromPOD(PTI.UnalignedQualLoc)); return; } @@ -5728,7 +5728,7 @@ llvm_unreachable("cannot be _Atomic qualified"); case DeclaratorChunk::Pointer: - Loc = SourceLocation::getFromRawEncoding(Chunk.Ptr.AtomicQualLoc); + Loc = SourceLocation::getFromPOD(Chunk.Ptr.AtomicQualLoc); break; case DeclaratorChunk::BlockPointer: Index: clang/lib/Sema/TreeTransform.h =================================================================== --- clang/lib/Sema/TreeTransform.h +++ clang/lib/Sema/TreeTransform.h @@ -13298,9 +13298,9 @@ if (DeclRefExpr *DRE = dyn_cast(Callee)) { DeclarationNameLoc NameLoc = DRE->getNameInfo().getInfo(); - LBrace = SourceLocation::getFromRawEncoding( + LBrace = SourceLocation::getFromPOD( NameLoc.CXXOperatorName.BeginOpNameLoc); - RBrace = SourceLocation::getFromRawEncoding( + RBrace = SourceLocation::getFromPOD( NameLoc.CXXOperatorName.EndOpNameLoc); } else { LBrace = Callee->getBeginLoc(); Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -9170,14 +9170,14 @@ case DeclarationName::CXXOperatorName: DNLoc.CXXOperatorName.BeginOpNameLoc - = ReadSourceLocation(F, Record, Idx).getRawEncoding(); + = ReadSourceLocation(F, Record, Idx).getPOD(); DNLoc.CXXOperatorName.EndOpNameLoc - = ReadSourceLocation(F, Record, Idx).getRawEncoding(); + = ReadSourceLocation(F, Record, Idx).getPOD(); break; case DeclarationName::CXXLiteralOperatorName: DNLoc.CXXLiteralOperatorName.OpNameLoc - = ReadSourceLocation(F, Record, Idx).getRawEncoding(); + = ReadSourceLocation(F, Record, Idx).getPOD(); break; case DeclarationName::Identifier: Index: clang/lib/Serialization/ASTWriter.cpp =================================================================== --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -5831,14 +5831,14 @@ break; case DeclarationName::CXXOperatorName: - AddSourceLocation(SourceLocation::getFromRawEncoding( + AddSourceLocation(SourceLocation::getFromPOD( DNLoc.CXXOperatorName.BeginOpNameLoc)); AddSourceLocation( - SourceLocation::getFromRawEncoding(DNLoc.CXXOperatorName.EndOpNameLoc)); + SourceLocation::getFromPOD(DNLoc.CXXOperatorName.EndOpNameLoc)); break; case DeclarationName::CXXLiteralOperatorName: - AddSourceLocation(SourceLocation::getFromRawEncoding( + AddSourceLocation(SourceLocation::getFromPOD( DNLoc.CXXLiteralOperatorName.OpNameLoc)); break; Index: clang/tools/clang-refactor/TestSupport.cpp =================================================================== --- clang/tools/clang-refactor/TestSupport.cpp +++ clang/tools/clang-refactor/TestSupport.cpp @@ -312,7 +312,9 @@ LangOptions LangOpts; LangOpts.CPlusPlus = 1; LangOpts.CPlusPlus11 = 1; - Lexer Lex(SourceLocation::getFromRawEncoding(0), LangOpts, Source.begin(), + PODSourceLocation BeginLoc; + BeginLoc.clear(); + Lexer Lex(SourceLocation::getFromPOD(BeginLoc), LangOpts, Source.begin(), Source.begin(), Source.end()); Lex.SetCommentRetentionState(true); Token Tok; Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -3251,9 +3251,9 @@ Pieces.push_back(*TemplateArgsLoc); if (Kind == DeclarationName::CXXOperatorName) { - Pieces.push_back(SourceLocation::getFromRawEncoding( + Pieces.push_back(SourceLocation::getFromPOD( NI.getInfo().CXXOperatorName.BeginOpNameLoc)); - Pieces.push_back(SourceLocation::getFromRawEncoding( + Pieces.push_back(SourceLocation::getFromPOD( NI.getInfo().CXXOperatorName.EndOpNameLoc)); }