Skip to content

Commit 6c1bb48

Browse files
authored
[Clang] Remove workaround for libstdc++4.7 (#139693)
We document libstdc++4.8 as the minimum supported version, and we carried a hack for `include/tr1/hashtable.h` fixed in 4.7. Cleanup some libstdc++ compatibility comments.
1 parent 301340a commit 6c1bb48

File tree

5 files changed

+15
-94
lines changed

5 files changed

+15
-94
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ C++ Specific Potentially Breaking Changes
5858
- The type trait builtin ``__is_referenceable`` has been removed, since it has
5959
very few users and all the type traits that could benefit from it in the
6060
standard library already have their own bespoke builtins.
61+
- A workaround for libstdc++4.7 has been removed. Note that 4.8.3 remains the oldest
62+
supported libstdc++ version.
6163

6264
ABI Changes in This Version
6365
---------------------------

clang/lib/Parse/ParseDecl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3736,13 +3736,14 @@ void Parser::ParseDeclarationSpecifiers(
37363736
}
37373737

37383738
case tok::kw___is_signed:
3739-
// GNU libstdc++ 4.4 uses __is_signed as an identifier, but Clang
3740-
// typically treats it as a trait. If we see __is_signed as it appears
3741-
// in libstdc++, e.g.,
3739+
// HACK: before 2022-12, libstdc++ uses __is_signed as an identifier,
3740+
// but Clang typically treats it as a trait.
3741+
// If we see __is_signed as it appears in libstdc++, e.g.,
37423742
//
37433743
// static const bool __is_signed;
37443744
//
37453745
// then treat __is_signed as an identifier rather than as a keyword.
3746+
// This was fixed by libstdc++ in December 2022.
37463747
if (DS.getTypeSpecType() == TST_bool &&
37473748
DS.getTypeQualifiers() == DeclSpec::TQ_const &&
37483749
DS.getStorageClassSpec() == DeclSpec::SCS_static)

clang/lib/Sema/SemaInit.cpp

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,11 @@ ExprResult InitListChecker::PerformEmptyInit(SourceLocation Loc,
637637
}
638638

639639
InitializationSequence InitSeq(SemaRef, Entity, Kind, SubInit);
640-
// libstdc++4.6 marks the vector default constructor as explicit in
641-
// _GLIBCXX_DEBUG mode, so recover using the C++03 logic in that case.
642-
// stlport does so too. Look for std::__debug for libstdc++, and for
643-
// std:: for stlport. This is effectively a compiler-side implementation of
644-
// LWG2193.
640+
// HACK: libstdc++ prior to 4.9 marks the vector default constructor
641+
// as explicit in _GLIBCXX_DEBUG mode, so recover using the C++03 logic
642+
// in that case. stlport does so too.
643+
// Look for std::__debug for libstdc++, and for std:: for stlport.
644+
// This is effectively a compiler-side implementation of LWG2193.
645645
if (!InitSeq && EmptyInitList && InitSeq.getFailureKind() ==
646646
InitializationSequence::FK_ExplicitConstructor) {
647647
OverloadCandidateSet::iterator Best;
@@ -6240,24 +6240,6 @@ static void TryUserDefinedConversion(Sema &S,
62406240
}
62416241
}
62426242

6243-
/// An egregious hack for compatibility with libstdc++-4.2: in <tr1/hashtable>,
6244-
/// a function with a pointer return type contains a 'return false;' statement.
6245-
/// In C++11, 'false' is not a null pointer, so this breaks the build of any
6246-
/// code using that header.
6247-
///
6248-
/// Work around this by treating 'return false;' as zero-initializing the result
6249-
/// if it's used in a pointer-returning function in a system header.
6250-
static bool isLibstdcxxPointerReturnFalseHack(Sema &S,
6251-
const InitializedEntity &Entity,
6252-
const Expr *Init) {
6253-
return S.getLangOpts().CPlusPlus11 &&
6254-
Entity.getKind() == InitializedEntity::EK_Result &&
6255-
Entity.getType()->isPointerType() &&
6256-
isa<CXXBoolLiteralExpr>(Init) &&
6257-
!cast<CXXBoolLiteralExpr>(Init)->getValue() &&
6258-
S.getSourceManager().isInSystemHeader(Init->getExprLoc());
6259-
}
6260-
62616243
/// The non-zero enum values here are indexes into diagnostic alternatives.
62626244
enum InvalidICRKind { IIK_okay, IIK_nonlocal, IIK_nonscalar };
62636245

@@ -6943,12 +6925,10 @@ void InitializationSequence::InitializeFrom(Sema &S,
69436925

69446926
AddPassByIndirectCopyRestoreStep(DestType, ShouldCopy);
69456927
} else if (ICS.isBad()) {
6946-
if (isLibstdcxxPointerReturnFalseHack(S, Entity, Initializer))
6947-
AddZeroInitializationStep(Entity.getType());
6948-
else if (DeclAccessPair Found;
6949-
Initializer->getType() == Context.OverloadTy &&
6950-
!S.ResolveAddressOfOverloadedFunction(Initializer, DestType,
6951-
/*Complain=*/false, Found))
6928+
if (DeclAccessPair Found;
6929+
Initializer->getType() == Context.OverloadTy &&
6930+
!S.ResolveAddressOfOverloadedFunction(Initializer, DestType,
6931+
/*Complain=*/false, Found))
69526932
SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
69536933
else if (Initializer->getType()->isFunctionType() &&
69546934
isExprAnUnaddressableFunction(S, Initializer))

clang/test/SemaCXX/libstdcxx_gets_hack.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

clang/test/SemaCXX/libstdcxx_pointer_return_false_hack.cpp

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)