Is going through walls really a problem in a 2D game? Usually the player is a box and you play a sprite animation. Even if the weapon was attached separately, overlapping a wall wouldnt be an issue, either you push against a wall and he plays a different animation and the weapon moves, or you can overlap the wall. If you chose to have the weapon separate from the character as design then I don't think making it solid is a good thing to do.