mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 22:16:05 +00:00
[clang][bytecode][NFC] Minor cleanups (#129553)
Pull local variables in to the closest scope, remove some unnecessary calls to getLocation() and remove an outdated comment.
This commit is contained in:
parent
3aab3fe56f
commit
82d111e820
@ -551,8 +551,8 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
|
||||
|
||||
if (const auto *VD = Ptr.getDeclDesc()->asVarDecl();
|
||||
VD && (VD->isConstexpr() || VD->hasGlobalStorage())) {
|
||||
const SourceInfo &Loc = S.Current->getSource(OpPC);
|
||||
if (VD->getAnyInitializer()) {
|
||||
const SourceInfo &Loc = S.Current->getSource(OpPC);
|
||||
S.FFDiag(Loc, diag::note_constexpr_var_init_non_constant, 1) << VD;
|
||||
S.Note(VD->getLocation(), diag::note_declared_at);
|
||||
} else {
|
||||
@ -722,7 +722,6 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
|
||||
if (F->isLambdaStaticInvoker())
|
||||
return true;
|
||||
|
||||
const SourceLocation &Loc = S.Current->getLocation(OpPC);
|
||||
if (S.getLangOpts().CPlusPlus11) {
|
||||
const FunctionDecl *DiagDecl = F->getDecl();
|
||||
|
||||
@ -748,7 +747,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
|
||||
// or an inheriting constructor, we should be much more explicit about why
|
||||
// it's not constexpr.
|
||||
if (CD && CD->isInheritingConstructor()) {
|
||||
S.FFDiag(Loc, diag::note_constexpr_invalid_inhctor, 1)
|
||||
S.FFDiag(S.Current->getLocation(OpPC),
|
||||
diag::note_constexpr_invalid_inhctor, 1)
|
||||
<< CD->getInheritedConstructor().getConstructor()->getParent();
|
||||
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
|
||||
} else {
|
||||
@ -766,7 +766,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
|
||||
DiagDecl->hasBody())
|
||||
return false;
|
||||
|
||||
S.FFDiag(Loc, diag::note_constexpr_invalid_function, 1)
|
||||
S.FFDiag(S.Current->getLocation(OpPC),
|
||||
diag::note_constexpr_invalid_function, 1)
|
||||
<< DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
|
||||
|
||||
if (DiagDecl->getDefinition())
|
||||
@ -776,7 +777,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
|
||||
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
|
||||
}
|
||||
} else {
|
||||
S.FFDiag(Loc, diag::note_invalid_subexpr_in_const_expr);
|
||||
S.FFDiag(S.Current->getLocation(OpPC),
|
||||
diag::note_invalid_subexpr_in_const_expr);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -980,11 +982,6 @@ bool CheckNonNullArgs(InterpState &S, CodePtr OpPC, const Function *F,
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: This is similar to code we already have in Compiler.cpp.
|
||||
// I think it makes sense to instead add the field and base destruction stuff
|
||||
// to the destructor Function itself. Then destroying a record would really
|
||||
// _just_ be calling its destructor. That would also help with the diagnostic
|
||||
// difference when the destructor or a field/base fails.
|
||||
static bool runRecordDestructor(InterpState &S, CodePtr OpPC,
|
||||
const Pointer &BasePtr,
|
||||
const Descriptor *Desc) {
|
||||
@ -1095,8 +1092,8 @@ bool Free(InterpState &S, CodePtr OpPC, bool DeleteIsArrayForm,
|
||||
|
||||
// For a class type with a virtual destructor, the selected operator delete
|
||||
// is the one looked up when building the destructor.
|
||||
QualType AllocType = Ptr.getType();
|
||||
if (!DeleteIsArrayForm && !IsGlobalDelete) {
|
||||
QualType AllocType = Ptr.getType();
|
||||
auto getVirtualOperatorDelete = [](QualType T) -> const FunctionDecl * {
|
||||
if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl())
|
||||
if (const CXXDestructorDecl *DD = RD->getDestructor())
|
||||
|
@ -384,7 +384,6 @@ void Pointer::initialize() const {
|
||||
return;
|
||||
|
||||
assert(PointeeStorage.BS.Pointee && "Cannot initialize null pointer");
|
||||
const Descriptor *Desc = getFieldDesc();
|
||||
|
||||
if (isRoot() && PointeeStorage.BS.Base == sizeof(GlobalInlineDescriptor)) {
|
||||
GlobalInlineDescriptor &GD = *reinterpret_cast<GlobalInlineDescriptor *>(
|
||||
@ -393,6 +392,7 @@ void Pointer::initialize() const {
|
||||
return;
|
||||
}
|
||||
|
||||
const Descriptor *Desc = getFieldDesc();
|
||||
assert(Desc);
|
||||
if (Desc->isPrimitiveArray()) {
|
||||
// Primitive global arrays don't have an initmap.
|
||||
|
Loading…
x
Reference in New Issue
Block a user