Repository navigation
unusedArgs: bring InstructionAPI into scope itself - #70
Merged
Merged
Conversation
unusedArgs.C uses Instruction unqualified. It only compiles because Dyninst's installed liveness.h has "using namespace Dyninst::InstructionAPI;" at global scope. dyninst/dyninst#2629 removes the using-directives from the installed headers, and with it this file fails to build: unusedArgs.C:74:5: error: 'Instruction' was not declared in this scope Add the using-directive here, next to the file's other ones. It compiles against Dyninst with or without that change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
I would prefer to not perpetuate using directives as we're doing in dyninst/dyninst#2629. |
Member
Author
I mean this is in .C file so I think it is fine? |
Collaborator
It's far less bad than in headers, but still not as clear as using explicit namespace prefixes. I guess this PR is fine, but it's a background task I'll add for myself for the non-core repos. |
hainest
approved these changes
Nov 23, 2026
bbiiggppiigg
added a commit
to dyninst/dyninst
that referenced
this pull request
Nov 24, 2026
…#2629) Seven installed headers put names into every consumer's scope: - ABI.h, InstructionCache.h, liveness.h and local_var.h had "using namespace Dyninst;" (and Dyninst::InstructionAPI, SymtabAPI, Stackwalker) at global scope. - PatchCommon.h had "using std::map; using std::set; using std::vector; using std::cerr;" at global scope. - Dereference.h and BinaryFunction.h had "using std::vector;" inside Dyninst::InstructionAPI, which a consumer's "using namespace Dyninst::InstructionAPI;" carries into its own scope. A program including one of them got those names in its scope, where they can collide with its own names or another library's. For example, adding a namespace Dyninst::abi made boost's use of the "abi" from <cxxabi.h> ambiguous for every consumer of ABI.h. Remove them and qualify the names instead, in these headers, in PatchCFG.h, and in the internal sources and the dataflowAPI Slicing docs example that relied on them. The classes and functions the headers declare keep their names and stay at global scope; the ABI is unchanged. Consumers that used Dyninst or std names unqualified through these headers must now qualify them or add their own using-directive. dyninst/examples#70 and dyninst/examples#71 did that for the examples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
How we found it
dyninst/dyninst#2629 removes the global-scope using-directives from Dyninst's installed headers. Built against that install, this repository fails in one file:
What is wrong
unusedArgs.CusesInstructionunqualified, but it never bringsDyninst::InstructionAPIinto scope itself. It compiles today only because the installedliveness.hhasusing namespace Dyninst::InstructionAPI;at global scope.How we fixed it
Add
using namespace InstructionAPI;next to the file's other using-directives. The change is backward-compatible: the file builds against Dyninst with or without dyninst/dyninst#2629, so this can merge first.The only other example that includes one of the affected headers,
dataflowAPI/liveness.cpp, already builds against dyninst/dyninst#2629.Validation
On 294a709, all 50 targets built on mahir (x86_64, gcc), with 0 errors and 0 warnings:
Not built on aarch64 or ppc64le; the change has no architecture-specific part.
🤖 Generated with Claude Code