diff options
author | Pavel Labath <labath@google.com> | 2016-03-04 10:00:08 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2016-03-04 10:00:08 +0000 |
commit | a174d8709fe7fab8c1275fe3d3310649ab2b46ca (patch) | |
tree | 6044fdaca2a6243b51bb1f5bf4dc95592ed43838 | |
parent | c5b1d320b856559db375e8effc2fe9b04bfaf6ee (diff) | |
download | llvm-a174d8709fe7fab8c1275fe3d3310649ab2b46ca.zip llvm-a174d8709fe7fab8c1275fe3d3310649ab2b46ca.tar.gz llvm-a174d8709fe7fab8c1275fe3d3310649ab2b46ca.tar.bz2 |
[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
llvm-svn: 262700
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 088b0ba..709718f 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/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) |