Skip to content

Commit

Permalink
Merged master:9819976032c into amd-gfx:16263922300
Browse files Browse the repository at this point in the history
Local branch amd-gfx 1626392 Merged master:aa93659c9ff into amd-gfx:b71fb3cd5d4
Remote branch master 9819976 [llvm-readobj] - Cleanup the DwarfCFIEH::PrinterContext class. NFCI.
  • Loading branch information
Sw authored and Sw committed May 29, 2020
2 parents 1626392 + 9819976 commit 5a80597
Show file tree
Hide file tree
Showing 36 changed files with 1,301 additions and 342 deletions.
2 changes: 2 additions & 0 deletions clang-tools-extra/clangd/Preamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ void escapeBackslashAndQuotes(llvm::StringRef Text, llvm::raw_ostream &OS) {
PreamblePatch PreamblePatch::create(llvm::StringRef FileName,
const ParseInputs &Modified,
const PreambleData &Baseline) {
trace::Span Tracer("CreatePreamblePatch");
SPAN_ATTACH(Tracer, "File", FileName);
assert(llvm::sys::path::is_absolute(FileName) && "relative FileName!");
// First scan preprocessor directives in Baseline and Modified. These will be
// used to figure out newly added directives in Modified. Scanning can fail,
Expand Down
7 changes: 5 additions & 2 deletions clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,12 @@ ToolChain::getTargetAndModeFromProgramName(StringRef PN) {
StringRef ToolChain::getDefaultUniversalArchName() const {
// In universal driver terms, the arch name accepted by -arch isn't exactly
// the same as the ones that appear in the triple. Roughly speaking, this is
// an inverse of the darwin::getArchTypeForDarwinArchName() function, but the
// only interesting special case is powerpc.
// an inverse of the darwin::getArchTypeForDarwinArchName() function.
switch (Triple.getArch()) {
case llvm::Triple::aarch64:
return "arm64";
case llvm::Triple::aarch64_32:
return "arm64_32";
case llvm::Triple::ppc:
return "ppc";
case llvm::Triple::ppc64:
Expand Down
9 changes: 8 additions & 1 deletion clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,14 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
case ToolChain::UNW_CompilerRT:
if (LGT == LibGccType::StaticLibGcc)
CmdArgs.push_back("-l:libunwind.a");
else
else if (TC.getTriple().isOSCygMing()) {
if (LGT == LibGccType::SharedLibGcc)
CmdArgs.push_back("-l:libunwind.dll.a");
else
// Let the linker choose between libunwind.dll.a and libunwind.a
// depending on what's available, and depending on the -static flag
CmdArgs.push_back("-lunwind");
} else
CmdArgs.push_back("-l:libunwind.so");
break;
}
Expand Down
23 changes: 23 additions & 0 deletions clang/test/Driver/compiler-rt-unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,26 @@
// RUN: --gcc-toolchain="" \
// RUN: FileCheck --input-file=%t.err --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s
// RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires --unwindlib=libgcc"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
// RUN: -shared-libgcc \
// RUN: --gcc-toolchain="" \
// RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT %s
// MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a"
// MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.dll.a"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
// RUN: -static-libgcc \
// RUN: --gcc-toolchain="" \
// RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT %s
// MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a"
// MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.a"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
// RUN: --gcc-toolchain="" \
// RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT %s
// MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a"
// MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind"
3 changes: 3 additions & 0 deletions clang/test/Driver/darwin-arm64-target.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// RUN: %clang -target aarch64-apple-darwin %s -miphoneos-version-min=8.0 -### 2>&1 | FileCheck %s

// CHECK: "-cc1"{{.*}} "-triple" "arm64-apple-ios8.0.0"
33 changes: 17 additions & 16 deletions clang/unittests/AST/ASTImporterFixtures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
llvm::MemoryBuffer::getMemBuffer(Code));
}

ASTImporterTestBase::TU::TU(StringRef Code, StringRef FileName, ArgVector Args,
ASTImporterTestBase::TU::TU(StringRef Code, StringRef FileName,
std::vector<std::string> Args,
ImporterConstructor C,
ASTImporter::ODRHandlingType ODRHandling)
: Code(std::string(Code)), FileName(std::string(FileName)),
Expand Down Expand Up @@ -112,11 +113,12 @@ void ASTImporterTestBase::lazyInitSharedState(TranslationUnitDecl *ToTU) {
SharedStatePtr = std::make_shared<ASTImporterSharedState>(*ToTU);
}

void ASTImporterTestBase::lazyInitToAST(Language ToLang, StringRef ToSrcCode,
void ASTImporterTestBase::lazyInitToAST(TestLanguage ToLang,
StringRef ToSrcCode,
StringRef FileName) {
if (ToAST)
return;
ArgVector ToArgs = getArgVectorForLanguage(ToLang);
std::vector<std::string> ToArgs = getCommandLineArgsForLanguage(ToLang);
// Source code must be a valid live buffer through the tests lifetime.
ToCode = std::string(ToSrcCode);
// Build the AST from an empty file.
Expand All @@ -136,12 +138,11 @@ ASTImporterTestBase::TU *ASTImporterTestBase::findFromTU(Decl *From) {
return &*It;
}

std::tuple<Decl *, Decl *>
ASTImporterTestBase::getImportedDecl(StringRef FromSrcCode, Language FromLang,
StringRef ToSrcCode, Language ToLang,
StringRef Identifier) {
ArgVector FromArgs = getArgVectorForLanguage(FromLang),
ToArgs = getArgVectorForLanguage(ToLang);
std::tuple<Decl *, Decl *> ASTImporterTestBase::getImportedDecl(
StringRef FromSrcCode, TestLanguage FromLang, StringRef ToSrcCode,
TestLanguage ToLang, StringRef Identifier) {
std::vector<std::string> FromArgs = getCommandLineArgsForLanguage(FromLang);
std::vector<std::string> ToArgs = getCommandLineArgsForLanguage(ToLang);

FromTUs.emplace_back(FromSrcCode, InputFileName, FromArgs, Creator,
ODRHandling);
Expand Down Expand Up @@ -170,28 +171,28 @@ ASTImporterTestBase::getImportedDecl(StringRef FromSrcCode, Language FromLang,
}

TranslationUnitDecl *ASTImporterTestBase::getTuDecl(StringRef SrcCode,
Language Lang,
TestLanguage Lang,
StringRef FileName) {
assert(llvm::find_if(FromTUs, [FileName](const TU &E) {
return E.FileName == FileName;
}) == FromTUs.end());

ArgVector Args = getArgVectorForLanguage(Lang);
std::vector<std::string> Args = getCommandLineArgsForLanguage(Lang);
FromTUs.emplace_back(SrcCode, FileName, Args, Creator, ODRHandling);
TU &Tu = FromTUs.back();

return Tu.TUDecl;
}

TranslationUnitDecl *ASTImporterTestBase::getToTuDecl(StringRef ToSrcCode,
Language ToLang) {
ArgVector ToArgs = getArgVectorForLanguage(ToLang);
TestLanguage ToLang) {
std::vector<std::string> ToArgs = getCommandLineArgsForLanguage(ToLang);
assert(!ToAST);
lazyInitToAST(ToLang, ToSrcCode, OutputFileName);
return ToAST->getASTContext().getTranslationUnitDecl();
}

Decl *ASTImporterTestBase::Import(Decl *From, Language ToLang) {
Decl *ASTImporterTestBase::Import(Decl *From, TestLanguage ToLang) {
lazyInitToAST(ToLang, "", OutputFileName);
TU *FromTU = findFromTU(From);
assert(SharedStatePtr);
Expand All @@ -200,7 +201,7 @@ Decl *ASTImporterTestBase::Import(Decl *From, Language ToLang) {
}

llvm::Expected<Decl *> ASTImporterTestBase::importOrError(Decl *From,
Language ToLang) {
TestLanguage ToLang) {
lazyInitToAST(ToLang, "", OutputFileName);
TU *FromTU = findFromTU(From);
assert(SharedStatePtr);
Expand All @@ -210,7 +211,7 @@ llvm::Expected<Decl *> ASTImporterTestBase::importOrError(Decl *From,
}

QualType ASTImporterTestBase::ImportType(QualType FromType, Decl *TUDecl,
Language ToLang) {
TestLanguage ToLang) {
lazyInitToAST(ToLang, "", OutputFileName);
TU *FromTU = findFromTU(TUDecl);
assert(SharedStatePtr);
Expand Down
46 changes: 26 additions & 20 deletions clang/unittests/AST/ASTImporterFixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,28 @@ void createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
class CompilerOptionSpecificTest : public ::testing::Test {
protected:
// Return the extra arguments appended to runtime options at compilation.
virtual ArgVector getExtraArgs() const { return ArgVector(); }
virtual std::vector<std::string> getExtraArgs() const { return {}; }

// Returns the argument vector used for a specific language option, this set
// can be tweaked by the test parameters.
ArgVector getArgVectorForLanguage(Language Lang) const {
ArgVector Args = getBasicRunOptionsForLanguage(Lang);
ArgVector ExtraArgs = getExtraArgs();
std::vector<std::string>
getCommandLineArgsForLanguage(TestLanguage Lang) const {
std::vector<std::string> Args = getCommandLineArgsForTesting(Lang);
std::vector<std::string> ExtraArgs = getExtraArgs();
for (const auto &Arg : ExtraArgs) {
Args.push_back(Arg);
}
return Args;
}
};

const auto DefaultTestArrayForRunOptions = std::array<ArgVector, 4>{
{ArgVector(), ArgVector{"-fdelayed-template-parsing"},
ArgVector{"-fms-compatibility"},
ArgVector{"-fdelayed-template-parsing", "-fms-compatibility"}}};
const auto DefaultTestArrayForRunOptions =
std::array<std::vector<std::string>, 4>{
{std::vector<std::string>(),
std::vector<std::string>{"-fdelayed-template-parsing"},
std::vector<std::string>{"-fms-compatibility"},
std::vector<std::string>{"-fdelayed-template-parsing",
"-fms-compatibility"}}};

const auto DefaultTestValuesForRunOptions =
::testing::ValuesIn(DefaultTestArrayForRunOptions);
Expand Down Expand Up @@ -111,7 +115,7 @@ class ASTImporterTestBase : public CompilerOptionSpecificTest {
ImporterConstructor Creator;
ASTImporter::ODRHandlingType ODRHandling;

TU(StringRef Code, StringRef FileName, ArgVector Args,
TU(StringRef Code, StringRef FileName, std::vector<std::string> Args,
ImporterConstructor C = ImporterConstructor(),
ASTImporter::ODRHandlingType ODRHandling =
ASTImporter::ODRHandlingType::Conservative);
Expand Down Expand Up @@ -141,7 +145,8 @@ class ASTImporterTestBase : public CompilerOptionSpecificTest {
// Initialize the shared state if not initialized already.
void lazyInitSharedState(TranslationUnitDecl *ToTU);

void lazyInitToAST(Language ToLang, StringRef ToSrcCode, StringRef FileName);
void lazyInitToAST(TestLanguage ToLang, StringRef ToSrcCode,
StringRef FileName);

protected:
std::shared_ptr<ASTImporterSharedState> SharedStatePtr;
Expand All @@ -157,32 +162,33 @@ class ASTImporterTestBase : public CompilerOptionSpecificTest {
// of the identifier into the To context.
// Must not be called more than once within the same test.
std::tuple<Decl *, Decl *>
getImportedDecl(StringRef FromSrcCode, Language FromLang, StringRef ToSrcCode,
Language ToLang, StringRef Identifier = DeclToImportID);
getImportedDecl(StringRef FromSrcCode, TestLanguage FromLang,
StringRef ToSrcCode, TestLanguage ToLang,
StringRef Identifier = DeclToImportID);

// Creates a TU decl for the given source code which can be used as a From
// context. May be called several times in a given test (with different file
// name).
TranslationUnitDecl *getTuDecl(StringRef SrcCode, Language Lang,
TranslationUnitDecl *getTuDecl(StringRef SrcCode, TestLanguage Lang,
StringRef FileName = "input.cc");

// Creates the To context with the given source code and returns the TU decl.
TranslationUnitDecl *getToTuDecl(StringRef ToSrcCode, Language ToLang);
TranslationUnitDecl *getToTuDecl(StringRef ToSrcCode, TestLanguage ToLang);

// Import the given Decl into the ToCtx.
// May be called several times in a given test.
// The different instances of the param From may have different ASTContext.
Decl *Import(Decl *From, Language ToLang);
Decl *Import(Decl *From, TestLanguage ToLang);

template <class DeclT> DeclT *Import(DeclT *From, Language Lang) {
template <class DeclT> DeclT *Import(DeclT *From, TestLanguage Lang) {
return cast_or_null<DeclT>(Import(cast<Decl>(From), Lang));
}

// Import the given Decl into the ToCtx.
// Same as Import but returns the result of the import which can be an error.
llvm::Expected<Decl *> importOrError(Decl *From, Language ToLang);
llvm::Expected<Decl *> importOrError(Decl *From, TestLanguage ToLang);

QualType ImportType(QualType FromType, Decl *TUDecl, Language ToLang);
QualType ImportType(QualType FromType, Decl *TUDecl, TestLanguage ToLang);

ASTImporterTestBase()
: ODRHandling(ASTImporter::ODRHandlingType::Conservative) {}
Expand All @@ -191,9 +197,9 @@ class ASTImporterTestBase : public CompilerOptionSpecificTest {

class ASTImporterOptionSpecificTestBase
: public ASTImporterTestBase,
public ::testing::WithParamInterface<ArgVector> {
public ::testing::WithParamInterface<std::vector<std::string>> {
protected:
ArgVector getExtraArgs() const override { return GetParam(); }
std::vector<std::string> getExtraArgs() const override { return GetParam(); }
};

template <class T>
Expand Down
Loading

0 comments on commit 5a80597

Please sign in to comment.