mirror of
https://git.FreeBSD.org/src.git
synced 2026-06-02 11:24:32 +00:00
Vendor import of llvm-project branch release/18.x llvmorg-18.1.7-0-g768118d1ad38.
This commit is contained in:
@@ -5159,9 +5159,11 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
|
||||
return true;
|
||||
if (Left.IsUnterminatedLiteral)
|
||||
return true;
|
||||
if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
|
||||
Right.Next->is(tok::string_literal)) {
|
||||
return true;
|
||||
if (const auto *BeforeLeft = Left.Previous, *AfterRight = Right.Next;
|
||||
BeforeLeft && BeforeLeft->is(tok::lessless) &&
|
||||
Left.is(tok::string_literal) && Right.is(tok::lessless) && AfterRight &&
|
||||
AfterRight->is(tok::string_literal)) {
|
||||
return Right.NewlinesBefore > 0;
|
||||
}
|
||||
if (Right.is(TT_RequiresClause)) {
|
||||
switch (Style.RequiresClausePosition) {
|
||||
|
||||
@@ -1185,12 +1185,6 @@ void UnwrappedLineParser::parsePPDefine() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (FormatTok->is(tok::identifier) &&
|
||||
Tokens->peekNextToken()->is(tok::colon)) {
|
||||
nextToken();
|
||||
nextToken();
|
||||
}
|
||||
|
||||
// Errors during a preprocessor directive can only affect the layout of the
|
||||
// preprocessor directive, and thus we ignore them. An alternative approach
|
||||
// would be to use the same approach we use on the file level (no
|
||||
@@ -1671,7 +1665,8 @@ void UnwrappedLineParser::parseStructuralElement(
|
||||
if (!Style.isJavaScript() && !Style.isVerilog() && !Style.isTableGen() &&
|
||||
Tokens->peekNextToken()->is(tok::colon) && !Line->MustBeDeclaration) {
|
||||
nextToken();
|
||||
Line->Tokens.begin()->Tok->MustBreakBefore = true;
|
||||
if (!Line->InMacroBody || CurrentLines->size() > 1)
|
||||
Line->Tokens.begin()->Tok->MustBreakBefore = true;
|
||||
FormatTok->setFinalizedType(TT_GotoLabelColon);
|
||||
parseLabel(!Style.IndentGotoLabels);
|
||||
if (HasLabel)
|
||||
|
||||
@@ -290,13 +290,6 @@ bool PPCMergeStringPool::mergeModuleStringPool(Module &M) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool userHasOperand(User *TheUser, GlobalVariable *GVOperand) {
|
||||
for (Value *Op : TheUser->operands())
|
||||
if (Op == GVOperand)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// For pooled strings we need to add the offset into the pool for each string.
|
||||
// This is done by adding a Get Element Pointer (GEP) before each user. This
|
||||
// function adds the GEP.
|
||||
@@ -307,29 +300,13 @@ void PPCMergeStringPool::replaceUsesWithGEP(GlobalVariable *GlobalToReplace,
|
||||
Indices.push_back(ConstantInt::get(Type::getInt32Ty(*Context), 0));
|
||||
Indices.push_back(ConstantInt::get(Type::getInt32Ty(*Context), ElementIndex));
|
||||
|
||||
// Need to save a temporary copy of each user list because we remove uses
|
||||
// as we replace them.
|
||||
SmallVector<User *> Users;
|
||||
for (User *CurrentUser : GlobalToReplace->users())
|
||||
Users.push_back(CurrentUser);
|
||||
|
||||
for (User *CurrentUser : Users) {
|
||||
// The user was not found so it must have been replaced earlier.
|
||||
if (!userHasOperand(CurrentUser, GlobalToReplace))
|
||||
continue;
|
||||
|
||||
// We cannot replace operands in globals so we ignore those.
|
||||
if (isa<GlobalValue>(CurrentUser))
|
||||
continue;
|
||||
|
||||
Constant *ConstGEP = ConstantExpr::getInBoundsGetElementPtr(
|
||||
PooledStructType, GPool, Indices);
|
||||
LLVM_DEBUG(dbgs() << "Replacing this global:\n");
|
||||
LLVM_DEBUG(GlobalToReplace->dump());
|
||||
LLVM_DEBUG(dbgs() << "with this:\n");
|
||||
LLVM_DEBUG(ConstGEP->dump());
|
||||
GlobalToReplace->replaceAllUsesWith(ConstGEP);
|
||||
}
|
||||
Constant *ConstGEP =
|
||||
ConstantExpr::getInBoundsGetElementPtr(PooledStructType, GPool, Indices);
|
||||
LLVM_DEBUG(dbgs() << "Replacing this global:\n");
|
||||
LLVM_DEBUG(GlobalToReplace->dump());
|
||||
LLVM_DEBUG(dbgs() << "with this:\n");
|
||||
LLVM_DEBUG(ConstGEP->dump());
|
||||
GlobalToReplace->replaceAllUsesWith(ConstGEP);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user