Speed up `updateLocationDataIfMissing`.

  * Avoid excessive search for missing `locationData`
  * Fix `locationData` for `ELSE IF`.
Merge pull request #3042 from marchaefner/issue2844

Avoid excessive AST traversal in `updateLocationDataIfMissing`.