Skip to content

Commit 29b0c71

Browse files
committed
Only analyse user code in address taken visitor
1 parent f6bfec7 commit 29b0c71

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎cpp2rust/converter/models/boxed_vars.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "converter/models/boxed_vars.h"
55

66
#include <clang/AST/RecursiveASTVisitor.h>
7+
#include <clang/Basic/SourceManager.h>
78

89
#include <algorithm>
910
#include <unordered_map>
@@ -110,6 +111,14 @@ class AddressTakenVisitor
110111

111112
bool shouldVisitTemplateInstantiations() const { return true; }
112113

114+
bool TraverseDecl(clang::Decl *decl) {
115+
if (decl && !llvm::isa<clang::TranslationUnitDecl>(decl) &&
116+
ctx_.getSourceManager().isInSystemHeader(decl->getLocation())) {
117+
return true;
118+
}
119+
return RecursiveASTVisitor::TraverseDecl(decl);
120+
}
121+
113122
// Only the semantic form of an initializer list is converted, in which the
114123
// values of variables are read through lvalue-to-rvalue conversions.
115124
bool TraverseInitListExpr(clang::InitListExpr *expr,

0 commit comments

Comments
 (0)