r338301 - Avoid returning an invalid end source loc

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 6 19:23:04 PDT 2018


test case?

On Mon, Jul 30, 2018 at 1:39 PM Stephen Kelly via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: steveire
> Date: Mon Jul 30 13:39:14 2018
> New Revision: 338301
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338301&view=rev
> Log:
> Avoid returning an invalid end source loc
>
> Modified:
>     cfe/trunk/include/clang/AST/DeclarationName.h
>     cfe/trunk/lib/AST/DeclarationName.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclarationName.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=338301&r1=338300&r2=338301&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/AST/DeclarationName.h (original)
> +++ cfe/trunk/include/clang/AST/DeclarationName.h Mon Jul 30 13:39:14 2018
> @@ -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
>
> Modified: cfe/trunk/lib/AST/DeclarationName.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=338301&r1=338300&r2=338301&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/AST/DeclarationName.cpp (original)
> +++ cfe/trunk/lib/AST/DeclarationName.cpp Mon Jul 30 13:39:14 2018
> @@ -689,7 +689,7 @@ void DeclarationNameInfo::printName(raw_
>    llvm_unreachable("Unexpected declaration name kind");
>  }
>
> -SourceLocation DeclarationNameInfo::getEndLoc() const {
> +SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
>    switch (Name.getNameKind()) {
>    case DeclarationName::Identifier:
>    case DeclarationName::CXXDeductionGuideName:
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180806/5a78267d/attachment.html>


More information about the cfe-commits mailing list