/llvm-project/llvm/lib/BinaryFormat/ |
H A D | Magic.cpp | 1 //===- llvm/BinaryFormat/Magic.cpp - File magic identification --*- C++ -*-===// 9 #include "llvm/BinaryFormat/Magic.h" 28 static bool startswith(StringRef Magic, const char (&S)[N]) { in startswith() argument 29 return Magic.starts_with(StringRef(S, N - 1)); in startswith() 32 /// Identify the magic in magic. 33 file_magic llvm::identify_magic(StringRef Magic) { in identify_magic() argument 34 if (Magic.size() < 4) in identify_magic() 36 switch ((unsigned char)Magic[0]) { in identify_magic() 39 if (startswith(Magic, "\0\0\xFF\xFF")) { in identify_magic() 42 if (Magic.size() < MinSize) in identify_magic() [all …]
|
/llvm-project/clang-tools-extra/test/clang-tidy/checkers/readability/ |
H A D | magic-numbers.cpp | 1 // RUN: %check_clang_tidy %s readability-magic-numbers %t \ 3 // RUN: {readability-magic-numbers.IgnoredIntegerValues: "0;1;2;10;100;", \ 4 // RUN: readability-magic-numbers.IgnoredFloatingPointValues: "3.14;2.71828;9.81;10000.0;101.0;0x… 5 // RUN: readability-magic-numbers.IgnoreBitFieldsWidths: false, \ 6 // RUN: readability-magic-numbers.IgnorePowersOf2IntegerValues: true, \ 7 // RUN: readability-magic-numbers.IgnoreTypeAliases: false}}' \ 16 …GES: :[[@LINE-1]]:20: warning: 5 is a magic number; consider replacing it with a named constant [r… 24 …GES: :[[@LINE-1]]:21: warning: 6 is a magic number; consider replacing it with a named constant [r… in BuggyFunction() 27 …GES: :[[@LINE-1]]:20: warning: 7 is a magic number; consider replacing it with a named constant [r… in BuggyFunction() 30 …ES: :[[@LINE-1]]:18: warning: 15 is a magic number; consider replacing it with a named constant [r… in BuggyFunction() [all …]
|
H A D | magic-numbers-userliteral.cpp | 1 // RUN: %check_clang_tidy -check-suffixes=UDL-ALLOWED -std=c++14-or-later %s readability-magic-numb… 3 // RUN: {readability-magic-numbers.IgnoreUserDefinedLiterals: false}}' \ 5 // RUN: %check_clang_tidy -check-suffixes=UDL-IGNORED -std=c++14-or-later %s readability-magic-numb… 7 // RUN: {readability-magic-numbers.IgnoreUserDefinedLiterals: true}}' \ 23 … :[[@LINE-1]]:11: warning: 3600s is a magic number; consider replacing it with a named constant [r… in UserDefinedLiteral() 24 … :[[@LINE-2]]:11: warning: 3600s is a magic number; consider replacing it with a named constant [r… in UserDefinedLiteral() 26 …[[@LINE-1]]:13: warning: 3600.0s is a magic number; consider replacing it with a named constant [r… in UserDefinedLiteral() 27 …[[@LINE-1]]:13: warning: 3600.0s is a magic number; consider replacing it with a named constant [r… in UserDefinedLiteral()
|
H A D | magic-numbers-bitfields.cpp | 1 // RUN: %check_clang_tidy %s readability-magic-numbers %t \ 3 // RUN: {readability-magic-numbers.IgnoredIntegerValues: "1;2;10;100;"}}' \ 20 …GES: :[[@LINE-1]]:25: warning: 3 is a magic number; consider replacing it with a named constant [r…
|
/llvm-project/llvm/test/Transforms/InstCombine/ |
H A D | conditional-variable-length-signext-after-high-bit-extract.ll | 23 ; CHECK-NEXT: [[MAGIC:%.*]] = select i1 [[SHOULD_SIGNEXT]], i32 [[ALL_BITS_EXCEPT_LOW_NBITS]], i32 0 28 ; CHECK-NEXT: call void @use32(i32 [[MAGIC]]) 36 %magic = select i1 %should_signext, i32 %all_bits_except_low_nbits, i32 0 42 call void @use32(i32 %magic) 44 %signextended = add i32 %high_bits_extracted, %magic 54 ; CHECK-NEXT: [[MAGIC:%.*]] = select i1 [[SHOULD_SIGNEXT]], i32 [[ALL_BITS_EXCEPT_LOW_NBITS]], i32 0 59 ; CHECK-NEXT: call void @use32(i32 [[MAGIC]]) 67 %magic = select i1 %should_signext, i32 %all_bits_except_low_nbits, i32 0 73 call void @use32(i32 %magic) 75 %signextended = or i32 %high_bits_extracted, %magic [all...] |
/llvm-project/llvm/utils/TableGen/jupyter/tablegen_kernel/ |
H A D | kernel.py | 22 is "%" in which case it is a "magic" line. 24 The supported cell magic is: 26 * %reset - to reset the cached code and magic state. 27 * %noreset - to not reset the cached code and magic state 31 These are "cell magic" meaning it applies to the whole cell. Therefore 32 it must be the first line, or part of a run of magic lines starting 35 The following are global magic (that applies to all cells going 40 Global magic must be written in the same way as cell magic. 70 # A list of (code, magic) tuple 203 should_reset(self, magic) global() argument [all...] |
/llvm-project/clang-tools-extra/docs/clang-tidy/checks/readability/ |
H A D | magic-numbers.rst | 1 .. title:: clang-tidy - readability-magic-numbers 3 readability-magic-numbers 6 Detects magic numbers, integer or floating point literals that are embedded in 9 Many coding guidelines advise replacing the magic values with symbolic 12 …: Avoid "magic constants"; use symbolic constants in C++ Core Guidelines <https://isocpp.github.io… 23 Examples of magic values: 49 Example with magic values refactored: 117 Semicolon-separated list of magic positive integers that will be accepted 128 Semicolon-separated list of magic positive floating point values that will 139 Boolean value indicating whether to accept magic numbers as bit field widths [all …]
|
/llvm-project/llvm/unittests/BinaryFormat/ |
H A D | TestFileMagic.cpp | 1 //===- llvm/unittest/BinaryFormat/TestFileMagic.cpp - File magic tests ----===// 11 #include "llvm/BinaryFormat/Magic.h" 93 TEST_F(MagicTest, Magic) { in TEST_F() argument 98 file_magic magic; in TEST_F() member 100 #define DEFINE(magic) {#magic, magic, sizeof(magic), file_magic::magic} in TEST_F() argument 136 // Create some files filled with magic. in TEST_F() 144 StringRef magic(i->magic_str, i->magic_str_len); in TEST_F() local 145 file << magic; in TEST_F() 147 EXPECT_EQ(i->magic, identify_magic(magic)); in TEST_F()
|
/llvm-project/llvm/test/tools/llvm-readobj/MachO/ |
H A D | file-headers.test | 10 # I386-NEXT: Magic: Magic (0xFEEDFACE) 24 magic: 0xFEEDFACE 41 # X86-64-NEXT: Magic: Magic64 (0xFEEDFACF) 56 magic: 0xFEEDFACF 74 # PPC-NEXT: Magic: Magic (0xFEEDFACE) 89 magic: 0xFEEDFACE 106 # PPC64-NEXT: Magic: Magic64 (0xFEEDFACF) 122 magic: 0xFEEDFACF 140 # ARM-NEXT: Magic: Magic (0xFEEDFACE) 154 magic: 0xFEEDFACE
|
/llvm-project/llvm/test/ObjectYAML/MachO/ |
H A D | fat_macho_i386_x86_64.yaml | 10 magic: 0xCAFEBABE 25 magic: 0xFEEDFACE 33 magic: 0xFEEDFACF 46 #CHECK: magic: 0xCAFEBABE 62 #CHECK: magic: 0xFEEDFACE 71 #CHECK: magic: 0xFEEDFACF 90 magic: 0xCAFEBABE 101 magic: 0xFEEDFACE 109 magic: 0xFEEDFACE
|
/llvm-project/llvm/lib/ExecutionEngine/JITLink/ |
H A D | MachO.cpp | 35 uint32_t Magic; in createLinkGraphFromMachOObject() 36 memcpy(&Magic, Data.data(), sizeof(uint32_t)); in createLinkGraphFromMachOObject() local 38 dbgs() << "jitLink_MachO: magic = " << format("0x%08" PRIx32, Magic) in createLinkGraphFromMachOObject() 43 if (Magic == MachO::MH_MAGIC || Magic == MachO::MH_CIGAM) in createLinkGraphFromMachOObject() 45 else if (Magic == MachO::MH_MAGIC_64 || Magic == MachO::MH_CIGAM_64) { in createLinkGraphFromMachOObject() 55 if (Magic == MachO::MH_CIGAM_64) in createLinkGraphFromMachOObject() 72 return make_error<JITLinkError>("Unrecognized MachO magic valu in createLinkGraphFromMachOObject() [all...] |
H A D | COFF.cpp | 47 // Check magic in createLinkGraphFromCOFFObject() 48 auto Magic = identify_magic(ObjectBuffer.getBuffer()); in createLinkGraphFromCOFFObject() 49 if (Magic != file_magic::coff_object) in createLinkGraphFromCOFFObject() local 62 if (DH->Magic[0] == 'M' && DH->Magic[1] == 'Z') { in createLinkGraphFromCOFFObject() 63 // Check the PE magic bytes. ("PE\0\0") in createLinkGraphFromCOFFObject() 67 return make_error<JITLinkError>("Incorrect PE magic"); in createLinkGraphFromCOFFObject()
|
/llvm-project/llvm/test/tools/yaml2obj/Archives/ |
H A D | regular.yaml | 14 Magic: "[[MAGIC=!<arch>\n]]" 33 ## Check we can specify magic bytes of size greater than the normal size (size of "!<arch>\n"). 36 # RUN: wc -c < %t.magic2.a | FileCheck %s --check-prefix=MAGIC-SIZE-GR 37 # RUN: od -t x1 -v %t.magic2.a | FileCheck %s --ignore-case --check-prefix=MAGIC-DATA-GR 39 # MAGIC-SIZE-GR: 9{{$}} 40 # MAGIC-DATA-GR: 31 32 33 34 35 36 37 38 39 42 ## Check we can specify magic bytes of size less than the normal size (size of "!<arch>\n"). 45 # RUN: wc -c < %t.magic3.a | FileCheck %s --check-prefix=MAGIC-SIZE-LESS 46 # RUN: od -t x1 -v %t.magic3.a | FileCheck %s --ignore-case --check-prefix=MAGIC-DATA-LESS 48 # MAGIC-SIZE-LESS: 7{{$}} [all …]
|
/llvm-project/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/ |
H A D | avoid-magic-numbers.rst | 1 .. title:: clang-tidy - cppcoreguidelines-avoid-magic-numbers 3 :http-equiv=refresh: 5;URL=../readability/magic-numbers.html 5 cppcoreguidelines-avoid-magic-numbers 8 The cppcoreguidelines-avoid-magic-numbers check is an alias, please see 9 :doc:`readability-magic-numbers <../readability/magic-numbers>`
|
/llvm-project/llvm/lib/DebugInfo/GSYM/ |
H A D | Header.cpp | 25 OS << " Magic = " << HEX32(H.Magic) << "\n"; in operator <<() 42 if (Magic != GSYM_MAGIC) in checkForError() 44 "invalid GSYM magic 0x%8.8x", Magic); in checkForError() 71 H.Magic = Data.getU32(&Offset); in decode() 89 O.writeU32(Magic); in encode() 102 return LHS.Magic == RHS.Magic && LHS.Version == RHS.Version && in operator ==()
|
/llvm-project/llvm/include/llvm/Support/ |
H A D | DivisionByConstantInfo.h | 20 /// Magic data for optimising signed division by a constant. 23 APInt Magic; ///< magic number member 27 /// Magic data for optimising unsigned division by a constant. 32 APInt Magic; ///< magic number member
|
/llvm-project/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ |
H A D | ObjectContainerUniversalMachO.cpp | 59 uint32_t magic = data.GetU32(&offset); in MagicBytesMatch() local 60 return magic == FAT_MAGIC || magic == FAT_CIGAM || magic == FAT_MAGIC_64 || in MagicBytesMatch() 61 magic == FAT_CIGAM_64; in MagicBytesMatch() 91 header.magic = data.GetU32(&offset); in ParseHeader() 95 if (header.magic == FAT_MAGIC || header.magic == FAT_MAGIC_64) { in ParseHeader() 96 const bool is_fat64 = header.magic == FAT_MAGIC_64; in ParseHeader()
|
/llvm-project/llvm/lib/Support/ |
H A D | DivisionByConstantInfo.cpp | 17 /// Calculate the magic numbers required to implement a signed integer division 59 Retval.Magic = std::move(Q2); in get() 60 ++Retval.Magic; in get() 62 Retval.Magic.negate(); // resulting magic number in get() 67 /// Calculate the magic numbers required to implement an unsigned integer 145 Retval.Magic = std::move(Q2); // resulting magic number in get() 146 ++Retval.Magic; in get()
|
/llvm-project/lldb/examples/python/ |
H A D | mach_o.py | 14 # Mach header "magic" constants 494 class Magic(dict_utils.Enum): class in Mach 536 self.magic = Mach.Magic() 588 self.magic.unpack(data) 589 if self.magic.is_skinny_mach_file(): 591 elif self.magic.is_universal_mach_file(): 597 self.content.unpack(data, self.magic) 607 self.magic = None 622 def unpack(self, data, magic=None): argument 624 if magic is None: [all …]
|
/llvm-project/llvm/unittests/Support/ |
H A D | DivisionByConstantTest.cpp | 39 Magics.Magic = 0; in SignedDivideUsingMagic() 42 } else if (Divisor.isStrictlyPositive() && Magics.Magic.isNegative()) { in SignedDivideUsingMagic() 45 } else if (Divisor.isNegative() && Magics.Magic.isStrictlyPositive()) { in SignedDivideUsingMagic() 50 // Multiply the numerator by the magic value. in SignedDivideUsingMagic() 51 APInt Q = MULHS(Numerator, Magics.Magic); in SignedDivideUsingMagic() 102 assert(!Divisor.isOne() && "Division by 1 is not supported using Magic."); in UnsignedDivideUsingMagic() 131 // Multiply the numerator by the magic value. in UnsignedDivideUsingMagic() 132 Q = MULHU(Q, Magics.Magic); in UnsignedDivideUsingMagic()
|
/llvm-project/llvm/tools/obj2yaml/ |
H A D | archive2yaml.cpp | 10 #include "llvm/BinaryFormat/Magic.h" 26 StringRef Magic = "!<arch>\n"; in dump() local 27 if (!Buffer.starts_with(Magic)) in dump() 30 Obj->Magic = Magic; in dump() 31 Buffer = Buffer.drop_front(Magic.size()); in dump()
|
/llvm-project/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ |
H A D | ObjectContainerMachOFileset.cpp | 86 static uint32_t MachHeaderSizeFromMagic(uint32_t magic) { in MachHeaderSizeFromMagic() argument 87 switch (magic) { in MachHeaderSizeFromMagic() 102 header.magic = data.GetU32(&offset); in ParseMachOHeader() 103 switch (header.magic) { in ParseMachOHeader() 140 lldb::offset_t offset = MachHeaderSizeFromMagic(header.magic); in ParseFileset() 181 const size_t header_size = MachHeaderSizeFromMagic(header->magic); in ParseHeader() 204 const size_t header_size = MachHeaderSizeFromMagic(header->magic); in ParseHeader() 255 uint32_t magic = data.GetU32(&offset); in MagicBytesMatch() local 256 switch (magic) { in MagicBytesMatch()
|
/llvm-project/llvm/test/tools/llvm-objcopy/MachO/Inputs/ |
H A D | code-signature-check.py | 58 magic: int 79 magic: int 102 magic: int 127 magic: int 155 magic: int 206 magic: int
|
/llvm-project/lld/test/MachO/Inputs/ |
H A D | code-signature-check.py | 58 magic: int 79 magic: int 102 magic: int 127 magic: int 155 magic: int 206 magic: int
|
/llvm-project/llvm/test/TableGen/ |
H A D | assert.td | 56 // CHECK: [[FILE]]:[[@LINE+4]]:10: error: assertion failed: magic field is incorrect: 42 59 int magic = 13; 60 assert !eq(magic, 13), "magic field is incorrect: " # magic; 61 let magic = 42;
|