Skip to content

Commit

Permalink
[SemaExprCXX] Avoid calling isInSystemHeader for invalid source locat…
Browse files Browse the repository at this point in the history
…ions

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
  • Loading branch information
labath committed Mar 4, 2016
1 parent c5b1d32 commit a174d87
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaExprCXX.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit a174d87

Please sign in to comment.