Index: include/clang/AST/DeclarationName.h =================================================================== --- include/clang/AST/DeclarationName.h +++ include/clang/AST/DeclarationName.h @@ -562,17 +562,13 @@ /// getSourceRange - The range of the declaration name. SourceRange getSourceRange() const LLVM_READONLY { - return SourceRange(getLocStart(), getLocEnd()); + auto EndLoc = getEndLoc(); + return SourceRange(getLocStart(), EndLoc.isValid() ? EndLoc : getLocStart()); } SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } - - SourceLocation getLocEnd() const LLVM_READONLY { - SourceLocation EndLoc = getEndLoc(); - return EndLoc.isValid() ? EndLoc : getLocStart(); - } }; /// Insertion operator for diagnostics. This allows sending DeclarationName's Index: include/clang/AST/ExprCXX.h =================================================================== --- include/clang/AST/ExprCXX.h +++ include/clang/AST/ExprCXX.h @@ -2828,7 +2828,9 @@ SourceLocation getLocEnd() const LLVM_READONLY { if (hasExplicitTemplateArgs()) return getRAngleLoc(); - return getNameInfo().getLocEnd(); + auto nameInfo = getNameInfo(); + auto endLoc = nameInfo.getEndLoc(); + return endLoc.isValid() ? endLoc : nameInfo.getBeginLoc(); } child_range children() { @@ -3559,7 +3561,10 @@ SourceLocation getLocEnd() const LLVM_READONLY { if (hasExplicitTemplateArgs()) return getRAngleLoc(); - return getMemberNameInfo().getLocEnd(); + + auto nameInfo = getMemberNameInfo(); + auto endLoc = nameInfo.getEndLoc(); + return endLoc.isValid() ? endLoc : nameInfo.getBeginLoc(); } static bool classof(const Stmt *T) {