Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) rewriter: add __attribute__((visibility("default")) to IA2_FN address taken functions if they don't already default visibility #445

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tools/rewriter/SourceRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,22 @@ class FnPtrExpr : public RefactoringCallback {
}
}

if (fn_decl->getVisibility() != clang::Visibility::DefaultVisibility) {
auto decl_start = fn_decl->getBeginLoc();
if (!decl_start.isFileID()) {
llvm::errs() << "Error: non-file loc for function " << fn_name << '\n';
} else {
llvm::errs() << "trying to add __attribute__((visibility(\"default\"))) for " << fn_name << '\n';
Replacement old_used_attr(sm, decl_start, 0,
llvm::StringRef("__attribute__((visibility(\"default\"))) "));
Replacement used_attr = replace_new_file(filename, old_used_attr);
auto err = file_replacements[filename].add(used_attr);
if (err) {
llvm::errs() << "Error adding replacements: " << err << '\n';
}
}
}

// This check must come after modifying the maps in this pass but before the
// Replacement is added
if (in_fn_like_macro(loc, sm)) {
Expand Down