Skip to content

Commit 74a76cc

Browse files
committed
update LLVM sources to 20.1.2
1 parent 2909bfb commit 74a76cc

File tree

5,046 files changed

+392090
-171781
lines changed

Some content is hidden

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

5,046 files changed

+392090
-171781
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ end with a fully operational Zig compiler for any target.
88
This repository copies sources from upstream. Patches listed below. Use git
99
to find and inspect the patch diffs.
1010

11-
* LLVM, LLD, Clang 19.1.7
11+
* LLVM, LLD, Clang 20.1.2
1212
* zlib 1.3.1
1313
* zstd 1.5.2
1414
* zig 0.15.0-dev.203+53270f008

clang/CMakeLists.txt

+2-53
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ if(NOT DEFINED CLANG_VERSION_SUFFIX)
331331
set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
332332
endif()
333333
set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}")
334+
set(MAX_CLANG_ABI_COMPAT_VERSION "${LLVM_VERSION_MAJOR}")
334335
message(STATUS "Clang version: ${CLANG_VERSION}")
335336

336337
# Configure the Version.inc file.
@@ -362,7 +363,6 @@ if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*")
362363
message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
363364
endif()
364365

365-
include(CMakeParseArguments)
366366
include(AddClang)
367367

368368
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -498,6 +498,7 @@ add_subdirectory(tools)
498498
add_subdirectory(runtime)
499499

500500
option(CLANG_BUILD_EXAMPLES "Build CLANG example programs by default." OFF)
501+
add_subdirectory(examples)
501502

502503
if(APPLE)
503504
# this line is needed as a cleanup to ensure that any CMakeCaches with the old
@@ -872,58 +873,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
872873
endforeach()
873874
endif()
874875

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-
VERBATIM
902-
)
903-
add_custom_target(clang-bolt-training-deps DEPENDS clang-instrumented)
904-
else() # perf or LBR
905-
add_custom_target(clang-bolt-training-deps DEPENDS clang)
906-
endif()
907-
908-
# Optimize original (pre-bolt) Clang using the collected profile
909-
set(CLANG_OPTIMIZED ${CMAKE_CURRENT_BINARY_DIR}/clang.bolt)
910-
add_custom_target(clang-bolt
911-
DEPENDS ${CLANG_OPTIMIZED}
912-
)
913-
add_custom_command(OUTPUT ${CLANG_OPTIMIZED}
914-
DEPENDS clang-bolt-profile
915-
COMMAND llvm-bolt ${CLANG_PATH}
916-
-o ${CLANG_OPTIMIZED}
917-
-data ${BOLT_FDATA}
918-
-reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions
919-
-split-all-cold -split-eh -dyno-stats -icf=1 -use-gnu-stack
920-
${BOLT_NO_LBR}
921-
COMMAND ${CMAKE_COMMAND} -E rename ${CLANG_OPTIMIZED} $<TARGET_FILE:clang>
922-
COMMENT "Optimizing Clang with BOLT"
923-
VERBATIM
924-
)
925-
endif()
926-
927876
if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
928877
add_subdirectory(utils/ClangVisualizers)
929878
endif()

clang/README.txt

-26
This file was deleted.

clang/cmake/modules/AddClang.cmake

+14
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ macro(add_clang_library name)
108108
endif()
109109
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
110110

111+
if(MSVC AND NOT CLANG_LINK_CLANG_DYLIB)
112+
# Make sure all consumers also turn off visibility macros so they're not
113+
# trying to dllimport symbols.
114+
target_compile_definitions(${name} PUBLIC CLANG_BUILD_STATIC)
115+
if(TARGET "obj.${name}")
116+
target_compile_definitions("obj.${name}" PUBLIC CLANG_BUILD_STATIC)
117+
endif()
118+
elseif(TARGET "obj.${name}" AND NOT ARG_SHARED AND NOT ARG_STATIC)
119+
# Clang component libraries linked to clang-cpp are declared without SHARED or STATIC
120+
target_compile_definitions("obj.${name}" PUBLIC CLANG_EXPORTS)
121+
endif()
122+
111123
set(libs ${name})
112124
if(ARG_SHARED AND ARG_STATIC)
113125
list(APPEND libs ${name}_static)
@@ -147,6 +159,7 @@ endmacro(add_clang_library)
147159
macro(add_clang_executable name)
148160
add_llvm_executable( ${name} ${ARGN} )
149161
set_clang_windows_version_resource_properties(${name})
162+
set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON)
150163
endmacro(add_clang_executable)
151164

152165
macro(add_clang_tool name)
@@ -181,6 +194,7 @@ macro(add_clang_tool name)
181194
set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
182195
endif()
183196
endif()
197+
set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON)
184198
endmacro()
185199

186200
macro(add_clang_symlink name dest)

clang/include/clang-c/CXSourceLocation.h

+10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
7474
CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
7575
CXSourceLocation loc2);
7676

77+
/**
78+
* Determine for two source locations if the first comes
79+
* strictly before the second one in the source code.
80+
*
81+
* \returns non-zero if the first source location comes
82+
* strictly before the second one, zero otherwise.
83+
*/
84+
CINDEX_LINKAGE unsigned clang_isBeforeInTranslationUnit(CXSourceLocation loc1,
85+
CXSourceLocation loc2);
86+
7787
/**
7888
* Returns non-zero if the given source location is in a system header.
7989
*/

clang/include/clang-c/CXString.h

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ typedef struct {
4646

4747
/**
4848
* Retrieve the character data associated with the given string.
49+
*
50+
* The returned data is a reference and not owned by the user. This data
51+
* is only valid while the `CXString` is valid. This function is similar
52+
* to `std::string::c_str()`.
4953
*/
5054
CINDEX_LINKAGE const char *clang_getCString(CXString string);
5155

clang/include/clang-c/Index.h

+92-4
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,10 @@ enum CXCursorKind {
21542154
*/
21552155
CXCursor_OMPInterchangeDirective = 308,
21562156

2157+
/** OpenMP assume directive.
2158+
*/
2159+
CXCursor_OMPAssumeDirective = 309,
2160+
21572161
/** OpenACC Compute Construct.
21582162
*/
21592163
CXCursor_OpenACCComputeConstruct = 320,
@@ -2162,7 +2166,47 @@ enum CXCursorKind {
21622166
*/
21632167
CXCursor_OpenACCLoopConstruct = 321,
21642168

2165-
CXCursor_LastStmt = CXCursor_OpenACCLoopConstruct,
2169+
/** OpenACC Combined Constructs.
2170+
*/
2171+
CXCursor_OpenACCCombinedConstruct = 322,
2172+
2173+
/** OpenACC data Construct.
2174+
*/
2175+
CXCursor_OpenACCDataConstruct = 323,
2176+
2177+
/** OpenACC enter data Construct.
2178+
*/
2179+
CXCursor_OpenACCEnterDataConstruct = 324,
2180+
2181+
/** OpenACC exit data Construct.
2182+
*/
2183+
CXCursor_OpenACCExitDataConstruct = 325,
2184+
2185+
/** OpenACC host_data Construct.
2186+
*/
2187+
CXCursor_OpenACCHostDataConstruct = 326,
2188+
2189+
/** OpenACC wait Construct.
2190+
*/
2191+
CXCursor_OpenACCWaitConstruct = 327,
2192+
2193+
/** OpenACC init Construct.
2194+
*/
2195+
CXCursor_OpenACCInitConstruct = 328,
2196+
2197+
/** OpenACC shutdown Construct.
2198+
*/
2199+
CXCursor_OpenACCShutdownConstruct = 329,
2200+
2201+
/** OpenACC set Construct.
2202+
*/
2203+
CXCursor_OpenACCSetConstruct = 330,
2204+
2205+
/** OpenACC update Construct.
2206+
*/
2207+
CXCursor_OpenACCUpdateConstruct = 331,
2208+
2209+
CXCursor_LastStmt = CXCursor_OpenACCUpdateConstruct,
21662210

21672211
/**
21682212
* Cursor that represents the translation unit itself.
@@ -2974,7 +3018,11 @@ enum CXTypeKind {
29743018

29753019
CXType_ExtVector = 176,
29763020
CXType_Atomic = 177,
2977-
CXType_BTFTagAttributed = 178
3021+
CXType_BTFTagAttributed = 178,
3022+
3023+
/* HLSL Types */
3024+
CXType_HLSLResource = 179,
3025+
CXType_HLSLAttributedResource = 180
29783026
};
29793027

29803028
/**
@@ -3557,8 +3605,8 @@ CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
35573605

35583606
/**
35593607
* List the possible error codes for \c clang_Type_getSizeOf,
3560-
* \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3561-
* \c clang_Cursor_getOffsetOf.
3608+
* \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf,
3609+
* \c clang_Cursor_getOffsetOf, and \c clang_getOffsetOfBase.
35623610
*
35633611
* A value of this enumeration type can be returned if the target type is not
35643612
* a valid argument to sizeof, alignof or offsetof.
@@ -3723,6 +3771,15 @@ CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
37233771
*/
37243772
CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
37253773

3774+
/**
3775+
* Returns the offset in bits of a CX_CXXBaseSpecifier relative to the parent
3776+
* class.
3777+
*
3778+
* Returns a small negative number if the offset cannot be computed. See
3779+
* CXTypeLayoutError for error codes.
3780+
*/
3781+
CINDEX_LINKAGE long long clang_getOffsetOfBase(CXCursor Parent, CXCursor Base);
3782+
37263783
/**
37273784
* Represents the C++ access control level to a base class for a
37283785
* cursor with kind CX_CXXBaseSpecifier.
@@ -4134,6 +4191,14 @@ CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
41344191
CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
41354192
CXPrintingPolicy Policy);
41364193

4194+
/**
4195+
* Pretty-print the underlying type using a custom printing policy.
4196+
*
4197+
* If the type is invalid, an empty string is returned.
4198+
*/
4199+
CINDEX_LINKAGE CXString clang_getTypePrettyPrinted(CXType CT,
4200+
CXPrintingPolicy cxPolicy);
4201+
41374202
/**
41384203
* Retrieve the display name for the entity referenced by this cursor.
41394204
*
@@ -6592,6 +6657,29 @@ typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
65926657
CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
65936658
CXClientData client_data);
65946659

6660+
/**
6661+
* Visit the base classes of a type.
6662+
*
6663+
* This function visits all the direct base classes of a the given cursor,
6664+
* invoking the given \p visitor function with the cursors of each
6665+
* visited base. The traversal may be ended prematurely, if
6666+
* the visitor returns \c CXFieldVisit_Break.
6667+
*
6668+
* \param T the record type whose field may be visited.
6669+
*
6670+
* \param visitor the visitor function that will be invoked for each
6671+
* field of \p T.
6672+
*
6673+
* \param client_data pointer data supplied by the client, which will
6674+
* be passed to the visitor each time it is invoked.
6675+
*
6676+
* \returns a non-zero value if the traversal was terminated
6677+
* prematurely by the visitor returning \c CXFieldVisit_Break.
6678+
*/
6679+
CINDEX_LINKAGE unsigned clang_visitCXXBaseClasses(CXType T,
6680+
CXFieldVisitor visitor,
6681+
CXClientData client_data);
6682+
65956683
/**
65966684
* Describes the kind of binary operators.
65976685
*/

clang/include/clang/APINotes/APINotesReader.h

+7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ class APINotesReader {
141141
ObjCSelectorRef Selector,
142142
bool IsInstanceMethod);
143143

144+
/// Look for information regarding the given field of a C struct.
145+
///
146+
/// \param Name The name of the field.
147+
///
148+
/// \returns information about the field, if known.
149+
VersionedInfo<FieldInfo> lookupField(ContextID CtxID, llvm::StringRef Name);
150+
144151
/// Look for information regarding the given C++ method in the given C++ tag
145152
/// context.
146153
///

clang/include/clang/APINotes/APINotesWriter.h

+8
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ class APINotesWriter {
8686
void addCXXMethod(ContextID CtxID, llvm::StringRef Name,
8787
const CXXMethodInfo &Info, llvm::VersionTuple SwiftVersion);
8888

89+
/// Add information about a specific C record field.
90+
///
91+
/// \param CtxID The context in which this field resides, i.e. a C/C++ tag.
92+
/// \param Name The name of the field.
93+
/// \param Info Information about this field.
94+
void addField(ContextID CtxID, llvm::StringRef Name, const FieldInfo &Info,
95+
llvm::VersionTuple SwiftVersion);
96+
8997
/// Add information about a global variable.
9098
///
9199
/// \param Name The name of this global variable.

0 commit comments

Comments
 (0)