Skip to content

Conversation

@ahmed532
Copy link

src/odb/include/odb/3dblox.h forward declared BumpMapEntry as a class while its definition is a struct. Clang warned about it.
Fixes: #9093

src/odb/include/odb/3dblox.h forward declared BumpMapEntry as a class
while its definition is a struct. Clang warned about it.

Signed-off-by: Ahmed R. Mohamed <[email protected]>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a forward declaration mismatch for BumpMapEntry in src/odb/include/odb/3dblox.h. The change modifies the forward declaration from class to struct to match its definition, which resolves a Clang compiler warning. The change is correct and improves code clarity. I approve these changes.

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@ahmed532 ahmed532 self-assigned this Dec 30, 2025
@maliberty maliberty merged commit c3bd3a2 into The-OpenROAD-Project:master Dec 30, 2025
13 checks passed
@stefanottili
Copy link

Hard to fix things if you don't use a compiler that issues these warnings.
Sorry that I wasn't more explicit in my bug report, but it seems the change from class to struct has to be applied to all "non db" classes in 3dblox.h.

This compiles using clang without -Wmismatched-tags

src/odb/include/odb/3dblox.h

 17 namespace odb {
 18 class dbDatabase;
 19 class dbChip;
 20 class dbChipRegionInst;
 21 class dbChipInst;
 22 class dbChipRegion;
 23 class dbBlock;
 24 class dbBTerm;
 25 class dbInst;
 26 class dbTech;
 27 class dbLib;
 28 
 29 struct ChipletDef;
 30 struct ChipletRegion;
 31 struct ChipletInst;
 32 struct DesignDef;
 33 struct Connection;
 34 struct BumpMapEntry;
 35 
 36 class ThreeDBlox
 37 {

@ahmed532
Copy link
Author

Sorry I missed it 😅 I'll create another PR. What is the standard way of compiling with clang then? I used bazel; it doesn't have all the needed flags set?

@maliberty
Copy link
Member

maliberty commented Dec 30, 2025

You can manually run cmake with -DCMAKE_C_COMPILER=<path>/clang -DCMAKE_CXX_COMPILER=<path>/clang++

@ahmed532
Copy link
Author

I tried -DCMAKE_C_COMPILER=<path>/clang -DCMAKE_CXX_COMPILER=<path>/clang++ but unfortunately there were errors because of my particular env I think (too many libraries everywhere). So, I used bazel. Maybe I should try cmake in the container?

@maliberty
Copy link
Member

bazel doesn't show this error. It may also be specific to the mac version of clang.

@ahmed532
Copy link
Author

usually clang on mac is older I think.

@ahmed532
Copy link
Author

GCC supports the warning flag. I can find them with cmake -B mismatch-build -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-Werror=mismatched-tags"
Will fix them all.

@maliberty
Copy link
Member

maliberty commented Dec 30, 2025

Please add that flag to add_compile_options in src/CMakeLists.txt and OPENROAD_COPTS in BUILD.bazel (if supported in that compiler too).

@ahmed532
Copy link
Author

I'm encountering internal compiler errors with this flag on GCC. It looks like a known issue and it has complex interactions with libraries, PreCompiled Headers, and other flags.
I do not think we should add it. Especially because the C++ standard does not distinguish between class and struct in declarations. Only the definition matters in specifying the visibility struct -> public by default and class -> private by default.

I think I found all the mismatches anyway.

@ahmed532
Copy link
Author

The only concern, I think, is "MSVC (Microsoft Visual C++) can exhibit issues with Name Mangling if tags do not match between declaration and definition".

@ahmed532
Copy link
Author

I can add it conditionally to clang and MSVC though 🤔

@maliberty
Copy link
Member

We don't support MSVC so I wouldn't worry about it. I suspect there would be lots of other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mismatch between struct and class definition in 3dblox.h

3 participants