It's well understood what they are doing, because the companies are quite open about it. Back in the 90s Apple invented something called the Double Irish, which is where they register is shell company with no employees or other interesting in Ireland and have all the other Apple corporations around the world pay their profits to it in exchange for using the Apple name. Starbucks, Google, Amazon and others all do the same. Since the local corporations don't make any profit (due to the "crippling" fees they pay to Apple Ireland) they pay next to no tax.
So why doesn't Apple Ireland pay tax on all the money it takes? Irish law states that corporations that are headquartered overseas pay corporation taxes where their headquarters are. So Ireland says they pay in the US, the US says they pay in Ireland... and thus they pay no tax on all that money.
Of course they are quite open about this and list the money held in Ireland as part of their balance sheets. Apple is currently taking low interest loans to pay shareholders based on the vast reserves it has in Ireland, rather than bring some of that money back and pay ~40% tax on it.
The EU is working on a fix where corporations pay tax based on how much business they do in each country. This seems to be the best that the US can come up with, given the political climate.