steveire created this revision.
steveire added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.

Note that CXXDependentScopeMemberExpr uses getEndLoc, not getLocEnd,
unlike UnresolvedMemberExpr and UnresolvedLookupExpr (which are changed
by this commit).


Repository:
  rC Clang

https://reviews.llvm.org/D49100

Files:
  include/clang/AST/DeclarationName.h
  include/clang/AST/ExprCXX.h


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) {
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) {
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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to