Skip to content

Cherry-pick bugfixes for rdar://52134074+55025799 #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
51a300c
Performance: Add a set of visited SymbolFiles to the other FindFiles …
adrian-prantl Nov 12, 2019
ac0183c
[lldb] Fix evaluation of nested classes with parent from other CU
Teemperor Oct 2, 2019
db1c9f4
[DWARFASTParserClang] Factor out structure-like type parsing, NFC
vedantk Oct 7, 2019
4babafb
Rename ParseTypeFromDWO to ParseTypeFromClangModule (NFC)
adrian-prantl Nov 13, 2019
b9ea84f
Rename clang-module-related *DWO* functions to *ClangModule* (NFC)
adrian-prantl Nov 13, 2019
e7e2afc
Use cheaper, equivalent predicate. (NFC)
adrian-prantl Nov 13, 2019
d0acede
Remove redundant check. (NFC)
adrian-prantl Nov 13, 2019
e095666
[lldb][NFC] Make include directories in Clang expression parser a std…
Teemperor Sep 11, 2019
e06630a
[lldb] Print better diagnostics for user expressions and modules
Teemperor Sep 18, 2019
62487b8
[lldb][NFC] Sort files in unittests/Expression/CMakeLists.txt
Teemperor Sep 11, 2019
472d716
[lldb] Decouple importing the std C++ module from the way the program…
Teemperor Sep 24, 2019
0bbf139
[lldb] Provide a getter for m_materializer_up in LLVMUserExpression i…
Teemperor Nov 4, 2019
8242661
[lldb][NFC] Move LLVM RTTI implementation from enum to static ID vari…
Teemperor Nov 12, 2019
524c571
[lldb] Add log output for the support files we pass to the CppModuleC…
Teemperor Oct 10, 2019
1f70495
Use ForEachExternalModule in ParseTypeFromClangModule (NFC)
adrian-prantl Nov 14, 2019
c8ac360
Rename DWO -> Clang module to avoid confusion. (NFC)
adrian-prantl Nov 14, 2019
b6ff242
Convert UpdateExternalModuleListIfNeeded to use early exits.
adrian-prantl Nov 14, 2019
25ba63a
Convert condition to early exit (NFC)
adrian-prantl Nov 14, 2019
e6114df
Fix incorrect comment.
adrian-prantl Nov 14, 2019
4193fb6
Comment the fact that DWARFDebugInfoEntry isn't copyable.
adrian-prantl Nov 15, 2019
9d0801e
Rename posix/FileSystem.cpp to FileSystemPosix.cpp
adrian-prantl Nov 15, 2019
e3aca47
Add RTTI support to the SymbolFile class hierarchy
adrian-prantl Nov 15, 2019
98f73c6
[-gmodules] Let LLDB log a warning if the Clang module hash mismatches.
adrian-prantl Nov 14, 2019
c149d67
Add a testcase for Clang modules being updated within one LLDB session.
adrian-prantl Nov 16, 2019
cc94b18
Replace bitfield in lldb::Type with byte-sized members. (NFC)
adrian-prantl Nov 18, 2019
8b13e72
Early-exitify ClangASTContext::AddObjCClassProperty() (NFC)
adrian-prantl Nov 21, 2019
f9bbb79
[lldb-test] Modify lldb-test to print out ASTs from symbol file
shafik Oct 11, 2019
fc57501
Add support for DW_AT_export_symbols for anonymous structs
shafik Oct 28, 2019
c212a53
[LLDB] Fix for windows bots broken by unsupported tests
shafik Oct 29, 2019
68bb94e
Register Objective-C property accessors with their property decls.
adrian-prantl Nov 22, 2019
ffd1c4a
Complete complete types early when importing types from Clang module …
adrian-prantl Nov 22, 2019
b0db0ed
Reformat code for readability.
adrian-prantl Nov 22, 2019
71c0c1b
Fix compiler error after cherry-picking.
adrian-prantl Nov 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/include/clang/Basic/DiagnosticOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ DIAGOPT(Pedantic, 1, 0) /// -pedantic
DIAGOPT(PedanticErrors, 1, 0) /// -pedantic-errors
DIAGOPT(ShowColumn, 1, 1) /// Show column number on diagnostics.
DIAGOPT(ShowLocation, 1, 1) /// Show source location information.
DIAGOPT(ShowLevel, 1, 1) /// Show diagnostic level.
DIAGOPT(AbsolutePath, 1, 0) /// Use absolute paths.
DIAGOPT(ShowCarets, 1, 1) /// Show carets in diagnostics.
DIAGOPT(ShowFixits, 1, 1) /// Show fixit information.
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Frontend/TextDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,9 @@ void TextDiagnostic::emitDiagnosticMessage(
if (DiagOpts->ShowColors)
OS.resetColor();

printDiagnosticLevel(OS, Level, DiagOpts->ShowColors,
DiagOpts->CLFallbackMode);
if (DiagOpts->ShowLevel)
printDiagnosticLevel(OS, Level, DiagOpts->ShowColors,
DiagOpts->CLFallbackMode);
printDiagnosticMessage(OS,
/*IsSupplemental*/ Level == DiagnosticsEngine::Note,
Message, OS.tell() - StartOfLocationInfo,
Expand Down
4 changes: 4 additions & 0 deletions lldb/include/lldb/Core/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,11 @@ class Module : public std::enable_shared_from_this<Module>,
/// This behaves like the other FindTypes method but allows to
/// specify a DeclContext and a language for the type being searched
/// for.
///
/// \param searched_symbol_files
/// Prevents one file from being visited multiple times.
void FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);

lldb::TypeSP FindFirstType(const SymbolContext &sc,
Expand Down
28 changes: 9 additions & 19 deletions lldb/include/lldb/Expression/Expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,11 @@ class RecordingMemoryManager;
/// LLVM IR from the expression.
class Expression {
public:
/// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
enum ExpressionKind {
eKindFunctionCaller,
eKindClangFunctionCaller,
eKindUserExpression,
eKindLLVMUserExpression,
eKindClangUserExpression,
eKindUtilityFunction,
eKindClangUtilityFunction,
};

enum ResultType { eResultTypeAny, eResultTypeId };

Expression(Target &target, ExpressionKind kind);
Expression(Target &target);

Expression(ExecutionContextScope &exe_scope, ExpressionKind kind);
Expression(ExecutionContextScope &exe_scope);

/// Destructor
virtual ~Expression() {}
Expand All @@ -64,6 +53,10 @@ class Expression {
/// default, return eLanguageTypeUnknown.
virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }

/// Return the Materializer that the parser should use when registering
/// external values.
virtual Materializer *GetMaterializer() { return nullptr; }

/// Return the desired result type of the function, or eResultTypeAny if
/// indifferent.
virtual ResultType DesiredResultType() { return eResultTypeAny; }
Expand All @@ -90,12 +83,9 @@ class Expression {

virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }

/// LLVM-style RTTI support.
ExpressionKind getKind() const { return m_kind; }

private:
/// LLVM-style RTTI support.
const ExpressionKind m_kind;
// LLVM RTTI support
virtual bool isA(const void *ClassID) const = 0;

protected:
lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but
Expand Down
11 changes: 6 additions & 5 deletions lldb/include/lldb/Expression/FunctionCaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ namespace lldb_private {
/// Any of the methods that take arg_addr_ptr can be passed nullptr, and the
/// argument space will be managed for you.
class FunctionCaller : public Expression {
// LLVM RTTI support
static char ID;

public:
/// LLVM-style RTTI support.
static bool classof(const Expression *E) {
return E->getKind() == eKindFunctionCaller;
}

bool isA(const void *ClassID) const override { return ClassID == &ID; }
static bool classof(const Expression *obj) { return obj->isA(&ID); }

/// Constructor
///
/// \param[in] exe_scope
Expand Down
14 changes: 9 additions & 5 deletions lldb/include/lldb/Expression/LLVMUserExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ namespace lldb_private {
/// implementations of LLVMUserExpression - which will be vended through the
/// appropriate TypeSystem.
class LLVMUserExpression : public UserExpression {
// LLVM RTTI support
static char ID;

public:
/// LLVM-style RTTI support.
static bool classof(const Expression *E) {
return E->getKind() == eKindLLVMUserExpression;
bool isA(const void *ClassID) const override {
return ClassID == &ID || UserExpression::isA(ClassID);
}
static bool classof(const Expression *obj) { return obj->isA(&ID); }

// The IRPasses struct is filled in by a runtime after an expression is
// compiled and can be used to to run fixups/analysis passes as required.
Expand All @@ -51,8 +54,7 @@ class LLVMUserExpression : public UserExpression {
LLVMUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options,
ExpressionKind kind);
const EvaluateExpressionOptions &options);
~LLVMUserExpression() override;

bool FinalizeJITExecution(
Expand All @@ -63,6 +65,8 @@ class LLVMUserExpression : public UserExpression {

bool CanInterpret() override { return m_can_interpret; }

Materializer *GetMaterializer() override { return m_materializer_up.get(); }

/// Return the string that the parser should parse. Must be a full
/// translation unit.
const char *Text() override { return m_transformed_text.c_str(); }
Expand Down
14 changes: 7 additions & 7 deletions lldb/include/lldb/Expression/UserExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ namespace lldb_private {
/// implementations of UserExpression - which will be vended through the
/// appropriate TypeSystem.
class UserExpression : public Expression {
/// LLVM RTTI support.
static char ID;

public:
/// LLVM-style RTTI support.
static bool classof(const Expression *E) {
return E->getKind() == eKindUserExpression;
}

bool isA(const void *ClassID) const override { return ClassID == &ID; }
static bool classof(const Expression *obj) { return obj->isA(&ID); }

enum { kDefaultTimeout = 500000u };

/// Constructor
Expand All @@ -61,8 +62,7 @@ class UserExpression : public Expression {
UserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options,
ExpressionKind kind);
const EvaluateExpressionOptions &options);

/// Destructor
~UserExpression() override;
Expand Down
13 changes: 7 additions & 6 deletions lldb/include/lldb/Expression/UtilityFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ namespace lldb_private {
/// self-contained function meant to be used from other code. Utility
/// functions can perform error-checking for ClangUserExpressions,
class UtilityFunction : public Expression {
// LLVM RTTI support
static char ID;

public:
/// LLVM-style RTTI support.
static bool classof(const Expression *E) {
return E->getKind() == eKindUtilityFunction;
}

bool isA(const void *ClassID) const override { return ClassID == &ID; }
static bool classof(const Expression *obj) { return obj->isA(&ID); }

/// Constructor
///
/// \param[in] text
Expand All @@ -42,7 +43,7 @@ class UtilityFunction : public Expression {
/// \param[in] name
/// The name of the function, as used in the text.
UtilityFunction(ExecutionContextScope &exe_scope, const char *text,
const char *name, ExpressionKind kind);
const char *name);

~UtilityFunction() override;

Expand Down
11 changes: 10 additions & 1 deletion lldb/include/lldb/Symbol/ClangASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ class ClangASTContext : public TypeSystem {
CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
lldb::AccessType access_type, const char *name,
int kind, lldb::LanguageType language,
ClangASTMetadata *metadata = nullptr);
ClangASTMetadata *metadata = nullptr,
bool exports_symbols = false);

class TemplateParameterInfos {
public:
Expand Down Expand Up @@ -893,6 +894,14 @@ class ClangASTContext : public TypeSystem {

void Dump(Stream &s);

/// Dump clang AST types from the symbol file.
///
/// \param[in] s
/// A stream to send the dumped AST node(s) to
/// \param[in] symbol_name
/// The name of the symbol to dump, if it is empty dump all the symbols
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name);

void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
Stream *s, lldb::Format format, const DataExtractor &data,
lldb::offset_t data_offset, size_t data_byte_size,
Expand Down
20 changes: 20 additions & 0 deletions lldb/include/lldb/Symbol/CompileUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "lldb/lldb-enumerations.h"

#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"

namespace lldb_private {
/// \class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h"
Expand Down Expand Up @@ -237,6 +238,25 @@ class CompileUnit : public std::enable_shared_from_this<CompileUnit>,

DebugMacros *GetDebugMacros();

/// Apply a lambda to each external lldb::Module referenced by this
/// compilation unit. Recursively also descends into the referenced external
/// modules of any encountered compilation unit.
///
/// \param visited_symbol_files
/// A set of SymbolFiles that were already visited to avoid
/// visiting one file more than once.
///
/// \param[in] lambda
/// The lambda that should be applied to every function. The lambda can
/// return true if the iteration should be aborted earlier.
///
/// \return
/// If the lambda early-exited, this function returns true to
/// propagate the early exit.
virtual bool ForEachExternalModule(
llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
llvm::function_ref<bool(Module &)> lambda);

/// Get the compile unit's support file list.
///
/// The support file list is used by the line table, and any objects that
Expand Down
49 changes: 46 additions & 3 deletions lldb/include/lldb/Symbol/SymbolFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@
namespace lldb_private {

class SymbolFile : public PluginInterface {
/// LLVM RTTI support.
static char ID;

public:
/// LLVM RTTI support.
/// \{
virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
/// \}

// Symbol file ability bits.
//
// Each symbol file can claim to support one or more symbol file abilities.
Expand Down Expand Up @@ -122,6 +131,35 @@ class SymbolFile : public PluginInterface {
virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0;
virtual bool ParseLineTable(CompileUnit &comp_unit) = 0;
virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0;

/// Apply a lambda to each external lldb::Module referenced by this
/// \p comp_unit. Recursively also descends into the referenced external
/// modules of any encountered compilation unit.
///
/// \param comp_unit
/// When this SymbolFile consists of multiple auxilliary
/// SymbolFiles, for example, a Darwin debug map that references
/// multiple .o files, comp_unit helps choose the auxilliary
/// file. In most other cases comp_unit's symbol file is
/// identiacal with *this.
///
/// \param[in] lambda
/// The lambda that should be applied to every function. The lambda can
/// return true if the iteration should be aborted earlier.
///
/// \param visited_symbol_files
/// A set of SymbolFiles that were already visited to avoid
/// visiting one file more than once.
///
/// \return
/// If the lambda early-exited, this function returns true to
/// propagate the early exit.
virtual bool ForEachExternalModule(
lldb_private::CompileUnit &comp_unit,
llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
llvm::function_ref<bool(Module &)> lambda) {
return false;
}
virtual bool ParseSupportFiles(CompileUnit &comp_unit,
FileSpecList &support_files) = 0;
virtual size_t ParseTypes(CompileUnit &comp_unit) = 0;
Expand Down Expand Up @@ -192,9 +230,14 @@ class SymbolFile : public PluginInterface {
TypeMap &types);

/// Find types specified by a CompilerContextPattern.
/// \param languages Only return results in these languages.
virtual void FindTypes(llvm::ArrayRef<CompilerContext> pattern,
LanguageSet languages, TypeMap &types);
/// \param languages
/// Only return results in these languages.
/// \param searched_symbol_files
/// Prevents one file from being visited multiple times.
virtual void
FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);

virtual void
GetMangledNamesForFunction(const std::string &scope_qualified_name,
Expand Down
38 changes: 12 additions & 26 deletions lldb/include/lldb/Symbol/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,12 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {
eEncodingIsSyntheticUID
};

// We must force the underlying type of the enum to be unsigned here. Not
// all compilers behave the same with regards to the default underlying type
// of an enum, but because this enum is used in an enum bitfield and integer
// comparisons are done with the value we need to guarantee that it's always
// unsigned so that, for example, eResolveStateFull doesn't compare less than
// eResolveStateUnresolved when used in a 2-bit bitfield.
typedef enum ResolveStateTag : unsigned {
eResolveStateUnresolved = 0,
eResolveStateForward = 1,
eResolveStateLayout = 2,
eResolveStateFull = 3
} ResolveState;
enum class ResolveState : unsigned char {
Unresolved = 0,
Forward = 1,
Layout = 2,
Full = 3
};

Type(lldb::user_id_t uid, SymbolFile *symbol_file, ConstString name,
llvm::Optional<uint64_t> byte_size, SymbolContextScope *context,
Expand Down Expand Up @@ -200,34 +194,26 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {

uint32_t GetEncodingMask();

bool IsCompleteObjCClass() { return m_flags.is_complete_objc_class; }
bool IsCompleteObjCClass() { return m_is_complete_objc_class; }

void SetIsCompleteObjCClass(bool is_complete_objc_class) {
m_flags.is_complete_objc_class = is_complete_objc_class;
m_is_complete_objc_class = is_complete_objc_class;
}

protected:
ConstString m_name;
SymbolFile *m_symbol_file;
SymbolContextScope
*m_context; // The symbol context in which this type is defined
/// The symbol context in which this type is defined.
SymbolContextScope *m_context;
Type *m_encoding_type;
lldb::user_id_t m_encoding_uid;
EncodingDataType m_encoding_uid_type;
uint64_t m_byte_size : 63;
uint64_t m_byte_size_has_value : 1;
Declaration m_decl;
CompilerType m_compiler_type;

struct Flags {
#ifdef __GNUC__
// using unsigned type here to work around a very noisy gcc warning
unsigned compiler_type_resolve_state : 2;
#else
ResolveState compiler_type_resolve_state : 2;
#endif
bool is_complete_objc_class : 1;
} m_flags;
ResolveState m_compiler_type_resolve_state;
bool m_is_complete_objc_class;

Type *GetEncodingType();

Expand Down
Loading