[Lldb-commits] [lldb] 518597c - [lldb] Remove default llvm::Triple argument from ClangASTContext constructor

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 8 03:06:24 PST 2020


Author: Raphael Isemann
Date: 2020-01-08T12:05:51+01:00
New Revision: 518597c1737646ea1f087c1fa43109f689adf7a6

URL: https://github.com/llvm/llvm-project/commit/518597c1737646ea1f087c1fa43109f689adf7a6
DIFF: https://github.com/llvm/llvm-project/commit/518597c1737646ea1f087c1fa43109f689adf7a6.diff

LOG: [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).

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/ClangASTContext.h
    lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 3cad8414b128..b59ada2a3df4 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -61,7 +61,7 @@ class ClangASTContext : public TypeSystem {
   ///               certain characteristics of the ASTContext and its types
   ///               (e.g., whether certain primitive types exist or what their
   ///               signedness is).
-  explicit ClangASTContext(llvm::Triple triple = llvm::Triple());
+  explicit ClangASTContext(llvm::Triple triple);
 
   /// Constructs a ClangASTContext that uses an existing ASTContext internally.
   /// Useful when having an existing ASTContext created by Clang.

diff  --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
index bfc9f24770af..8f0368d11ed4 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -9,6 +9,7 @@
 #include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
 #include "TestingSupport/SubsystemRAII.h"
+#include "lldb/Host/HostInfo.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -16,7 +17,7 @@ using namespace lldb;
 using namespace lldb_private;
 
 class DWARFASTParserClangTests : public testing::Test {
-  SubsystemRAII<FileSystem, ClangASTContext> subsystems;
+  SubsystemRAII<FileSystem, HostInfo, ClangASTContext> subsystems;
 };
 
 namespace {
@@ -38,7 +39,7 @@ class DWARFASTParserClangStub : public DWARFASTParserClang {
 // defining here, causing this test to fail, feel free to delete it.
 TEST_F(DWARFASTParserClangTests,
        EnsureAllDIEsInDeclContextHaveBeenParsedParsesOnlyMatchingEntries) {
-  ClangASTContext ast_ctx;
+  ClangASTContext ast_ctx(HostInfoBase::GetTargetTriple());
   DWARFASTParserClangStub ast_parser(ast_ctx);
 
   DWARFUnit *unit = nullptr;


        


More information about the lldb-commits mailing list