Skip to content

Commit 80f470c

Browse files
committed
Revert "[Clang] Fix dependency of SourceLocExpr. (#78436)"
This reverts commit 8c2b0d4.
1 parent 69c77fe commit 80f470c

File tree

5 files changed

+2
-47
lines changed

5 files changed

+2
-47
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,6 @@ Bug Fixes to C++ Support
972972
(`#57410 <https://github.com/llvm/llvm-project/issues/57410>`_) and
973973
(`#76604 <https://github.com/llvm/llvm-project/issues/57410>`_)
974974

975-
- Fix a bug where clang would produce inconsistent values when
976-
``std::source_location::current()`` was used in a function template.
977-
Fixes (`#78128 <https://github.com/llvm/llvm-project/issues/78128>`_)
978-
979975
Bug Fixes to AST Handling
980976
^^^^^^^^^^^^^^^^^^^^^^^^^
981977
- Fixed an import failure of recursive friend class template.

clang/include/clang/AST/Expr.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4808,17 +4808,6 @@ class SourceLocExpr final : public Expr {
48084808
return T->getStmtClass() == SourceLocExprClass;
48094809
}
48104810

4811-
static bool MayBeDependent(SourceLocIdentKind Kind) {
4812-
switch (Kind) {
4813-
case SourceLocIdentKind::Function:
4814-
case SourceLocIdentKind::FuncSig:
4815-
case SourceLocIdentKind::SourceLocStruct:
4816-
return true;
4817-
default:
4818-
return false;
4819-
}
4820-
}
4821-
48224811
private:
48234812
friend class ASTStmtReader;
48244813
};

clang/lib/AST/Expr.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,10 +2274,7 @@ SourceLocExpr::SourceLocExpr(const ASTContext &Ctx, SourceLocIdentKind Kind,
22742274
: Expr(SourceLocExprClass, ResultTy, VK_PRValue, OK_Ordinary),
22752275
BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) {
22762276
SourceLocExprBits.Kind = llvm::to_underlying(Kind);
2277-
// In dependent contexts, function names may change.
2278-
setDependence(MayBeDependent(Kind) && ParentContext->isDependentContext()
2279-
? ExprDependence::Value
2280-
: ExprDependence::None);
2277+
setDependence(ExprDependence::None);
22812278
}
22822279

22832280
StringRef SourceLocExpr::getBuiltinStr() const {

clang/lib/Sema/TreeTransform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12200,7 +12200,7 @@ TreeTransform<Derived>::TransformCXXMemberCallExpr(CXXMemberCallExpr *E) {
1220012200

1220112201
template <typename Derived>
1220212202
ExprResult TreeTransform<Derived>::TransformSourceLocExpr(SourceLocExpr *E) {
12203-
bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
12203+
bool NeedRebuildFunc = E->getIdentKind() == SourceLocIdentKind::Function &&
1220412204
getSema().CurContext != E->getParentContext();
1220512205

1220612206
if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)

clang/test/SemaCXX/source_location.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -805,30 +805,3 @@ static_assert(S(0).j == S{0}.j);
805805
static_assert(S(0).j == S{0}.i);
806806
}
807807
#endif
808-
809-
namespace GH78128 {
810-
811-
template<int N>
812-
constexpr int f() {
813-
return N;
814-
}
815-
816-
template<typename T>
817-
void foo() {
818-
constexpr auto* F1 = std::source_location::current().function();
819-
static_assert(__builtin_strlen(F1) == f<__builtin_strlen(F1)>());
820-
821-
constexpr auto* F2 = __builtin_FUNCTION();
822-
static_assert(__builtin_strlen(F2) == f<__builtin_strlen(F2)>());
823-
824-
#ifdef MS
825-
constexpr auto* F3 = __builtin_FUNCSIG();
826-
static_assert(__builtin_strlen(F3) == f<__builtin_strlen(F3)>());
827-
#endif
828-
}
829-
830-
void test() {
831-
foo<int>();
832-
}
833-
834-
}

0 commit comments

Comments
 (0)