Skip to content

Commit

Permalink
Merged master:a9bb669e59f into amd-gfx:7404bcaed72
Browse files Browse the repository at this point in the history
Local branch amd-gfx 7404bca Merged master:a21940eac14 into amd-gfx:776f23f3a1f
Remote branch master a9bb669 [FileCollector] Ignore empty paths.
  • Loading branch information
Sw authored and Sw committed Nov 20, 2019
2 parents 7404bca + a9bb669 commit a3f66b0
Show file tree
Hide file tree
Showing 61 changed files with 1,222 additions and 708 deletions.
6 changes: 2 additions & 4 deletions clang-tools-extra/clangd/ExpectedTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ static const Type *toEquivClass(ASTContext &Ctx, QualType T) {
static llvm::Optional<QualType>
typeOfCompletion(const CodeCompletionResult &R) {
const NamedDecl *D = R.Declaration;
if (!D)
return llvm::None;
// Templates do not have a type on their own, look at the templated decl.
if (auto *Template = dyn_cast<TemplateDecl>(D))
if (auto *Template = dyn_cast_or_null<TemplateDecl>(D))
D = Template->getTemplatedDecl();
auto *VD = dyn_cast<ValueDecl>(D);
auto *VD = dyn_cast_or_null<ValueDecl>(D);
if (!VD)
return llvm::None; // We handle only variables and functions below.
auto T = VD->getType();
Expand Down
10 changes: 10 additions & 0 deletions clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,16 @@ TEST(CompletionTest, DefaultArgs) {
SnippetSuffix("(${1:int A})"))));
}

TEST(CompletionTest, NoCrashWithTemplateParamsAndPreferredTypes) {
auto Completions = completions(R"cpp(
template <template <class> class TT> int foo() {
int a = ^
}
)cpp")
.Completions;
EXPECT_THAT(Completions, Contains(Named("TT")));
}

SignatureHelp signatures(llvm::StringRef Text, Position Point,
std::vector<Symbol> IndexSymbols = {}) {
std::unique_ptr<SymbolIndex> Index;
Expand Down
246 changes: 124 additions & 122 deletions lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,178 +938,180 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
}
}

void ClangExpressionDeclMap::FindExternalVisibleDecls(
NameSearchContext &context, lldb::ModuleSP module_sp,
CompilerDeclContext &namespace_decl, unsigned int current_id) {
assert(m_ast_context);

void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
unsigned int current_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));

SymbolContextList sc_list;
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();

const ConstString name(context.m_decl_name.getAsString().c_str());
if (IgnoreName(name, false))
return;
if (m_ctx_obj) {
Status status;
lldb::ValueObjectSP ctx_obj_ptr = m_ctx_obj->AddressOf(status);
if (!ctx_obj_ptr || status.Fail())
return;

// Only look for functions by name out in our symbols if the function doesn't
// start with our phony prefix of '$'
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
SymbolContext sym_ctx;
if (frame != nullptr)
sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
lldb::eSymbolContextBlock);
AddOneType(context, TypeFromUser(m_ctx_obj->GetCompilerType()), current_id);

// Try the persistent decls, which take precedence over all else.
if (!namespace_decl)
SearchPersistenDecls(context, name, current_id);
m_struct_vars->m_object_pointer_type =
TypeFromUser(ctx_obj_ptr->GetCompilerType());

if (name.GetCString()[0] == '$' && !namespace_decl) {
static ConstString g_lldb_class_name("$__lldb_class");
return;
}

if (name == g_lldb_class_name) {
LookUpLldbClass(context, current_id);
return;
}
// Clang is looking for the type of "*self"

static ConstString g_lldb_objc_class_name("$__lldb_objc_class");
if (name == g_lldb_objc_class_name) {
if (m_ctx_obj) {
Status status;
lldb::ValueObjectSP ctx_obj_ptr = m_ctx_obj->AddressOf(status);
if (!ctx_obj_ptr || status.Fail())
return;
if (!frame)
return;

SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
lldb::eSymbolContextBlock);

AddOneType(context, TypeFromUser(m_ctx_obj->GetCompilerType()),
current_id);
// Find the block that defines the function represented by "sym_ctx"
Block *function_block = sym_ctx.GetFunctionBlock();

m_struct_vars->m_object_pointer_type =
TypeFromUser(ctx_obj_ptr->GetCompilerType());
if (!function_block)
return;

return;
}
CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();

// Clang is looking for the type of "*self"
if (!function_decl_ctx)
return;

if (!frame)
return;
clang::ObjCMethodDecl *method_decl =
ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx);

SymbolContext sym_ctx = frame->GetSymbolContext(
lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
if (method_decl) {
ObjCInterfaceDecl *self_interface = method_decl->getClassInterface();

// Find the block that defines the function represented by "sym_ctx"
Block *function_block = sym_ctx.GetFunctionBlock();
if (!self_interface)
return;

if (!function_block)
return;
const clang::Type *interface_type = self_interface->getTypeForDecl();

CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
if (!interface_type)
return; // This is unlikely, but we have seen crashes where this
// occurred

if (!function_decl_ctx)
return;
TypeFromUser class_user_type(
QualType(interface_type, 0).getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));

if (log) {
ASTDumper ast_dumper(interface_type);
LLDB_LOGF(log, " FEVD[%u] Adding type for $__lldb_objc_class: %s",
current_id, ast_dumper.GetCString());
}

clang::ObjCMethodDecl *method_decl =
ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
AddOneType(context, class_user_type, current_id);

if (method_decl) {
ObjCInterfaceDecl *self_interface = method_decl->getClassInterface();
if (method_decl->isInstanceMethod()) {
// self is a pointer to the object

if (!self_interface)
return;
QualType class_pointer_type =
method_decl->getASTContext().getObjCObjectPointerType(
QualType(interface_type, 0));

const clang::Type *interface_type = self_interface->getTypeForDecl();
TypeFromUser self_user_type(
class_pointer_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));

if (!interface_type)
return; // This is unlikely, but we have seen crashes where this
// occurred
m_struct_vars->m_object_pointer_type = self_user_type;
} else {
// self is a Class pointer
QualType class_type = method_decl->getASTContext().getObjCClassType();

TypeFromUser class_user_type(
QualType(interface_type, 0).getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
TypeFromUser self_user_type(
class_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));

if (log) {
ASTDumper ast_dumper(interface_type);
LLDB_LOGF(log, " FEVD[%u] Adding type for $__lldb_objc_class: %s",
current_id, ast_dumper.GetCString());
}
m_struct_vars->m_object_pointer_type = self_user_type;
}

AddOneType(context, class_user_type, current_id);
return;
}
// This branch will get hit if we are executing code in the context of
// a function that claims to have an object pointer (through
// DW_AT_object_pointer?) but is not formally a method of the class.
// In that case, just look up the "self" variable in the current scope
// and use its type.

if (method_decl->isInstanceMethod()) {
// self is a pointer to the object
VariableList *vars = frame->GetVariableList(false);

QualType class_pointer_type =
method_decl->getASTContext().getObjCObjectPointerType(
QualType(interface_type, 0));
lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));

TypeFromUser self_user_type(
class_pointer_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
if (self_var && self_var->IsInScope(frame) &&
self_var->LocationIsValidForFrame(frame)) {
Type *self_type = self_var->GetType();

m_struct_vars->m_object_pointer_type = self_user_type;
} else {
// self is a Class pointer
QualType class_type = method_decl->getASTContext().getObjCClassType();
if (!self_type)
return;

TypeFromUser self_user_type(
class_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
CompilerType self_clang_type = self_type->GetFullCompilerType();

m_struct_vars->m_object_pointer_type = self_user_type;
}
if (ClangASTContext::IsObjCClassType(self_clang_type)) {
return;
} else if (ClangASTContext::IsObjCObjectPointerType(self_clang_type)) {
self_clang_type = self_clang_type.GetPointeeType();

if (!self_clang_type)
return;
} else {
// This branch will get hit if we are executing code in the context of
// a function that claims to have an object pointer (through
// DW_AT_object_pointer?) but is not formally a method of the class.
// In that case, just look up the "self" variable in the current scope
// and use its type.

VariableList *vars = frame->GetVariableList(false);
if (log) {
ASTDumper ast_dumper(self_type->GetFullCompilerType());
LLDB_LOGF(log, " FEVD[%u] Adding type for $__lldb_objc_class: %s",
current_id, ast_dumper.GetCString());
}

lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
TypeFromUser class_user_type(self_clang_type);

if (self_var && self_var->IsInScope(frame) &&
self_var->LocationIsValidForFrame(frame)) {
Type *self_type = self_var->GetType();
AddOneType(context, class_user_type, current_id);

if (!self_type)
return;
TypeFromUser self_user_type(self_type->GetFullCompilerType());

CompilerType self_clang_type = self_type->GetFullCompilerType();
m_struct_vars->m_object_pointer_type = self_user_type;
}
}
}

if (ClangASTContext::IsObjCClassType(self_clang_type)) {
return;
} else if (ClangASTContext::IsObjCObjectPointerType(
self_clang_type)) {
self_clang_type = self_clang_type.GetPointeeType();
void ClangExpressionDeclMap::FindExternalVisibleDecls(
NameSearchContext &context, lldb::ModuleSP module_sp,
CompilerDeclContext &namespace_decl, unsigned int current_id) {
assert(m_ast_context);

if (!self_clang_type)
return;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));

if (log) {
ASTDumper ast_dumper(self_type->GetFullCompilerType());
LLDB_LOGF(log,
" FEVD[%u] Adding type for $__lldb_objc_class: %s",
current_id, ast_dumper.GetCString());
}
SymbolContextList sc_list;

TypeFromUser class_user_type(self_clang_type);
const ConstString name(context.m_decl_name.getAsString().c_str());
if (IgnoreName(name, false))
return;

AddOneType(context, class_user_type, current_id);
// Only look for functions by name out in our symbols if the function doesn't
// start with our phony prefix of '$'
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
SymbolContext sym_ctx;
if (frame != nullptr)
sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
lldb::eSymbolContextBlock);

TypeFromUser self_user_type(self_type->GetFullCompilerType());
// Try the persistent decls, which take precedence over all else.
if (!namespace_decl)
SearchPersistenDecls(context, name, current_id);

m_struct_vars->m_object_pointer_type = self_user_type;
return;
}
}
}
if (name.GetCString()[0] == '$' && !namespace_decl) {
static ConstString g_lldb_class_name("$__lldb_class");

if (name == g_lldb_class_name) {
LookUpLldbClass(context, current_id);
return;
}

static ConstString g_lldb_objc_class_name("$__lldb_objc_class");
if (name == g_lldb_objc_class_name) {
LookUpLldbObjCClass(context, current_id);
return;
}
if (name == ConstString(g_lldb_local_vars_namespace_cstr)) {
CompilerDeclContext frame_decl_context =
sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,16 @@ class ClangExpressionDeclMap : public ClangASTSource {
/// for logging purposes.
void LookUpLldbClass(NameSearchContext &context, unsigned int current_id);

/// Handles looking up $__lldb_objc_class which requires special treatment.
///
/// \param[in] context
/// The NameSearchContext that can construct Decls for this name.
///
/// \param[in] current_id
/// The ID for the current FindExternalVisibleDecls invocation,
/// for logging purposes.
void LookUpLldbObjCClass(NameSearchContext &context, unsigned int current_id);

/// Given a target, find a variable that matches the given name and type.
///
/// \param[in] target
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/CodeGen/CommandFlags.inc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static cl::opt<bool>
"attribute not to use exceptions"),
cl::init(false));

static cl::opt<llvm::FPDenormal::DenormalMode> DenormalMode(
static cl::opt<llvm::FPDenormal::DenormalMode> DenormalFPMath(
"denormal-fp-math",
cl::desc("Select which denormal numbers the code is permitted to require"),
cl::init(FPDenormal::IEEE),
Expand Down Expand Up @@ -291,7 +291,7 @@ static TargetOptions InitTargetOptionsFromCodeGenFlags() {
Options.NoNaNsFPMath = EnableNoNaNsFPMath;
Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
Options.NoTrappingFPMath = EnableNoTrappingFPMath;
Options.FPDenormalMode = DenormalMode;
Options.FPDenormalMode = DenormalFPMath;
Options.HonorSignDependentRoundingFPMathOption =
EnableHonorSignDependentRoundingFPMath;
if (FloatABIForCalls != FloatABI::Default)
Expand Down
9 changes: 9 additions & 0 deletions llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ class TargetLoweringObjectFileXCOFF : public TargetLoweringObjectFile {
MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
const TargetMachine &TM) const override;

MCSection *getSectionForJumpTable(const Function &F,
const TargetMachine &TM) const override;

/// Given a constant with the SectionKind, return a section that it should be
/// placed in.
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
const Constant *C,
unsigned &Align) const override;

static XCOFF::StorageClass getStorageClassForGlobal(const GlobalObject *GO);
};

Expand Down
5 changes: 5 additions & 0 deletions llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class DWARFLocationTable {
const MCRegisterInfo *MRI, DWARFUnit *U,
DIDumpOptions DumpOpts, unsigned Indent) const;

Error visitAbsoluteLocationList(
uint64_t Offset, Optional<object::SectionedAddress> BaseAddr,
std::function<Optional<object::SectionedAddress>(uint32_t)> LookupAddr,
function_ref<bool(Expected<DWARFLocationExpression>)> Callback) const;

protected:
DWARFDataExtractor Data;

Expand Down
Loading

0 comments on commit a3f66b0

Please sign in to comment.