Skip to content

Commit 239a341

Browse files
authored
Merge branch 'main' into main
2 parents 176bfa8 + 7db789b commit 239a341

File tree

184 files changed

+11961
-895
lines changed

Some content is hidden

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

184 files changed

+11961
-895
lines changed

clang/CMakeLists.txt

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -872,58 +872,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
872872
endforeach()
873873
endif()
874874

875-
set(CLANG_BOLT OFF CACHE STRING "Apply BOLT optimization to Clang. \
876-
May be specified as Instrument or Perf or LBR to use a particular profiling \
877-
mechanism.")
878-
string(TOUPPER "${CLANG_BOLT}" CLANG_BOLT)
879-
880-
if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
881-
set(CLANG_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
882-
set(CLANG_INSTRUMENTED ${LLVM_RUNTIME_OUTPUT_INTDIR}/${CLANG_BOLT_INSTRUMENTED})
883-
set(BOLT_FDATA ${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/prof.fdata)
884-
885-
# Pass extra flag in no-LBR mode
886-
if (CLANG_BOLT STREQUAL "PERF")
887-
set(BOLT_NO_LBR "-nl")
888-
endif()
889-
890-
if (CLANG_BOLT STREQUAL "INSTRUMENT")
891-
# Instrument clang with BOLT
892-
add_custom_target(clang-instrumented
893-
DEPENDS ${CLANG_INSTRUMENTED}
894-
)
895-
add_custom_command(OUTPUT ${CLANG_INSTRUMENTED}
896-
DEPENDS clang llvm-bolt
897-
COMMAND llvm-bolt ${CLANG_PATH} -o ${CLANG_INSTRUMENTED}
898-
-instrument --instrumentation-file-append-pid
899-
--instrumentation-file=${BOLT_FDATA}
900-
COMMENT "Instrumenting clang binary with BOLT"
901-
USES_TERMINAL
902-
VERBATIM
903-
)
904-
add_custom_target(clang-bolt-training-deps DEPENDS clang-instrumented)
905-
else() # perf or LBR
906-
add_custom_target(clang-bolt-training-deps DEPENDS clang)
907-
endif()
908-
909-
# Optimize original (pre-bolt) Clang using the collected profile
910-
add_custom_target(clang-bolt
911-
DEPENDS clang-bolt-profile
912-
COMMAND ${CMAKE_COMMAND} -E rename $<TARGET_FILE:clang> ${CLANG_PATH}-prebolt
913-
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CLANG_PATH}-prebolt ${CLANG_PATH}++-prebolt
914-
COMMAND llvm-bolt ${CLANG_PATH}-prebolt
915-
-o $<TARGET_FILE:clang>
916-
-data ${BOLT_FDATA}
917-
-reorder-blocks=ext-tsp -reorder-functions=cdsort -split-functions
918-
-split-all-cold -split-eh -dyno-stats -use-gnu-stack
919-
-update-debug-sections
920-
${BOLT_NO_LBR}
921-
COMMENT "Optimizing Clang with BOLT"
922-
USES_TERMINAL
923-
VERBATIM
924-
)
925-
endif()
926-
927875
if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
928876
add_subdirectory(utils/ClangVisualizers)
929877
endif()

clang/include/clang/AST/APValue.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ class APValue {
161161

162162
template <class T> T get() const { return cast<T>(Ptr); }
163163

164-
template <class T>
165-
T dyn_cast() const { return Ptr.dyn_cast<T>(); }
164+
template <class T> T dyn_cast() const {
165+
return dyn_cast_if_present<T>(Ptr);
166+
}
166167

167168
void *getOpaqueValue() const;
168169

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
769769
/// pool.
770770
DeclListNode *AllocateDeclListNode(clang::NamedDecl *ND) {
771771
if (DeclListNode *Alloc = ListNodeFreeList) {
772-
ListNodeFreeList = Alloc->Rest.dyn_cast<DeclListNode*>();
772+
ListNodeFreeList = dyn_cast_if_present<DeclListNode *>(Alloc->Rest);
773773
Alloc->D = ND;
774774
Alloc->Rest = nullptr;
775775
return Alloc;

clang/include/clang/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4035,7 +4035,7 @@ class EnumDecl : public TagDecl {
40354035
/// Return the type source info for the underlying integer type,
40364036
/// if no type source info exists, return 0.
40374037
TypeSourceInfo *getIntegerTypeSourceInfo() const {
4038-
return IntegerType.dyn_cast<TypeSourceInfo*>();
4038+
return dyn_cast_if_present<TypeSourceInfo *>(IntegerType);
40394039
}
40404040

40414041
/// Retrieve the source range that covers the underlying type if

clang/include/clang/AST/DeclBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ class DeclContextLookupResult {
13911391
const_iterator end() const { return iterator(); }
13921392

13931393
bool empty() const { return Result.isNull(); }
1394-
bool isSingleResult() const { return Result.dyn_cast<NamedDecl*>(); }
1394+
bool isSingleResult() const { return isa_and_present<NamedDecl *>(Result); }
13951395
reference front() const { return *begin(); }
13961396

13971397
// Find the first declaration of the given type in the list. Note that this

clang/include/clang/AST/DeclTemplate.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
20092009
/// Retrieve the template argument list as written in the sources,
20102010
/// if any.
20112011
const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const {
2012-
if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>())
2012+
if (auto *Info =
2013+
dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
20132014
return Info->TemplateArgsAsWritten;
20142015
return cast<const ASTTemplateArgumentListInfo *>(ExplicitInfo);
20152016
}
@@ -2041,7 +2042,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
20412042

20422043
/// Gets the location of the template keyword, if present.
20432044
SourceLocation getTemplateKeywordLoc() const {
2044-
if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>())
2045+
if (auto *Info =
2046+
dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
20452047
return Info->TemplateKeywordLoc;
20462048
return SourceLocation();
20472049
}
@@ -2786,7 +2788,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
27862788
/// Set the template argument list as written in the sources.
27872789
void
27882790
setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten) {
2789-
if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>())
2791+
if (auto *Info =
2792+
dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
27902793
Info->TemplateArgsAsWritten = ArgsWritten;
27912794
else
27922795
ExplicitInfo = ArgsWritten;

clang/include/clang/AST/Expr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5180,7 +5180,7 @@ class InitListExpr : public Expr {
51805180
/// than there are initializers in the list, specifies an expression to be
51815181
/// used for value initialization of the rest of the elements.
51825182
Expr *getArrayFiller() {
5183-
return ArrayFillerOrUnionFieldInit.dyn_cast<Expr *>();
5183+
return dyn_cast_if_present<Expr *>(ArrayFillerOrUnionFieldInit);
51845184
}
51855185
const Expr *getArrayFiller() const {
51865186
return const_cast<InitListExpr *>(this)->getArrayFiller();
@@ -5205,7 +5205,7 @@ class InitListExpr : public Expr {
52055205
/// union. However, a designated initializer can specify the
52065206
/// initialization of a different field within the union.
52075207
FieldDecl *getInitializedFieldInUnion() {
5208-
return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5208+
return dyn_cast_if_present<FieldDecl *>(ArrayFillerOrUnionFieldInit);
52095209
}
52105210
const FieldDecl *getInitializedFieldInUnion() const {
52115211
return const_cast<InitListExpr *>(this)->getInitializedFieldInUnion();

clang/include/clang/AST/ExprCXX.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5026,19 +5026,19 @@ class CXXParenListInitExpr final
50265026
void setArrayFiller(Expr *E) { ArrayFillerOrUnionFieldInit = E; }
50275027

50285028
Expr *getArrayFiller() {
5029-
return ArrayFillerOrUnionFieldInit.dyn_cast<Expr *>();
5029+
return dyn_cast_if_present<Expr *>(ArrayFillerOrUnionFieldInit);
50305030
}
50315031

50325032
const Expr *getArrayFiller() const {
5033-
return ArrayFillerOrUnionFieldInit.dyn_cast<Expr *>();
5033+
return dyn_cast_if_present<Expr *>(ArrayFillerOrUnionFieldInit);
50345034
}
50355035

50365036
void setInitializedFieldInUnion(FieldDecl *FD) {
50375037
ArrayFillerOrUnionFieldInit = FD;
50385038
}
50395039

50405040
FieldDecl *getInitializedFieldInUnion() {
5041-
return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5041+
return dyn_cast_if_present<FieldDecl *>(ArrayFillerOrUnionFieldInit);
50425042
}
50435043

50445044
const FieldDecl *getInitializedFieldInUnion() const {

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ class Selector {
10081008
}
10091009

10101010
const IdentifierInfo *getAsIdentifierInfo() const {
1011-
return InfoPtr.getPointer().dyn_cast<const IdentifierInfo *>();
1011+
return dyn_cast_if_present<const IdentifierInfo *>(InfoPtr.getPointer());
10121012
}
10131013

10141014
MultiKeywordSelector *getMultiKeywordSelector() const {

clang/include/clang/Lex/Preprocessor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ class Preprocessor {
856856
!PP.CurSubmoduleState->VisibleModules.getGeneration())
857857
return nullptr;
858858

859-
auto *Info = State.dyn_cast<ModuleMacroInfo*>();
859+
auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State);
860860
if (!Info) {
861861
Info = new (PP.getPreprocessorAllocator())
862862
ModuleMacroInfo(cast<MacroDirective *>(State));
@@ -885,18 +885,18 @@ class Preprocessor {
885885
}
886886

887887
~MacroState() {
888-
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
888+
if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
889889
Info->~ModuleMacroInfo();
890890
}
891891

892892
MacroDirective *getLatest() const {
893-
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
893+
if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
894894
return Info->MD;
895895
return cast<MacroDirective *>(State);
896896
}
897897

898898
void setLatest(MacroDirective *MD) {
899-
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
899+
if (auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State))
900900
Info->MD = MD;
901901
else
902902
State = MD;
@@ -940,7 +940,7 @@ class Preprocessor {
940940

941941
void setOverriddenMacros(Preprocessor &PP,
942942
ArrayRef<ModuleMacro *> Overrides) {
943-
auto *Info = State.dyn_cast<ModuleMacroInfo*>();
943+
auto *Info = dyn_cast_if_present<ModuleMacroInfo *>(State);
944944
if (!Info) {
945945
if (Overrides.empty())
946946
return;

clang/lib/APINotes/APINotesManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ APINotesManager::APINotesManager(SourceManager &SM, const LangOptions &LangOpts)
5656
APINotesManager::~APINotesManager() {
5757
// Free the API notes readers.
5858
for (const auto &Entry : Readers) {
59-
if (auto Reader = Entry.second.dyn_cast<APINotesReader *>())
59+
if (auto Reader = dyn_cast_if_present<APINotesReader *>(Entry.second))
6060
delete Reader;
6161
}
6262

@@ -381,7 +381,7 @@ APINotesManager::findAPINotes(SourceLocation Loc) {
381381
}
382382

383383
// We have the answer.
384-
if (auto Reader = Known->second.dyn_cast<APINotesReader *>())
384+
if (auto Reader = dyn_cast_if_present<APINotesReader *>(Known->second))
385385
Results.push_back(Reader);
386386
break;
387387
}

0 commit comments

Comments
 (0)