Skip to content

Commit 518597c

Browse files
committed
[lldb] Remove default llvm::Triple argument from ClangASTContext constructor
Creating an ASTContext with an unknown triple is rarely a good idea (as usually all our ASTs have a valid triple that is either from the host or the target) and the default argument makes it far to easy to implicitly create such an AST. Let's remove it and force people to pass a triple. The only place where we don't pass a triple is a DWARFASTParserClangTests where we now just pass the host triple instead (the test doesn't depend on any triple so this shouldn't change anything).
1 parent dfeb873 commit 518597c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lldb/include/lldb/Symbol/ClangASTContext.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ClangASTContext : public TypeSystem {
6161
/// certain characteristics of the ASTContext and its types
6262
/// (e.g., whether certain primitive types exist or what their
6363
/// signedness is).
64-
explicit ClangASTContext(llvm::Triple triple = llvm::Triple());
64+
explicit ClangASTContext(llvm::Triple triple);
6565

6666
/// Constructs a ClangASTContext that uses an existing ASTContext internally.
6767
/// Useful when having an existing ASTContext created by Clang.

lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
1010
#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
1111
#include "TestingSupport/SubsystemRAII.h"
12+
#include "lldb/Host/HostInfo.h"
1213
#include "gmock/gmock.h"
1314
#include "gtest/gtest.h"
1415

1516
using namespace lldb;
1617
using namespace lldb_private;
1718

1819
class DWARFASTParserClangTests : public testing::Test {
19-
SubsystemRAII<FileSystem, ClangASTContext> subsystems;
20+
SubsystemRAII<FileSystem, HostInfo, ClangASTContext> subsystems;
2021
};
2122

2223
namespace {
@@ -38,7 +39,7 @@ class DWARFASTParserClangStub : public DWARFASTParserClang {
3839
// defining here, causing this test to fail, feel free to delete it.
3940
TEST_F(DWARFASTParserClangTests,
4041
EnsureAllDIEsInDeclContextHaveBeenParsedParsesOnlyMatchingEntries) {
41-
ClangASTContext ast_ctx;
42+
ClangASTContext ast_ctx(HostInfoBase::GetTargetTriple());
4243
DWARFASTParserClangStub ast_parser(ast_ctx);
4344

4445
DWARFUnit *unit = nullptr;

0 commit comments

Comments
 (0)