Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,8 @@ Bug Fixes in This Version
declaration statements. Clang now emits a warning for these patterns. (#GH141659)
- Fixed false positives for redeclaration errors of using enum in
nested scopes. (#GH147495)
- Fixed a failed assertion with an operator call expression which comes from a
macro expansion when performing analysis for nullability attributes. (#GH138371)

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
11 changes: 8 additions & 3 deletions clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -14034,9 +14034,14 @@ TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
if (Object.isInvalid())
return ExprError();

// FIXME: Poor location information
SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(
static_cast<Expr *>(Object.get())->getEndLoc());
// FIXME: Poor location information. Also, if the location for the end of
// the token is within a macro expansion, getLocForEndOfToken() will return
// an invalid source location. If that happens and we have an otherwise
// valid end location, use the valid one instead of the invalid one.
SourceLocation EndLoc = static_cast<Expr *>(Object.get())->getEndLoc();
SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(EndLoc);
if (FakeLParenLoc.isInvalid() && EndLoc.isValid())
FakeLParenLoc = EndLoc;

// Transform the call arguments.
SmallVector<Expr*, 8> Args;
Expand Down
22 changes: 22 additions & 0 deletions clang/test/SemaTemplate/gh138371.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics

// This would previously trigger a failed assertion when instantiating the
// template which uses an overloaded call operator because the end location
// for the expression came from a macro expansion.

#define ASSIGN_OR_RETURN(...) (__VA_ARGS__)

struct Loc {
int operator()(const char* _Nonnull f = __builtin_FILE()) const;
};

template <typename Ty>
void f() {
ASSIGN_OR_RETURN(Loc()());
}

void test() {
f<int>();
}

Loading