Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: Id200063a64ee23ee9f52f068ea77d329be753e88
  • Loading branch information
Jenkins committed Feb 18, 2024
2 parents bcedb28 + 3496927 commit c164257
Show file tree
Hide file tree
Showing 52 changed files with 422 additions and 501 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,29 @@ StringRef getEquivalentBoolLiteralForExpr(const Expr *Expression,
return {};
}

bool needsSpacePrefix(SourceLocation Loc, ASTContext &Context) {
SourceRange PrefixRange(Loc.getLocWithOffset(-1), Loc);
StringRef SpaceBeforeStmtStr = Lexer::getSourceText(
CharSourceRange::getCharRange(PrefixRange), Context.getSourceManager(),
Context.getLangOpts(), nullptr);
if (SpaceBeforeStmtStr.empty())
return true;

const StringRef AllowedCharacters(" \t\n\v\f\r(){}[]<>;,+=-|&~!^*/");
return !AllowedCharacters.contains(SpaceBeforeStmtStr.back());
}

void fixGenericExprCastFromBool(DiagnosticBuilder &Diag,
const ImplicitCastExpr *Cast,
ASTContext &Context, StringRef OtherType) {
const Expr *SubExpr = Cast->getSubExpr();
bool NeedParens = !isa<ParenExpr>(SubExpr);
const bool NeedParens = !isa<ParenExpr>(SubExpr->IgnoreImplicit());
const bool NeedSpace = needsSpacePrefix(Cast->getBeginLoc(), Context);

Diag << FixItHint::CreateInsertion(
Cast->getBeginLoc(),
(Twine("static_cast<") + OtherType + ">" + (NeedParens ? "(" : ""))
.str());
Cast->getBeginLoc(), (Twine() + (NeedSpace ? " " : "") + "static_cast<" +
OtherType + ">" + (NeedParens ? "(" : ""))
.str());

if (NeedParens) {
SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ Changes in existing checks
<clang-tidy/checks/modernize/use-override>` check to also remove any trailing
whitespace when deleting the ``virtual`` keyword.

- Improved :doc:`readability-implicit-bool-conversion
<clang-tidy/checks/readability/implicit-bool-conversion>` check to provide
valid fix suggestions for ``static_cast`` without a preceding space and
fixed problem with duplicate parentheses in double implicit casts.

- Improved :doc:`readability-redundant-inline-specifier
<clang-tidy/checks/readability/redundant-inline-specifier>` check to properly
emit warnings for static data member with an in-class initializer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,12 @@ namespace PR71867 {
// CHECK-FIXES: return (x ? 1 : 0) != 0;
}
}

namespace PR71848 {
int fun() {
bool foo = false;
return( foo );
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
// CHECK-FIXES: return static_cast<int>( foo );
}
}
3 changes: 1 addition & 2 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3994,8 +3994,7 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
// behavior may break ABI compatibility of the current unit.
if (const Module *M = F->getOwningModule();
M && M->getTopLevelModule()->isNamedModule() &&
getContext().getCurrentNamedModule() != M->getTopLevelModule() &&
!F->hasAttr<AlwaysInlineAttr>())
getContext().getCurrentNamedModule() != M->getTopLevelModule())
return false;

if (F->hasAttr<NoInlineAttr>())
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CodeGenCXX/module-funcs-from-imports.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ int use() {
return exported_func() + always_inline_func();
}

// Checks that none of the function (except the always_inline_func) in the importees
// Checks that none of the function in the importees
// are generated in the importer's code.
// CHECK-O0: define{{.*}}_Z3usev(
// CHECK-O0: declare{{.*}}_ZW1M13exported_funcv(
// CHECK-O0: define{{.*}}available_externally{{.*}}_ZW1M18always_inline_funcv(
// CHECK-O0: declare{{.*}}_ZW1M18always_inline_funcv(
// CHECK-O0-NOT: func_in_gmf
// CHECK-O0-NOT: func_in_gmf_not_called
// CHECK-O0-NOT: non_exported_func
Expand All @@ -68,7 +68,7 @@ int use() {
// O0 to keep consistent ABI.
// CHECK-O1: define{{.*}}_Z3usev(
// CHECK-O1: declare{{.*}}_ZW1M13exported_funcv(
// CHECK-O1: define{{.*}}available_externally{{.*}}_ZW1M18always_inline_funcv(
// CHECK-O1: declare{{.*}}_ZW1M18always_inline_funcv(
// CHECK-O1-NOT: func_in_gmf
// CHECK-O1-NOT: func_in_gmf_not_called
// CHECK-O1-NOT: non_exported_func
Expand Down
3 changes: 2 additions & 1 deletion flang/lib/Lower/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2640,7 +2640,8 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
? nullptr
: mlir::ArrayAttr::get(converter.getFirOpBuilder().getContext(),
reductionDeclSymbols),
procBindKindAttr);
procBindKindAttr, /*private_vars=*/llvm::SmallVector<mlir::Value>{},
/*privatizers=*/nullptr);
}

static mlir::omp::SectionOp
Expand Down
6 changes: 0 additions & 6 deletions lldb/bindings/interface/SBStatisticsOptionsDocstrings.i
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@
) lldb::SBStatisticsOptions::SetSummaryOnly;
%feature("docstring", "Gets whether the statistics only dump a summary."
) lldb::SBStatisticsOptions::GetSummaryOnly;
%feature("docstring", "
Sets whether the statistics will force loading all possible debug info."
) lldb::SBStatisticsOptions::SetReportAllAvailableDebugInfo;
%feature("docstring", "
Gets whether the statistics will force loading all possible debug info."
) lldb::SBStatisticsOptions::GetReportAllAvailableDebugInfo;
8 changes: 0 additions & 8 deletions lldb/include/lldb/API/SBStatisticsOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ class LLDB_API SBStatisticsOptions {
void SetSummaryOnly(bool b);
bool GetSummaryOnly();

/// If set to true, the debugger will load all debug info that is available
/// and report statistics on the total amount. If this is set to false, then
/// only report statistics on the currently loaded debug information.
/// This can avoid loading debug info from separate files just so it can
/// report the total size which can slow down statistics reporting.
void SetReportAllAvailableDebugInfo(bool b);
bool GetReportAllAvailableDebugInfo();

protected:
friend class SBTarget;
const lldb_private::StatisticsOptions &ref() const;
Expand Down
14 changes: 3 additions & 11 deletions lldb/include/lldb/Symbol/SymbolFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ class SymbolFile : public PluginInterface {

/// Metrics gathering functions

/// Return the size in bytes of all loaded debug information or total possible
/// debug info in the symbol file.
/// Return the size in bytes of all debug information in the symbol file.
///
/// If the debug information is contained in sections of an ObjectFile, then
/// this call should add the size of all sections that contain debug
Expand All @@ -392,14 +391,7 @@ class SymbolFile : public PluginInterface {
/// entire file should be returned. The default implementation of this
/// function will iterate over all sections in a module and add up their
/// debug info only section byte sizes.
///
/// \param load_all_debug_info
/// If true, force loading any symbol files if they are not yet loaded and
/// add to the total size. Default to false.
///
/// \returns
/// Total currently loaded debug info size in bytes
virtual uint64_t GetDebugInfoSize(bool load_all_debug_info = false) = 0;
virtual uint64_t GetDebugInfoSize() = 0;

/// Return the time taken to parse the debug information.
///
Expand Down Expand Up @@ -542,7 +534,7 @@ class SymbolFileCommon : public SymbolFile {

void Dump(Stream &s) override;

uint64_t GetDebugInfoSize(bool load_all_debug_info = false) override;
uint64_t GetDebugInfoSize() override;

bool GetDebugInfoIndexWasLoadedFromCache() const override {
return m_index_was_loaded_from_cache;
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Symbol/SymbolFileOnDemand.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile {

void PreloadSymbols() override;

uint64_t GetDebugInfoSize(bool load_all_debug_info = false) override;
uint64_t GetDebugInfoSize() override;
lldb_private::StatsDuration::Duration GetDebugInfoParseTime() override;
lldb_private::StatsDuration::Duration GetDebugInfoIndexTime() override;

Expand Down
1 change: 0 additions & 1 deletion lldb/include/lldb/Target/Statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ struct ConstStringStats {

struct StatisticsOptions {
bool summary_only = false;
bool load_all_debug_info = false;
};

/// A class that represents statistics for a since lldb_private::Target.
Expand Down
8 changes: 0 additions & 8 deletions lldb/source/API/SBStatisticsOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ void SBStatisticsOptions::SetSummaryOnly(bool b) {

bool SBStatisticsOptions::GetSummaryOnly() { return m_opaque_up->summary_only; }

void SBStatisticsOptions::SetReportAllAvailableDebugInfo(bool b) {
m_opaque_up->load_all_debug_info = b;
}

bool SBStatisticsOptions::GetReportAllAvailableDebugInfo() {
return m_opaque_up->load_all_debug_info;
}

const lldb_private::StatisticsOptions &SBStatisticsOptions::ref() const {
return *m_opaque_up;
}
3 changes: 0 additions & 3 deletions lldb/source/Commands/CommandObjectStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ class CommandObjectStatsDump : public CommandObjectParsed {
case 's':
m_stats_options.summary_only = true;
break;
case 'f':
m_stats_options.load_all_debug_info = true;
break;
default:
llvm_unreachable("Unimplemented option");
}
Expand Down
6 changes: 1 addition & 5 deletions lldb/source/Commands/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1419,10 +1419,6 @@ let Command = "statistics dump" in {
def statistics_dump_all: Option<"all-targets", "a">, Group<1>,
Desc<"Include statistics for all targets.">;
def statistics_dump_summary: Option<"summary", "s">, Group<1>,
Desc<"Dump only high-level summary statistics. "
Desc<"Dump only high-level summary statistics."
"Exclude targets, modules, breakpoints etc... details.">;
def statistics_dump_force: Option<"load-all-debug-info", "f">, Group<1>,
Desc<"Dump the total possible debug info statistics. "
"Force loading all the debug information if not yet loaded, and collect "
"statistics with those.">;
}
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ void SymbolFileBreakpad::ParseUnwindData() {
m_unwind_data->win.Sort();
}

uint64_t SymbolFileBreakpad::GetDebugInfoSize(bool load_all_debug_info) {
uint64_t SymbolFileBreakpad::GetDebugInfoSize() {
// Breakpad files are all debug info.
return m_objfile_sp->GetByteSize();
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class SymbolFileBreakpad : public SymbolFileCommon {

llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }

uint64_t GetDebugInfoSize(bool load_all_debug_info = false) override;
uint64_t GetDebugInfoSize() override;

private:
// A class representing a position in the breakpad file. Useful for
Expand Down
5 changes: 2 additions & 3 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,9 +896,8 @@ void DWARFUnit::ComputeAbsolutePath() {
m_file_spec->MakeAbsolute(GetCompilationDirectory());
}

SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile(bool load_all_debug_info) {
if (load_all_debug_info)
ExtractUnitDIEIfNeeded();
SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile() {
ExtractUnitDIEIfNeeded();
if (m_dwo)
return &llvm::cast<SymbolFileDWARFDwo>(m_dwo->GetSymbolFileDWARF());
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class DWARFUnit : public UserID {
FileSpec GetFile(size_t file_idx);
FileSpec::Style GetPathStyle();

SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_all_debug_info = false);
SymbolFileDWARFDwo *GetDwoSymbolFile();

die_iterator_range dies() {
ExtractDIEsIfNeeded();
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2672,7 +2672,7 @@ static bool UpdateCompilerContextForSimpleTemplateNames(TypeQuery &match) {
return any_context_updated;
}

uint64_t SymbolFileDWARF::GetDebugInfoSize(bool load_all_debug_info) {
uint64_t SymbolFileDWARF::GetDebugInfoSize() {
DWARFDebugInfo &info = DebugInfo();
uint32_t num_comp_units = info.GetNumUnits();

Expand All @@ -2687,7 +2687,7 @@ uint64_t SymbolFileDWARF::GetDebugInfoSize(bool load_all_debug_info) {
if (cu == nullptr)
continue;

SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(load_all_debug_info);
SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
if (dwo)
debug_info_size += dwo->GetDebugInfoSize();
}
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class SymbolFileDWARF : public SymbolFileCommon {
GetMangledNamesForFunction(const std::string &scope_qualified_name,
std::vector<ConstString> &mangled_names) override;

uint64_t GetDebugInfoSize(bool load_all_debug_info = false) override;
uint64_t GetDebugInfoSize() override;

void FindTypes(const lldb_private::TypeQuery &match,
lldb_private::TypeResults &results) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ lldb::offset_t SymbolFileDWARFDwo::GetVendorDWARFOpcodeSize(
return GetBaseSymbolFile().GetVendorDWARFOpcodeSize(data, data_offset, op);
}

uint64_t SymbolFileDWARFDwo::GetDebugInfoSize(bool load_all_debug_info) {
uint64_t SymbolFileDWARFDwo::GetDebugInfoSize() {
// Directly get debug info from current dwo object file's section list
// instead of asking SymbolFileCommon::GetDebugInfo() which parses from
// owning module which is wrong.
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF {
const lldb::offset_t data_offset,
const uint8_t op) const override;

uint64_t GetDebugInfoSize(bool load_all_debug_info = false) override;
uint64_t GetDebugInfoSize() override;

bool ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes,
lldb::offset_t &offset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,7 @@ SymbolFileNativePDB::GetTypeSystemForLanguage(lldb::LanguageType language) {
return type_system_or_err;
}

uint64_t SymbolFileNativePDB::GetDebugInfoSize(bool load_all_debug_info) {
uint64_t SymbolFileNativePDB::GetDebugInfoSize() {
// PDB files are a separate file that contains all debug info.
return m_index->pdb().getFileSize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class SymbolFileNativePDB : public SymbolFileCommon {

void InitializeObject() override;

uint64_t GetDebugInfoSize(bool load_all_debug_info = false) override;
uint64_t GetDebugInfoSize() override;

// Compile Unit function calls

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Symbol/SymbolFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ SymbolFileCommon::GetTypeSystemForLanguage(lldb::LanguageType language) {
return type_system_or_err;
}

uint64_t SymbolFileCommon::GetDebugInfoSize(bool load_all_debug_info) {
uint64_t SymbolFileCommon::GetDebugInfoSize() {
if (!m_objfile_sp)
return 0;
ModuleSP module_sp(m_objfile_sp->GetModule());
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Symbol/SymbolFileOnDemand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,11 @@ void SymbolFileOnDemand::PreloadSymbols() {
return m_sym_file_impl->PreloadSymbols();
}

uint64_t SymbolFileOnDemand::GetDebugInfoSize(bool load_all_debug_info) {
uint64_t SymbolFileOnDemand::GetDebugInfoSize() {
// Always return the real debug info size.
LLDB_LOG(GetLog(), "[{0}] {1} is not skipped", GetSymbolFileName(),
__FUNCTION__);
return m_sym_file_impl->GetDebugInfoSize(load_all_debug_info);
return m_sym_file_impl->GetDebugInfoSize();
}

StatsDuration::Duration SymbolFileOnDemand::GetDebugInfoParseTime() {
Expand Down
4 changes: 1 addition & 3 deletions lldb/source/Target/Statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ llvm::json::Value DebuggerStats::ReportStatistics(
const lldb_private::StatisticsOptions &options) {

const bool summary_only = options.summary_only;
const bool load_all_debug_info = options.load_all_debug_info;

json::Array json_targets;
json::Array json_modules;
Expand Down Expand Up @@ -281,8 +280,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(
++debug_index_saved;
module_stat.debug_index_time = sym_file->GetDebugInfoIndexTime().count();
module_stat.debug_parse_time = sym_file->GetDebugInfoParseTime().count();
module_stat.debug_info_size =
sym_file->GetDebugInfoSize(load_all_debug_info);
module_stat.debug_info_size = sym_file->GetDebugInfoSize();
module_stat.symtab_stripped = module->GetObjectFile()->IsStripped();
if (module_stat.symtab_stripped)
++num_stripped_modules;
Expand Down
35 changes: 0 additions & 35 deletions lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,38 +117,3 @@ def test_command_stats_api(self):
self.assertNotIn("bt", command_stats)
# Verify bt's regex command is not duplicatedly captured.
self.assertNotIn("_regexp-bt", command_stats)

def test_command_stats_force(self):
"""
Test reporting all pssible debug info stats by force loading all debug
info. For example, dwo files
"""
src_dir = self.getSourceDir()
dwo_yaml_path = os.path.join(src_dir, "main.dwo.yaml")
obj_yaml_path = os.path.join(src_dir, "main.o.yaml")
dwo_path = self.getBuildArtifact("main.dwo")
obj_path = self.getBuildArtifact("main.o")
self.yaml2obj(dwo_yaml_path, dwo_path)
self.yaml2obj(obj_yaml_path, obj_path)

# We need the current working directory to be set to the build directory
os.chdir(self.getBuildDir())
# Create a target with the object file we just created from YAML
target = self.dbg.CreateTarget(obj_path)
self.assertTrue(target, VALID_TARGET)

# Get statistics
stats_options = lldb.SBStatisticsOptions()
stats = target.GetStatistics(stats_options)
stream = lldb.SBStream()
stats.GetAsJSON(stream)
debug_stats = json.loads(stream.GetData())
self.assertEqual(debug_stats["totalDebugInfoByteSize"], 188)

# Get statistics with force loading
stats_options.SetReportAllAvailableDebugInfo(True)
stats_force = target.GetStatistics(stats_options)
stream_force = lldb.SBStream()
stats_force.GetAsJSON(stream_force)
debug_stats_force = json.loads(stream_force.GetData())
self.assertEqual(debug_stats_force["totalDebugInfoByteSize"], 435)
Loading

0 comments on commit c164257

Please sign in to comment.