Skip to content

Commit b5068cb

Browse files
committed
[FOLD] undo changes to FunctionTypeInfo and check hasMethodTypeQualifiers instead
1 parent 6135600 commit b5068cb

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

clang/include/clang/Sema/DeclSpec.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,20 +1527,20 @@ struct DeclaratorChunk {
15271527

15281528
/// Retrieve the location of the 'const' qualifier.
15291529
SourceLocation getConstQualifierLoc() const {
1530-
return MethodQualifiers ? MethodQualifiers->getConstSpecLoc()
1531-
: SourceLocation();
1530+
assert(MethodQualifiers);
1531+
return MethodQualifiers->getConstSpecLoc();
15321532
}
15331533

15341534
/// Retrieve the location of the 'volatile' qualifier.
15351535
SourceLocation getVolatileQualifierLoc() const {
1536-
return MethodQualifiers ? MethodQualifiers->getVolatileSpecLoc()
1537-
: SourceLocation();
1536+
assert(MethodQualifiers);
1537+
return MethodQualifiers->getVolatileSpecLoc();
15381538
}
15391539

15401540
/// Retrieve the location of the 'restrict' qualifier.
15411541
SourceLocation getRestrictQualifierLoc() const {
1542-
return MethodQualifiers ? MethodQualifiers->getRestrictSpecLoc()
1543-
: SourceLocation();
1542+
assert(MethodQualifiers);
1543+
return MethodQualifiers->getRestrictSpecLoc();
15441544
}
15451545

15461546
/// Retrieve the location of the 'mutable' qualifier, if any.

clang/lib/Sema/SemaDecl.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9223,13 +9223,14 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
92239223
if (const auto &FTI = ExtraArgs.D.getFunctionTypeInfo(); !NewFDisConst)
92249224
DB << FixItHint::CreateInsertion(FTI.getRParenLoc().getLocWithOffset(1),
92259225
" const");
9226-
else if (SourceLocation ConstLoc = FTI.getConstQualifierLoc();
9227-
ConstLoc.isValid())
9228-
DB << FixItHint::CreateRemoval(ConstLoc);
9229-
} else
9226+
else if (FTI.hasMethodTypeQualifiers() &&
9227+
FTI.getConstQualifierLoc().isValid())
9228+
DB << FixItHint::CreateRemoval(FTI.getConstQualifierLoc());
9229+
} else {
92309230
SemaRef.Diag(FD->getLocation(),
92319231
IsMember ? diag::note_member_def_close_match
92329232
: diag::note_local_decl_close_match);
9233+
}
92339234
}
92349235
return nullptr;
92359236
}

0 commit comments

Comments
 (0)