Make normalize work for (nearly) all the things

Summary: Our normalize function handled the common case of "AbcDef.GhiJklMno" very well,
where we would end up with `abc_def.ghi_jkl_mno`.

But when it came to something like "SSLPort", we would end up with `sslport` instead
of `ssl_port` or "HHIRNumFreeRegs" would be `hhirnum_free_regs`

This diffs hopefully handles 99.9% of the cases now. We may want to make `-` into `_`
or something (e.g. "xdebug-not-done.enable"). That should be easy and can be done
separately.

Reviewed By: @ptarjan

Differential Revision: D1511106
fbcode: __x__-protect all __attribute__ keywords, mechanically

Summary: The first (and sometimes 2nd) argument to __attribute__
should begin and end with "__". If it does not, then it
is at risk of conflicting with user cpp-defined symbols.
Don't do that.  This change mechanically corrects most
such violations in fbcode.  A companion change (see parent task)
adds a lint rule to help keep things clean going forwards.

Define this function to filter the list of file names to which
we will apply the transformations. First, ensure we modify only
C and C++ sources.  The second process excludes a few directories
that appear to contain third-party code:

  filter() {
    grep -E '\.(c|h|cc|cpp|hpp)$' | grep -vE \
      '^external/|/unbound/|/gearmand_|(3rd|third.)party|/external/libevent'
  }

then, run this command,

  git grep -l __attribute__ | filter \
    | xargs perl -pi -e 's/(__attribute__ *)\(\(( *[^_]\w+)/$1((__${2}__/g'

inducing changes like this, for each such keyword:

  -} __attribute__((packed));
  +} __attribute__((__packed__));

That got all but the __format__ archetype arguments like this:
__attribute__((__format__(printf.  That final "printf"
keyword should have the "__" prefix and suffix, too.

Run this command to transform those remaining uses:

  git grep -l '__attribute__.*__format' | filter | xargs perl -pi -e \
    's/(__attribute__ *\(\(__format__ *)\( *(printf|scanf|strftime|strfmon)/$1(__${2}__/g'

That command induces changes like this:

  -static inline int __attribute__ ((__format__ (printf, 3, 4)))
  +static inline int __attribute__ ((__format__ (__printf__, 3, 4)))

This exercise is useful to avoid spurious name-space conflicts,
especially when the unprotected keyword is used in a header file.

Reviewed By: @Gownta

Differential Revision: D1508983
Fix the warning raised when calling a function with too few arguments

Summary: Fixes #3336.

Well, it doesn't give exactly the same output as PHP does, but now the output is (hopefully) correct.
Closes https://github.com/facebook/hhvm/pull/3347

Reviewed By: @ptarjan

Differential Revision: D1506565

Pulled By: @fredemmott
Support the namespace "namespace"

Summary: This seems pretty weird, since it refers to the current
namespace, but it's easy enough to implement. Also take the opportunity
to fix a comment which was full of lies.

Reviewed By: @elgenie

Differential Revision: D1510411
PHPUnit Updates

Summary: This updates phpunit-selenium from 1.3.3 to 1.4.1, phpunit from 4.2.0 to 4.2.2, and instantiator from 1.1.1 to 1.1.2.
Closes https://github.com/facebook/hhvm/pull/3549

Reviewed By: @fredemmott

Differential Revision: D1511365
Some improvements to the RegionDesc API

Summary: I started with the motivation of making it more efficient to search
arcs incident to a particular block, and then ended up cleaning up
some other stuff as well.

Reviewed By: @edwinsmith

Differential Revision: D1505074
Remove duplicate bindings

Summary: There were cases where we double bound config settings, which is wasteful. I have to imagine these were leftovers that were needed before we had `Config::IniName` and `Config::normalize`.

I left the ones that had custom getters and settings for `IniSetting::Bind`

Also, there are few other stragglers that I am going to look at for another diff. Particularly things like `AssertFrequency` and `WarningFrequency` which have `IniSetting::Bind` at the bottom of `runtime-option.cpp` but also have `Config::Bind` for the same settings towards the top.

Reviewed By: @ptarjan

Differential Revision: D1492543
Fix Freetype to look for ft2build.h first

Summary: In the previous configuration, it would find freetype2 for me, but then fail to #include freetype.h through the macro header include.  In this configuration, it finds ft2build.h goes along happily.
Closes https://github.com/facebook/hhvm/pull/3532

Reviewed By: @ptarjan, @sgolemon

Differential Revision: D1508208
Move shape class constant typecheck from declaration to typing

Summary: The check needs to know about available classes and typedefs so
it can look into class constants and see what the typedef's underlying
type is. This means we needed to have completed declaration before doing
the shape class constant check. However, it was placed directly into
declaration itself, and so was sensitive to the order in which classes
were declared, which is nondeterministic. Instead, move it into typing,
when we know that everything has been declared and is available.

Reviewed By: @gabelevi

Differential Revision: D1512071
hash_equals raises a warning on wrong types

Summary: Also moved all good tests

Closes #3477
Closes https://github.com/facebook/hhvm/pull/3479

Reviewed By: @fredemmott

Differential Revision: D1500295
VASM part 6: generate vasm for the whole IRUnit

Summary: Finish converting all the remaining HHIR cg functions to vasm.
This required copying and specializing codeGenImpl(), so I added
that to the BackEnd api. The code duplication with ARM is unfortunate
but I expect it to be temporary; we'll be able to share a lot more
code again once ARM is converted.

Reviewed By: @alexmalyshev

Differential Revision: D1460418
VASM part 6 continued: remove useless control flow

Summary: Enable vasm classic control flow optimizations. The actual implementation
is in D1494657 just not used yet; see vasm-jumps.cpp. This diff starts using it.

 * if both targets of a jcc are the same, convert to jmp
 * if an edge goes to a jmp, use the jmp's target
 * if B1 ends with a jmp to B2 and B2 has 1 pred, merge B1 & B2
 * if B1 ends with a jump to an empty block with a jcc, copy the jcc.

Reviewed By: @alexmalyshev

Differential Revision: D1460505
Fix external build?

Summary: One external report that this unused variable was causing an
error in the build. Our internal build went fine, so this might be a
change in default warnings between 3.12 and 4.01? In any event, easy
enough to fix, and also remove warn-error in the external build for now.

Reviewed By: @gabelevi

Differential Revision: D1512305
Covariance fixes

Summary: This diff updates the typechecker to support covariance for the following
interfaces: Traversable, Container, Iterable, Iterator, ConstCollection,
KeyedTraversable, KeyedContainer, Indexish, KeyedIterable, KeyedIterator.

This diff also two bugs with covariance. First, it fixes the logic for
checking if array<..> is a subtype of Indexish<..>, Traversable<..>,
KeyedTraversable<..>, Container<..>, or KeyedContainer<..>. Second, it
fixes a bug in the covariance logic that was erroneously allowing certain
subtype relationships (for example, it was allowing a Pair to be passed to
a function expecting an ImmMap).

Reviewed By: @jwatzman

Differential Revision: D1511248
Make Set implement KeyedIterable and support bracket syntax for reading

Summary: Over time, Sets have slowly been moving towards supporting more key-based
operations (ex."array_diff_key(..)", "foreach ($set as $k => $v) {..}",
etc) to make collection adoption easier and to make things more convenient.
Likewise, Set->array was changed a while ago so that each value in the Set
is inserted into the array as both the key and value (to make interop
smoother between arrays and collections).

This diff takes another step in this direction by making Set to implement
KeyedIterable, by making Sets support bracket syntax for reading and
unsetting elements, and by making idx() work with Sets. This makes things
more consistent than the current state of affairs, and it also makes
migration easier by enabling things like "isset($set[$x])" to check if a
value is present in the Set. It also positions us better to eventually
merge Iterable and KeyedIterable into a single interface, which I think
would be a good way of simplifying the number of interfaces in the
Collections framework (same goes for Traversable / KeyedTraversable,
Iterator / KeyedIterator, and Container / KeyedContainer).

Care is taken to prevent the use of "$set[$x]" syntax to overwrite an
element or modify an element in place for Sets.

For now, Set does not implement ConstIndexAccess or Indexish. Making Set
implement these interfaces in the future might make sense, but I'd like to
punt on the decision for now.

Reviewed By: @elgenie

Differential Revision: D1435557
Update paris. No longer 100%.

Summary: Was blocked by #3155 which is now fixed.

refs #3024

Reviewed By: @JoelMarcey

Differential Revision: D1512038
Remove die() and exit()

Summary: These functions do still exist but not in HNI anymore as they were only used by the following syntax:

```php
$x = "exit";
$x();
```

Part of #3525.
Closes https://github.com/facebook/hhvm/pull/3552

Reviewed By: @sgolemon, @ptarjan

Differential Revision: D1512234
VASM part 7: use a Vreg temp in ArgGroup, finish removing m_rScratch

Summary: Finish converting remaining uses of m_rScratch to virtual (temp)
registers, and extend ArgGroup to allow srcs to be Vreg temps.
refactor shuffle2 into a copyTV helper functions.

Reviewed By: @alexmalyshev

Differential Revision: D1460426
VASM part 8: add Vloc

Summary: Vloc is like PhysLoc; its the holder for the virtual registers we
assign to an SSATmp. Helpers taking Vout generally need to take Vreg
and Vloc parameters instead of PhysReg and PhysLoc, to prepare for
the next diff, where code generation uses virtual registers for
nearly everything.

Reviewed By: @alexmalyshev

Differential Revision: D1460430
typechecker: Fix column numbers in errors.

Reviewed By: @pikatchu

Differential Revision: D1512788