Skip to content

Commit 2683ed9

Browse files
Merge pull request #384 from adrian-prantl/52134074+55025799
Cherry-pick bugfixes for rdar://52134074+55025799
2 parents fee9a82 + 71c0c1b commit 2683ed9

File tree

147 files changed

+2621
-1272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+2621
-1272
lines changed

clang/include/clang/Basic/DiagnosticOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ DIAGOPT(Pedantic, 1, 0) /// -pedantic
4949
DIAGOPT(PedanticErrors, 1, 0) /// -pedantic-errors
5050
DIAGOPT(ShowColumn, 1, 1) /// Show column number on diagnostics.
5151
DIAGOPT(ShowLocation, 1, 1) /// Show source location information.
52+
DIAGOPT(ShowLevel, 1, 1) /// Show diagnostic level.
5253
DIAGOPT(AbsolutePath, 1, 0) /// Use absolute paths.
5354
DIAGOPT(ShowCarets, 1, 1) /// Show carets in diagnostics.
5455
DIAGOPT(ShowFixits, 1, 1) /// Show fixit information.

clang/lib/Frontend/TextDiagnostic.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,9 @@ void TextDiagnostic::emitDiagnosticMessage(
683683
if (DiagOpts->ShowColors)
684684
OS.resetColor();
685685

686-
printDiagnosticLevel(OS, Level, DiagOpts->ShowColors,
687-
DiagOpts->CLFallbackMode);
686+
if (DiagOpts->ShowLevel)
687+
printDiagnosticLevel(OS, Level, DiagOpts->ShowColors,
688+
DiagOpts->CLFallbackMode);
688689
printDiagnosticMessage(OS,
689690
/*IsSupplemental*/ Level == DiagnosticsEngine::Note,
690691
Message, OS.tell() - StartOfLocationInfo,

lldb/include/lldb/Core/Module.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,11 @@ class Module : public std::enable_shared_from_this<Module>,
457457
/// This behaves like the other FindTypes method but allows to
458458
/// specify a DeclContext and a language for the type being searched
459459
/// for.
460+
///
461+
/// \param searched_symbol_files
462+
/// Prevents one file from being visited multiple times.
460463
void FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
464+
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
461465
TypeMap &types);
462466

463467
lldb::TypeSP FindFirstType(const SymbolContext &sc,

lldb/include/lldb/Expression/Expression.h

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,11 @@ class RecordingMemoryManager;
3232
/// LLVM IR from the expression.
3333
class Expression {
3434
public:
35-
/// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
36-
enum ExpressionKind {
37-
eKindFunctionCaller,
38-
eKindClangFunctionCaller,
39-
eKindUserExpression,
40-
eKindLLVMUserExpression,
41-
eKindClangUserExpression,
42-
eKindUtilityFunction,
43-
eKindClangUtilityFunction,
44-
};
45-
4635
enum ResultType { eResultTypeAny, eResultTypeId };
4736

48-
Expression(Target &target, ExpressionKind kind);
37+
Expression(Target &target);
4938

50-
Expression(ExecutionContextScope &exe_scope, ExpressionKind kind);
39+
Expression(ExecutionContextScope &exe_scope);
5140

5241
/// Destructor
5342
virtual ~Expression() {}
@@ -64,6 +53,10 @@ class Expression {
6453
/// default, return eLanguageTypeUnknown.
6554
virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
6655

56+
/// Return the Materializer that the parser should use when registering
57+
/// external values.
58+
virtual Materializer *GetMaterializer() { return nullptr; }
59+
6760
/// Return the desired result type of the function, or eResultTypeAny if
6861
/// indifferent.
6962
virtual ResultType DesiredResultType() { return eResultTypeAny; }
@@ -90,12 +83,9 @@ class Expression {
9083

9184
virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }
9285

93-
/// LLVM-style RTTI support.
94-
ExpressionKind getKind() const { return m_kind; }
95-
96-
private:
97-
/// LLVM-style RTTI support.
98-
const ExpressionKind m_kind;
86+
// LLVM RTTI support
87+
virtual bool isA(const void *ClassID) const = 0;
88+
9989
protected:
10090
lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
10191
lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but

lldb/include/lldb/Expression/FunctionCaller.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ namespace lldb_private {
5454
/// Any of the methods that take arg_addr_ptr can be passed nullptr, and the
5555
/// argument space will be managed for you.
5656
class FunctionCaller : public Expression {
57+
// LLVM RTTI support
58+
static char ID;
59+
5760
public:
58-
/// LLVM-style RTTI support.
59-
static bool classof(const Expression *E) {
60-
return E->getKind() == eKindFunctionCaller;
61-
}
62-
61+
bool isA(const void *ClassID) const override { return ClassID == &ID; }
62+
static bool classof(const Expression *obj) { return obj->isA(&ID); }
63+
6364
/// Constructor
6465
///
6566
/// \param[in] exe_scope

lldb/include/lldb/Expression/LLVMUserExpression.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ namespace lldb_private {
3030
/// implementations of LLVMUserExpression - which will be vended through the
3131
/// appropriate TypeSystem.
3232
class LLVMUserExpression : public UserExpression {
33+
// LLVM RTTI support
34+
static char ID;
35+
3336
public:
34-
/// LLVM-style RTTI support.
35-
static bool classof(const Expression *E) {
36-
return E->getKind() == eKindLLVMUserExpression;
37+
bool isA(const void *ClassID) const override {
38+
return ClassID == &ID || UserExpression::isA(ClassID);
3739
}
40+
static bool classof(const Expression *obj) { return obj->isA(&ID); }
3841

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

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

6466
bool CanInterpret() override { return m_can_interpret; }
6567

68+
Materializer *GetMaterializer() override { return m_materializer_up.get(); }
69+
6670
/// Return the string that the parser should parse. Must be a full
6771
/// translation unit.
6872
const char *Text() override { return m_transformed_text.c_str(); }

lldb/include/lldb/Expression/UserExpression.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ namespace lldb_private {
3333
/// implementations of UserExpression - which will be vended through the
3434
/// appropriate TypeSystem.
3535
class UserExpression : public Expression {
36+
/// LLVM RTTI support.
37+
static char ID;
38+
3639
public:
37-
/// LLVM-style RTTI support.
38-
static bool classof(const Expression *E) {
39-
return E->getKind() == eKindUserExpression;
40-
}
41-
40+
bool isA(const void *ClassID) const override { return ClassID == &ID; }
41+
static bool classof(const Expression *obj) { return obj->isA(&ID); }
42+
4243
enum { kDefaultTimeout = 500000u };
4344

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

6767
/// Destructor
6868
~UserExpression() override;

lldb/include/lldb/Expression/UtilityFunction.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ namespace lldb_private {
2828
/// self-contained function meant to be used from other code. Utility
2929
/// functions can perform error-checking for ClangUserExpressions,
3030
class UtilityFunction : public Expression {
31+
// LLVM RTTI support
32+
static char ID;
33+
3134
public:
32-
/// LLVM-style RTTI support.
33-
static bool classof(const Expression *E) {
34-
return E->getKind() == eKindUtilityFunction;
35-
}
36-
35+
bool isA(const void *ClassID) const override { return ClassID == &ID; }
36+
static bool classof(const Expression *obj) { return obj->isA(&ID); }
37+
3738
/// Constructor
3839
///
3940
/// \param[in] text
@@ -42,7 +43,7 @@ class UtilityFunction : public Expression {
4243
/// \param[in] name
4344
/// The name of the function, as used in the text.
4445
UtilityFunction(ExecutionContextScope &exe_scope, const char *text,
45-
const char *name, ExpressionKind kind);
46+
const char *name);
4647

4748
~UtilityFunction() override;
4849

lldb/include/lldb/Symbol/ClangASTContext.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ class ClangASTContext : public TypeSystem {
266266
CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
267267
lldb::AccessType access_type, const char *name,
268268
int kind, lldb::LanguageType language,
269-
ClangASTMetadata *metadata = nullptr);
269+
ClangASTMetadata *metadata = nullptr,
270+
bool exports_symbols = false);
270271

271272
class TemplateParameterInfos {
272273
public:
@@ -893,6 +894,14 @@ class ClangASTContext : public TypeSystem {
893894

894895
void Dump(Stream &s);
895896

897+
/// Dump clang AST types from the symbol file.
898+
///
899+
/// \param[in] s
900+
/// A stream to send the dumped AST node(s) to
901+
/// \param[in] symbol_name
902+
/// The name of the symbol to dump, if it is empty dump all the symbols
903+
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name);
904+
896905
void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
897906
Stream *s, lldb::Format format, const DataExtractor &data,
898907
lldb::offset_t data_offset, size_t data_byte_size,

lldb/include/lldb/Symbol/CompileUnit.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "lldb/lldb-enumerations.h"
2020

2121
#include "llvm/ADT/DenseMap.h"
22+
#include "llvm/ADT/DenseSet.h"
2223

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

238239
DebugMacros *GetDebugMacros();
239240

241+
/// Apply a lambda to each external lldb::Module referenced by this
242+
/// compilation unit. Recursively also descends into the referenced external
243+
/// modules of any encountered compilation unit.
244+
///
245+
/// \param visited_symbol_files
246+
/// A set of SymbolFiles that were already visited to avoid
247+
/// visiting one file more than once.
248+
///
249+
/// \param[in] lambda
250+
/// The lambda that should be applied to every function. The lambda can
251+
/// return true if the iteration should be aborted earlier.
252+
///
253+
/// \return
254+
/// If the lambda early-exited, this function returns true to
255+
/// propagate the early exit.
256+
virtual bool ForEachExternalModule(
257+
llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
258+
llvm::function_ref<bool(Module &)> lambda);
259+
240260
/// Get the compile unit's support file list.
241261
///
242262
/// The support file list is used by the line table, and any objects that

lldb/include/lldb/Symbol/SymbolFile.h

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@
3333
namespace lldb_private {
3434

3535
class SymbolFile : public PluginInterface {
36+
/// LLVM RTTI support.
37+
static char ID;
38+
3639
public:
40+
/// LLVM RTTI support.
41+
/// \{
42+
virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
43+
static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
44+
/// \}
45+
3746
// Symbol file ability bits.
3847
//
3948
// Each symbol file can claim to support one or more symbol file abilities.
@@ -122,6 +131,35 @@ class SymbolFile : public PluginInterface {
122131
virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0;
123132
virtual bool ParseLineTable(CompileUnit &comp_unit) = 0;
124133
virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0;
134+
135+
/// Apply a lambda to each external lldb::Module referenced by this
136+
/// \p comp_unit. Recursively also descends into the referenced external
137+
/// modules of any encountered compilation unit.
138+
///
139+
/// \param comp_unit
140+
/// When this SymbolFile consists of multiple auxilliary
141+
/// SymbolFiles, for example, a Darwin debug map that references
142+
/// multiple .o files, comp_unit helps choose the auxilliary
143+
/// file. In most other cases comp_unit's symbol file is
144+
/// identiacal with *this.
145+
///
146+
/// \param[in] lambda
147+
/// The lambda that should be applied to every function. The lambda can
148+
/// return true if the iteration should be aborted earlier.
149+
///
150+
/// \param visited_symbol_files
151+
/// A set of SymbolFiles that were already visited to avoid
152+
/// visiting one file more than once.
153+
///
154+
/// \return
155+
/// If the lambda early-exited, this function returns true to
156+
/// propagate the early exit.
157+
virtual bool ForEachExternalModule(
158+
lldb_private::CompileUnit &comp_unit,
159+
llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
160+
llvm::function_ref<bool(Module &)> lambda) {
161+
return false;
162+
}
125163
virtual bool ParseSupportFiles(CompileUnit &comp_unit,
126164
FileSpecList &support_files) = 0;
127165
virtual size_t ParseTypes(CompileUnit &comp_unit) = 0;
@@ -192,9 +230,14 @@ class SymbolFile : public PluginInterface {
192230
TypeMap &types);
193231

194232
/// Find types specified by a CompilerContextPattern.
195-
/// \param languages Only return results in these languages.
196-
virtual void FindTypes(llvm::ArrayRef<CompilerContext> pattern,
197-
LanguageSet languages, TypeMap &types);
233+
/// \param languages
234+
/// Only return results in these languages.
235+
/// \param searched_symbol_files
236+
/// Prevents one file from being visited multiple times.
237+
virtual void
238+
FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
239+
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
240+
TypeMap &types);
198241

199242
virtual void
200243
GetMangledNamesForFunction(const std::string &scope_qualified_name,

lldb/include/lldb/Symbol/Type.h

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,12 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {
8484
eEncodingIsSyntheticUID
8585
};
8686

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

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

201195
uint32_t GetEncodingMask();
202196

203-
bool IsCompleteObjCClass() { return m_flags.is_complete_objc_class; }
197+
bool IsCompleteObjCClass() { return m_is_complete_objc_class; }
204198

205199
void SetIsCompleteObjCClass(bool is_complete_objc_class) {
206-
m_flags.is_complete_objc_class = is_complete_objc_class;
200+
m_is_complete_objc_class = is_complete_objc_class;
207201
}
208202

209203
protected:
210204
ConstString m_name;
211205
SymbolFile *m_symbol_file;
212-
SymbolContextScope
213-
*m_context; // The symbol context in which this type is defined
206+
/// The symbol context in which this type is defined.
207+
SymbolContextScope *m_context;
214208
Type *m_encoding_type;
215209
lldb::user_id_t m_encoding_uid;
216210
EncodingDataType m_encoding_uid_type;
217211
uint64_t m_byte_size : 63;
218212
uint64_t m_byte_size_has_value : 1;
219213
Declaration m_decl;
220214
CompilerType m_compiler_type;
221-
222-
struct Flags {
223-
#ifdef __GNUC__
224-
// using unsigned type here to work around a very noisy gcc warning
225-
unsigned compiler_type_resolve_state : 2;
226-
#else
227-
ResolveState compiler_type_resolve_state : 2;
228-
#endif
229-
bool is_complete_objc_class : 1;
230-
} m_flags;
215+
ResolveState m_compiler_type_resolve_state;
216+
bool m_is_complete_objc_class;
231217

232218
Type *GetEncodingType();
233219

0 commit comments

Comments
 (0)