From e083b17212302c0abb2b08468df7697839c0841f Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 4 Mar 2016 10:00:08 +0000 Subject: [PATCH] [SemaExprCXX] Avoid calling isInSystemHeader for invalid source locations Summary: While diagnosing a CXXNewExpr warning, we were calling isInSystemHeader(), which expect to be called with a valid source location. This causes an assertion failure if the location is unknown. A quick grep shows it's not without precedent to guard calls to the function with a "Loc.isValid()". This fixes a test failure in LLDB, which always creates object with invalid source locations as it does not (always) have access to the source. Reviewers: nlewycky Subscribers: lldb-commits, cfe-commits Differential Revision: http://reviews.llvm.org/D17847 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262700 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 088b0ba423..709718f26c 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1551,7 +1551,8 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, // new. if (PlacementArgs.empty() && OperatorNew && (OperatorNew->isImplicit() || - getSourceManager().isInSystemHeader(OperatorNew->getLocStart()))) { + (OperatorNew->getLocStart().isValid() && + getSourceManager().isInSystemHeader(OperatorNew->getLocStart())))) { if (unsigned Align = Context.getPreferredTypeAlign(AllocType.getTypePtr())){ unsigned SuitableAlign = Context.getTargetInfo().getSuitableAlign(); if (Align > SuitableAlign) -- 2.40.0