Commit Graph

9 Commits

Author SHA1 Message Date
Saleem Abdulrasool
040050a6c7 Basic: out-of-line equality operator (NFCI)
MSVC did not like the original code and would fail to build as:

  ```
  swift\include\swift/Basic/Located.h(50): error C2995: 'bool swift::operator ==(const swift::Located<T> &,const swift::Located<T> &)': function template has already been defined
  swift\include\swift/Basic/Located.h(50): note: see declaration of 'swift::operator =='
  llvm\include\llvm/Support/TrailingObjects.h(76): note: see reference to class template instantiation 'swift::Located<swift::Identifier>' being compiled
  llvm\include\llvm/Support/TrailingObjects.h(233): note: see reference to class template instantiation 'llvm::trailing_objects_internal::AlignmentCalcHelper<swift::Located<swift::Identifier>>' being compiled
  swift\include\swift/AST/Decl.h(1512): note: see reference to class template instantiation 'llvm::TrailingObjects<swift::ImportDecl,swift::Located<swift::Identifier>>' being compiled
  ```

The original code is odd.  There appears to be some unnecessary
complexity.

First, the member function is marked as a friend of a
`struct` type which does not change the member's visibility, thus all
the members are `public`, and the function need not be friended.

Second, the function is templated over the same parameter type, which
means that the original template parameter could be used and the
standard member equality operator could be used rather than the
free-standing form.

It is unclear why the member equality operator is insufficient, and the
extraneous template instatiations here seem wasteful.  Out-of-line the
free-standing form and not mark it as a friend to restore the build.
Switching to a member form can be a follow up change.
2020-01-06 15:53:19 -08:00
Kita, Maksim
646e9ac77f SR-11889: Fixed code review issues 2019-12-22 14:42:47 +03:00
Kita, Maksim
a2cce2b293 SR-11889: Fixed code review issues 2019-12-20 17:19:00 +03:00
Kita, Maksim
c70bd2b2c9 SR-11889: Located added dump methods 2019-12-20 17:19:00 +03:00
Kita, Maksim
ea6a2dc094 SR-11889: Fixed code review issues
1. Updated Located field names with Pascal Case
2. Updated Located constuctor
3. Formatted lines with more than 80 symbols
2019-12-20 17:18:59 +03:00
Kita, Maksim
5fdea64d7e SR-11889: Fixed code review issues. 2019-12-20 17:18:59 +03:00
Kita, Maksim
c88ac85b3f SR-11889: Fixed code review issues
1. Removed two braces {{ usage of Located initialization
2. Wrapped documentation into 80 characters
2019-12-20 17:18:59 +03:00
Kita, Maksim
c1444dea18 SR-11889: Fixed code review issues 2019-12-20 17:18:59 +03:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00