Skip to content

Commit c32b96a

Browse files
committed
Merge tag 'llvmorg-12.0.1' into ldc-release/12.x
Tag 12.0.1
2 parents 0ae541f + fed4134 commit c32b96a

File tree

243 files changed

+7421
-2536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

243 files changed

+7421
-2536
lines changed

.github/workflows/libclang-abi-tests.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
remote_repo='https://github.com/llvm/llvm-project'
4242
if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 -o ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
4343
major_version=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))
44-
baseline_ref="$major_version.0.0"
44+
baseline_ref="llvmorg-$major_version.0.0"
4545
4646
# If there is a minor release, we want to use that as the base line.
4747
minor_ref=`git ls-remote --refs -t $remote_repo llvmorg-$major_version.[1-9].[0-9] | tail -n1 | grep -o 'llvmorg-.\+' || true`
@@ -60,7 +60,7 @@ jobs:
6060
echo ::set-output name=ABI_LIBS::libclang.so
6161
else
6262
echo ::set-output name=BASELINE_VERSION_MAJOR::${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
63-
echo ::set-output name=BASELINE_REF::${{ steps.version.outputs.LLVM_VERSION_MAJOR }}.0.0
63+
echo ::set-output name=BASELINE_REF::llvmorg-${{ steps.version.outputs.LLVM_VERSION_MAJOR }}.0.0
6464
echo ::set-output name=ABI_HEADERS::.
6565
echo ::set-output name=ABI_LIBS::libclang.so libclang-cpp.so
6666
fi
@@ -104,7 +104,7 @@ jobs:
104104
- name: Configure
105105
run: |
106106
mkdir install
107-
cmake -B build -S llvm -G Ninja -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_DEBUG="-g -Og" -DCMAKE_CXX_FLAGS_DEBUG="-g -Og" -DCMAKE_INSTALL_PREFIX=`pwd`/install llvm
107+
cmake -B build -S llvm -G Ninja -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_DEBUG="-g1 -Og" -DCMAKE_CXX_FLAGS_DEBUG="-g1 -Og" -DCMAKE_INSTALL_PREFIX=`pwd`/install llvm
108108
- name: Build
109109
run: ninja -C build/ ${{ needs.abi-dump-setup.outputs.ABI_LIBS }} install-clang-headers
110110
- name: Dump ABI
@@ -113,13 +113,12 @@ jobs:
113113
for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do
114114
# Remove symbol versioning from dumps, so we can compare across major versions.
115115
sed -i 's/LLVM_${{ matrix.llvm_version_major }}/LLVM_NOVERSION/' $lib-${{ matrix.ref }}.abi
116-
tar -czf $lib-${{ matrix.ref }}.abi.tar.gz $lib-${{ matrix.ref }}.abi
117116
done
118117
- name: Upload ABI file
119118
uses: actions/upload-artifact@v2
120119
with:
121120
name: ${{ matrix.name }}
122-
path: "*${{ matrix.ref }}.abi.tar.gz"
121+
path: "*${{ matrix.ref }}.abi"
123122

124123
abi-compare:
125124
runs-on: ubuntu-latest
@@ -141,7 +140,7 @@ jobs:
141140
- name: Compare ABI
142141
run: |
143142
for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do
144-
abi-compliance-checker -lib $lib -old build-baseline/$lib*.abi.tar.gz -new build-latest/$lib*.abi.tar.gz
143+
abi-compliance-checker -lib $lib -old build-baseline/$lib*.abi -new build-latest/$lib*.abi
145144
done
146145
- name: Upload ABI Comparison
147146
if: always()

.github/workflows/llvm-tests.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
- name: Configure
108108
run: |
109109
mkdir install
110-
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_DEBUG="-g -Og" -DCMAKE_CXX_FLAGS_DEBUG="-g -Og" -DCMAKE_INSTALL_PREFIX=`pwd`/install llvm
110+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_DEBUG="-g1 -Og" -DCMAKE_CXX_FLAGS_DEBUG="-g1 -Og" -DCMAKE_INSTALL_PREFIX=`pwd`/install llvm
111111
- name: Build
112112
# Need to run install-LLVM twice to ensure the symlink is installed (this is a bug).
113113
run: |
@@ -126,12 +126,11 @@ jobs:
126126
abi-dumper $EXTRA_ARGS -lver ${{ matrix.ref }} -skip-cxx -public-headers ./install/include/${{ needs.abi-dump-setup.outputs.ABI_HEADERS }} -o ${{ matrix.ref }}.abi ./install/lib/libLLVM.so
127127
# Remove symbol versioning from dumps, so we can compare across major versions.
128128
sed -i 's/LLVM_${{ matrix.llvm_version_major }}/LLVM_NOVERSION/' ${{ matrix.ref }}.abi
129-
tar -czf ${{ matrix.ref }}.abi.tar.gz ${{ matrix.ref }}.abi
130129
- name: Upload ABI file
131130
uses: actions/upload-artifact@v1
132131
with:
133132
name: ${{ matrix.name }}
134-
path: ${{ matrix.ref }}.abi.tar.gz
133+
path: ${{ matrix.ref }}.abi
135134

136135
- name: Upload symbol list file
137136
if: matrix.name == 'build-baseline'
@@ -167,7 +166,10 @@ jobs:
167166
# This option doesn't seem to work with the ABI dumper, so passing it here.
168167
export EXTRA_ARGS="-symbols-list symbol-list/llvm.symbols"
169168
fi
170-
abi-compliance-checker $EXTRA_ARGS -l libLLVM.so -old build-baseline/*.tar.gz -new build-latest/*.tar.gz || test "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c"
169+
# FIXME: Reading of gzip'd abi files on the GitHub runners stop
170+
# working some time in March of 2021, likely due to a change in the
171+
# runner's environment.
172+
abi-compliance-checker $EXTRA_ARGS -l libLLVM.so -old build-baseline/*.abi -new build-latest/*.abi || test "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c"
171173
- name: Upload ABI Comparison
172174
if: always()
173175
uses: actions/upload-artifact@v1

clang-tools-extra/clangd/ConfigCompile.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct FragmentCompiler {
101101
llvm::SourceMgr *SourceMgr;
102102
// Normalized Fragment::SourceInfo::Directory.
103103
std::string FragmentDirectory;
104+
bool Trusted = false;
104105

105106
llvm::Optional<llvm::Regex>
106107
compileRegex(const Located<std::string> &Text,
@@ -183,6 +184,7 @@ struct FragmentCompiler {
183184
}
184185

185186
void compile(Fragment &&F) {
187+
Trusted = F.Source.Trusted;
186188
if (!F.Source.Directory.empty()) {
187189
FragmentDirectory = llvm::sys::path::convert_to_slash(F.Source.Directory);
188190
if (FragmentDirectory.back() != '/')
@@ -319,10 +321,18 @@ struct FragmentCompiler {
319321

320322
void compile(Fragment::IndexBlock::ExternalBlock &&External,
321323
llvm::SMRange BlockRange) {
324+
if (External.Server && !Trusted) {
325+
diag(Error,
326+
"Remote index may not be specified by untrusted configuration. "
327+
"Copy this into user config to use it.",
328+
External.Server->Range);
329+
return;
330+
}
322331
#ifndef CLANGD_ENABLE_REMOTE
323332
if (External.Server) {
324-
diag(Error, "Clangd isn't compiled with remote index support, ignoring "
325-
"Server." External.Server->Range);
333+
elog("Clangd isn't compiled with remote index support, ignoring Server: "
334+
"{0}",
335+
*External.Server);
326336
External.Server.reset();
327337
}
328338
#endif
@@ -488,8 +498,8 @@ CompiledFragment Fragment::compile(DiagnosticCallback D) && {
488498
trace::Span Tracer("ConfigCompile");
489499
SPAN_ATTACH(Tracer, "ConfigFile", ConfigFile);
490500
auto Result = std::make_shared<CompiledFragmentImpl>();
491-
vlog("Config fragment: compiling {0}:{1} -> {2}", ConfigFile, LineCol.first,
492-
Result.get());
501+
vlog("Config fragment: compiling {0}:{1} -> {2} (trusted={3})", ConfigFile,
502+
LineCol.first, Result.get(), Source.Trusted);
493503

494504
FragmentCompiler{*Result, D, Source.Manager.get()}.compile(std::move(*this));
495505
// Return as cheaply-copyable wrapper.

clang-tools-extra/clangd/ConfigFragment.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ struct Fragment {
9494
/// Absolute path to directory the fragment is associated with. Relative
9595
/// paths mentioned in the fragment are resolved against this.
9696
std::string Directory;
97+
/// Whether this fragment is allowed to make critical security/privacy
98+
/// decisions.
99+
bool Trusted = false;
97100
};
98101
SourceInfo Source;
99102

clang-tools-extra/clangd/ConfigProvider.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class FileConfigCache : public FileCache {
3434
: FileCache(Path), Directory(Directory) {}
3535

3636
void get(const ThreadsafeFS &TFS, DiagnosticCallback DC,
37-
std::chrono::steady_clock::time_point FreshTime,
37+
std::chrono::steady_clock::time_point FreshTime, bool Trusted,
3838
std::vector<CompiledFragment> &Out) const {
3939
read(
4040
TFS, FreshTime,
@@ -43,6 +43,7 @@ class FileConfigCache : public FileCache {
4343
if (Data)
4444
for (auto &Fragment : Fragment::parseYAML(*Data, path(), DC)) {
4545
Fragment.Source.Directory = Directory;
46+
Fragment.Source.Trusted = Trusted;
4647
CachedValue.push_back(std::move(Fragment).compile(DC));
4748
}
4849
},
@@ -52,35 +53,38 @@ class FileConfigCache : public FileCache {
5253

5354
std::unique_ptr<Provider> Provider::fromYAMLFile(llvm::StringRef AbsPath,
5455
llvm::StringRef Directory,
55-
const ThreadsafeFS &FS) {
56+
const ThreadsafeFS &FS,
57+
bool Trusted) {
5658
class AbsFileProvider : public Provider {
5759
mutable FileConfigCache Cache; // threadsafe
5860
const ThreadsafeFS &FS;
61+
bool Trusted;
5962

6063
std::vector<CompiledFragment>
6164
getFragments(const Params &P, DiagnosticCallback DC) const override {
6265
std::vector<CompiledFragment> Result;
63-
Cache.get(FS, DC, P.FreshTime, Result);
66+
Cache.get(FS, DC, P.FreshTime, Trusted, Result);
6467
return Result;
6568
};
6669

6770
public:
6871
AbsFileProvider(llvm::StringRef Path, llvm::StringRef Directory,
69-
const ThreadsafeFS &FS)
70-
: Cache(Path, Directory), FS(FS) {
72+
const ThreadsafeFS &FS, bool Trusted)
73+
: Cache(Path, Directory), FS(FS), Trusted(Trusted) {
7174
assert(llvm::sys::path::is_absolute(Path));
7275
}
7376
};
7477

75-
return std::make_unique<AbsFileProvider>(AbsPath, Directory, FS);
78+
return std::make_unique<AbsFileProvider>(AbsPath, Directory, FS, Trusted);
7679
}
7780

7881
std::unique_ptr<Provider>
7982
Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath,
80-
const ThreadsafeFS &FS) {
83+
const ThreadsafeFS &FS, bool Trusted) {
8184
class RelFileProvider : public Provider {
8285
std::string RelPath;
8386
const ThreadsafeFS &FS;
87+
bool Trusted;
8488

8589
mutable std::mutex Mu;
8690
// Keys are the (posix-style) ancestor directory, not the config within it.
@@ -128,18 +132,19 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath,
128132
// This will take a (per-file) lock for each file that actually exists.
129133
std::vector<CompiledFragment> Result;
130134
for (FileConfigCache *Cache : Caches)
131-
Cache->get(FS, DC, P.FreshTime, Result);
135+
Cache->get(FS, DC, P.FreshTime, Trusted, Result);
132136
return Result;
133137
};
134138

135139
public:
136-
RelFileProvider(llvm::StringRef RelPath, const ThreadsafeFS &FS)
137-
: RelPath(RelPath), FS(FS) {
140+
RelFileProvider(llvm::StringRef RelPath, const ThreadsafeFS &FS,
141+
bool Trusted)
142+
: RelPath(RelPath), FS(FS), Trusted(Trusted) {
138143
assert(llvm::sys::path::is_relative(RelPath));
139144
}
140145
};
141146

142-
return std::make_unique<RelFileProvider>(RelPath, FS);
147+
return std::make_unique<RelFileProvider>(RelPath, FS, Trusted);
143148
}
144149

145150
std::unique_ptr<Provider>

clang-tools-extra/clangd/ConfigProvider.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class Provider {
6969
/// Directory will be used to resolve relative paths in the fragments.
7070
static std::unique_ptr<Provider> fromYAMLFile(llvm::StringRef AbsPath,
7171
llvm::StringRef Directory,
72-
const ThreadsafeFS &);
72+
const ThreadsafeFS &,
73+
bool Trusted = false);
7374
// Reads fragments from YAML files found relative to ancestors of Params.Path.
7475
//
7576
// All fragments that exist are returned, starting from distant ancestors.
@@ -78,7 +79,8 @@ class Provider {
7879
//
7980
// If Params does not specify a path, no fragments are returned.
8081
static std::unique_ptr<Provider>
81-
fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath, const ThreadsafeFS &);
82+
fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath, const ThreadsafeFS &,
83+
bool Trusted = false);
8284

8385
/// A provider that includes fragments from all the supplied providers.
8486
/// Order is preserved; later providers take precedence over earlier ones.

clang-tools-extra/clangd/quality/CompletionModel.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# ${CMAKE_CURRENT_BINARY_DIR}. The generated header
55
# will define a C++ class called ${cpp_class} - which may be a
66
# namespace-qualified class name.
7+
set(CLANGD_COMPLETION_MODEL_COMPILER ${CMAKE_CURRENT_LIST_DIR}/CompletionModelCodegen.py)
78
function(gen_decision_forest model filename cpp_class)
8-
set(model_compiler ${CMAKE_SOURCE_DIR}/../clang-tools-extra/clangd/quality/CompletionModelCodegen.py)
9-
9+
set(model_compiler ${CLANGD_COMPLETION_MODEL_COMPILER})
10+
1011
set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
1112
set(header_file ${output_dir}/${filename}.h)
1213
set(cpp_file ${output_dir}/${filename}.cpp)

clang-tools-extra/clangd/tool/ClangdMain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,8 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
831831
if (llvm::sys::path::user_config_directory(UserConfig)) {
832832
llvm::sys::path::append(UserConfig, "clangd", "config.yaml");
833833
vlog("User config file is {0}", UserConfig);
834-
ProviderStack.push_back(
835-
config::Provider::fromYAMLFile(UserConfig, /*Directory=*/"", TFS));
834+
ProviderStack.push_back(config::Provider::fromYAMLFile(
835+
UserConfig, /*Directory=*/"", TFS, /*Trusted=*/true));
836836
} else {
837837
elog("Couldn't determine user config file, not loading");
838838
}

clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,35 @@ TEST_F(ConfigCompileTests, TidyBadChecks) {
318318
DiagKind(llvm::SourceMgr::DK_Warning))));
319319
}
320320

321+
TEST_F(ConfigCompileTests, ExternalServerNeedsTrusted) {
322+
Fragment::IndexBlock::ExternalBlock External;
323+
External.Server.emplace("xxx");
324+
Frag.Index.External = std::move(External);
325+
compileAndApply();
326+
EXPECT_THAT(
327+
Diags.Diagnostics,
328+
ElementsAre(DiagMessage(
329+
"Remote index may not be specified by untrusted configuration. "
330+
"Copy this into user config to use it.")));
331+
EXPECT_FALSE(Conf.Index.External.hasValue());
332+
}
333+
321334
TEST_F(ConfigCompileTests, ExternalBlockWarnOnMultipleSource) {
335+
Frag.Source.Trusted = true;
322336
Fragment::IndexBlock::ExternalBlock External;
323337
External.File.emplace("");
324338
External.Server.emplace("");
325339
Frag.Index.External = std::move(External);
326340
compileAndApply();
327-
llvm::StringLiteral ExpectedDiag =
328341
#ifdef CLANGD_ENABLE_REMOTE
329-
"Exactly one of File or Server must be set.";
342+
EXPECT_THAT(
343+
Diags.Diagnostics,
344+
Contains(AllOf(DiagMessage("Exactly one of File or Server must be set."),
345+
DiagKind(llvm::SourceMgr::DK_Error))));
330346
#else
331-
"Clangd isn't compiled with remote index support, ignoring Server.";
347+
ASSERT_TRUE(Conf.Index.External.hasValue());
348+
EXPECT_EQ(Conf.Index.External->Kind, Config::ExternalIndexSpec::File);
332349
#endif
333-
EXPECT_THAT(Diags.Diagnostics,
334-
Contains(AllOf(DiagMessage(ExpectedDiag),
335-
DiagKind(llvm::SourceMgr::DK_Error))));
336350
}
337351

338352
TEST_F(ConfigCompileTests, ExternalBlockErrOnNoSource) {

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ clang-format
389389
``AlignConsecutiveDeclarations`` and ``AlignConsecutiveMacros`` have been modified to allow
390390
alignment across empty lines and/or comments.
391391

392+
- Support for Whitesmiths has been improved, with fixes for ``namespace`` blocks
393+
and ``case`` blocks and labels.
394+
392395
libclang
393396
--------
394397

0 commit comments

Comments
 (0)