Skip to content

Commit

Permalink
[clang] Upgrade clang to 19.1.1
Browse files Browse the repository at this point in the history
Summary:
This diff upgrades the clang version to 19.1.1:
https://github.com/llvm/llvm-project/releases/tag/llvmorg-19.1.1

- Amended pre-existing patches.
- Removed not-supported functions in clang: `NamespaceDecl::isOriginalNamespace` and `UnresolvedLookupExpr::isOverloaded`
- Used `object_getClass` instead of `isa` in objc models.
- Some FNs are introduced in Inferbo, Cost/c++, and Biabduction/objc.

NOTE: On macos laptop with arm, ninja should be used to build clang.

Reviewed By: martintrojer

Differential Revision: D64109640

fbshipit-source-id: ad61a0a061dcefec93feee5ddc047bd99a1081bb
  • Loading branch information
skcho authored and facebook-github-bot committed Oct 16, 2024
1 parent 9e5388d commit e083d3f
Show file tree
Hide file tree
Showing 118 changed files with 6,597 additions and 5,727 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ TranslationUnitDecl None:None:None None:None:None
NamespaceDecl tests/namespace_decl.cpp:17:1 tests/namespace_decl.cpp:19:1
UsingDirectiveDecl tests/namespace_decl.cpp:17:11 tests/namespace_decl.cpp:17:11
TypedefDecl tests/namespace_decl.cpp:17:11 tests/namespace_decl.cpp:17:11
58 98
64 98
TranslationUnitDecl None:None:None None:None:None
TypedefDecl None:None:None None:None:None
TypedefDecl None:None:None None:None:None
Expand Down Expand Up @@ -748,6 +748,12 @@ TranslationUnitDecl None:None:None None:None:None
ParmVarDecl tests/new.cpp:34:12 tests/new.cpp:34:12
FunctionDecl tests/new.cpp:34:12 tests/new.cpp:34:12
ParmVarDecl tests/new.cpp:34:12 tests/new.cpp:34:12
ParmVarDecl tests/new.cpp:34:12 tests/new.cpp:34:12
FunctionDecl tests/new.cpp:34:12 tests/new.cpp:34:12
ParmVarDecl tests/new.cpp:34:12 tests/new.cpp:34:12
FunctionDecl tests/new.cpp:34:12 tests/new.cpp:34:12
ParmVarDecl tests/new.cpp:34:12 tests/new.cpp:34:12
ParmVarDecl tests/new.cpp:34:12 tests/new.cpp:34:12
FunctionDecl tests/new.cpp:38:1 tests/new.cpp:43:1
CompoundStmt
DeclStmt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ test
operator new
operator new[]
operator delete
operator delete
operator delete[]
operator delete[]
test_c11
operator new
Expand Down
6 changes: 6 additions & 0 deletions facebook-clang-plugins/clang/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CLANG_INSTALLED_VERSION_FILE="$SCRIPT_DIR/installed.version"
PATCHELF=${PATCHELF:-patchelf}
PLATFORM=$(uname)
PLATFORM_ENV=${PLATFORM_ENV:-}
SANDCASTLE=${SANDCASTLE:-}
STRIP=${STRIP:-strip}
CMAKE=${CMAKE:-cmake}
ZLIB=${ZLIB:-$CLANG_SRC}
Expand Down Expand Up @@ -182,6 +183,11 @@ if [ "$PLATFORM" = "Darwin" ]; then
-DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS $CMAKE_SHARED_LINKER_FLAGS"
-DLLVM_BUILD_LLVM_DYLIB=ON
)
if [ -n "$SANDCASTLE" ]; then
CMAKE_ARGS+=(
-DCMAKE_OSX_ARCHITECTURES=arm64
)
fi
else
CMAKE_ARGS+=(
-DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS $CMAKE_SHARED_LINKER_FLAGS -lstdc++ -fPIC"
Expand Down
12 changes: 6 additions & 6 deletions facebook-clang-plugins/clang/src/err_ret_local_block.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
--- a/llvm-project/clang/lib/Sema/SemaInit.cpp
+++ b/llvm-project/clang/lib/Sema/SemaInit.cpp
@@ -8282,7 +8282,9 @@ void Sema::checkInitializerLifetime(cons
<< Entity.getType()->isReferenceType() << DRE->getDecl()
--- a/llvm-project/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/llvm-project/clang/lib/Sema/CheckExprLifetime.cpp
@@ -1202,7 +1202,9 @@ static void checkExprLifetimeImpl(Sema &
<< InitEntity->getType()->isReferenceType() << DRE->getDecl()
<< isa<ParmVarDecl>(DRE->getDecl()) << DiagRange;
} else if (isa<BlockExpr>(L)) {
- Diag(DiagLoc, diag::err_ret_local_block) << DiagRange;
- SemaRef.Diag(DiagLoc, diag::err_ret_local_block) << DiagRange;
+ // Don't throw this error during Infer runs
+ // Diag(DiagLoc, diag::err_ret_local_block) << DiagRange;
+ // SemaRef.Diag(DiagLoc, diag::err_ret_local_block) << DiagRange;
+ return false;
} else if (isa<AddrLabelExpr>(L)) {
// Don't warn when returning a label from a statement expression.
Expand Down
30 changes: 15 additions & 15 deletions facebook-clang-plugins/clang/src/mangle_suppress_errors.patch
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
--- a/llvm-project/clang/lib/AST/ItaniumMangle.cpp
+++ b/llvm-project/clang/lib/AST/ItaniumMangle.cpp
@@ -1239,10 +1239,7 @@ void CXXNameMangler::mangleFloatLiteral(
@@ -1240,10 +1240,7 @@ void CXXNameMangler::mangleFloatLiteral(
}

void CXXNameMangler::mangleFixedPointLiteral() {
- DiagnosticsEngine &Diags = Context.getDiags();
- unsigned DiagID = Diags.getCustomDiagID(
- DiagnosticsEngine::Error, "cannot mangle fixed point literals yet");
- Diags.Report(DiagID);
+ Out << "__unhandled_FixedPointLiteral";
}

void CXXNameMangler::mangleNullPointer(QualType T) {
@@ -3812,11 +3809,7 @@ void CXXNameMangler::mangleNeonVectorTyp
@@ -3822,11 +3819,7 @@ void CXXNameMangler::mangleNeonVectorTyp
}

void CXXNameMangler::mangleNeonVectorType(const DependentVectorType *T) {
- DiagnosticsEngine &Diags = Context.getDiags();
- unsigned DiagID = Diags.getCustomDiagID(
Expand All @@ -23,9 +23,9 @@
- Diags.Report(T->getAttributeLoc(), DiagID);
+ Out << "__unhandled_NeonVectorType";
}

static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) {
@@ -3889,11 +3882,7 @@ void CXXNameMangler::mangleAArch64NeonVe
@@ -3899,11 +3892,7 @@ void CXXNameMangler::mangleAArch64NeonVe
Out << TypeName.length() << TypeName;
}
void CXXNameMangler::mangleAArch64NeonVectorType(const DependentVectorType *T) {
Expand All @@ -36,10 +36,10 @@
- Diags.Report(T->getAttributeLoc(), DiagID);
+ Out << "__unhandled_AArch64NeonVectorType";
}

// The AArch64 ACLE specifies that fixed-length SVE vector and predicate types
@@ -3986,11 +3975,7 @@ void CXXNameMangler::mangleAArch64FixedS

@@ -3996,11 +3985,7 @@ void CXXNameMangler::mangleAArch64FixedS
void CXXNameMangler::mangleAArch64FixedSveVectorType(
const DependentVectorType *T) {
- DiagnosticsEngine &Diags = Context.getDiags();
Expand All @@ -49,9 +49,9 @@
- Diags.Report(T->getAttributeLoc(), DiagID);
+ Out << "__unhandled_AArch64FixedSveVectorType";
}

void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) {
@@ -4747,12 +4732,7 @@ recurse:
@@ -4770,12 +4755,7 @@ recurse:
{
NotPrimaryExpr();
if (!NullOut) {
Expand All @@ -65,7 +65,7 @@
return;
}
break;
@@ -4787,12 +4767,7 @@ recurse:
@@ -4810,12 +4790,7 @@ recurse:
// Even gcc-4.5 doesn't mangle this.
case Expr::BinaryConditionalOperatorClass: {
NotPrimaryExpr();
Expand All @@ -78,8 +78,8 @@
+ Out << "__unhandled_BinaryConditionalOperatorClass";
return;
}

@@ -5157,18 +5132,11 @@ recurse:
@@ -5188,18 +5163,11 @@ recurse:
return;
}
case UETT_VecStep: {
Expand Down
4 changes: 2 additions & 2 deletions facebook-clang-plugins/clang/src/prepare_clang_src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SHASUM=${SHASUM:-shasum -a 256}
PATCH=${PATCH:-patch}

LLVM_VER="18.1.3"
LLVM_VER="19.1.1"
LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/llvm-project-${LLVM_VER}.src.tar.xz"
LLVM_SHA="2929f62d69dec0379e529eb632c40e15191e36f3bd58c2cb2df0413a0dc48651"
LLVM_SHA="d40e933e2a208ee142898f85d886423a217e991abbcd42dd8211f507c93e1266"
LLVM_FILE="llvm-project.src.tar.xz"
CLANG_PREBUILD_PATCHES=(
"$SCRIPT_DIR/err_ret_local_block.patch"
Expand Down
20 changes: 5 additions & 15 deletions facebook-clang-plugins/libtooling/ASTExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1172,22 +1172,16 @@ int ASTExporter<ATDWriter>::NamespaceDeclTupleSize() {
//@atd #define namespace_decl_tuple named_decl_tuple * decl_context_tuple * namespace_decl_info
//@atd type namespace_decl_info = {
//@atd ~is_inline : bool;
//@atd ?original_namespace : decl_ref option;
//@atd } <ocaml field_prefix="ndi_">
template <class ATDWriter>
void ASTExporter<ATDWriter>::VisitNamespaceDecl(const NamespaceDecl *D) {
VisitNamedDecl(D);
VisitDeclContext(D);

bool IsInline = D->isInline();
bool IsOriginalNamespace = D->isOriginalNamespace();
ObjectScope Scope(OF, 0 + IsInline + !IsOriginalNamespace);
ObjectScope Scope(OF, 0 + IsInline);

OF.emitFlag("is_inline", IsInline);
if (!IsOriginalNamespace) {
OF.emitTag("original_namespace");
dumpDeclRef(*D->getOriginalNamespace());
}
}

template <class ATDWriter>
Expand Down Expand Up @@ -3450,7 +3444,6 @@ int ASTExporter<ATDWriter>::UnresolvedLookupExprTupleSize() {
//@atd #define unresolved_lookup_expr_tuple overload_expr_tuple * unresolved_lookup_expr_info
//@atd type unresolved_lookup_expr_info = {
//@atd ~requires_ADL : bool;
//@atd ~is_overloaded : bool;
//@atd ?naming_class : decl_ref option;
//@atd } <ocaml field_prefix="ulei_">
template <class ATDWriter>
Expand All @@ -3459,14 +3452,11 @@ void ASTExporter<ATDWriter>::VisitUnresolvedLookupExpr(
VisitOverloadExpr(Node);

bool RequiresADL = Node->requiresADL();
bool IsOverloaded = Node->isOverloaded();
bool HasNamingClass = Node->getNamingClass();
ObjectScope Scope(
OF,
0 + RequiresADL + IsOverloaded + HasNamingClass); // not covered by tests
ObjectScope Scope(OF,
0 + RequiresADL + HasNamingClass); // not covered by tests

OF.emitFlag("requires_ADL", RequiresADL);
OF.emitFlag("is_overloaded", IsOverloaded);
if (HasNamingClass) {
OF.emitTag("naming_class");
dumpDeclRef(*Node->getNamingClass());
Expand Down Expand Up @@ -3856,7 +3846,7 @@ int ASTExporter<ATDWriter>::AtomicExprTupleSize() {
//@atd } <ocaml field_prefix="aei_">
//@atd type atomic_expr_kind = [
#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) //@atd | AO@@ID
#include <clang/Basic/Builtins.def>
#include <clang/Basic/Builtins.inc>
//@atd ]
template <class ATDWriter>
void ASTExporter<ATDWriter>::VisitAtomicExpr(const AtomicExpr *Node) {
Expand All @@ -3869,7 +3859,7 @@ void ASTExporter<ATDWriter>::VisitAtomicExpr(const AtomicExpr *Node) {
case AtomicExpr::AO##ID: \
OF.emitSimpleVariant("AO" #ID); \
break;
#include <clang/Basic/Builtins.def>
#include <clang/Basic/Builtins.inc>
default:
llvm_unreachable("Unknown atomic_expr_kind is given!");
}
Expand Down
Loading

0 comments on commit e083d3f

Please sign in to comment.