Skip to content

Fix llvm assertions v2 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions clang-tools-extra/clang-doc/Representation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ bool Reference::mergeable(const Reference &Other) {
}

void Reference::merge(Reference &&Other) {
assert(mergeable(Other));
assert_DISABLED(mergeable(Other));
if (Name.empty())
Name = Other.Name;
if (Path.empty())
Path = Other.Path;
}

void Info::mergeBase(Info &&Other) {
assert(mergeable(Other));
assert_DISABLED(mergeable(Other));
if (USR == EmptySID)
USR = Other.USR;
if (Name == "")
Expand All @@ -209,7 +209,7 @@ bool Info::mergeable(const Info &Other) {
}

void SymbolInfo::merge(SymbolInfo &&Other) {
assert(mergeable(Other));
assert_DISABLED(mergeable(Other));
if (!DefLoc)
DefLoc = std::move(Other.DefLoc);
// Unconditionally extend the list of locations, since we want all of them.
Expand All @@ -224,7 +224,7 @@ NamespaceInfo::NamespaceInfo(SymbolID USR, StringRef Name, StringRef Path)
: Info(InfoType::IT_namespace, USR, Name, Path) {}

void NamespaceInfo::merge(NamespaceInfo &&Other) {
assert(mergeable(Other));
assert_DISABLED(mergeable(Other));
// Reduce children if necessary.
reduceChildren(Children.Namespaces, std::move(Other.Children.Namespaces));
reduceChildren(Children.Records, std::move(Other.Children.Records));
Expand All @@ -238,7 +238,7 @@ RecordInfo::RecordInfo(SymbolID USR, StringRef Name, StringRef Path)
: SymbolInfo(InfoType::IT_record, USR, Name, Path) {}

void RecordInfo::merge(RecordInfo &&Other) {
assert(mergeable(Other));
assert_DISABLED(mergeable(Other));
if (!llvm::to_underlying(TagType))
TagType = Other.TagType;
IsTypeDef = IsTypeDef || Other.IsTypeDef;
Expand All @@ -261,7 +261,7 @@ void RecordInfo::merge(RecordInfo &&Other) {
}

void EnumInfo::merge(EnumInfo &&Other) {
assert(mergeable(Other));
assert_DISABLED(mergeable(Other));
if (!Scoped)
Scoped = Other.Scoped;
if (Members.empty())
Expand All @@ -270,7 +270,7 @@ void EnumInfo::merge(EnumInfo &&Other) {
}

void FunctionInfo::merge(FunctionInfo &&Other) {
assert(mergeable(Other));
assert_DISABLED(mergeable(Other));
if (!IsMethod)
IsMethod = Other.IsMethod;
if (!Access)
Expand All @@ -287,7 +287,7 @@ void FunctionInfo::merge(FunctionInfo &&Other) {
}

void TypedefInfo::merge(TypedefInfo &&Other) {
assert(mergeable(Other));
assert_DISABLED(mergeable(Other));
if (!IsUsing)
IsUsing = Other.IsUsing;
if (Underlying.Type.Name == "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ HeaderMapCollector::getMappedHeader(llvm::StringRef Header) const {
for (auto &Entry : RegexHeaderMappingTable) {
#ifndef NDEBUG
std::string Dummy;
assert(Entry.first.isValid(Dummy) && "Regex should never be invalid!");
assert_DISABLED(Entry.first.isValid(Dummy) && "Regex should never be invalid!");
#endif
if (Entry.first.match(Header))
return Entry.second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ static bool retrieveConstExprFromBothSides(const BinaryOperator *&BinOp,
const Expr *&LhsConst,
const Expr *&RhsConst,
const ASTContext *AstCtx) {
assert(areSidesBinaryConstExpressions(BinOp, AstCtx) &&
assert_DISABLED(areSidesBinaryConstExpressions(BinOp, AstCtx) &&
"Both sides of binary operator must be constant expressions!");

MainOpcode = BinOp->getOpcode();
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5008,8 +5008,8 @@ void Redeclarable<decl_type>::setPreviousDecl(decl_type *PrevDecl) {
// First one will point to this one as latest.
First->RedeclLink.setLatest(static_cast<decl_type*>(this));

assert(!isa<NamedDecl>(static_cast<decl_type*>(this)) ||
cast<NamedDecl>(static_cast<decl_type*>(this))->isLinkageValid());
assert(!isa<NamedDecl>(static_cast<const decl_type*>(this)) ||
cast<NamedDecl>(static_cast<const decl_type*>(this))->isLinkageValid());
}

// Inline function definitions.
Expand Down
8 changes: 6 additions & 2 deletions clang/include/clang/AST/DeclTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,12 @@ class FixedSizeTemplateParameterListStorage
SourceLocation RAngleLoc,
Expr *RequiresClause)
: FixedSizeStorageOwner(
(assert(N == Params.size()),
assert(HasRequiresClause == (RequiresClause != nullptr)),
([&]() {
((void)Params);
((void)RequiresClause);
assert(N == Params.size());
assert(HasRequiresClause == (RequiresClause != nullptr));
}(),
new (static_cast<void *>(&storage)) TemplateParameterList(C,
TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class LexicallyOrderedRecursiveASTVisitor
// but right now we only care about getting the correct lexical parent, so
// we can traverse the gathered nested declarations after the declarations
// in the decl context.
assert(!BaseType::getDerived().shouldTraversePostOrder() &&
assert_DISABLED(!BaseType::getDerived().shouldTraversePostOrder() &&
"post-order traversal is not supported for lexically ordered "
"recursive ast visitor");
for (Decl *D : LexicallyNestedDeclarations) {
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Lex/Preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ class Preprocessor {
void EnableBacktrackAtThisPos(bool Unannotated = false);

private:
std::pair<CachedTokensTy::size_type, bool> LastBacktrackPos();
std::pair<CachedTokensTy::size_type, bool> LastBacktrackPos() const;

CachedTokensTy PopUnannotatedBacktrackTokens();

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Sema/DelayedDiagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class DelayedDiagnosticPool {

/// Add a diagnostic to the current delay pool.
inline void Sema::DelayedDiagnostics::add(const sema::DelayedDiagnostic &diag) {
assert(shouldDelayDiagnostics() && "trying to delay without pool");
assert_DISABLED(shouldDelayDiagnostics() && "trying to delay without pool");
CurPool->add(diag);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class NodeBuilder {
const NodeBuilderContext &Ctx, bool F = true)
: C(Ctx), Finalized(F), Frontier(DstSet) {
Frontier.insert(SrcSet);
assert(hasNoSinksInFrontier());
assert_DISABLED(hasNoSinksInFrontier());
}

virtual ~NodeBuilder() = default;
Expand All @@ -303,7 +303,7 @@ class NodeBuilder {

const ExplodedNodeSet &getResults() {
finalizeResults();
assert(checkResults());
assert_DISABLED(checkResults());
return Frontier;
}

Expand All @@ -312,7 +312,7 @@ class NodeBuilder {
/// Iterators through the results frontier.
iterator begin() {
finalizeResults();
assert(checkResults());
assert_DISABLED(checkResults());
return Frontier.begin();
}

Expand Down
10 changes: 5 additions & 5 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ ASTContext::setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl,
void
ASTContext::setTemplateOrSpecializationInfo(VarDecl *Inst,
TemplateOrSpecializationInfo TSI) {
assert(!TemplateOrInstantiation[Inst] &&
assert_DISABLED(!TemplateOrInstantiation[Inst] &&
"Already noted what the variable was instantiated from");
TemplateOrInstantiation[Inst] = TSI;
}
Expand All @@ -1556,7 +1556,7 @@ ASTContext::setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern) {
isa<UnresolvedUsingValueDecl>(Inst) ||
isa<UnresolvedUsingTypenameDecl>(Inst)) &&
"instantiation did not produce a using decl");
assert(!InstantiatedFromUsingDecl[Inst] && "pattern already exists");
assert_DISABLED(!InstantiatedFromUsingDecl[Inst] && "pattern already exists");
InstantiatedFromUsingDecl[Inst] = Pattern;
}

Expand All @@ -1567,7 +1567,7 @@ ASTContext::getInstantiatedFromUsingEnumDecl(UsingEnumDecl *UUD) {

void ASTContext::setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst,
UsingEnumDecl *Pattern) {
assert(!InstantiatedFromUsingEnumDecl[Inst] && "pattern already exists");
assert_DISABLED(!InstantiatedFromUsingEnumDecl[Inst] && "pattern already exists");
InstantiatedFromUsingEnumDecl[Inst] = Pattern;
}

Expand All @@ -1579,7 +1579,7 @@ ASTContext::getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst) {
void
ASTContext::setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst,
UsingShadowDecl *Pattern) {
assert(!InstantiatedFromUsingShadowDecl[Inst] && "pattern already exists");
assert_DISABLED(!InstantiatedFromUsingShadowDecl[Inst] && "pattern already exists");
InstantiatedFromUsingShadowDecl[Inst] = Pattern;
}

Expand All @@ -1591,7 +1591,7 @@ void ASTContext::setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst,
FieldDecl *Tmpl) {
assert(!Inst->getDeclName() && "Instantiated field decl is not unnamed");
assert(!Tmpl->getDeclName() && "Template field decl is not unnamed");
assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
assert_DISABLED(!InstantiatedFromUnnamedFieldDecl[Inst] &&
"Already noted what unnamed field was instantiated from");

InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3454,7 +3454,7 @@ bool Compiler<Emitter>::VisitCXXUuidofExpr(const CXXUuidofExpr *E) {
if (!this->emitGetPtrGlobal(*GlobalIndex, E))
return false;

assert(this->getRecord(E->getType()));
assert_DISABLED(this->getRecord(E->getType()));

const APValue &V = GuidDecl->getAsAPValue();
if (V.getKind() == APValue::None)
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5014,7 +5014,7 @@ RecordDecl::RecordDecl(Kind DK, TagKind TK, const ASTContext &C,
SourceLocation IdLoc, IdentifierInfo *Id,
RecordDecl *PrevDecl)
: TagDecl(DK, TK, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
assert(classof(static_cast<Decl *>(this)) && "Invalid Kind!");
assert_DISABLED(classof(static_cast<Decl *>(this)) && "Invalid Kind!");
setHasFlexibleArrayMember(false);
setAnonymousStructOrUnion(false);
setHasObjectMember(false);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/DeclTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void RedeclarableTemplateDecl::addSpecializationImpl(
if (InsertPos) {
#ifndef NDEBUG
void *CorrectInsertPos;
assert(!findSpecializationImpl(Specializations,
assert_DISABLED(!findSpecializationImpl(Specializations,
CorrectInsertPos,
SETraits::getTemplateArgs(Entry)) &&
InsertPos == CorrectInsertPos &&
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7212,7 +7212,7 @@ class APValueToBufferConverter {

// Write out Val with type Ty into Buffer starting at Offset.
bool visit(const APValue &Val, QualType Ty, CharUnits Offset) {
assert((size_t)Offset.getQuantity() <= Buffer.size());
assert_DISABLED((size_t)Offset.getQuantity() <= Buffer.size());

// As a special case, nullptr_t has an indeterminate value.
if (Ty->isNullPtrType())
Expand Down Expand Up @@ -10860,7 +10860,7 @@ bool RecordExprEvaluator::VisitCXXStdInitializerListExpr(
Array.moveInto(Result.getStructField(1));
}

assert(++Field == Record->field_end() &&
assert_DISABLED(++Field == Record->field_end() &&
"Expected std::initializer_list to only have two fields");

return true;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/MicrosoftCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class MicrosoftCXXABI : public CXXABI {
addCopyConstructorForExceptionObject(CXXRecordDecl *RD,
CXXConstructorDecl *CD) override {
assert(CD != nullptr);
assert(RecordToCopyCtor[RD] == nullptr || RecordToCopyCtor[RD] == CD);
assert_DISABLED(RecordToCopyCtor[RD] == nullptr || RecordToCopyCtor[RD] == CD);
RecordToCopyCtor[RD] = CD;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/RecordLayoutBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
if (BTy->getKind() == BuiltinType::Double ||
BTy->getKind() == BuiltinType::LongDouble) {
assert(PreferredAlign == CharUnits::fromQuantity(4) &&
assert_DISABLED(PreferredAlign == CharUnits::fromQuantity(4) &&
"No need to upgrade the alignment value.");
PreferredAlign = CharUnits::fromQuantity(8);
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ void CFGBuilder::addAutomaticObjDestruction(LocalScope::const_iterator B,
/// * ScopeEnd for each scope left
void CFGBuilder::addScopeExitHandling(LocalScope::const_iterator B,
LocalScope::const_iterator E, Stmt *S) {
assert(!B.inSameLocalScope(E));
assert_DISABLED(!B.inSameLocalScope(E));
if (!BuildOpts.AddLifetime && !BuildOpts.AddScopes)
return;

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ RecordStorageLocation &DataflowAnalysisContext::createRecordStorageLocation(
QualType Type, RecordStorageLocation::FieldToLoc FieldLocs,
RecordStorageLocation::SyntheticFieldMap SyntheticFields) {
assert(Type->isRecordType());
assert(containsSameFields(getModeledFields(Type), FieldLocs));
assert(getKeys(getSyntheticFields(Type)) == getKeys(SyntheticFields));
assert_DISABLED(containsSameFields(getModeledFields(Type), FieldLocs));
assert_DISABLED(getKeys(getSyntheticFields(Type)) == getKeys(SyntheticFields));

RecordStorageLocationCreated = true;
return arena().create<RecordStorageLocation>(Type, std::move(FieldLocs),
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void Environment::setStorageLocation(const ValueDecl &D, StorageLocation &Loc) {
// are declarations of reference type and `BindingDecl`. For all other
// declaration, the storage location should be the stable storage location
// returned by `createStorageLocation()`.
assert(D.getType()->isReferenceType() || isa<BindingDecl>(D) ||
assert_DISABLED(D.getType()->isReferenceType() || isa<BindingDecl>(D) ||
&Loc == &createStorageLocation(D));
DeclToLoc[&D] = &Loc;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGBlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ static llvm::Constant *buildGlobalBlock(CodeGenModule &CGM,
// Callers should detect this case on their own: calling this function
// generally requires computing layout information, which is a waste of time
// if we've already emitted this block.
assert(!CGM.getAddrOfGlobalBlockIfEmitted(blockInfo.BlockExpression) &&
assert_DISABLED(!CGM.getAddrOfGlobalBlockIfEmitted(blockInfo.BlockExpression) &&
"Refusing to re-emit a global block.");

// Generate the constants for the block literal initializer.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4627,7 +4627,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,

// Store the stack pointer to the setjmp buffer.
Value *StackAddr = Builder.CreateStackSave();
assert(Buf.emitRawPointer(*this)->getType() == StackAddr->getType());
assert_DISABLED(Buf.emitRawPointer(*this)->getType() == StackAddr->getType());

Address StackSaveSlot = Builder.CreateConstInBoundsGEP(Buf, 2);
Builder.CreateStore(StackAddr, StackSaveSlot);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ llvm::Value *CGCXXABI::loadIncomingCXXThis(CodeGenFunction &CGF) {

void CGCXXABI::setCXXABIThisValue(CodeGenFunction &CGF, llvm::Value *ThisPtr) {
/// Initialize the 'this' slot.
assert(getThisDecl(CGF) && "no 'this' variable for function");
assert_DISABLED(getThisDecl(CGF) && "no 'this' variable for function");
CGF.CXXABIThisValue = ThisPtr;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ CodeGenFunction::GetAddressOfDirectBaseInCompleteClass(Address This,
const CXXRecordDecl *Base,
bool BaseIsVirtual) {
// 'this' must be a pointer (in some address space) to Derived.
assert(This.getElementType() == ConvertType(Derived));
assert_DISABLED(This.getElementType() == ConvertType(Derived));

// Compute the offset of the virtual base.
CharUnits Offset;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ CodeGenFunction::getDestroyer(QualType::DestructionKind kind) {
void CodeGenFunction::pushEHDestroy(QualType::DestructionKind dtorKind,
Address addr, QualType type) {
assert(dtorKind && "cannot push destructor for trivial type");
assert(needsEHCleanup(dtorKind));
assert_DISABLED(needsEHCleanup(dtorKind));

pushDestroy(EHCleanup, addr, type, getDestroyer(dtorKind), true);
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
cast<ItaniumMangleContext>(getCXXABI().getMangleContext())
.mangleModuleInitializer(M, Out);
}
assert(!GetGlobalValue(FnName.str()) &&
assert_DISABLED(!GetGlobalValue(FnName.str()) &&
"We should only have one use of the initializer call");
llvm::Function *Fn = llvm::Function::Create(
FTy, llvm::Function::ExternalLinkage, FnName.str(), &getModule());
Expand Down Expand Up @@ -879,7 +879,7 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
cast<ItaniumMangleContext>(getCXXABI().getMangleContext())
.mangleModuleInitializer(M, Out);
}
assert(!GetGlobalValue(FnName.str()) &&
assert_DISABLED(!GetGlobalValue(FnName.str()) &&
"We should only have one use of the initializer call");
llvm::Function *Fn = llvm::Function::Create(
FTy, llvm::Function::ExternalLinkage, FnName.str(), &getModule());
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/CodeGen/CGException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() {
continue;

case EHScope::Filter: {
assert(I.next() == EHStack.end() && "EH filter is not end of EH stack");
assert_DISABLED(I.next() == EHStack.end() && "EH filter is not end of EH stack");
assert(!hasCatchAll && "EH filter reached after catch-all");

// Filter scopes get added to the landingpad in weird ways.
Expand Down Expand Up @@ -1440,9 +1440,9 @@ void CodeGenFunction::FinallyInfo::enter(CodeGenFunction &CGF, const Stmt *body,
llvm::FunctionCallee beginCatchFn,
llvm::FunctionCallee endCatchFn,
llvm::FunctionCallee rethrowFn) {
assert((!!beginCatchFn) == (!!endCatchFn) &&
assert_DISABLED((!!beginCatchFn) == (!!endCatchFn) &&
"begin/end catch functions not paired");
assert(rethrowFn && "rethrow function is required");
assert_DISABLED(rethrowFn && "rethrow function is required");

BeginCatchFn = beginCatchFn;

Expand Down Expand Up @@ -1589,7 +1589,7 @@ llvm::BasicBlock *CodeGenFunction::getTerminateHandler() {
}

llvm::BasicBlock *CodeGenFunction::getTerminateFunclet() {
assert(EHPersonality::get(*this).usesFuncletPads() &&
assert_DISABLED(EHPersonality::get(*this).usesFuncletPads() &&
"use getTerminateLandingPad for non-funclet EH");

llvm::BasicBlock *&TerminateFunclet = TerminateFunclets[CurrentFuncletPad];
Expand Down
Loading