Skip to content

Commit

Permalink
Merged master:76d294cb874 into amd-gfx:0185fe179ea
Browse files Browse the repository at this point in the history
Local branch amd-gfx 0185fe1 Merged master:6d5e35e89d7 into amd-gfx:f9336878686
Remote branch master 76d294c [lldb][NFC] Delete all 'else return ...' in CompilerDeclContext.cpp
  • Loading branch information
Sw authored and Sw committed Dec 23, 2019
2 parents 0185fe1 + 76d294c commit f2ac07a
Show file tree
Hide file tree
Showing 62 changed files with 973 additions and 490 deletions.
4 changes: 3 additions & 1 deletion clang/lib/CodeGen/ItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2684,7 +2684,9 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs(

if (Init) {
Init->setVisibility(Var->getVisibility());
Init->setDSOLocal(Var->isDSOLocal());
// Don't mark an extern_weak function DSO local on windows.
if (!CGM.getTriple().isOSWindows() || !Init->hasExternalWeakLinkage())
Init->setDSOLocal(Var->isDSOLocal());
}

llvm::LLVMContext &Context = CGM.getModule().getContext();
Expand Down
9 changes: 9 additions & 0 deletions clang/test/CodeGenCXX/mingw-thread-local.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-w64-mingw32 | FileCheck %s

extern thread_local int var;

int get() {
return var;
}

// CHECK: declare extern_weak void @_ZTH3var()
12 changes: 8 additions & 4 deletions lldb/include/lldb/Symbol/ClangASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,8 @@ class ClangASTContext : public TypeSystem {

uint32_t GetPointerByteSize() override;

static clang::DeclContext *GetTranslationUnitDecl(clang::ASTContext *ast);

clang::DeclContext *GetTranslationUnitDecl() {
return GetTranslationUnitDecl(&getASTContext());
clang::TranslationUnitDecl *GetTranslationUnitDecl() {
return getASTContext().getTranslationUnitDecl();
}

static clang::Decl *CopyDecl(clang::ASTContext *dest_context,
Expand Down Expand Up @@ -440,6 +438,12 @@ class ClangASTContext : public TypeSystem {

// CompilerDeclContext override functions

/// Creates a CompilerDeclContext from the given DeclContext
/// with the current ClangASTContext instance as its typesystem.
/// The DeclContext has to come from the ASTContext of this
/// ClangASTContext.
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx);

std::vector<CompilerDecl>
DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
const bool ignore_using_decls) override;
Expand Down
8 changes: 7 additions & 1 deletion lldb/include/lldb/Symbol/CompilerDeclContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ namespace lldb_private {

class CompilerDeclContext {
public:
// Constructors and Destructors
/// Constructs an invalid CompilerDeclContext.
CompilerDeclContext() = default;

/// Constructs a CompilerDeclContext with the given opaque decl context
/// and its respective TypeSystem instance.
///
/// Do not use this constructor directly but instead call the respective
/// wrapper from the TypeSystem subclass.
/// @see lldb_private::ClangASTContext::CreateDeclContext(clang::DeclContext*)
CompilerDeclContext(TypeSystem *type_system, void *decl_ctx)
: m_type_system(type_system), m_opaque_decl_ctx(decl_ctx) {}

Expand Down
1 change: 1 addition & 0 deletions lldb/source/Interpreter/ScriptInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) {
case eScriptLanguageUnknown:
return "Unknown";
}
llvm_unreachable("Unhandled ScriptInterpreter!");
}

lldb::ScriptLanguage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,9 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
dyn_cast<NamespaceDecl>(context.m_decl_context)) {
if (namespace_context->getName().str() ==
std::string(g_lldb_local_vars_namespace_cstr)) {
CompilerDeclContext compiler_decl_ctx(
GetClangASTContext(), const_cast<void *>(static_cast<const void *>(
context.m_decl_context)));
CompilerDeclContext compiler_decl_ctx =
m_clang_ast_context->CreateDeclContext(
const_cast<clang::DeclContext *>(context.m_decl_context));
FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx,
current_id);
return;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,7 @@ CompilerDeclContext
DWARFASTParserClang::GetDeclContextForUIDFromDWARF(const DWARFDIE &die) {
clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE(die);
if (clang_decl_ctx)
return CompilerDeclContext(&m_ast, clang_decl_ctx);
return m_ast.CreateDeclContext(clang_decl_ctx);
return CompilerDeclContext();
}

Expand All @@ -2227,7 +2227,7 @@ DWARFASTParserClang::GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) {
clang::DeclContext *clang_decl_ctx =
GetClangDeclContextContainingDIE(die, nullptr);
if (clang_decl_ctx)
return CompilerDeclContext(&m_ast, clang_decl_ctx);
return m_ast.CreateDeclContext(clang_decl_ctx);
return CompilerDeclContext();
}

Expand Down
21 changes: 1 addition & 20 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,25 +732,6 @@ removeHostnameFromPathname(llvm::StringRef path_from_dwarf) {
return path;
}

static FileSpec resolveCompDir(const FileSpec &path) {
bool is_symlink = SymbolFileDWARF::GetSymlinkPaths().FindFileIndex(
0, path, /*full*/ true) != UINT32_MAX;

if (!is_symlink)
return path;

namespace fs = llvm::sys::fs;
if (fs::get_file_type(path.GetPath(), false) != fs::file_type::symlink_file)
return path;

FileSpec resolved_symlink;
const auto error = FileSystem::Instance().Readlink(path, resolved_symlink);
if (error.Success())
return resolved_symlink;

return path;
}

void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
m_comp_dir = FileSpec();
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
Expand All @@ -762,7 +743,7 @@ void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
if (!comp_dir.empty()) {
FileSpec::Style comp_dir_style =
FileSpec::GuessPathStyle(comp_dir).getValueOr(FileSpec::Style::native);
m_comp_dir = resolveCompDir(FileSpec(comp_dir, comp_dir_style));
m_comp_dir = FileSpec(comp_dir, comp_dir_style);
} else {
// Try to detect the style based on the DW_AT_name attribute, but just store
// the detected style in the m_comp_dir field.
Expand Down
11 changes: 11 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,17 @@ SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType language) {
void SymbolFileDWARF::InitializeObject() {
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);

Module &module = *GetObjectFile()->GetModule();

for (const FileSpec &symlink : GetSymlinkPaths()) {
FileSpec resolved;
Status status = FileSystem::Instance().Readlink(symlink, resolved);
if (status.Success())
module.GetSourceMappingList().Append(ConstString(symlink.GetPath()),
ConstString(resolved.GetPath()),
/*notify=*/true);
}

if (!GetGlobalPluginProperties()->IgnoreFileIndexes()) {
DWARFDataExtractor apple_names, apple_namespaces, apple_types, apple_objc;
LoadSectionData(eSectionTypeDWARFAppleNames, apple_names);
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ CompilerType PdbAstBuilder::ToCompilerType(clang::QualType qt) {

CompilerDeclContext
PdbAstBuilder::ToCompilerDeclContext(clang::DeclContext &context) {
return {&m_clang, &context};
return m_clang.CreateDeclContext(&context);
}

clang::Decl * PdbAstBuilder::FromCompilerDecl(CompilerDecl decl) {
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
CompilerType target_ast_type = target_type->GetFullCompilerType();

ast_typedef = m_ast.CreateTypedefType(
target_ast_type, name.c_str(), CompilerDeclContext(&m_ast, decl_ctx));
target_ast_type, name.c_str(), m_ast.CreateDeclContext(decl_ctx));
if (!ast_typedef)
return nullptr;

Expand Down
7 changes: 3 additions & 4 deletions lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ SymbolFilePDB::GetDeclContextForUID(lldb::user_id_t uid) {
if (!decl_context)
return GetDeclContextContainingUID(uid);

return CompilerDeclContext(clang_ast_ctx, decl_context);
return clang_ast_ctx->CreateDeclContext(decl_context);
}

lldb_private::CompilerDeclContext
Expand Down Expand Up @@ -695,7 +695,7 @@ SymbolFilePDB::GetDeclContextContainingUID(lldb::user_id_t uid) {
auto decl_context = pdb->GetDeclContextContainingSymbol(*symbol);
assert(decl_context);

return CompilerDeclContext(clang_ast_ctx, decl_context);
return clang_ast_ctx->CreateDeclContext(decl_context);
}

void SymbolFilePDB::ParseDeclsForContext(
Expand Down Expand Up @@ -1703,8 +1703,7 @@ lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
if (!namespace_decl)
return CompilerDeclContext();

return CompilerDeclContext(clang_type_system,
static_cast<clang::DeclContext *>(namespace_decl));
return clang_type_system->CreateDeclContext(namespace_decl);
}

lldb_private::ConstString SymbolFilePDB::GetPluginName() {
Expand Down
26 changes: 12 additions & 14 deletions lldb/source/Symbol/ClangASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,11 +1153,6 @@ CompilerType ClangASTContext::GetCStringType(bool is_const) {
return CompilerType(this, ast.getPointerType(char_type).getAsOpaquePtr());
}

clang::DeclContext *
ClangASTContext::GetTranslationUnitDecl(clang::ASTContext *ast) {
return ast->getTranslationUnitDecl();
}

clang::Decl *ClangASTContext::CopyDecl(ASTContext *dst_ast, ASTContext *src_ast,
clang::Decl *source_decl) {
FileSystemOptions file_system_options;
Expand Down Expand Up @@ -1205,9 +1200,15 @@ CompilerType ClangASTContext::GetTypeForDecl(void *opaque_decl) {
return CompilerType();
}

CompilerDeclContext ClangASTContext::CreateDeclContext(DeclContext *ctx) {
// Check that the DeclContext actually belongs to this ASTContext.
assert(&ctx->getParentASTContext() == &getASTContext());
return CompilerDeclContext(this, ctx);
}

CompilerType ClangASTContext::GetTypeForDecl(clang::NamedDecl *decl) {
if (clang::ObjCInterfaceDecl *interface_decl =
llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
return GetTypeForDecl(interface_decl);
if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
return GetTypeForDecl(tag_decl);
Expand Down Expand Up @@ -1778,8 +1779,7 @@ clang::DeclContext *FindLCABetweenDecls(clang::DeclContext *left,
clang::UsingDirectiveDecl *ClangASTContext::CreateUsingDirectiveDeclaration(
clang::DeclContext *decl_ctx, clang::NamespaceDecl *ns_decl) {
if (decl_ctx != nullptr && ns_decl != nullptr) {
clang::TranslationUnitDecl *translation_unit =
(clang::TranslationUnitDecl *)GetTranslationUnitDecl(&getASTContext());
auto *translation_unit = getASTContext().getTranslationUnitDecl();
clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
getASTContext(), decl_ctx, clang::SourceLocation(),
clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
Expand Down Expand Up @@ -9039,10 +9039,8 @@ ConstString ClangASTContext::DeclGetMangledName(void *opaque_decl) {

CompilerDeclContext ClangASTContext::DeclGetDeclContext(void *opaque_decl) {
if (opaque_decl)
return CompilerDeclContext(this,
((clang::Decl *)opaque_decl)->getDeclContext());
else
return CompilerDeclContext();
return CreateDeclContext(((clang::Decl *)opaque_decl)->getDeclContext());
return CompilerDeclContext();
}

CompilerType ClangASTContext::DeclGetFunctionReturnType(void *opaque_decl) {
Expand Down Expand Up @@ -9108,7 +9106,7 @@ std::vector<CompilerDecl> ClangASTContext::DeclContextFindDeclByName(
if (!searched.insert(it->second).second)
continue;
symbol_file->ParseDeclsForContext(
CompilerDeclContext(this, it->second));
CreateDeclContext(it->second));

for (clang::Decl *child : it->second->decls()) {
if (clang::UsingDirectiveDecl *ud =
Expand Down Expand Up @@ -9223,7 +9221,7 @@ uint32_t ClangASTContext::CountDeclLevels(clang::DeclContext *frame_decl_ctx,

searched.insert(it->second);
symbol_file->ParseDeclsForContext(
CompilerDeclContext(this, it->second));
CreateDeclContext(it->second));

for (clang::Decl *child : it->second->decls()) {
if (clang::UsingDirectiveDecl *ud =
Expand Down
12 changes: 4 additions & 8 deletions lldb/source/Symbol/CompilerDeclContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@ CompilerDeclContext::FindDeclByName(ConstString name,
if (IsValid())
return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name,
ignore_using_decls);
else
return std::vector<CompilerDecl>();
return std::vector<CompilerDecl>();
}

ConstString CompilerDeclContext::GetName() const {
if (IsValid())
return m_type_system->DeclContextGetName(m_opaque_decl_ctx);
else
return ConstString();
return ConstString();
}

ConstString CompilerDeclContext::GetScopeQualifiedName() const {
if (IsValid())
return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx);
else
return ConstString();
return ConstString();
}

bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr,
Expand All @@ -44,8 +41,7 @@ bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr,
return m_type_system->DeclContextIsClassMethod(
m_opaque_decl_ctx, language_ptr, is_instance_method_ptr,
language_object_name_ptr);
else
return false;
return false;
}

bool CompilerDeclContext::IsContainedInLookup(CompilerDeclContext other) const {
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/Shell/ScriptInterpreter/Lua/bindings.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# RUN: cat %s | %lldb --script-language lua 2>&1 | FileCheck %s
script
debugger = lldb.SBDebugger.Create()
print(string.format("debugger is valid: %s", debugger:IsValid()))
print("debugger is valid:", tostring(debugger:IsValid()))
# CHECK: debugger is valid: true
12 changes: 3 additions & 9 deletions lldb/unittests/Core/MangledTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
#include "TestingSupport/SubsystemRAII.h"
#include "TestingSupport/TestUtilities.h"

#include "lldb/Core/Mangled.h"
Expand Down Expand Up @@ -58,10 +59,8 @@ TEST(MangledTest, EmptyForInvalidName) {
}

TEST(MangledTest, NameIndexes_FindFunctionSymbols) {
FileSystem::Initialize();
HostInfo::Initialize();
ObjectFileELF::Initialize();
SymbolFileSymtab::Initialize();
SubsystemRAII<FileSystem, HostInfo, ObjectFileELF, SymbolFileSymtab>
subsystems;

auto ExpectedFile = TestFile::fromYaml(R"(
--- !ELF
Expand Down Expand Up @@ -251,9 +250,4 @@ TEST(MangledTest, NameIndexes_FindFunctionSymbols) {
EXPECT_EQ(0, Count("_Z12undemangableEvx42", eFunctionNameTypeMethod));
EXPECT_EQ(0, Count("undemangable", eFunctionNameTypeBase));
EXPECT_EQ(0, Count("undemangable", eFunctionNameTypeMethod));

SymbolFileSymtab::Terminate();
ObjectFileELF::Terminate();
HostInfo::Terminate();
FileSystem::Terminate();
}
7 changes: 2 additions & 5 deletions lldb/unittests/Editline/EditlineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <memory>
#include <thread>

#include "TestingSupport/SubsystemRAII.h"
#include "lldb/Host/Editline.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Pipe.h"
Expand Down Expand Up @@ -242,7 +243,7 @@ void EditlineAdapter::ConsumeAllOutput() {
}

class EditlineTestFixture : public ::testing::Test {
private:
SubsystemRAII<FileSystem> subsystems;
EditlineAdapter _el_adapter;
std::shared_ptr<std::thread> _sp_output_thread;

Expand All @@ -253,8 +254,6 @@ class EditlineTestFixture : public ::testing::Test {
}

void SetUp() override {
FileSystem::Initialize();

// Validate the editline adapter.
EXPECT_TRUE(_el_adapter.IsValid());
if (!_el_adapter.IsValid())
Expand All @@ -269,8 +268,6 @@ class EditlineTestFixture : public ::testing::Test {
_el_adapter.CloseInput();
if (_sp_output_thread)
_sp_output_thread->join();

FileSystem::Terminate();
}

EditlineAdapter &GetEditlineAdapter() { return _el_adapter; }
Expand Down
Loading

0 comments on commit f2ac07a

Please sign in to comment.