Skip to content

Commit

Permalink
(WIP) rewriter: add __attribute__((visibility("default")) to `IA2_F…
Browse files Browse the repository at this point in the history
…N` address taken functions if they don't already default visibility
  • Loading branch information
kkysen committed Oct 14, 2024
1 parent 872cdfd commit da081bb
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit da081bb

Please sign in to comment.