Skip to content

[HIPIFY][fix] LLVM upstream preparations - Part 4 - namespace usage revision - #2467

Open
ranapratap55 wants to merge 1 commit into
ROCm:amd-developfrom
ranapratap55:users/ranapratap55/llvm-prep-namespace
Open

[HIPIFY][fix] LLVM upstream preparations - Part 4 - namespace usage revision#2467
ranapratap55 wants to merge 1 commit into
ROCm:amd-developfrom
ranapratap55:users/ranapratap55/llvm-prep-namespace

Conversation

@ranapratap55

Copy link
Copy Markdown
Collaborator

Addresses using namespace violations in headers and main source(.cpp) files to match with LLVM coding standards.

  • Removed using namespace llvm;, using namespace llvm; and used llvm::, std:: in header files.
  • Added using namespace llvm; in main source(.cpp) files

@ranapratap55 ranapratap55 self-assigned this Mar 30, 2026
@ranapratap55 ranapratap55 added enhancement Enhancement fix It fixes bug clang clang compiler related issue or change compatibility Compatibility change or request labels Mar 30, 2026
@ranapratap55
ranapratap55 force-pushed the users/ranapratap55/llvm-prep-namespace branch from d1dc065 to ef050ff Compare March 30, 2026 08:31
@ranapratap55 ranapratap55 changed the title [HIPIFY][fix] LLVM upstream preparations - Part 4 - namespace usage revision [HIPIFY][fix] LLVM upstream preparations - Part 4 - namespace usage revision Mar 30, 2026
@ranapratap55
ranapratap55 marked this pull request as draft March 31, 2026 05:12
Comment thread src/CUDA2HIP_Doc.cpp
namespace doc {

using namespace std;
using namespace llvm;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using namespace llvm;

Inconsistent llvm namespace management, as the same directive was explicitly added to (or kept in) other source files.
The point is to remove using namespace llvm from header files. Utilizing using namespace within .cpp is safe. Whereas all llvm:: prefixes are redundant.

Comment thread src/CUDA2HIP_Doc.cpp
files.insert({ t, file });
tmpFiles.insert({ t, tmpFile.str().str() });
streams.insert(make_pair(t, unique_ptr<ostream>(new ofstream(tmpFile.c_str(), ios_base::trunc))));
streams.insert(make_pair(t, unique_ptr<ostream>(new ofstream(tmpFile.c_str(), std::ios_base::trunc))));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the change logic, using std::ios_base; should be utilized instead.

Comment thread src/main.cpp

constexpr auto DEBUG_TYPE = "cuda2hip";

using namespace llvm;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the PR logic, all llvm:: prefixes should be removed in this compilation unit as well.

Comment thread src/CUDA2HIP_Doc.cpp

typedef map<unsigned int, StringRef> sectionMap;
typedef map<StringRef, hipCounter> functionMap;
typedef map<unsigned int, llvm::StringRef> sectionMap;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below, in the compilation unit, the llvm:: prefixes are unnecessary (including the existing ones). Keeping using namespace llvm; is recommended instead.

@ranapratap55
ranapratap55 marked this pull request as ready for review September 1, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang clang compiler related issue or change compatibility Compatibility change or request enhancement Enhancement fix It fixes bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants