https://github.com/mcbarton updated https://github.com/llvm/llvm-project/pull/146786
>From ef5f9e92dca662c7de4dd6cc2ef8c02ec3aaad60 Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbar...@users.noreply.github.com> Date: Wed, 2 Jul 2025 22:17:30 +0100 Subject: [PATCH 1/3] Add __attribute__((visibility("default"))) attribute to stop symbols being hidden when linking clangInterpreter library to other libraries during Emscripten build Currently CppInterOp links its Emscripten shared library to the Emscripten static library libclangInterpreter.a . Certain symbols get hidden in libclangInterOp.a due to the -fvisibility-inlines-hidden flag when building an Emscripten build of llvm. This causes the CppInterOp to have to manually export these in a non Emscripten recommended way (see https://github.com/compiler-research/CppInterOp/blob/main/lib/CppInterOp/exports.ld ). This patch would allow us to avoid this method, by marking these symbols are visible, instead of hidden. --- clang/lib/AST/ASTContext.cpp | 8 ++++---- clang/lib/AST/Decl.cpp | 10 +++++----- clang/lib/AST/DeclBase.cpp | 14 +++++++------- clang/lib/AST/DeclTemplate.cpp | 4 ++-- clang/lib/AST/Mangle.cpp | 4 ++-- clang/lib/AST/Type.cpp | 6 +++--- clang/lib/Interpreter/Interpreter.cpp | 8 ++++---- clang/lib/Interpreter/InterpreterValuePrinter.cpp | 4 ++-- clang/lib/Sema/SemaDeclCXX.cpp | 2 +- llvm/include/llvm/ADT/SmallVector.h | 4 ++-- llvm/include/llvm/Support/raw_ostream.h | 2 +- llvm/lib/Support/APInt.cpp | 10 +++++----- llvm/lib/Support/Debug.cpp | 2 +- llvm/lib/Support/Error.cpp | 4 ++-- llvm/lib/Support/ErrorHandling.cpp | 2 +- llvm/lib/Support/MemAlloc.cpp | 2 +- llvm/lib/Support/StringMap.cpp | 6 +++--- llvm/lib/Support/Valgrind.cpp | 4 ++-- llvm/lib/Support/raw_ostream.cpp | 12 ++++++------ 19 files changed, 54 insertions(+), 54 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b13bdd5642977..3b05d83944052 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3895,7 +3895,7 @@ void ASTContext::adjustExceptionSpec( /// getComplexType - Return the uniqued reference to the type for a complex /// number with the specified element type. -QualType ASTContext::getComplexType(QualType T) const { +__attribute__((visibility("default"))) QualType ASTContext::getComplexType(QualType T) const { // Unique pointers, to guarantee there is only one pointer of a particular // structure. llvm::FoldingSetNodeID ID; @@ -4079,7 +4079,7 @@ QualType ASTContext::getBlockPointerType(QualType T) const { /// getLValueReferenceType - Return the uniqued reference to the type for an /// lvalue reference to the specified type. -QualType +__attribute__((visibility("default"))) QualType ASTContext::getLValueReferenceType(QualType T, bool SpelledAsLValue) const { assert((!T->isPlaceholderType() || T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) && @@ -5251,7 +5251,7 @@ QualType ASTContext::getInjectedClassNameType(CXXRecordDecl *Decl, /// getTypeDeclType - Return the unique reference to the type for the /// specified type declaration. -QualType ASTContext::getTypeDeclTypeSlow(const TypeDecl *Decl) const { +__attribute__((visibility("default"))) QualType ASTContext::getTypeDeclTypeSlow(const TypeDecl *Decl) const { assert(Decl && "Passed null for Decl param"); assert(!Decl->TypeForDecl && "TypeForDecl present in slow case"); @@ -13125,7 +13125,7 @@ VTableContextBase *ASTContext::getVTableContext() { return VTContext.get(); } -MangleContext *ASTContext::createMangleContext(const TargetInfo *T) { +__attribute__((visibility("default"))) MangleContext *ASTContext::createMangleContext(const TargetInfo *T) { if (!T) T = Target; switch (T->getCXXABI().getKind()) { diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 5cdf75d71e4d7..c6d9cfc918bee 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2255,7 +2255,7 @@ bool VarDecl::isInExternCXXContext() const { VarDecl *VarDecl::getCanonicalDecl() { return getFirstDecl(); } -VarDecl::DefinitionKind +__attribute__((visibility("default"))) VarDecl::DefinitionKind VarDecl::isThisDeclarationADefinition(ASTContext &C) const { if (isThisDeclarationADemotedDefinition()) return DeclarationOnly; @@ -3763,7 +3763,7 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const { /// getNumParams - Return the number of parameters this function must have /// based on its FunctionType. This is the length of the ParamInfo array /// after it has been created. -unsigned FunctionDecl::getNumParams() const { +__attribute__((visibility("default"))) unsigned FunctionDecl::getNumParams() const { const auto *FPT = getType()->getAs<FunctionProtoType>(); return FPT ? FPT->getNumParams() : 0; } @@ -4200,7 +4200,7 @@ bool FunctionDecl::isTemplateInstantiation() const { return clang::isTemplateInstantiation(getTemplateSpecializationKind()); } -FunctionDecl * +__attribute__((visibility("default"))) FunctionDecl * FunctionDecl::getTemplateInstantiationPattern(bool ForDefinition) const { // If this is a generic lambda call operator specialization, its // instantiation pattern is always its primary template's pattern @@ -4265,7 +4265,7 @@ FunctionDecl::getTemplateSpecializationInfo() const { TemplateOrSpecialization); } -const TemplateArgumentList * +__attribute__((visibility("default"))) const TemplateArgumentList * FunctionDecl::getTemplateSpecializationArgs() const { if (FunctionTemplateSpecializationInfo *Info = dyn_cast_if_present<FunctionTemplateSpecializationInfo *>( @@ -5143,7 +5143,7 @@ RecordDecl *RecordDecl::CreateDeserialized(const ASTContext &C, return R; } -bool RecordDecl::isInjectedClassName() const { +__attribute__((visibility("default"))) bool RecordDecl::isInjectedClassName() const { return isImplicit() && getDeclName() && getDeclContext()->isRecord() && cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName(); } diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 13c46fdbff96a..83441e9bdd068 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -526,7 +526,7 @@ TranslationUnitDecl *Decl::getTranslationUnitDecl() { return cast<TranslationUnitDecl>(DC); } -ASTContext &Decl::getASTContext() const { +__attribute__((visibility("default"))) ASTContext &Decl::getASTContext() const { return getTranslationUnitDecl()->getASTContext(); } @@ -613,7 +613,7 @@ ExternalSourceSymbolAttr *Decl::getExternalSourceSymbolAttr() const { return nullptr; } -bool Decl::hasDefiningAttr() const { +__attribute__((visibility("default"))) bool Decl::hasDefiningAttr() const { return hasAttr<AliasAttr>() || hasAttr<IFuncAttr>() || hasAttr<LoaderUninitializedAttr>(); } @@ -1047,7 +1047,7 @@ void Decl::addAttr(Attr *A) { Attrs.insert(I, A); } -const AttrVec &Decl::getAttrs() const { +__attribute__((visibility("default"))) const AttrVec &Decl::getAttrs() const { assert(HasAttrs && "No attrs to get!"); return getASTContext().getDeclAttrs(this); } @@ -1065,7 +1065,7 @@ Decl *Decl::castFromDeclContext (const DeclContext *D) { } } -DeclContext *Decl::castToDeclContext(const Decl *D) { +__attribute__((visibility("default"))) DeclContext *Decl::castToDeclContext(const Decl *D) { Decl::Kind DK = D->getKind(); switch(DK) { #define DECL(NAME, BASE) @@ -1291,7 +1291,7 @@ DeclContext::DeclContext(Decl::Kind K) { setUseQualifiedLookup(false); } -bool DeclContext::classof(const Decl *D) { +__attribute__((visibility("default"))) bool DeclContext::classof(const Decl *D) { Decl::Kind DK = D->getKind(); switch (DK) { #define DECL(NAME, BASE) @@ -1662,7 +1662,7 @@ ExternalASTSource::SetExternalVisibleDeclsForName(const DeclContext *DC, return List.getLookupResult(); } -DeclContext::decl_iterator DeclContext::decls_begin() const { +__attribute__((visibility("default"))) DeclContext::decl_iterator DeclContext::decls_begin() const { if (hasExternalLexicalStorage()) LoadLexicalDeclsFromExternalStorage(); return decl_iterator(FirstDecl); @@ -1891,7 +1891,7 @@ void DeclContext::buildLookupImpl(DeclContext *DCtx, bool Internal) { } } -DeclContext::lookup_result +__attribute__((visibility("default"))) DeclContext::lookup_result DeclContext::lookup(DeclarationName Name) const { // For transparent DeclContext, we should lookup in their enclosing context. if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export) diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 5035f2d33b0a1..9a1a35a39df36 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -549,7 +549,7 @@ void ClassTemplateDecl::LoadLazySpecializations( loadLazySpecializationsImpl(OnlyPartial); } -llvm::FoldingSetVector<ClassTemplateSpecializationDecl> & +__attribute__((visibility("default"))) llvm::FoldingSetVector<ClassTemplateSpecializationDecl> & ClassTemplateDecl::getSpecializations() const { LoadLazySpecializations(); return getCommonPtr()->Specializations; @@ -1451,7 +1451,7 @@ void VarTemplateSpecializationDecl::getNameForDiagnostic( } } -VarTemplateDecl *VarTemplateSpecializationDecl::getSpecializedTemplate() const { +__attribute__((visibility("default"))) VarTemplateDecl *VarTemplateSpecializationDecl::getSpecializedTemplate() const { if (const auto *PartialSpec = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>()) return PartialSpec->PartialSpecialization->getSpecializedTemplate(); diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index 9652fdbc4e125..fad5f316f1040 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -118,7 +118,7 @@ static CCMangling getCallingConvMangling(const ASTContext &Context, } } -bool MangleContext::shouldMangleDeclName(const NamedDecl *D) { +__attribute__((visibility("default"))) bool MangleContext::shouldMangleDeclName(const NamedDecl *D) { const ASTContext &ASTContext = getASTContext(); CCMangling CC = getCallingConvMangling(ASTContext, D); @@ -152,7 +152,7 @@ bool MangleContext::shouldMangleDeclName(const NamedDecl *D) { return shouldMangleCXXName(D); } -void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) { +__attribute__((visibility("default"))) void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) { const ASTContext &ASTContext = getASTContext(); const NamedDecl *D = cast<NamedDecl>(GD.getDecl()); diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index e5a1ab2ff8906..128b46b3d46d9 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -650,7 +650,7 @@ template <> const CountAttributedType *Type::getAs() const { /// getUnqualifiedDesugaredType - Pull any qualifiers and syntactic /// sugar off the given type. This should produce an object of the /// same dynamic type as the canonical type. -const Type *Type::getUnqualifiedDesugaredType() const { +__attribute__((visibility("default"))) const Type *Type::getUnqualifiedDesugaredType() const { const Type *Cur = this; while (true) { @@ -2302,7 +2302,7 @@ bool Type::hasUnsignedIntegerRepresentation() const { return isUnsignedIntegerOrEnumerationType(); } -bool Type::isFloatingType() const { +__attribute__((visibility("default"))) bool Type::isFloatingType() const { if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) return BT->isFloatingPoint(); if (const auto *CT = dyn_cast<ComplexType>(CanonicalType)) @@ -4227,7 +4227,7 @@ static TagDecl *getInterestingTagDecl(TagDecl *decl) { return decl; } -TagDecl *TagType::getDecl() const { return getInterestingTagDecl(decl); } +__attribute__((visibility("default"))) TagDecl *TagType::getDecl() const { return getInterestingTagDecl(decl); } bool TagType::isBeingDefined() const { return getDecl()->isBeingDefined(); } diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 2f110659d19a4..3402e274109cb 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -194,7 +194,7 @@ IncrementalCompilerBuilder::create(std::string TT, return CreateCI(**ErrOrCC1Args); } -llvm::Expected<std::unique_ptr<CompilerInstance>> +__attribute__((visibility("default"))) llvm::Expected<std::unique_ptr<CompilerInstance>> IncrementalCompilerBuilder::CreateCpp() { std::vector<const char *> Argv; Argv.reserve(5 + 1 + UserArgs.size()); @@ -524,7 +524,7 @@ const CompilerInstance *Interpreter::getCompilerInstance() const { return CI.get(); } -CompilerInstance *Interpreter::getCompilerInstance() { return CI.get(); } +__attribute__((visibility("default"))) CompilerInstance *Interpreter::getCompilerInstance() { return CI.get(); } llvm::Expected<llvm::orc::LLJIT &> Interpreter::getExecutionEngine() { if (!IncrExecutor) { @@ -577,7 +577,7 @@ Interpreter::RegisterPTU(TranslationUnitDecl *TU, return LastPTU; } -llvm::Expected<PartialTranslationUnit &> +__attribute__((visibility("default"))) llvm::Expected<PartialTranslationUnit &> Interpreter::Parse(llvm::StringRef Code) { // If we have a device parser, parse it first. The generated code will be // included in the host compilation @@ -673,7 +673,7 @@ llvm::Error Interpreter::CreateExecutor() { void Interpreter::ResetExecutor() { IncrExecutor.reset(); } -llvm::Error Interpreter::Execute(PartialTranslationUnit &T) { +__attribute__((visibility("default"))) llvm::Error Interpreter::Execute(PartialTranslationUnit &T) { assert(T.TheModule); LLVM_DEBUG( llvm::dbgs() << "execute-ptu " diff --git a/clang/lib/Interpreter/InterpreterValuePrinter.cpp b/clang/lib/Interpreter/InterpreterValuePrinter.cpp index 3e7e32b2e8557..195de31155904 100644 --- a/clang/lib/Interpreter/InterpreterValuePrinter.cpp +++ b/clang/lib/Interpreter/InterpreterValuePrinter.cpp @@ -300,7 +300,7 @@ llvm::Expected<Expr *> Interpreter::ExtractValueFromExpr(Expr *E) { using namespace clang; // Temporary rvalue struct that need special care. -REPL_EXTERNAL_VISIBILITY void * +REPL_EXTERNAL_VISIBILITY __attribute__((visibility("default"))) void * __clang_Interpreter_SetValueWithAlloc(void *This, void *OutVal, void *OpaqueType) { Value &VRef = *(Value *)OutVal; @@ -308,7 +308,7 @@ __clang_Interpreter_SetValueWithAlloc(void *This, void *OutVal, return VRef.getPtr(); } -extern "C" void REPL_EXTERNAL_VISIBILITY __clang_Interpreter_SetValueNoAlloc( +extern "C" __attribute__((visibility("default"))) void REPL_EXTERNAL_VISIBILITY __clang_Interpreter_SetValueNoAlloc( void *This, void *OutVal, void *OpaqueType, ...) { Value &VRef = *(Value *)OutVal; Interpreter *I = static_cast<Interpreter *>(This); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index e8c65025bfe6d..965f8b096f64f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -11959,7 +11959,7 @@ EnumDecl *Sema::getStdAlignValT() const { return cast_or_null<EnumDecl>(StdAlignValT.get(Context.getExternalSource())); } -NamespaceDecl *Sema::getStdNamespace() const { +__attribute__((visibility("default"))) NamespaceDecl *Sema::getStdNamespace() const { return cast_or_null<NamespaceDecl>( StdNamespace.get(Context.getExternalSource())); } diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index 0b8bb48b8fe5e..d124f44d72e94 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -73,7 +73,7 @@ template <class Size_T> class SmallVectorBase { /// This is an implementation of the grow() method which only works /// on POD-like data types and is out of line to reduce code duplication. /// This function will report a fatal error if it cannot increase capacity. - LLVM_ABI void grow_pod(void *FirstEl, size_t MinSize, size_t TSize); + __attribute__((visibility("default"))) LLVM_ABI void grow_pod(void *FirstEl, size_t MinSize, size_t TSize); public: size_t size() const { return Size; } @@ -86,7 +86,7 @@ template <class Size_T> class SmallVectorBase { /// capacity for. /// /// This does not construct or destroy any elements in the vector. - void set_size(size_t N) { + __attribute__((visibility("default"))) void set_size(size_t N) { assert(N <= capacity()); // implies no overflow in assignment Size = static_cast<Size_T>(N); } diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h index f87344e860518..ca8935c9e02e5 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -659,7 +659,7 @@ class raw_fd_stream : public raw_fd_ostream { /// raw_string_ostream operates without a buffer, delegating all memory /// management to the std::string. Thus the std::string is always up-to-date, /// may be used directly and there is no need to call flush(). -class LLVM_ABI raw_string_ostream : public raw_ostream { +class __attribute__((visibility("default"))) LLVM_ABI raw_string_ostream : public raw_ostream { std::string &OS; /// See raw_ostream::write_impl. diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 954af7fff92a8..a4afa302725ae 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -104,7 +104,7 @@ void APInt::initFromArray(ArrayRef<uint64_t> bigVal) { clearUnusedBits(); } -APInt::APInt(unsigned numBits, ArrayRef<uint64_t> bigVal) : BitWidth(numBits) { +__attribute__((visibility("default"))) APInt::APInt(unsigned numBits, ArrayRef<uint64_t> bigVal) : BitWidth(numBits) { initFromArray(bigVal); } @@ -281,7 +281,7 @@ bool APInt::equalSlowCase(const APInt &RHS) const { return std::equal(U.pVal, U.pVal + getNumWords(), RHS.U.pVal); } -int APInt::compare(const APInt& RHS) const { +__attribute__((visibility("default"))) int APInt::compare(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"); if (isSingleWord()) return U.VAL < RHS.U.VAL ? -1 : U.VAL > RHS.U.VAL; @@ -289,7 +289,7 @@ int APInt::compare(const APInt& RHS) const { return tcCompare(U.pVal, RHS.U.pVal, getNumWords()); } -int APInt::compareSigned(const APInt& RHS) const { +__attribute__((visibility("default"))) int APInt::compareSigned(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"); if (isSingleWord()) { int64_t lhsSext = SignExtend64(U.VAL, BitWidth); @@ -982,7 +982,7 @@ APInt APInt::truncSSat(unsigned width) const { } // Sign extend to a new width. -APInt APInt::sext(unsigned Width) const { +__attribute__((visibility("default"))) APInt APInt::sext(unsigned Width) const { assert(Width >= BitWidth && "Invalid APInt SignExtend request"); if (Width <= APINT_BITS_PER_WORD) @@ -1009,7 +1009,7 @@ APInt APInt::sext(unsigned Width) const { } // Zero extend to a new width. -APInt APInt::zext(unsigned width) const { +__attribute__((visibility("default"))) APInt APInt::zext(unsigned width) const { assert(width >= BitWidth && "Invalid APInt ZeroExtend request"); if (width <= APINT_BITS_PER_WORD) diff --git a/llvm/lib/Support/Debug.cpp b/llvm/lib/Support/Debug.cpp index 5bb04d0c22998..7f85a0ceda01d 100644 --- a/llvm/lib/Support/Debug.cpp +++ b/llvm/lib/Support/Debug.cpp @@ -159,7 +159,7 @@ static void debug_user_sig_handler(void *Cookie) { } /// dbgs - Return a circular-buffered debug stream. -raw_ostream &llvm::dbgs() { +__attribute__((visibility("default"))) raw_ostream &llvm::dbgs() { // Do one-time initialization in a thread-safe way. static struct dbgstream { circular_raw_ostream strm; diff --git a/llvm/lib/Support/Error.cpp b/llvm/lib/Support/Error.cpp index d168b462a6eb2..13b66a581cc32 100644 --- a/llvm/lib/Support/Error.cpp +++ b/llvm/lib/Support/Error.cpp @@ -62,7 +62,7 @@ char ECError::ID = 0; char StringError::ID = 0; char FileError::ID = 0; -void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) { +__attribute__((visibility("default"))) void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) { if (!E) return; OS << ErrorBanner; @@ -125,7 +125,7 @@ std::error_code errorToErrorCode(Error Err) { } #if LLVM_ENABLE_ABI_BREAKING_CHECKS -void Error::fatalUncheckedError() const { +__attribute__((visibility("default"))) void Error::fatalUncheckedError() const { dbgs() << "Program aborted due to an unhandled Error:\n"; if (getPtr()) { getPtr()->log(dbgs()); diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp index cc16f2037ea58..014622aa35dba 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -219,7 +219,7 @@ void llvm::install_out_of_memory_new_handler() { } #endif -void llvm::llvm_unreachable_internal(const char *msg, const char *file, +__attribute__((visibility("default"))) void llvm::llvm_unreachable_internal(const char *msg, const char *file, unsigned line) { // This code intentionally doesn't call the ErrorHandler callback, because // llvm_unreachable is intended to be used to indicate "impossible" diff --git a/llvm/lib/Support/MemAlloc.cpp b/llvm/lib/Support/MemAlloc.cpp index 6adc9abd75c5b..f671be4426abe 100644 --- a/llvm/lib/Support/MemAlloc.cpp +++ b/llvm/lib/Support/MemAlloc.cpp @@ -11,7 +11,7 @@ // These are out of line to have __cpp_aligned_new not affect ABI. -LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * +__attribute__((visibility("default"))) LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * llvm::allocate_buffer(size_t Size, size_t Alignment) { void *Result = ::operator new(Size, #ifdef __cpp_aligned_new diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp index 432e1fc343f1f..aea9a6ae08d6c 100644 --- a/llvm/lib/Support/StringMap.cpp +++ b/llvm/lib/Support/StringMap.cpp @@ -43,7 +43,7 @@ static inline unsigned *getHashTable(StringMapEntryBase **TheTable, return reinterpret_cast<unsigned *>(TheTable + NumBuckets + 1); } -uint32_t StringMapImpl::hash(StringRef Key) { return xxh3_64bits(Key); } +__attribute__((visibility("default"))) uint32_t StringMapImpl::hash(StringRef Key) { return xxh3_64bits(Key); } StringMapImpl::StringMapImpl(unsigned InitSize, unsigned itemSize) { ItemSize = itemSize; @@ -83,7 +83,7 @@ void StringMapImpl::init(unsigned InitSize) { /// specified bucket will be non-null. Otherwise, it will be null. In either /// case, the FullHashValue field of the bucket will be set to the hash value /// of the string. -unsigned StringMapImpl::LookupBucketFor(StringRef Name, +__attribute__((visibility("default"))) unsigned StringMapImpl::LookupBucketFor(StringRef Name, uint32_t FullHashValue) { #ifdef EXPENSIVE_CHECKS assert(FullHashValue == hash(Name)); @@ -215,7 +215,7 @@ StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) { /// RehashTable - Grow the table, redistributing values into the buckets with /// the appropriate mod-of-hashtable-size. -unsigned StringMapImpl::RehashTable(unsigned BucketNo) { +__attribute__((visibility("default"))) unsigned StringMapImpl::RehashTable(unsigned BucketNo) { unsigned NewSize; // If the hash table is now more than 3/4 full, or if fewer than 1/8 of // the buckets are empty (meaning that many are filled with tombstones), diff --git a/llvm/lib/Support/Valgrind.cpp b/llvm/lib/Support/Valgrind.cpp index 5994656c5c031..e54b192f61fba 100644 --- a/llvm/lib/Support/Valgrind.cpp +++ b/llvm/lib/Support/Valgrind.cpp @@ -19,7 +19,7 @@ #if HAVE_VALGRIND_VALGRIND_H #include <valgrind/valgrind.h> -bool llvm::sys::RunningOnValgrind() { +__attribute__((visibility("default"))) bool llvm::sys::RunningOnValgrind() { return RUNNING_ON_VALGRIND; } @@ -29,7 +29,7 @@ void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) { #else // !HAVE_VALGRIND_VALGRIND_H -bool llvm::sys::RunningOnValgrind() { +__attribute__((visibility("default"))) bool llvm::sys::RunningOnValgrind() { return false; } diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index 07b99896543bd..b6ada2b509701 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -72,7 +72,7 @@ constexpr raw_ostream::Colors raw_ostream::WHITE; constexpr raw_ostream::Colors raw_ostream::SAVEDCOLOR; constexpr raw_ostream::Colors raw_ostream::RESET; -raw_ostream::~raw_ostream() { +__attribute__((visibility("default"))) raw_ostream::~raw_ostream() { // raw_ostream's subclasses should take care to flush the buffer // in their destructors. assert(OutBufCur == OutBufStart && @@ -103,7 +103,7 @@ void raw_ostream::SetBuffered() { SetUnbuffered(); } -void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, +__attribute__((visibility("default"))) void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, BufferKind Mode) { assert(((Mode == BufferKind::Unbuffered && !BufferStart && Size == 0) || (Mode != BufferKind::Unbuffered && BufferStart && Size != 0)) && @@ -122,7 +122,7 @@ void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, assert(OutBufStart <= OutBufEnd && "Invalid size!"); } -raw_ostream &raw_ostream::operator<<(unsigned long N) { +__attribute__((visibility("default"))) raw_ostream &raw_ostream::operator<<(unsigned long N) { write_integer(*this, static_cast<uint64_t>(N), 0, IntegerStyle::Integer); return *this; } @@ -215,7 +215,7 @@ raw_ostream &raw_ostream::operator<<(double N) { return *this; } -void raw_ostream::flush_nonempty() { +__attribute__((visibility("default"))) void raw_ostream::flush_nonempty() { assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty."); size_t Length = OutBufCur - OutBufStart; OutBufCur = OutBufStart; @@ -242,7 +242,7 @@ raw_ostream &raw_ostream::write(unsigned char C) { return *this; } -raw_ostream &raw_ostream::write(const char *Ptr, size_t Size) { +__attribute__((visibility("default"))) raw_ostream &raw_ostream::write(const char *Ptr, size_t Size) { // Group exceptional cases into a single branch. if (LLVM_UNLIKELY(size_t(OutBufEnd - OutBufCur) < Size)) { if (LLVM_UNLIKELY(!OutBufStart)) { @@ -905,7 +905,7 @@ raw_fd_ostream &llvm::outs() { return S; } -raw_fd_ostream &llvm::errs() { +__attribute__((visibility("default"))) raw_fd_ostream &llvm::errs() { // On z/OS we need to enable auto conversion static std::error_code EC = enableAutoConversion(STDERR_FILENO); assert(!EC); >From be752e29d3de450bf46697175e5e93c65d7b95e4 Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbar...@users.noreply.github.com> Date: Wed, 2 Jul 2025 23:10:46 +0100 Subject: [PATCH 2/3] Apply git clang format --- clang/lib/AST/ASTContext.cpp | 9 ++++++--- clang/lib/AST/Decl.cpp | 6 ++++-- clang/lib/AST/DeclBase.cpp | 9 ++++++--- clang/lib/AST/DeclTemplate.cpp | 6 ++++-- clang/lib/AST/Mangle.cpp | 6 ++++-- clang/lib/AST/Type.cpp | 7 +++++-- clang/lib/Interpreter/Interpreter.cpp | 11 ++++++++--- clang/lib/Interpreter/InterpreterValuePrinter.cpp | 5 +++-- clang/lib/Sema/SemaDeclCXX.cpp | 3 ++- llvm/include/llvm/ADT/SmallVector.h | 3 ++- llvm/include/llvm/Support/raw_ostream.h | 3 ++- llvm/lib/Support/APInt.cpp | 10 +++++++--- llvm/lib/Support/Error.cpp | 3 ++- llvm/lib/Support/ErrorHandling.cpp | 5 +++-- llvm/lib/Support/MemAlloc.cpp | 3 ++- llvm/lib/Support/StringMap.cpp | 12 ++++++++---- llvm/lib/Support/raw_ostream.cpp | 10 ++++++---- 17 files changed, 74 insertions(+), 37 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 3b05d83944052..35b5e019dcdef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3895,7 +3895,8 @@ void ASTContext::adjustExceptionSpec( /// getComplexType - Return the uniqued reference to the type for a complex /// number with the specified element type. -__attribute__((visibility("default"))) QualType ASTContext::getComplexType(QualType T) const { +__attribute__((visibility("default"))) QualType +ASTContext::getComplexType(QualType T) const { // Unique pointers, to guarantee there is only one pointer of a particular // structure. llvm::FoldingSetNodeID ID; @@ -5251,7 +5252,8 @@ QualType ASTContext::getInjectedClassNameType(CXXRecordDecl *Decl, /// getTypeDeclType - Return the unique reference to the type for the /// specified type declaration. -__attribute__((visibility("default"))) QualType ASTContext::getTypeDeclTypeSlow(const TypeDecl *Decl) const { +__attribute__((visibility("default"))) QualType +ASTContext::getTypeDeclTypeSlow(const TypeDecl *Decl) const { assert(Decl && "Passed null for Decl param"); assert(!Decl->TypeForDecl && "TypeForDecl present in slow case"); @@ -13125,7 +13127,8 @@ VTableContextBase *ASTContext::getVTableContext() { return VTContext.get(); } -__attribute__((visibility("default"))) MangleContext *ASTContext::createMangleContext(const TargetInfo *T) { +__attribute__((visibility("default"))) MangleContext * +ASTContext::createMangleContext(const TargetInfo *T) { if (!T) T = Target; switch (T->getCXXABI().getKind()) { diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index c6d9cfc918bee..dac8f2076285d 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3763,7 +3763,8 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const { /// getNumParams - Return the number of parameters this function must have /// based on its FunctionType. This is the length of the ParamInfo array /// after it has been created. -__attribute__((visibility("default"))) unsigned FunctionDecl::getNumParams() const { +__attribute__((visibility("default"))) unsigned +FunctionDecl::getNumParams() const { const auto *FPT = getType()->getAs<FunctionProtoType>(); return FPT ? FPT->getNumParams() : 0; } @@ -5143,7 +5144,8 @@ RecordDecl *RecordDecl::CreateDeserialized(const ASTContext &C, return R; } -__attribute__((visibility("default"))) bool RecordDecl::isInjectedClassName() const { +__attribute__((visibility("default"))) bool +RecordDecl::isInjectedClassName() const { return isImplicit() && getDeclName() && getDeclContext()->isRecord() && cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName(); } diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 83441e9bdd068..122df4520f3bf 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1065,7 +1065,8 @@ Decl *Decl::castFromDeclContext (const DeclContext *D) { } } -__attribute__((visibility("default"))) DeclContext *Decl::castToDeclContext(const Decl *D) { +__attribute__((visibility("default"))) DeclContext * +Decl::castToDeclContext(const Decl *D) { Decl::Kind DK = D->getKind(); switch(DK) { #define DECL(NAME, BASE) @@ -1291,7 +1292,8 @@ DeclContext::DeclContext(Decl::Kind K) { setUseQualifiedLookup(false); } -__attribute__((visibility("default"))) bool DeclContext::classof(const Decl *D) { +__attribute__((visibility("default"))) bool +DeclContext::classof(const Decl *D) { Decl::Kind DK = D->getKind(); switch (DK) { #define DECL(NAME, BASE) @@ -1662,7 +1664,8 @@ ExternalASTSource::SetExternalVisibleDeclsForName(const DeclContext *DC, return List.getLookupResult(); } -__attribute__((visibility("default"))) DeclContext::decl_iterator DeclContext::decls_begin() const { +__attribute__((visibility("default"))) DeclContext::decl_iterator +DeclContext::decls_begin() const { if (hasExternalLexicalStorage()) LoadLexicalDeclsFromExternalStorage(); return decl_iterator(FirstDecl); diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 9a1a35a39df36..97b0fa9bf106a 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -549,7 +549,8 @@ void ClassTemplateDecl::LoadLazySpecializations( loadLazySpecializationsImpl(OnlyPartial); } -__attribute__((visibility("default"))) llvm::FoldingSetVector<ClassTemplateSpecializationDecl> & +__attribute__((visibility("default"))) +llvm::FoldingSetVector<ClassTemplateSpecializationDecl> & ClassTemplateDecl::getSpecializations() const { LoadLazySpecializations(); return getCommonPtr()->Specializations; @@ -1451,7 +1452,8 @@ void VarTemplateSpecializationDecl::getNameForDiagnostic( } } -__attribute__((visibility("default"))) VarTemplateDecl *VarTemplateSpecializationDecl::getSpecializedTemplate() const { +__attribute__((visibility("default"))) VarTemplateDecl * +VarTemplateSpecializationDecl::getSpecializedTemplate() const { if (const auto *PartialSpec = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>()) return PartialSpec->PartialSpecialization->getSpecializedTemplate(); diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index fad5f316f1040..704820e9223d2 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -118,7 +118,8 @@ static CCMangling getCallingConvMangling(const ASTContext &Context, } } -__attribute__((visibility("default"))) bool MangleContext::shouldMangleDeclName(const NamedDecl *D) { +__attribute__((visibility("default"))) bool +MangleContext::shouldMangleDeclName(const NamedDecl *D) { const ASTContext &ASTContext = getASTContext(); CCMangling CC = getCallingConvMangling(ASTContext, D); @@ -152,7 +153,8 @@ __attribute__((visibility("default"))) bool MangleContext::shouldMangleDeclName( return shouldMangleCXXName(D); } -__attribute__((visibility("default"))) void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) { +__attribute__((visibility("default"))) void +MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) { const ASTContext &ASTContext = getASTContext(); const NamedDecl *D = cast<NamedDecl>(GD.getDecl()); diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 128b46b3d46d9..c4e451c9d78db 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -650,7 +650,8 @@ template <> const CountAttributedType *Type::getAs() const { /// getUnqualifiedDesugaredType - Pull any qualifiers and syntactic /// sugar off the given type. This should produce an object of the /// same dynamic type as the canonical type. -__attribute__((visibility("default"))) const Type *Type::getUnqualifiedDesugaredType() const { +__attribute__((visibility("default"))) const Type * +Type::getUnqualifiedDesugaredType() const { const Type *Cur = this; while (true) { @@ -4227,7 +4228,9 @@ static TagDecl *getInterestingTagDecl(TagDecl *decl) { return decl; } -__attribute__((visibility("default"))) TagDecl *TagType::getDecl() const { return getInterestingTagDecl(decl); } +__attribute__((visibility("default"))) TagDecl *TagType::getDecl() const { + return getInterestingTagDecl(decl); +} bool TagType::isBeingDefined() const { return getDecl()->isBeingDefined(); } diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 3402e274109cb..8ecc507044ba7 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -194,7 +194,8 @@ IncrementalCompilerBuilder::create(std::string TT, return CreateCI(**ErrOrCC1Args); } -__attribute__((visibility("default"))) llvm::Expected<std::unique_ptr<CompilerInstance>> +__attribute__((visibility("default"))) +llvm::Expected<std::unique_ptr<CompilerInstance>> IncrementalCompilerBuilder::CreateCpp() { std::vector<const char *> Argv; Argv.reserve(5 + 1 + UserArgs.size()); @@ -524,7 +525,10 @@ const CompilerInstance *Interpreter::getCompilerInstance() const { return CI.get(); } -__attribute__((visibility("default"))) CompilerInstance *Interpreter::getCompilerInstance() { return CI.get(); } +__attribute__((visibility("default"))) CompilerInstance * +Interpreter::getCompilerInstance() { + return CI.get(); +} llvm::Expected<llvm::orc::LLJIT &> Interpreter::getExecutionEngine() { if (!IncrExecutor) { @@ -673,7 +677,8 @@ llvm::Error Interpreter::CreateExecutor() { void Interpreter::ResetExecutor() { IncrExecutor.reset(); } -__attribute__((visibility("default"))) llvm::Error Interpreter::Execute(PartialTranslationUnit &T) { +__attribute__((visibility("default"))) llvm::Error +Interpreter::Execute(PartialTranslationUnit &T) { assert(T.TheModule); LLVM_DEBUG( llvm::dbgs() << "execute-ptu " diff --git a/clang/lib/Interpreter/InterpreterValuePrinter.cpp b/clang/lib/Interpreter/InterpreterValuePrinter.cpp index 195de31155904..7fa7d40234d7a 100644 --- a/clang/lib/Interpreter/InterpreterValuePrinter.cpp +++ b/clang/lib/Interpreter/InterpreterValuePrinter.cpp @@ -308,8 +308,9 @@ __clang_Interpreter_SetValueWithAlloc(void *This, void *OutVal, return VRef.getPtr(); } -extern "C" __attribute__((visibility("default"))) void REPL_EXTERNAL_VISIBILITY __clang_Interpreter_SetValueNoAlloc( - void *This, void *OutVal, void *OpaqueType, ...) { +extern "C" __attribute__((visibility("default"))) void REPL_EXTERNAL_VISIBILITY +__clang_Interpreter_SetValueNoAlloc(void *This, void *OutVal, void *OpaqueType, + ...) { Value &VRef = *(Value *)OutVal; Interpreter *I = static_cast<Interpreter *>(This); VRef = Value(I, OpaqueType); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 965f8b096f64f..8723113a6ce5c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -11959,7 +11959,8 @@ EnumDecl *Sema::getStdAlignValT() const { return cast_or_null<EnumDecl>(StdAlignValT.get(Context.getExternalSource())); } -__attribute__((visibility("default"))) NamespaceDecl *Sema::getStdNamespace() const { +__attribute__((visibility("default"))) NamespaceDecl * +Sema::getStdNamespace() const { return cast_or_null<NamespaceDecl>( StdNamespace.get(Context.getExternalSource())); } diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index d124f44d72e94..2c41c2d2eef18 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -73,7 +73,8 @@ template <class Size_T> class SmallVectorBase { /// This is an implementation of the grow() method which only works /// on POD-like data types and is out of line to reduce code duplication. /// This function will report a fatal error if it cannot increase capacity. - __attribute__((visibility("default"))) LLVM_ABI void grow_pod(void *FirstEl, size_t MinSize, size_t TSize); + __attribute__((visibility("default"))) LLVM_ABI void + grow_pod(void *FirstEl, size_t MinSize, size_t TSize); public: size_t size() const { return Size; } diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h index ca8935c9e02e5..03ab297178c0c 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -659,7 +659,8 @@ class raw_fd_stream : public raw_fd_ostream { /// raw_string_ostream operates without a buffer, delegating all memory /// management to the std::string. Thus the std::string is always up-to-date, /// may be used directly and there is no need to call flush(). -class __attribute__((visibility("default"))) LLVM_ABI raw_string_ostream : public raw_ostream { +class __attribute__((visibility("default"))) LLVM_ABI raw_string_ostream + : public raw_ostream { std::string &OS; /// See raw_ostream::write_impl. diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index a4afa302725ae..4d25553923a00 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -104,7 +104,9 @@ void APInt::initFromArray(ArrayRef<uint64_t> bigVal) { clearUnusedBits(); } -__attribute__((visibility("default"))) APInt::APInt(unsigned numBits, ArrayRef<uint64_t> bigVal) : BitWidth(numBits) { +__attribute__((visibility("default"))) APInt::APInt(unsigned numBits, + ArrayRef<uint64_t> bigVal) + : BitWidth(numBits) { initFromArray(bigVal); } @@ -281,7 +283,8 @@ bool APInt::equalSlowCase(const APInt &RHS) const { return std::equal(U.pVal, U.pVal + getNumWords(), RHS.U.pVal); } -__attribute__((visibility("default"))) int APInt::compare(const APInt& RHS) const { +__attribute__((visibility("default"))) int +APInt::compare(const APInt &RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"); if (isSingleWord()) return U.VAL < RHS.U.VAL ? -1 : U.VAL > RHS.U.VAL; @@ -289,7 +292,8 @@ __attribute__((visibility("default"))) int APInt::compare(const APInt& RHS) cons return tcCompare(U.pVal, RHS.U.pVal, getNumWords()); } -__attribute__((visibility("default"))) int APInt::compareSigned(const APInt& RHS) const { +__attribute__((visibility("default"))) int +APInt::compareSigned(const APInt &RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"); if (isSingleWord()) { int64_t lhsSext = SignExtend64(U.VAL, BitWidth); diff --git a/llvm/lib/Support/Error.cpp b/llvm/lib/Support/Error.cpp index 13b66a581cc32..8abb816383dd5 100644 --- a/llvm/lib/Support/Error.cpp +++ b/llvm/lib/Support/Error.cpp @@ -62,7 +62,8 @@ char ECError::ID = 0; char StringError::ID = 0; char FileError::ID = 0; -__attribute__((visibility("default"))) void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) { +__attribute__((visibility("default"))) void +logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) { if (!E) return; OS << ErrorBanner; diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp index 014622aa35dba..59ac50260d801 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -219,8 +219,9 @@ void llvm::install_out_of_memory_new_handler() { } #endif -__attribute__((visibility("default"))) void llvm::llvm_unreachable_internal(const char *msg, const char *file, - unsigned line) { +__attribute__((visibility("default"))) void +llvm::llvm_unreachable_internal(const char *msg, const char *file, + unsigned line) { // This code intentionally doesn't call the ErrorHandler callback, because // llvm_unreachable is intended to be used to indicate "impossible" // situations, and not legitimate runtime errors. diff --git a/llvm/lib/Support/MemAlloc.cpp b/llvm/lib/Support/MemAlloc.cpp index f671be4426abe..d70a5c0f85d64 100644 --- a/llvm/lib/Support/MemAlloc.cpp +++ b/llvm/lib/Support/MemAlloc.cpp @@ -11,7 +11,8 @@ // These are out of line to have __cpp_aligned_new not affect ABI. -__attribute__((visibility("default"))) LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * +__attribute__((visibility("default"))) +LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * llvm::allocate_buffer(size_t Size, size_t Alignment) { void *Result = ::operator new(Size, #ifdef __cpp_aligned_new diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp index aea9a6ae08d6c..bc54d63026e64 100644 --- a/llvm/lib/Support/StringMap.cpp +++ b/llvm/lib/Support/StringMap.cpp @@ -43,7 +43,10 @@ static inline unsigned *getHashTable(StringMapEntryBase **TheTable, return reinterpret_cast<unsigned *>(TheTable + NumBuckets + 1); } -__attribute__((visibility("default"))) uint32_t StringMapImpl::hash(StringRef Key) { return xxh3_64bits(Key); } +__attribute__((visibility("default"))) uint32_t +StringMapImpl::hash(StringRef Key) { + return xxh3_64bits(Key); +} StringMapImpl::StringMapImpl(unsigned InitSize, unsigned itemSize) { ItemSize = itemSize; @@ -83,8 +86,8 @@ void StringMapImpl::init(unsigned InitSize) { /// specified bucket will be non-null. Otherwise, it will be null. In either /// case, the FullHashValue field of the bucket will be set to the hash value /// of the string. -__attribute__((visibility("default"))) unsigned StringMapImpl::LookupBucketFor(StringRef Name, - uint32_t FullHashValue) { +__attribute__((visibility("default"))) unsigned +StringMapImpl::LookupBucketFor(StringRef Name, uint32_t FullHashValue) { #ifdef EXPENSIVE_CHECKS assert(FullHashValue == hash(Name)); #endif @@ -215,7 +218,8 @@ StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) { /// RehashTable - Grow the table, redistributing values into the buckets with /// the appropriate mod-of-hashtable-size. -__attribute__((visibility("default"))) unsigned StringMapImpl::RehashTable(unsigned BucketNo) { +__attribute__((visibility("default"))) unsigned +StringMapImpl::RehashTable(unsigned BucketNo) { unsigned NewSize; // If the hash table is now more than 3/4 full, or if fewer than 1/8 of // the buckets are empty (meaning that many are filled with tombstones), diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index b6ada2b509701..d73ae6231fbf9 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -103,8 +103,8 @@ void raw_ostream::SetBuffered() { SetUnbuffered(); } -__attribute__((visibility("default"))) void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, - BufferKind Mode) { +__attribute__((visibility("default"))) void +raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, BufferKind Mode) { assert(((Mode == BufferKind::Unbuffered && !BufferStart && Size == 0) || (Mode != BufferKind::Unbuffered && BufferStart && Size != 0)) && "stream must be unbuffered or have at least one byte"); @@ -122,7 +122,8 @@ __attribute__((visibility("default"))) void raw_ostream::SetBufferAndMode(char * assert(OutBufStart <= OutBufEnd && "Invalid size!"); } -__attribute__((visibility("default"))) raw_ostream &raw_ostream::operator<<(unsigned long N) { +__attribute__((visibility("default"))) raw_ostream & +raw_ostream::operator<<(unsigned long N) { write_integer(*this, static_cast<uint64_t>(N), 0, IntegerStyle::Integer); return *this; } @@ -242,7 +243,8 @@ raw_ostream &raw_ostream::write(unsigned char C) { return *this; } -__attribute__((visibility("default"))) raw_ostream &raw_ostream::write(const char *Ptr, size_t Size) { +__attribute__((visibility("default"))) raw_ostream & +raw_ostream::write(const char *Ptr, size_t Size) { // Group exceptional cases into a single branch. if (LLVM_UNLIKELY(size_t(OutBufEnd - OutBufCur) < Size)) { if (LLVM_UNLIKELY(!OutBufStart)) { >From 4c5f7afafe33d97237d9540f4d683e137ad9f6ce Mon Sep 17 00:00:00 2001 From: mcbarton <matthew.c.bar...@hotmail.co.uk> Date: Wed, 2 Jul 2025 23:49:26 +0100 Subject: [PATCH 3/3] Try to fix PR --- clang/lib/AST/ASTContext.cpp | 8 ++++---- clang/lib/AST/Decl.cpp | 11 ++++++----- clang/lib/AST/DeclBase.cpp | 15 ++++++++------- clang/lib/AST/DeclTemplate.cpp | 5 +++-- clang/lib/AST/Mangle.cpp | 5 +++-- clang/lib/AST/Type.cpp | 7 ++++--- clang/lib/Interpreter/Interpreter.cpp | 9 +++++---- clang/lib/Interpreter/InterpreterValuePrinter.cpp | 6 +++--- clang/lib/Sema/SemaDeclCXX.cpp | 3 ++- llvm/include/llvm/ADT/SmallVector.h | 4 ++-- llvm/include/llvm/Support/raw_ostream.h | 2 +- llvm/lib/Support/APInt.cpp | 11 ++++++----- llvm/lib/Support/Debug.cpp | 3 ++- llvm/lib/Support/Error.cpp | 5 +++-- llvm/lib/Support/ErrorHandling.cpp | 3 ++- llvm/lib/Support/MemAlloc.cpp | 3 ++- llvm/lib/Support/StringMap.cpp | 7 ++++--- llvm/lib/Support/Valgrind.cpp | 5 +++-- llvm/lib/Support/raw_ostream.cpp | 12 ++++++------ 19 files changed, 69 insertions(+), 55 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 35b5e019dcdef..f0ed7b2804d7a 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3895,7 +3895,7 @@ void ASTContext::adjustExceptionSpec( /// getComplexType - Return the uniqued reference to the type for a complex /// number with the specified element type. -__attribute__((visibility("default"))) QualType +LLVM_ABI QualType ASTContext::getComplexType(QualType T) const { // Unique pointers, to guarantee there is only one pointer of a particular // structure. @@ -4080,7 +4080,7 @@ QualType ASTContext::getBlockPointerType(QualType T) const { /// getLValueReferenceType - Return the uniqued reference to the type for an /// lvalue reference to the specified type. -__attribute__((visibility("default"))) QualType +LLVM_ABI QualType ASTContext::getLValueReferenceType(QualType T, bool SpelledAsLValue) const { assert((!T->isPlaceholderType() || T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) && @@ -5252,7 +5252,7 @@ QualType ASTContext::getInjectedClassNameType(CXXRecordDecl *Decl, /// getTypeDeclType - Return the unique reference to the type for the /// specified type declaration. -__attribute__((visibility("default"))) QualType +LLVM_ABI QualType ASTContext::getTypeDeclTypeSlow(const TypeDecl *Decl) const { assert(Decl && "Passed null for Decl param"); assert(!Decl->TypeForDecl && "TypeForDecl present in slow case"); @@ -13127,7 +13127,7 @@ VTableContextBase *ASTContext::getVTableContext() { return VTContext.get(); } -__attribute__((visibility("default"))) MangleContext * +LLVM_ABI MangleContext * ASTContext::createMangleContext(const TargetInfo *T) { if (!T) T = Target; diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index dac8f2076285d..c9b2f1c1fdff0 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -59,6 +59,7 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Triple.h" @@ -2255,7 +2256,7 @@ bool VarDecl::isInExternCXXContext() const { VarDecl *VarDecl::getCanonicalDecl() { return getFirstDecl(); } -__attribute__((visibility("default"))) VarDecl::DefinitionKind +LLVM_ABI VarDecl::DefinitionKind VarDecl::isThisDeclarationADefinition(ASTContext &C) const { if (isThisDeclarationADemotedDefinition()) return DeclarationOnly; @@ -3763,7 +3764,7 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const { /// getNumParams - Return the number of parameters this function must have /// based on its FunctionType. This is the length of the ParamInfo array /// after it has been created. -__attribute__((visibility("default"))) unsigned +LLVM_ABI unsigned FunctionDecl::getNumParams() const { const auto *FPT = getType()->getAs<FunctionProtoType>(); return FPT ? FPT->getNumParams() : 0; @@ -4201,7 +4202,7 @@ bool FunctionDecl::isTemplateInstantiation() const { return clang::isTemplateInstantiation(getTemplateSpecializationKind()); } -__attribute__((visibility("default"))) FunctionDecl * +LLVM_ABI FunctionDecl * FunctionDecl::getTemplateInstantiationPattern(bool ForDefinition) const { // If this is a generic lambda call operator specialization, its // instantiation pattern is always its primary template's pattern @@ -4266,7 +4267,7 @@ FunctionDecl::getTemplateSpecializationInfo() const { TemplateOrSpecialization); } -__attribute__((visibility("default"))) const TemplateArgumentList * +LLVM_ABI const TemplateArgumentList * FunctionDecl::getTemplateSpecializationArgs() const { if (FunctionTemplateSpecializationInfo *Info = dyn_cast_if_present<FunctionTemplateSpecializationInfo *>( @@ -5144,7 +5145,7 @@ RecordDecl *RecordDecl::CreateDeserialized(const ASTContext &C, return R; } -__attribute__((visibility("default"))) bool +LLVM_ABI bool RecordDecl::isInjectedClassName() const { return isImplicit() && getDeclName() && getDeclContext()->isRecord() && cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName(); diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 122df4520f3bf..86e02ddb9ad7e 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -37,6 +37,7 @@ #include "clang/Basic/TargetInfo.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/VersionTuple.h" @@ -526,7 +527,7 @@ TranslationUnitDecl *Decl::getTranslationUnitDecl() { return cast<TranslationUnitDecl>(DC); } -__attribute__((visibility("default"))) ASTContext &Decl::getASTContext() const { +LLVM_ABI ASTContext &Decl::getASTContext() const { return getTranslationUnitDecl()->getASTContext(); } @@ -613,7 +614,7 @@ ExternalSourceSymbolAttr *Decl::getExternalSourceSymbolAttr() const { return nullptr; } -__attribute__((visibility("default"))) bool Decl::hasDefiningAttr() const { +LLVM_ABI bool Decl::hasDefiningAttr() const { return hasAttr<AliasAttr>() || hasAttr<IFuncAttr>() || hasAttr<LoaderUninitializedAttr>(); } @@ -1047,7 +1048,7 @@ void Decl::addAttr(Attr *A) { Attrs.insert(I, A); } -__attribute__((visibility("default"))) const AttrVec &Decl::getAttrs() const { +LLVM_ABI const AttrVec &Decl::getAttrs() const { assert(HasAttrs && "No attrs to get!"); return getASTContext().getDeclAttrs(this); } @@ -1065,7 +1066,7 @@ Decl *Decl::castFromDeclContext (const DeclContext *D) { } } -__attribute__((visibility("default"))) DeclContext * +LLVM_ABI DeclContext * Decl::castToDeclContext(const Decl *D) { Decl::Kind DK = D->getKind(); switch(DK) { @@ -1292,7 +1293,7 @@ DeclContext::DeclContext(Decl::Kind K) { setUseQualifiedLookup(false); } -__attribute__((visibility("default"))) bool +LLVM_ABI bool DeclContext::classof(const Decl *D) { Decl::Kind DK = D->getKind(); switch (DK) { @@ -1664,7 +1665,7 @@ ExternalASTSource::SetExternalVisibleDeclsForName(const DeclContext *DC, return List.getLookupResult(); } -__attribute__((visibility("default"))) DeclContext::decl_iterator +LLVM_ABI DeclContext::decl_iterator DeclContext::decls_begin() const { if (hasExternalLexicalStorage()) LoadLexicalDeclsFromExternalStorage(); @@ -1894,7 +1895,7 @@ void DeclContext::buildLookupImpl(DeclContext *DCtx, bool Internal) { } } -__attribute__((visibility("default"))) DeclContext::lookup_result +LLVM_ABI DeclContext::lookup_result DeclContext::lookup(DeclarationName Name) const { // For transparent DeclContext, we should lookup in their enclosing context. if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export) diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 97b0fa9bf106a..db81fe450eccc 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -31,6 +31,7 @@ #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include <cassert> #include <optional> @@ -549,7 +550,7 @@ void ClassTemplateDecl::LoadLazySpecializations( loadLazySpecializationsImpl(OnlyPartial); } -__attribute__((visibility("default"))) +LLVM_ABI llvm::FoldingSetVector<ClassTemplateSpecializationDecl> & ClassTemplateDecl::getSpecializations() const { LoadLazySpecializations(); @@ -1452,7 +1453,7 @@ void VarTemplateSpecializationDecl::getNameForDiagnostic( } } -__attribute__((visibility("default"))) VarTemplateDecl * +LLVM_ABI VarTemplateDecl * VarTemplateSpecializationDecl::getSpecializedTemplate() const { if (const auto *PartialSpec = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>()) diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index 704820e9223d2..2cc86a034f594 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -23,6 +23,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Mangler.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" @@ -118,7 +119,7 @@ static CCMangling getCallingConvMangling(const ASTContext &Context, } } -__attribute__((visibility("default"))) bool +LLVM_ABI bool MangleContext::shouldMangleDeclName(const NamedDecl *D) { const ASTContext &ASTContext = getASTContext(); @@ -153,7 +154,7 @@ MangleContext::shouldMangleDeclName(const NamedDecl *D) { return shouldMangleCXXName(D); } -__attribute__((visibility("default"))) void +LLVM_ABI void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) { const ASTContext &ASTContext = getASTContext(); const NamedDecl *D = cast<NamedDecl>(GD.getDecl()); diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index c4e451c9d78db..9de06e117a08c 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -44,6 +44,7 @@ #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include <algorithm> @@ -650,7 +651,7 @@ template <> const CountAttributedType *Type::getAs() const { /// getUnqualifiedDesugaredType - Pull any qualifiers and syntactic /// sugar off the given type. This should produce an object of the /// same dynamic type as the canonical type. -__attribute__((visibility("default"))) const Type * +LLVM_ABI const Type * Type::getUnqualifiedDesugaredType() const { const Type *Cur = this; @@ -2303,7 +2304,7 @@ bool Type::hasUnsignedIntegerRepresentation() const { return isUnsignedIntegerOrEnumerationType(); } -__attribute__((visibility("default"))) bool Type::isFloatingType() const { +LLVM_ABI bool Type::isFloatingType() const { if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) return BT->isFloatingPoint(); if (const auto *CT = dyn_cast<ComplexType>(CanonicalType)) @@ -4228,7 +4229,7 @@ static TagDecl *getInterestingTagDecl(TagDecl *decl) { return decl; } -__attribute__((visibility("default"))) TagDecl *TagType::getDecl() const { +LLVM_ABI TagDecl *TagType::getDecl() const { return getInterestingTagDecl(decl); } diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 8ecc507044ba7..115bcd387b6f1 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -49,6 +49,7 @@ #include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h" #include "llvm/ExecutionEngine/Orc/LLJIT.h" #include "llvm/IR/Module.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Errc.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" @@ -194,7 +195,7 @@ IncrementalCompilerBuilder::create(std::string TT, return CreateCI(**ErrOrCC1Args); } -__attribute__((visibility("default"))) +LLVM_ABI llvm::Expected<std::unique_ptr<CompilerInstance>> IncrementalCompilerBuilder::CreateCpp() { std::vector<const char *> Argv; @@ -525,7 +526,7 @@ const CompilerInstance *Interpreter::getCompilerInstance() const { return CI.get(); } -__attribute__((visibility("default"))) CompilerInstance * +LLVM_ABI CompilerInstance * Interpreter::getCompilerInstance() { return CI.get(); } @@ -581,7 +582,7 @@ Interpreter::RegisterPTU(TranslationUnitDecl *TU, return LastPTU; } -__attribute__((visibility("default"))) llvm::Expected<PartialTranslationUnit &> +LLVM_ABI llvm::Expected<PartialTranslationUnit &> Interpreter::Parse(llvm::StringRef Code) { // If we have a device parser, parse it first. The generated code will be // included in the host compilation @@ -677,7 +678,7 @@ llvm::Error Interpreter::CreateExecutor() { void Interpreter::ResetExecutor() { IncrExecutor.reset(); } -__attribute__((visibility("default"))) llvm::Error +LLVM_ABI llvm::Error Interpreter::Execute(PartialTranslationUnit &T) { assert(T.TheModule); LLVM_DEBUG( diff --git a/clang/lib/Interpreter/InterpreterValuePrinter.cpp b/clang/lib/Interpreter/InterpreterValuePrinter.cpp index 7fa7d40234d7a..fcfdac7742e6e 100644 --- a/clang/lib/Interpreter/InterpreterValuePrinter.cpp +++ b/clang/lib/Interpreter/InterpreterValuePrinter.cpp @@ -20,7 +20,7 @@ #include "clang/Interpreter/Value.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" - +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" @@ -300,7 +300,7 @@ llvm::Expected<Expr *> Interpreter::ExtractValueFromExpr(Expr *E) { using namespace clang; // Temporary rvalue struct that need special care. -REPL_EXTERNAL_VISIBILITY __attribute__((visibility("default"))) void * +REPL_EXTERNAL_VISIBILITY LLVM_ABI void * __clang_Interpreter_SetValueWithAlloc(void *This, void *OutVal, void *OpaqueType) { Value &VRef = *(Value *)OutVal; @@ -308,7 +308,7 @@ __clang_Interpreter_SetValueWithAlloc(void *This, void *OutVal, return VRef.getPtr(); } -extern "C" __attribute__((visibility("default"))) void REPL_EXTERNAL_VISIBILITY +extern "C" LLVM_ABI void REPL_EXTERNAL_VISIBILITY __clang_Interpreter_SetValueNoAlloc(void *This, void *OutVal, void *OpaqueType, ...) { Value &VRef = *(Value *)OutVal; diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 8723113a6ce5c..0de44d7a3946b 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -50,6 +50,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/SaveAndRestore.h" #include <map> @@ -11959,7 +11960,7 @@ EnumDecl *Sema::getStdAlignValT() const { return cast_or_null<EnumDecl>(StdAlignValT.get(Context.getExternalSource())); } -__attribute__((visibility("default"))) NamespaceDecl * +LLVM_ABI NamespaceDecl * Sema::getStdNamespace() const { return cast_or_null<NamespaceDecl>( StdNamespace.get(Context.getExternalSource())); diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index 2c41c2d2eef18..b0c9c26df7ddc 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -73,7 +73,7 @@ template <class Size_T> class SmallVectorBase { /// This is an implementation of the grow() method which only works /// on POD-like data types and is out of line to reduce code duplication. /// This function will report a fatal error if it cannot increase capacity. - __attribute__((visibility("default"))) LLVM_ABI void + LLVM_ABI void grow_pod(void *FirstEl, size_t MinSize, size_t TSize); public: @@ -87,7 +87,7 @@ template <class Size_T> class SmallVectorBase { /// capacity for. /// /// This does not construct or destroy any elements in the vector. - __attribute__((visibility("default"))) void set_size(size_t N) { + LLVM_ABI void set_size(size_t N) { assert(N <= capacity()); // implies no overflow in assignment Size = static_cast<Size_T>(N); } diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h index 03ab297178c0c..3839439e30e9a 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -659,7 +659,7 @@ class raw_fd_stream : public raw_fd_ostream { /// raw_string_ostream operates without a buffer, delegating all memory /// management to the std::string. Thus the std::string is always up-to-date, /// may be used directly and there is no need to call flush(). -class __attribute__((visibility("default"))) LLVM_ABI raw_string_ostream +class LLVM_ABI raw_string_ostream : public raw_ostream { std::string &OS; diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 4d25553923a00..b2862c8879837 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -20,6 +20,7 @@ #include "llvm/ADT/bit.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/Alignment.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" @@ -104,7 +105,7 @@ void APInt::initFromArray(ArrayRef<uint64_t> bigVal) { clearUnusedBits(); } -__attribute__((visibility("default"))) APInt::APInt(unsigned numBits, +LLVM_ABI APInt::APInt(unsigned numBits, ArrayRef<uint64_t> bigVal) : BitWidth(numBits) { initFromArray(bigVal); @@ -283,7 +284,7 @@ bool APInt::equalSlowCase(const APInt &RHS) const { return std::equal(U.pVal, U.pVal + getNumWords(), RHS.U.pVal); } -__attribute__((visibility("default"))) int +LLVM_ABI int APInt::compare(const APInt &RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"); if (isSingleWord()) @@ -292,7 +293,7 @@ APInt::compare(const APInt &RHS) const { return tcCompare(U.pVal, RHS.U.pVal, getNumWords()); } -__attribute__((visibility("default"))) int +LLVM_ABI int APInt::compareSigned(const APInt &RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"); if (isSingleWord()) { @@ -986,7 +987,7 @@ APInt APInt::truncSSat(unsigned width) const { } // Sign extend to a new width. -__attribute__((visibility("default"))) APInt APInt::sext(unsigned Width) const { +LLVM_ABI APInt APInt::sext(unsigned Width) const { assert(Width >= BitWidth && "Invalid APInt SignExtend request"); if (Width <= APINT_BITS_PER_WORD) @@ -1013,7 +1014,7 @@ __attribute__((visibility("default"))) APInt APInt::sext(unsigned Width) const { } // Zero extend to a new width. -__attribute__((visibility("default"))) APInt APInt::zext(unsigned width) const { +LLVM_ABI APInt APInt::zext(unsigned width) const { assert(width >= BitWidth && "Invalid APInt ZeroExtend request"); if (width <= APINT_BITS_PER_WORD) diff --git a/llvm/lib/Support/Debug.cpp b/llvm/lib/Support/Debug.cpp index 7f85a0ceda01d..62eb73dd630f3 100644 --- a/llvm/lib/Support/Debug.cpp +++ b/llvm/lib/Support/Debug.cpp @@ -23,6 +23,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" @@ -159,7 +160,7 @@ static void debug_user_sig_handler(void *Cookie) { } /// dbgs - Return a circular-buffered debug stream. -__attribute__((visibility("default"))) raw_ostream &llvm::dbgs() { +LLVM_ABI raw_ostream &llvm::dbgs() { // Do one-time initialization in a thread-safe way. static struct dbgstream { circular_raw_ostream strm; diff --git a/llvm/lib/Support/Error.cpp b/llvm/lib/Support/Error.cpp index 8abb816383dd5..39a550bb33430 100644 --- a/llvm/lib/Support/Error.cpp +++ b/llvm/lib/Support/Error.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include <system_error> @@ -62,7 +63,7 @@ char ECError::ID = 0; char StringError::ID = 0; char FileError::ID = 0; -__attribute__((visibility("default"))) void +LLVM_ABI void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) { if (!E) return; @@ -126,7 +127,7 @@ std::error_code errorToErrorCode(Error Err) { } #if LLVM_ENABLE_ABI_BREAKING_CHECKS -__attribute__((visibility("default"))) void Error::fatalUncheckedError() const { +LLVM_ABI void Error::fatalUncheckedError() const { dbgs() << "Program aborted due to an unhandled Error:\n"; if (getPtr()) { getPtr()->log(dbgs()); diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp index 59ac50260d801..f59d1d4acda2a 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -17,6 +17,7 @@ #include "llvm/ADT/Twine.h" #include "llvm/Config/config.h" #include "llvm/Config/llvm-config.h" // for LLVM_ENABLE_THREADS +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" @@ -219,7 +220,7 @@ void llvm::install_out_of_memory_new_handler() { } #endif -__attribute__((visibility("default"))) void +LLVM_ABI void llvm::llvm_unreachable_internal(const char *msg, const char *file, unsigned line) { // This code intentionally doesn't call the ErrorHandler callback, because diff --git a/llvm/lib/Support/MemAlloc.cpp b/llvm/lib/Support/MemAlloc.cpp index d70a5c0f85d64..20d8c90585583 100644 --- a/llvm/lib/Support/MemAlloc.cpp +++ b/llvm/lib/Support/MemAlloc.cpp @@ -6,12 +6,13 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Support/Compiler.h" #include "llvm/Support/MemAlloc.h" #include <new> // These are out of line to have __cpp_aligned_new not affect ABI. -__attribute__((visibility("default"))) +LLVM_ABI LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * llvm::allocate_buffer(size_t Size, size_t Alignment) { void *Result = ::operator new(Size, diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp index bc54d63026e64..c62d46178e33e 100644 --- a/llvm/lib/Support/StringMap.cpp +++ b/llvm/lib/Support/StringMap.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringMap.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/ReverseIteration.h" #include "llvm/Support/xxhash.h" @@ -43,7 +44,7 @@ static inline unsigned *getHashTable(StringMapEntryBase **TheTable, return reinterpret_cast<unsigned *>(TheTable + NumBuckets + 1); } -__attribute__((visibility("default"))) uint32_t +LLVM_ABI uint32_t StringMapImpl::hash(StringRef Key) { return xxh3_64bits(Key); } @@ -86,7 +87,7 @@ void StringMapImpl::init(unsigned InitSize) { /// specified bucket will be non-null. Otherwise, it will be null. In either /// case, the FullHashValue field of the bucket will be set to the hash value /// of the string. -__attribute__((visibility("default"))) unsigned +LLVM_ABI unsigned StringMapImpl::LookupBucketFor(StringRef Name, uint32_t FullHashValue) { #ifdef EXPENSIVE_CHECKS assert(FullHashValue == hash(Name)); @@ -218,7 +219,7 @@ StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) { /// RehashTable - Grow the table, redistributing values into the buckets with /// the appropriate mod-of-hashtable-size. -__attribute__((visibility("default"))) unsigned +LLVM_ABI unsigned StringMapImpl::RehashTable(unsigned BucketNo) { unsigned NewSize; // If the hash table is now more than 3/4 full, or if fewer than 1/8 of diff --git a/llvm/lib/Support/Valgrind.cpp b/llvm/lib/Support/Valgrind.cpp index e54b192f61fba..93517a87d732c 100644 --- a/llvm/lib/Support/Valgrind.cpp +++ b/llvm/lib/Support/Valgrind.cpp @@ -13,13 +13,14 @@ //===----------------------------------------------------------------------===// #include <stddef.h> +#include "llvm/Support/Compiler.h" #include "llvm/Support/Valgrind.h" #include "llvm/Config/config.h" #if HAVE_VALGRIND_VALGRIND_H #include <valgrind/valgrind.h> -__attribute__((visibility("default"))) bool llvm::sys::RunningOnValgrind() { +LLVM_ABI bool llvm::sys::RunningOnValgrind() { return RUNNING_ON_VALGRIND; } @@ -29,7 +30,7 @@ void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) { #else // !HAVE_VALGRIND_VALGRIND_H -__attribute__((visibility("default"))) bool llvm::sys::RunningOnValgrind() { +LLVM_ABI bool llvm::sys::RunningOnValgrind() { return false; } diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index d73ae6231fbf9..b3157a8ff1b85 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -72,7 +72,7 @@ constexpr raw_ostream::Colors raw_ostream::WHITE; constexpr raw_ostream::Colors raw_ostream::SAVEDCOLOR; constexpr raw_ostream::Colors raw_ostream::RESET; -__attribute__((visibility("default"))) raw_ostream::~raw_ostream() { +LLVM_ABI raw_ostream::~raw_ostream() { // raw_ostream's subclasses should take care to flush the buffer // in their destructors. assert(OutBufCur == OutBufStart && @@ -103,7 +103,7 @@ void raw_ostream::SetBuffered() { SetUnbuffered(); } -__attribute__((visibility("default"))) void +LLVM_ABI void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, BufferKind Mode) { assert(((Mode == BufferKind::Unbuffered && !BufferStart && Size == 0) || (Mode != BufferKind::Unbuffered && BufferStart && Size != 0)) && @@ -122,7 +122,7 @@ raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, BufferKind Mode) { assert(OutBufStart <= OutBufEnd && "Invalid size!"); } -__attribute__((visibility("default"))) raw_ostream & +LLVM_ABI raw_ostream & raw_ostream::operator<<(unsigned long N) { write_integer(*this, static_cast<uint64_t>(N), 0, IntegerStyle::Integer); return *this; @@ -216,7 +216,7 @@ raw_ostream &raw_ostream::operator<<(double N) { return *this; } -__attribute__((visibility("default"))) void raw_ostream::flush_nonempty() { +LLVM_ABI void raw_ostream::flush_nonempty() { assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty."); size_t Length = OutBufCur - OutBufStart; OutBufCur = OutBufStart; @@ -243,7 +243,7 @@ raw_ostream &raw_ostream::write(unsigned char C) { return *this; } -__attribute__((visibility("default"))) raw_ostream & +LLVM_ABI raw_ostream & raw_ostream::write(const char *Ptr, size_t Size) { // Group exceptional cases into a single branch. if (LLVM_UNLIKELY(size_t(OutBufEnd - OutBufCur) < Size)) { @@ -907,7 +907,7 @@ raw_fd_ostream &llvm::outs() { return S; } -__attribute__((visibility("default"))) raw_fd_ostream &llvm::errs() { +LLVM_ABI raw_fd_ostream &llvm::errs() { // On z/OS we need to enable auto conversion static std::error_code EC = enableAutoConversion(STDERR_FILENO); assert(!EC); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits