llvm-project/clang/test/Modules/stress1.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

137 lines
4.6 KiB
C++
Raw Normal View History

// RUN: rm -rf %t
// RUN: cd %S
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -emit-module -fmodule-name=m00 -o %t/m00.pcm \
// RUN: Inputs/stress1/module.modulemap
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -emit-module -fmodule-name=m00 -o %t/m00_check.pcm \
// RUN: Inputs/stress1/module.modulemap
//
[Modules] A second attempt at writing out on-disk hash tables for the decl context lookup tables. The first attepmt at this caused problems. We had significantly more sources of non-determinism that I realized at first, and my change essentially turned them from non-deterministic output into use-after-free. Except that they weren't necessarily caught by tools because the data wasn't really freed. The new approach is much simpler. The first big simplification is to inline the "visit" code and handle this directly. That works much better, and I'll try to go and clean up the other caller of the visit logic similarly. The second key to the entire approach is that we need to *only* collect names into a stable order at first. We then need to issue all of the actual 'lookup()' calls in the stable order of the names so that we load external results in a stable order. Once we have loaded all the results, the table of results will stop being invalidated and we can walk all of the names again and use the cheap 'noload_lookup()' method to quickly get the results and serialize them. To handle constructors and conversion functions (whose names can't be stably ordered) in this approach, what we do is record only the visible constructor and conversion function names at first. Then, if we have any, we walk the decls of the class and add those names in the order they occur in the AST. The rest falls out naturally. This actually ends up simpler than the previous approach and seems much more robust. It uncovered a latent issue where we were building on-disk hash tables for lookup results when the context was a linkage spec! This happened to dodge all of the assert by some miracle. Instead, add a proper predicate to the DeclContext class and use that which tests both for function contexts and linkage specs. It also uncovered PR23030 where we are forming somewhat bizarre negative lookup results. I've just worked around this with a FIXME in place because fixing this particular Clang bug seems quite hard. I've flipped the first part of the test case I added for stability back on in this commit. I'm taking it gradually to try and make sure the build bots are happy this time. llvm-svn: 233249
2015-03-26 11:11:40 +08:00
// RUN: diff %t/m00.pcm %t/m00_check.pcm
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 -fdelayed-template-parsing \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -emit-module -fmodule-name=m01 -o %t/m01.pcm \
// RUN: Inputs/stress1/module.modulemap
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 -fdelayed-template-parsing \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -emit-module -fmodule-name=m01 -o %t/m01_check.pcm \
// RUN: Inputs/stress1/module.modulemap
//
// RUN: diff %t/m01.pcm %t/m01_check.pcm
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -emit-module -fmodule-name=m02 -o %t/m02.pcm \
// RUN: Inputs/stress1/module.modulemap
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -emit-module -fmodule-name=m03 -o %t/m03.pcm \
// RUN: Inputs/stress1/module.modulemap
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -fmodule-file=%t/m00.pcm \
// RUN: -fmodule-file=%t/m01.pcm \
// RUN: -fmodule-file=%t/m02.pcm \
// RUN: -fmodule-file=%t/m03.pcm \
// RUN: -emit-module -fmodule-name=merge00 -o %t/merge00.pcm \
// RUN: Inputs/stress1/module.modulemap
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -fmodule-file=%t/m00.pcm \
// RUN: -fmodule-file=%t/m01.pcm \
// RUN: -fmodule-file=%t/m02.pcm \
// RUN: -fmodule-file=%t/m03.pcm \
// RUN: -emit-module -fmodule-name=merge00 -o %t/merge00_check.pcm \
// RUN: Inputs/stress1/module.modulemap
//
// RUN: diff %t/merge00.pcm %t/merge00_check.pcm
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -fmodule-map-file=Inputs/stress1/module.modulemap \
// RUN: -fmodule-file=%t/m00.pcm \
// RUN: -fmodule-file=%t/m01.pcm \
// RUN: -fmodule-file=%t/m02.pcm \
// RUN: -fmodule-file=%t/m03.pcm \
// RUN: -fmodule-file=%t/merge00.pcm \
// RUN: -verify stress1.cpp -S -emit-llvm -o %t/stress1.ll
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
// RUN: -I Inputs/stress1 \
// RUN: -fno-implicit-modules \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -fmodule-map-file=Inputs/stress1/module.modulemap \
// RUN: -fmodule-file=%t/m00.pcm \
// RUN: -fmodule-file=%t/m01.pcm \
// RUN: -fmodule-file=%t/m02.pcm \
// RUN: -fmodule-file=%t/m03.pcm \
// RUN: -fmodule-file=%t/merge00.pcm \
// RUN: -verify stress1.cpp -S -emit-llvm -o %t/stress1_check.ll
//
// RUN: diff -u %t/stress1.ll %t/stress1_check.ll
//
// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
// RUN: -I Inputs/stress1 \
// RUN: -fmodules-cache-path=%t \
// RUN: -fmodule-map-file-home-is-cwd \
// RUN: -fmodule-file=%t/m00.pcm \
// RUN: -fmodule-file=%t/m01.pcm \
// RUN: -fmodule-file=%t/m02.pcm \
// RUN: -fmodule-file=%t/m03.pcm \
// RUN: -emit-module -fmodule-name=merge00 -o /dev/null \
// RUN: -DMERGE_NO_REEXPORT \
// RUN: Inputs/stress1/module.modulemap
//
// expected-no-diagnostics
#include "m00.h"
#include "m01.h"
#include "m02.h"
#include "m03.h"
#include "merge00.h"
int f() { return N01::S00('a').method00('b') + (int)N00::S00(42) + function00(42) + g(); }
int f2() {
return pragma_weak00() + pragma_weak01() + pragma_weak02() +
pragma_weak03 + pragma_weak04 + pragma_weak05;
}