- Rearrange the atomic expr order to the API order when rebuilding atomic expr during template instantiation.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 38447 Build 38446: arc lint + arc unit
Event Timeline
The current BuildAtomicExpr expects the arguments to be in the API order instead of the AST order. If RebuildAtomicExpr uses the same BuildAtomicExpr, it needs to ensure the order of arguments are in API order; otherwise, arguments (especially the one with memory order) will be misplaced.
Yikes, good catch!
Would we be better off instead to just modify how the other switch loads the value? Presumably something like, "if (NeedsRearrangeArgs) SubExprs.append(Args.begin(), Args.end()); else /*the switch*/.
clang/lib/Sema/TreeTransform.h | ||
---|---|---|
3318 | When passing a bool, use the comment syntax /*paramname=*/ to make it clear whats happening. |
Loop from L4762 will check "value" arguments assuming the API order as well. That's why arguments are arranged so that the value checking logic also check the correct arguments.
It kinda stinks that we have to do this at such a late step. I'd have much preferred doing this as a part of the rebuild, but it appears that the 'form' takes quite a bit to calculate. Also, I'd likely have preferred that the initial reordering happened in codegen instead of this early, though perhaps thats too large of a change to do here.
I think then we're stuck with this reordering step.
That said, I'm not a fan at all of doing this parameter as a bool, particularly one with an ambiguous name. Can you introduce an enum like "enum class AtomicArgumentOrder { API, AST}" that makes it more clear?
Additionally, ReArgs is a confusing name, how about APIOrderedArgs?
Also, can you add a test for GNUCmpXchg in both situations (inside a template, and outside)? It is the most complicated, and would best reflect the issue.
Seems your test changes have disappeared as well? Otherwise, 1 comment then I'm ok with this.
clang/lib/Sema/TreeTransform.h | ||
---|---|---|
3319 | The comment is no longer necessary, since the enum describes the purpose. |
When passing a bool, use the comment syntax /*paramname=*/ to make it clear whats happening.