Skip to content

Commit fdb5f9b

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:99e6ef3e7c6e into amd-gfx:f0390051de34
Local branch amd-gfx f039005 Merged main:ff843c00ce1d into amd-gfx:8bf801a67373 Remote branch main 99e6ef3 [clang][NFC] Add missing placement-new after Allocate() calls (llvm#68382)
2 parents f039005 + 99e6ef3 commit fdb5f9b

File tree

62 files changed

+988
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+988
-622
lines changed

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,6 @@ class ASTWriter : public ASTDeserializationListener,
613613
/// the module but currently is merely a random 32-bit number.
614614
ASTFileSignature WriteAST(Sema &SemaRef, StringRef OutputFile,
615615
Module *WritingModule, StringRef isysroot,
616-
bool hasErrors = false,
617616
bool ShouldCacheASTInMemory = false);
618617

619618
/// Emit a token.

clang/lib/AST/DeclCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,8 @@ void CXXRecordDecl::setCaptures(ASTContext &Context,
14841484
if (Captures[I].isExplicit())
14851485
++Data.NumExplicitCaptures;
14861486

1487-
*ToCapture++ = Captures[I];
1487+
new (ToCapture) LambdaCapture(Captures[I]);
1488+
ToCapture++;
14881489
}
14891490

14901491
if (!lambdaIsDefaultConstructibleAndAssignable())

clang/lib/AST/DeclObjC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,8 @@ void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
931931
unsigned Size = sizeof(ParmVarDecl *) * NumParams +
932932
sizeof(SourceLocation) * SelLocs.size();
933933
ParamsAndSelLocs = C.Allocate(Size);
934-
std::copy(Params.begin(), Params.end(), getParams());
935-
std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
934+
std::uninitialized_copy(Params.begin(), Params.end(), getParams());
935+
std::uninitialized_copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
936936
}
937937

938938
void ObjCMethodDecl::getSelectorLocs(

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,12 +2341,9 @@ bool ASTUnit::Save(StringRef File) {
23412341
return false;
23422342
}
23432343

2344-
static bool serializeUnit(ASTWriter &Writer,
2345-
SmallVectorImpl<char> &Buffer,
2346-
Sema &S,
2347-
bool hasErrors,
2348-
raw_ostream &OS) {
2349-
Writer.WriteAST(S, std::string(), nullptr, "", hasErrors);
2344+
static bool serializeUnit(ASTWriter &Writer, SmallVectorImpl<char> &Buffer,
2345+
Sema &S, raw_ostream &OS) {
2346+
Writer.WriteAST(S, std::string(), nullptr, "");
23502347

23512348
// Write the generated bitstream to "Out".
23522349
if (!Buffer.empty())
@@ -2356,18 +2353,14 @@ static bool serializeUnit(ASTWriter &Writer,
23562353
}
23572354

23582355
bool ASTUnit::serialize(raw_ostream &OS) {
2359-
// For serialization we are lenient if the errors were only warn-as-error kind.
2360-
bool hasErrors = getDiagnostics().hasUncompilableErrorOccurred();
2361-
23622356
if (WriterData)
2363-
return serializeUnit(WriterData->Writer, WriterData->Buffer,
2364-
getSema(), hasErrors, OS);
2357+
return serializeUnit(WriterData->Writer, WriterData->Buffer, getSema(), OS);
23652358

23662359
SmallString<128> Buffer;
23672360
llvm::BitstreamWriter Stream(Buffer);
23682361
InMemoryModuleCache ModuleCache;
23692362
ASTWriter Writer(Stream, Buffer, ModuleCache, {});
2370-
return serializeUnit(Writer, Buffer, getSema(), hasErrors, OS);
2363+
return serializeUnit(Writer, Buffer, getSema(), OS);
23712364
}
23722365

23732366
using SLocRemap = ContinuousRangeMap<unsigned, int, 2>;

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,13 +2002,16 @@ void ASTDeclReader::ReadCXXDefinitionData(
20022002
case LCK_StarThis:
20032003
case LCK_This:
20042004
case LCK_VLAType:
2005-
*ToCapture++ = Capture(Loc, IsImplicit, Kind, nullptr,SourceLocation());
2005+
new (ToCapture)
2006+
Capture(Loc, IsImplicit, Kind, nullptr, SourceLocation());
2007+
ToCapture++;
20062008
break;
20072009
case LCK_ByCopy:
20082010
case LCK_ByRef:
20092011
auto *Var = readDeclAs<VarDecl>();
20102012
SourceLocation EllipsisLoc = readSourceLocation();
2011-
*ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
2013+
new (ToCapture) Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
2014+
ToCapture++;
20122015
break;
20132016
}
20142017
}

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4622,12 +4622,12 @@ time_t ASTWriter::getTimestampForOutput(const FileEntry *E) const {
46224622

46234623
ASTFileSignature ASTWriter::WriteAST(Sema &SemaRef, StringRef OutputFile,
46244624
Module *WritingModule, StringRef isysroot,
4625-
bool hasErrors,
46264625
bool ShouldCacheASTInMemory) {
46274626
llvm::TimeTraceScope scope("WriteAST", OutputFile);
46284627
WritingAST = true;
46294628

4630-
ASTHasCompilerErrors = hasErrors;
4629+
ASTHasCompilerErrors =
4630+
SemaRef.PP.getDiagnostics().hasUncompilableErrorOccurred();
46314631

46324632
// Emit the file header.
46334633
Stream.Emit((unsigned)'C', 8);

clang/lib/Serialization/GeneratePCH.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
6565

6666
// Emit the PCH file to the Buffer.
6767
assert(SemaPtr && "No Sema?");
68-
Buffer->Signature =
69-
Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot,
70-
// For serialization we are lenient if the errors were
71-
// only warn-as-error kind.
72-
PP.getDiagnostics().hasUncompilableErrorOccurred(),
73-
ShouldCacheASTInMemory);
68+
Buffer->Signature = Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot,
69+
ShouldCacheASTInMemory);
7470

7571
Buffer->IsComplete = true;
7672
}

clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ void* test9(B* x) { return dynamic_cast<void*>(x); }
9494
// CHECK-NEXT: [[VBTBL:%.*]] = load ptr, ptr [[VBPTR]], align 4
9595
// CHECK-NEXT: [[VBOFFP:%.*]] = getelementptr inbounds i32, ptr [[VBTBL]], i32 1
9696
// CHECK-NEXT: [[VBOFFS:%.*]] = load i32, ptr [[VBOFFP]], align 4
97-
// CHECK-NEXT: [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4
98-
// CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8, ptr %x, i32 [[DELTA]]
99-
// CHECK-NEXT: [[CALL:%.*]] = tail call ptr @__RTCastToVoid(ptr nonnull [[ADJ]])
97+
// CHECK-NEXT: [[BASE:%.*]] = getelementptr i8, ptr %x, i32 [[VBOFFS]]
98+
// CHECK-NEXT: [[ADJ:%.*]] = getelementptr i8, ptr [[BASE]], i32 4
99+
// CHECK-NEXT: [[CALL:%.*]] = tail call ptr @__RTCastToVoid(ptr [[ADJ]])
100100
// CHECK-NEXT: br label
101101
// CHECK: [[RET:%.*]] = phi ptr
102102
// CHECK-NEXT: ret ptr [[RET]]

0 commit comments

Comments
 (0)