]> granicus.if.org Git - clang/commitdiff
Avoid returning an invalid end source loc
authorStephen Kelly <steveire@gmail.com>
Mon, 30 Jul 2018 20:39:14 +0000 (20:39 +0000)
committerStephen Kelly <steveire@gmail.com>
Mon, 30 Jul 2018 20:39:14 +0000 (20:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338301 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclarationName.h
lib/AST/DeclarationName.cpp

index c9adcbbcde8504fff1a7ec9f237e2913f18f1d1a..856f3ab5720e3b59c4e5a69d1c0be8cacb0030bc 100644 (file)
@@ -558,7 +558,7 @@ public:
   SourceLocation getBeginLoc() const { return NameLoc; }
 
   /// getEndLoc - Retrieve the location of the last token.
-  SourceLocation getEndLoc() const;
+  SourceLocation getEndLoc() const { return getLocEnd(); }
 
   /// getSourceRange - The range of the declaration name.
   SourceRange getSourceRange() const LLVM_READONLY {
@@ -570,9 +570,11 @@ public:
   }
 
   SourceLocation getLocEnd() const LLVM_READONLY {
-    SourceLocation EndLoc = getEndLoc();
+    SourceLocation EndLoc = getEndLocPrivate();
     return EndLoc.isValid() ? EndLoc : getLocStart();
   }
+private:
+  SourceLocation getEndLocPrivate() const;
 };
 
 /// Insertion operator for diagnostics.  This allows sending DeclarationName's
index 78c4b9707efb3879349309e44f4a76be76e15db9..9866d92f61eb44e3dbd02f92d5dd5c24985c3f7e 100644 (file)
@@ -689,7 +689,7 @@ void DeclarationNameInfo::printName(raw_ostream &OS) const {
   llvm_unreachable("Unexpected declaration name kind");
 }
 
-SourceLocation DeclarationNameInfo::getEndLoc() const {
+SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
   switch (Name.getNameKind()) {
   case DeclarationName::Identifier:
   case DeclarationName::CXXDeductionGuideName: