| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| ; RUN: rm -rf %t | ||
| ; RUN: mkdir %t | ||
| ; RUN: cd %t | ||
| ; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-debug-names-ftu-ltu-mix-main.s \ | ||
| ; RUN: -split-dwarf-file=main.dwo -o main.o | ||
| ; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-debug-names-ftu-ltu-mix-helper.s -o helper.o | ||
| ; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-debug-names-ftu-ltu-mix-helper1.s -o helper1.o | ||
| ; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o helper1.o -o main.exe -fno-pic -no-pie | ||
| ; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --create-debug-names-section=true | ||
| ; RUN: llvm-dwarfdump --debug-names main.exe.bolt | FileCheck -check-prefix=BOLT %s | ||
|
|
||
| ;; Tests BOLT correctly sets foreign TU Index when there are local TUs. | ||
|
|
||
| ; BOLT: Compilation Unit offsets [ | ||
| ; BOLT-NEXT: CU[0]: {{.+}} | ||
| ; BOLT-NEXT: CU[1]: {{.+}} | ||
| ; BOLT-NEXT: CU[2]: {{.+}} | ||
| ; BOLT-NEXT: ] | ||
| ; BOLT-NEXT: Local Type Unit offsets [ | ||
| ; BOLT-NEXT: LocalTU[0]: {{.+}} | ||
| ; BOLT-NEXT: LocalTU[1]: {{.+}} | ||
| ; BOLT-NEXT: ] | ||
| ; BOLT-NEXT: Foreign Type Unit signatures [ | ||
| ; BOLT-NEXT: ForeignTU[0]: 0x889c84450dac881f | ||
| ; BOLT-NEXT: ] | ||
| ; BOLT: Name 3 { | ||
| ; BOLT-NEXT: Hash: 0x6A05C500 | ||
| ; BOLT-NEXT: String: {{.+}} "globalMono1" | ||
| ; BOLT-NEXT: Entry @ {{.+}} { | ||
| ; BOLT-NEXT: Abbrev: 0x5 | ||
| ; BOLT-NEXT: Tag: DW_TAG_variable | ||
| ; BOLT-NEXT: DW_IDX_compile_unit: 0x02 | ||
| ; BOLT-NEXT: DW_IDX_die_offset: 0x0000001e | ||
| ; BOLT-NEXT: } | ||
| ; BOLT-NEXT: } | ||
| ; BOLT: Name 6 { | ||
| ; BOLT-NEXT: Hash: 0xF283AF92 | ||
| ; BOLT-NEXT: String: {{.+}} "ASplit" | ||
| ; BOLT-NEXT: Entry @ {{.+}} { | ||
| ; BOLT-NEXT: Abbrev: 0x7 | ||
| ; BOLT-NEXT: Tag: DW_TAG_structure_type | ||
| ; BOLT-NEXT: DW_IDX_type_unit: 0x02 | ||
| ; BOLT-NEXT: DW_IDX_compile_unit: 0x00 | ||
| ; BOLT-NEXT: DW_IDX_die_offset: 0x00000021 | ||
| ; BOLT-NEXT: } | ||
| ; BOLT-NEXT: } | ||
| ; BOLT: Name 7 { | ||
| ; BOLT-NEXT: Hash: 0xF17F51F | ||
| ; BOLT-NEXT: String: {{.+}} "AMono" | ||
| ; BOLT-NEXT: Entry @ {{.+}} { | ||
| ; BOLT-NEXT: Abbrev: 0x4 | ||
| ; BOLT-NEXT: Tag: DW_TAG_structure_type | ||
| ; BOLT-NEXT: DW_IDX_type_unit: 0x00 | ||
| ; BOLT-NEXT: DW_IDX_die_offset: 0x00000023 | ||
| ; BOLT-NEXT: } | ||
| ; BOLT-NEXT: } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # REQUIRES: system-linux | ||
|
|
||
| # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o | ||
| # RUN: %clang %cflags -nostdlib %t.o -o %t.exe \ | ||
| # RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie | ||
| # RUN: llvm-bolt %t.exe --print-normalized -o %t.out |& FileCheck %s | ||
|
|
||
| ## Check that BOLT correctly parses the Linux kernel .pci_fixup section and | ||
| ## verify that PCI fixup hook in the middle of a function is detected. | ||
|
|
||
| # CHECK: BOLT-INFO: Linux kernel binary detected | ||
| # CHECK: BOLT-WARNING: PCI fixup detected in the middle of function _start | ||
| # CHECK: BOLT-INFO: parsed 2 PCI fixup entries | ||
|
|
||
| .text | ||
| .globl _start | ||
| .type _start, %function | ||
| _start: | ||
| nop | ||
| .L0: | ||
| ret | ||
| .size _start, .-_start | ||
|
|
||
| ## PCI fixup table. | ||
| .section .pci_fixup,"a",@progbits | ||
|
|
||
| .short 0x8086 # vendor | ||
| .short 0xbeef # device | ||
| .long 0xffffffff # class | ||
| .long 0x0 # class shift | ||
| .long _start - . # fixup | ||
|
|
||
| .short 0x8086 # vendor | ||
| .short 0xbad # device | ||
| .long 0xffffffff # class | ||
| .long 0x0 # class shift | ||
| .long .L0 - . # fixup | ||
|
|
||
| ## Fake Linux Kernel sections. | ||
| .section __ksymtab,"a",@progbits | ||
| .section __ksymtab_gpl,"a",@progbits |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // RUN: %check_clang_tidy %s bugprone-unused-return-value %t \ | ||
| // RUN: -config='{CheckOptions: \ | ||
| // RUN: {bugprone-unused-return-value.CheckedFunctions: "::*"}}' \ | ||
| // RUN: -- | ||
|
|
||
| struct S { | ||
| S(){}; | ||
| S(S const &); | ||
| S(S &&); | ||
| S &operator=(S const &); | ||
| S &operator=(S &&); | ||
| S &operator+=(S); | ||
| }; | ||
|
|
||
| S returnValue(); | ||
| S const &returnRef(); | ||
|
|
||
| void bar() { | ||
| returnValue(); | ||
| // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors | ||
|
|
||
| S a{}; | ||
| a = returnValue(); | ||
| a.operator=(returnValue()); | ||
|
|
||
| a = returnRef(); | ||
| a.operator=(returnRef()); | ||
|
|
||
| a += returnRef(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| //===--- Builtins.def - Builtin function info database ----------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // This is only documentation for the database layout. This will be removed once | ||
| // all builtin databases are converted to tablegen files | ||
|
|
||
| // The second value provided to the macro specifies the type of the function | ||
| // (result value, then each argument) as follows: | ||
| // v -> void | ||
| // b -> boolean | ||
| // c -> char | ||
| // s -> short | ||
| // i -> int | ||
| // h -> half (__fp16, OpenCL) | ||
| // x -> half (_Float16) | ||
| // y -> half (__bf16) | ||
| // f -> float | ||
| // d -> double | ||
| // z -> size_t | ||
| // w -> wchar_t | ||
| // F -> constant CFString | ||
| // G -> id | ||
| // H -> SEL | ||
| // M -> struct objc_super | ||
| // a -> __builtin_va_list | ||
| // A -> "reference" to __builtin_va_list | ||
| // V -> Vector, followed by the number of elements and the base type. | ||
| // q -> Scalable vector, followed by the number of elements and the base type. | ||
| // Q -> target builtin type, followed by a character to distinguish the builtin type | ||
| // Qa -> AArch64 svcount_t builtin type. | ||
| // E -> ext_vector, followed by the number of elements and the base type. | ||
| // X -> _Complex, followed by the base type. | ||
| // Y -> ptrdiff_t | ||
| // P -> FILE | ||
| // J -> jmp_buf | ||
| // SJ -> sigjmp_buf | ||
| // K -> ucontext_t | ||
| // p -> pid_t | ||
| // . -> "...". This may only occur at the end of the function list. | ||
| // | ||
| // Types may be prefixed with the following modifiers: | ||
| // L -> long (e.g. Li for 'long int', Ld for 'long double') | ||
| // LL -> long long (e.g. LLi for 'long long int', LLd for __float128) | ||
| // LLL -> __int128_t (e.g. LLLi) | ||
| // Z -> int32_t (require a native 32-bit integer type on the target) | ||
| // W -> int64_t (require a native 64-bit integer type on the target) | ||
| // N -> 'int' size if target is LP64, 'L' otherwise. | ||
| // O -> long for OpenCL targets, long long otherwise. | ||
| // S -> signed | ||
| // U -> unsigned | ||
| // I -> Required to constant fold to an integer constant expression. | ||
| // | ||
| // Types may be postfixed with the following modifiers: | ||
| // * -> pointer (optionally followed by an address space number, if no address | ||
| // space is specified than any address space will be accepted) | ||
| // & -> reference (optionally followed by an address space number) | ||
| // C -> const | ||
| // D -> volatile | ||
| // R -> restrict | ||
|
|
||
| // The third value provided to the macro specifies information about attributes | ||
| // of the function. These must be kept in sync with the predicates in the | ||
| // Builtin::Context class. Currently we have: | ||
| // n -> nothrow | ||
| // r -> noreturn | ||
| // U -> pure | ||
| // c -> const | ||
| // t -> signature is meaningless, use custom typechecking | ||
| // T -> type is not important to semantic analysis and codegen; recognize as | ||
| // builtin even if type doesn't match signature, and don't warn if we | ||
| // can't be sure the type is right | ||
| // F -> this is a libc/libm function with a '__builtin_' prefix added. | ||
| // f -> this is a libc/libm function without a '__builtin_' prefix, or with | ||
| // 'z', a C++ standard library function in namespace std::. This builtin | ||
| // is disableable by '-fno-builtin-foo' / '-fno-builtin-std-foo'. | ||
| // h -> this function requires a specific header or an explicit declaration. | ||
| // i -> this is a runtime library implemented function without the | ||
| // '__builtin_' prefix. It will be implemented in compiler-rt or libgcc. | ||
| // p:N: -> this is a printf-like function whose Nth argument is the format | ||
| // string. | ||
| // P:N: -> similar to the p:N: attribute, but the function is like vprintf | ||
| // in that it accepts its arguments as a va_list rather than | ||
| // through an ellipsis | ||
| // s:N: -> this is a scanf-like function whose Nth argument is the format | ||
| // string. | ||
| // S:N: -> similar to the s:N: attribute, but the function is like vscanf | ||
| // in that it accepts its arguments as a va_list rather than | ||
| // through an ellipsis | ||
| // e -> const, but only when -fno-math-errno and FP exceptions are ignored | ||
| // g -> const when FP exceptions are ignored | ||
| // j -> returns_twice (like setjmp) | ||
| // u -> arguments are not evaluated for their side-effects | ||
| // V:N: -> requires vectors of at least N bits to be legal | ||
| // C<N,M_0,...,M_k> -> callback behavior: argument N is called with argument | ||
| // M_0, ..., M_k as payload | ||
| // z -> this is a function in (possibly-versioned) namespace std | ||
| // E -> this function can be constant evaluated by Clang frontend |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| //===- InstallAPI/FrontendRecords.h ------------------------------*- C++-*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_CLANG_INSTALLAPI_FRONTENDRECORDS_H | ||
| #define LLVM_CLANG_INSTALLAPI_FRONTENDRECORDS_H | ||
|
|
||
| #include "clang/AST/Availability.h" | ||
| #include "clang/AST/DeclObjC.h" | ||
| #include "clang/InstallAPI/HeaderFile.h" | ||
| #include "clang/InstallAPI/MachO.h" | ||
|
|
||
| namespace clang { | ||
| namespace installapi { | ||
|
|
||
| /// Frontend information captured about records. | ||
| struct FrontendAttrs { | ||
| const AvailabilityInfo Avail; | ||
| const Decl *D; | ||
| const HeaderType Access; | ||
| }; | ||
|
|
||
| // Represents a collection of frontend records for a library that are tied to a | ||
| // darwin target triple. | ||
| class FrontendRecordsSlice : public llvm::MachO::RecordsSlice { | ||
| public: | ||
| FrontendRecordsSlice(const llvm::Triple &T) | ||
| : llvm::MachO::RecordsSlice({T}) {} | ||
|
|
||
| /// Add non-ObjC global record with attributes from AST. | ||
| /// | ||
| /// \param Name The name of symbol. | ||
| /// \param Linkage The linkage of symbol. | ||
| /// \param GV The kind of global. | ||
| /// \param Avail The availability information tied to the active target | ||
| /// triple. | ||
| /// \param D The pointer to the declaration from traversing AST. | ||
| /// \param Access The intended access level of symbol. | ||
| /// \param Flags The flags that describe attributes of the symbol. | ||
| /// \param Inlined Whether declaration is inlined, only applicable to | ||
| /// functions. | ||
| /// \return The non-owning pointer to added record in slice. | ||
| GlobalRecord *addGlobal(StringRef Name, RecordLinkage Linkage, | ||
| GlobalRecord::Kind GV, | ||
| const clang::AvailabilityInfo Avail, const Decl *D, | ||
| const HeaderType Access, | ||
| SymbolFlags Flags = SymbolFlags::None, | ||
| bool Inlined = false); | ||
|
|
||
| /// Add ObjC Class record with attributes from AST. | ||
| /// | ||
| /// \param Name The name of class, not symbol. | ||
| /// \param Linkage The linkage of symbol. | ||
| /// \param Avail The availability information tied to the active target | ||
| /// triple. | ||
| /// \param D The pointer to the declaration from traversing AST. | ||
| /// \param Access The intended access level of symbol. | ||
| /// \param IsEHType Whether declaration has an exception attribute. | ||
| /// \return The non-owning pointer to added record in slice. | ||
| ObjCInterfaceRecord *addObjCInterface(StringRef Name, RecordLinkage Linkage, | ||
| const clang::AvailabilityInfo Avail, | ||
| const Decl *D, HeaderType Access, | ||
| bool IsEHType); | ||
|
|
||
| /// Add ObjC Category record with attributes from AST. | ||
| /// | ||
| /// \param ClassToExtend The name of class that is extended by category, not | ||
| /// symbol. | ||
| /// \param CategoryName The name of category, not symbol. | ||
| /// \param Avail The availability information tied | ||
| /// to the active target triple. | ||
| /// \param D The pointer to the declaration from traversing AST. | ||
| /// \param Access The intended access level of symbol. | ||
| /// \return The non-owning pointer to added record in slice. | ||
| ObjCCategoryRecord *addObjCCategory(StringRef ClassToExtend, | ||
| StringRef CategoryName, | ||
| const clang::AvailabilityInfo Avail, | ||
| const Decl *D, HeaderType Access); | ||
|
|
||
| /// Add ObjC IVar record with attributes from AST. | ||
| /// | ||
| /// \param Container The owning pointer for instance variable. | ||
| /// \param Name The name of ivar, not symbol. | ||
| /// \param Linkage The linkage of symbol. | ||
| /// \param Avail The availability information tied to the active target | ||
| /// triple. | ||
| /// \param D The pointer to the declaration from traversing AST. | ||
| /// \param Access The intended access level of symbol. | ||
| /// \param AC The access control tied to the ivar declaration. | ||
| /// \return The non-owning pointer to added record in slice. | ||
| ObjCIVarRecord *addObjCIVar(ObjCContainerRecord *Container, | ||
| StringRef IvarName, RecordLinkage Linkage, | ||
| const clang::AvailabilityInfo Avail, | ||
| const Decl *D, HeaderType Access, | ||
| const clang::ObjCIvarDecl::AccessControl AC); | ||
|
|
||
| private: | ||
| /// Mapping of records stored in slice to their frontend attributes. | ||
| llvm::DenseMap<Record *, FrontendAttrs> FrontendRecords; | ||
| }; | ||
|
|
||
| } // namespace installapi | ||
| } // namespace clang | ||
|
|
||
| #endif // LLVM_CLANG_INSTALLAPI_FRONTENDRECORDS_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| //===- InstallAPI/MachO.h ---------------------------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Imports and forward declarations for llvm::MachO types. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_CLANG_INSTALLAPI_MACHO_H | ||
| #define LLVM_CLANG_INSTALLAPI_MACHO_H | ||
|
|
||
| #include "llvm/TextAPI/Architecture.h" | ||
| #include "llvm/TextAPI/InterfaceFile.h" | ||
| #include "llvm/TextAPI/PackedVersion.h" | ||
| #include "llvm/TextAPI/Platform.h" | ||
| #include "llvm/TextAPI/RecordVisitor.h" | ||
| #include "llvm/TextAPI/Target.h" | ||
| #include "llvm/TextAPI/TextAPIWriter.h" | ||
| #include "llvm/TextAPI/Utils.h" | ||
|
|
||
| using SymbolFlags = llvm::MachO::SymbolFlags; | ||
| using RecordLinkage = llvm::MachO::RecordLinkage; | ||
| using Record = llvm::MachO::Record; | ||
| using GlobalRecord = llvm::MachO::GlobalRecord; | ||
| using ObjCContainerRecord = llvm::MachO::ObjCContainerRecord; | ||
| using ObjCInterfaceRecord = llvm::MachO::ObjCInterfaceRecord; | ||
| using ObjCCategoryRecord = llvm::MachO::ObjCCategoryRecord; | ||
| using ObjCIVarRecord = llvm::MachO::ObjCIVarRecord; | ||
| using Records = llvm::MachO::Records; | ||
| using BinaryAttrs = llvm::MachO::RecordsSlice::BinaryAttrs; | ||
| using SymbolSet = llvm::MachO::SymbolSet; | ||
| using FileType = llvm::MachO::FileType; | ||
| using PackedVersion = llvm::MachO::PackedVersion; | ||
| using Target = llvm::MachO::Target; | ||
|
|
||
| #endif // LLVM_CLANG_INSTALLAPI_MACHO_H |