clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name LinkingContext.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-8/lib/clang/8.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lld/lib/Core -I /build/llvm-toolchain-snapshot-8~svn345461/tools/lld/lib/Core -I /build/llvm-toolchain-snapshot-8~svn345461/tools/lld/include -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lld/include -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/include -I /build/llvm-toolchain-snapshot-8~svn345461/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/include/clang/8.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/lld/lib/Core -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-10-27-211344-32123-1 -x c++ /build/llvm-toolchain-snapshot-8~svn345461/tools/lld/lib/Core/LinkingContext.cpp -faddrsig
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | #include "lld/Core/LinkingContext.h" |
11 | #include "lld/Core/File.h" |
12 | #include "lld/Core/Node.h" |
13 | #include "lld/Core/Simple.h" |
14 | #include "lld/Core/Writer.h" |
15 | #include <algorithm> |
16 | |
17 | namespace lld { |
18 | |
19 | LinkingContext::LinkingContext() = default; |
20 | |
21 | LinkingContext::~LinkingContext() = default; |
22 | |
23 | bool LinkingContext::validate() { |
24 | return validateImpl(); |
25 | } |
26 | |
27 | llvm::Error LinkingContext::writeFile(const File &linkedFile) const { |
28 | return this->writer().writeFile(linkedFile, _outputPath); |
29 | } |
30 | |
31 | std::unique_ptr<File> LinkingContext::createEntrySymbolFile() const { |
32 | return createEntrySymbolFile("<command line option -e>"); |
33 | } |
34 | |
35 | std::unique_ptr<File> |
36 | LinkingContext::createEntrySymbolFile(StringRef filename) const { |
37 | if (entrySymbolName().empty()) |
38 | return nullptr; |
39 | std::unique_ptr<SimpleFile> entryFile(new SimpleFile(filename, |
40 | File::kindEntryObject)); |
41 | entryFile->addAtom( |
42 | *(new (_allocator) SimpleUndefinedAtom(*entryFile, entrySymbolName()))); |
43 | return std::move(entryFile); |
44 | } |
45 | |
46 | std::unique_ptr<File> LinkingContext::createUndefinedSymbolFile() const { |
47 | return createUndefinedSymbolFile("<command line option -u or --defsym>"); |
| 3 | | Calling 'LinkingContext::createUndefinedSymbolFile' | |
|
48 | } |
49 | |
50 | std::unique_ptr<File> |
51 | LinkingContext::createUndefinedSymbolFile(StringRef filename) const { |
52 | if (_initialUndefinedSymbols.empty()) |
| 4 | | Assuming the condition is false | |
|
| |
53 | return nullptr; |
54 | std::unique_ptr<SimpleFile> undefinedSymFile( |
55 | new SimpleFile(filename, File::kindUndefinedSymsObject)); |
56 | for (StringRef undefSym : _initialUndefinedSymbols) |
57 | undefinedSymFile->addAtom(*(new (_allocator) SimpleUndefinedAtom( |
| 6 | | Forming reference to null pointer |
|
58 | *undefinedSymFile, undefSym))); |
59 | return std::move(undefinedSymFile); |
60 | } |
61 | |
62 | void LinkingContext::createInternalFiles( |
63 | std::vector<std::unique_ptr<File>> &result) const { |
64 | if (std::unique_ptr<File> file = createEntrySymbolFile()) |
| |
65 | result.push_back(std::move(file)); |
66 | if (std::unique_ptr<File> file = createUndefinedSymbolFile()) |
| 2 | | Calling 'LinkingContext::createUndefinedSymbolFile' | |
|
67 | result.push_back(std::move(file)); |
68 | } |
69 | |
70 | } |