Sfoglia il codice sorgente

Creating branches/google/testing and tags/google/testing/2017-11-14 from r317716

git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/testing@318248 91177308-0d34-0410-b5e6-96231b3b80d8
David L. Jones 7 anni fa
parent
commit
fdfce82b87
100 ha cambiato i file con 3181 aggiunte e 3118 eliminazioni
  1. 1 0
      CMakeLists.txt
  2. 14 4
      bindings/python/tests/cindex/test_tls_kind.py
  3. 43 0
      docs/LanguageExtensions.rst
  4. 2 1
      docs/ReleaseNotes.rst
  5. 45 25
      include/clang/AST/CanonicalType.h
  6. 153 114
      include/clang/AST/DeclBase.h
  7. 66 37
      include/clang/AST/ExternalASTSource.h
  8. 37 39
      include/clang/AST/PrettyPrinter.h
  9. 18 7
      include/clang/AST/QualTypeNames.h
  10. 133 129
      include/clang/Basic/Builtins.def
  11. 1 1
      include/clang/Basic/BuiltinsNVPTX.def
  12. 1 36
      include/clang/Basic/BuiltinsX86.def
  13. 1 1
      include/clang/Basic/DiagnosticSemaKinds.td
  14. 41 42
      include/clang/Basic/IdentifierTable.h
  15. 2 1
      include/clang/Basic/LangOptions.h
  16. 35 27
      include/clang/Basic/Module.h
  17. 3 0
      include/clang/Basic/Sanitizers.def
  18. 35 37
      include/clang/Basic/SourceManager.h
  19. 15 7
      include/clang/Basic/SourceManagerInternals.h
  20. 1 1
      include/clang/Driver/CC1Options.td
  21. 2 0
      include/clang/Driver/CLCompatOptions.td
  22. 5 1
      include/clang/Driver/Options.td
  23. 1 0
      include/clang/Driver/SanitizerArgs.h
  24. 2 0
      include/clang/Frontend/CodeGenOptions.def
  25. 7 0
      include/clang/Lex/Lexer.h
  26. 31 2
      include/clang/Lex/Preprocessor.h
  27. 303 31
      include/clang/Serialization/ASTBitCodes.h
  28. 184 136
      include/clang/Serialization/ASTReader.h
  29. 18 16
      include/clang/Serialization/ContinuousRangeMap.h
  30. 0 3
      include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  31. 7 0
      include/clang/Tooling/Execution.h
  32. 12 0
      include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  33. 22 0
      include/clang/Tooling/Refactoring/Rename/RenamingAction.h
  34. 5 0
      lib/AST/ASTContext.cpp
  35. 1 0
      lib/AST/CMakeLists.txt
  36. 27 12
      lib/AST/DeclBase.cpp
  37. 7 3
      lib/AST/ExternalASTSource.cpp
  38. 1 12
      lib/AST/QualTypeNames.cpp
  39. 32 29
      lib/Analysis/BodyFarm.cpp
  40. 43 25
      lib/Basic/IdentifierTable.cpp
  41. 18 7
      lib/Basic/Module.cpp
  42. 1 1
      lib/Basic/SanitizerSpecialCaseList.cpp
  43. 30 25
      lib/Basic/SourceManager.cpp
  44. 2 0
      lib/Basic/Targets/X86.cpp
  45. 10 26
      lib/CodeGen/CGBuiltin.cpp
  46. 10 0
      lib/CodeGen/CGCall.cpp
  47. 47 47
      lib/CodeGen/CGOpenMPRuntime.cpp
  48. 1 1
      lib/CodeGen/CodeGenFunction.cpp
  49. 9 10
      lib/CodeGen/CodeGenModule.cpp
  50. 1 1
      lib/CodeGen/TargetInfo.cpp
  51. 7 1
      lib/Driver/Driver.cpp
  52. 10 13
      lib/Driver/SanitizerArgs.cpp
  53. 10 1
      lib/Driver/ToolChains/Clang.cpp
  54. 7 1
      lib/Driver/ToolChains/CommonArgs.cpp
  55. 1 0
      lib/Driver/ToolChains/Cuda.h
  56. 3 2
      lib/Driver/ToolChains/Linux.cpp
  57. 2 10
      lib/Driver/ToolChains/MinGW.cpp
  58. 2 1
      lib/Format/TokenAnnotator.cpp
  59. 21 2
      lib/Format/UsingDeclarationsSorter.cpp
  60. 5 3
      lib/Frontend/CompilerInvocation.cpp
  61. 131 319
      lib/Headers/avx512bwintrin.h
  62. 3 2
      lib/Headers/avx512cdintrin.h
  63. 99 287
      lib/Headers/avx512fintrin.h
  64. 263 639
      lib/Headers/avx512vlbwintrin.h
  65. 5 5
      lib/Headers/avx512vlcdintrin.h
  66. 199 576
      lib/Headers/avx512vlintrin.h
  67. 11 0
      lib/Index/IndexBody.cpp
  68. 20 16
      lib/Lex/Lexer.cpp
  69. 20 11
      lib/Lex/PPDirectives.cpp
  70. 1 0
      lib/Lex/PPMacroExpansion.cpp
  71. 7 0
      lib/Lex/Preprocessor.cpp
  72. 22 15
      lib/Parse/ParseExprCXX.cpp
  73. 3 0
      lib/Sema/SemaChecking.cpp
  74. 5 2
      lib/Sema/SemaCodeComplete.cpp
  75. 7 0
      lib/Sema/SemaDecl.cpp
  76. 4 0
      lib/Sema/SemaInit.cpp
  77. 1 1
      lib/Sema/SemaOpenMP.cpp
  78. 1 2
      lib/Sema/SemaPseudoObject.cpp
  79. 147 104
      lib/Serialization/ASTReader.cpp
  80. 11 0
      lib/Serialization/ASTWriter.cpp
  81. 18 9
      lib/Serialization/ASTWriterDecl.cpp
  82. 41 28
      lib/Serialization/MultiOnDiskHashTable.h
  83. 4 2
      lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  84. 12 4
      lib/StaticAnalyzer/Core/ExprEngineC.cpp
  85. 0 1
      lib/Tooling/Core/CMakeLists.txt
  86. 20 4
      lib/Tooling/Execution.cpp
  87. 22 1
      lib/Tooling/Refactoring/ASTSelection.cpp
  88. 2 1
      lib/Tooling/Refactoring/CMakeLists.txt
  89. 7 3
      lib/Tooling/Refactoring/Extract/Extract.cpp
  90. 112 0
      lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
  91. 52 0
      lib/Tooling/Refactoring/Extract/SourceExtraction.h
  92. 20 0
      lib/Tooling/Refactoring/RefactoringActions.cpp
  93. 65 18
      lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  94. 4 4
      lib/Tooling/StandaloneExecution.cpp
  95. 56 0
      test/Analysis/call_once.cpp
  96. 10 0
      test/Analysis/string-with-signedness.c
  97. 161 131
      test/Analysis/unix-fns.c
  98. 28 0
      test/Analysis/vector.c
  99. 2 2
      test/CodeCompletion/call.cpp
  100. 31 0
      test/CodeCompletion/qualifiers-as-written.cpp

+ 1 - 0
CMakeLists.txt

@@ -429,6 +429,7 @@ add_subdirectory(include)
 # All targets below may depend on all tablegen'd files.
 # All targets below may depend on all tablegen'd files.
 get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
 get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
 add_custom_target(clang-tablegen-targets DEPENDS ${CLANG_TABLEGEN_TARGETS})
 add_custom_target(clang-tablegen-targets DEPENDS ${CLANG_TABLEGEN_TARGETS})
+set_target_properties(clang-tablegen-targets PROPERTIES FOLDER "Misc")
 list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)
 list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)
 
 
 # Force target to be built as soon as possible. Clang modules builds depend
 # Force target to be built as soon as possible. Clang modules builds depend

+ 14 - 4
bindings/python/tests/cindex/test_tls_kind.py

@@ -27,11 +27,21 @@ _Thread_local int tls_static;
     # The following case tests '__declspec(thread)'.  Since it is a Microsoft
     # The following case tests '__declspec(thread)'.  Since it is a Microsoft
     # specific extension, specific flags are required for the parser to pick
     # specific extension, specific flags are required for the parser to pick
     # these up.
     # these up.
-    flags = ['-fms-extensions', '-target', 'x86_64-unknown-windows-win32']
+    flags = ['-fms-extensions', '-target', 'x86_64-unknown-windows-win32',
+             '-fms-compatibility-version=18']
     tu = get_tu("""
     tu = get_tu("""
-__declspec(thread) int tls_declspec;
+__declspec(thread) int tls_declspec_msvc18;
 """, lang = 'cpp', flags=flags)
 """, lang = 'cpp', flags=flags)
 
 
-    tls_declspec = get_cursor(tu.cursor, 'tls_declspec')
-    assert tls_declspec.tls_kind == TLSKind.STATIC
+    tls_declspec_msvc18 = get_cursor(tu.cursor, 'tls_declspec_msvc18')
+    assert tls_declspec_msvc18.tls_kind == TLSKind.STATIC
+
+    flags = ['-fms-extensions', '-target', 'x86_64-unknown-windows-win32',
+             '-fms-compatibility-version=19']
+    tu = get_tu("""
+__declspec(thread) int tls_declspec_msvc19;
+""", lang = 'cpp', flags=flags)
+
+    tls_declspec_msvc19 = get_cursor(tu.cursor, 'tls_declspec_msvc19')
+    assert tls_declspec_msvc19.tls_kind == TLSKind.DYNAMIC
 
 

+ 43 - 0
docs/LanguageExtensions.rst

@@ -436,6 +436,49 @@ const_cast                       no      no      no      no
 
 
 See also :ref:`langext-__builtin_shufflevector`, :ref:`langext-__builtin_convertvector`.
 See also :ref:`langext-__builtin_shufflevector`, :ref:`langext-__builtin_convertvector`.
 
 
+Half-Precision Floating Point
+=============================
+
+Clang supports two half-precision (16-bit) floating point types: ``__fp16`` and
+``_Float16``. ``__fp16`` is defined in the ARM C Language Extensions (`ACLE
+<http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053d/IHI0053D_acle_2_1.pdf>`_)
+and ``_Float16`` in ISO/IEC TS 18661-3:2015.
+
+``__fp16`` is a storage and interchange format only. This means that values of
+``__fp16`` promote to (at least) float when used in arithmetic operations.
+There are two ``__fp16`` formats. Clang supports the IEEE 754-2008 format and
+not the ARM alternative format.
+
+ISO/IEC TS 18661-3:2015 defines C support for additional floating point types.
+``_FloatN`` is defined as a binary floating type, where the N suffix denotes
+the number of bits and is 16, 32, 64, or greater and equal to 128 and a
+multiple of 32. Clang supports ``_Float16``. The difference from ``__fp16`` is
+that arithmetic on ``_Float16`` is performed in half-precision, thus it is not
+a storage-only format. ``_Float16`` is available as a source language type in
+both C and C++ mode.
+
+It is recommended that portable code use the ``_Float16`` type because
+``__fp16`` is an ARM C-Language Extension (ACLE), whereas ``_Float16`` is
+defined by the C standards committee, so using ``_Float16`` will not prevent
+code from being ported to architectures other than Arm.  Also, ``_Float16``
+arithmetic and operations will directly map on half-precision instructions when
+they are available (e.g. Armv8.2-A), avoiding conversions to/from
+single-precision, and thus will result in more performant code. If
+half-precision instructions are unavailable, values will be promoted to
+single-precision, similar to the semantics of ``__fp16`` except that the
+results will be stored in single-precision.
+
+In an arithmetic operation where one operand is of ``__fp16`` type and the
+other is of ``_Float16`` type, the ``_Float16`` type is first converted to
+``__fp16`` type and then the operation is completed as if both operands were of
+``__fp16`` type.
+
+To define a ``_Float16`` literal, suffix ``f16`` can be appended to the compile-time
+constant declaration. There is no default argument promotion for ``_Float16``; this
+applies to the standard floating types only. As a consequence, for example, an
+explicit cast is required for printing a ``_Float16`` value (there is no string
+format specifier for ``_Float16``).
+
 Messages on ``deprecated`` and ``unavailable`` Attributes
 Messages on ``deprecated`` and ``unavailable`` Attributes
 =========================================================
 =========================================================
 
 

+ 2 - 1
docs/ReleaseNotes.rst

@@ -82,7 +82,8 @@ Improvements to Clang's diagnostics
   tautological comparisons between integer variable of the type ``T`` and the
   tautological comparisons between integer variable of the type ``T`` and the
   largest/smallest possible integer constant of that same type.
   largest/smallest possible integer constant of that same type.
 
 
-- For C code, ``-Wsign-compare``, ``-Wtautological-constant-compare`` and
+- For C code, ``-Wsign-compare``, ``-Wsign-conversion``,
+  ``-Wtautological-constant-compare`` and
   ``-Wtautological-constant-out-of-range-compare`` were adjusted to use the
   ``-Wtautological-constant-out-of-range-compare`` were adjusted to use the
   underlying datatype of ``enum``.
   underlying datatype of ``enum``.
 
 

+ 45 - 25
include/clang/AST/CanonicalType.h

@@ -1,4 +1,4 @@
-//===-- CanonicalType.h - C Language Family Type Representation -*- C++ -*-===//
+//===- CanonicalType.h - C Language Family Type Representation --*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -16,13 +16,29 @@
 #define LLVM_CLANG_AST_CANONICALTYPE_H
 #define LLVM_CLANG_AST_CANONICALTYPE_H
 
 
 #include "clang/AST/Type.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/PointerLikeTypeTraits.h"
+#include <cassert>
+#include <iterator>
+#include <type_traits>
 
 
 namespace clang {
 namespace clang {
 
 
 template<typename T> class CanProxy;
 template<typename T> class CanProxy;
 template<typename T> struct CanProxyAdaptor;
 template<typename T> struct CanProxyAdaptor;
+class CXXRecordDecl;
+class EnumDecl;
+class Expr;
+class IdentifierInfo;
+class ObjCInterfaceDecl;
+class RecordDecl;
+class TagDecl;
+class TemplateTypeParmDecl;
 
 
 //----------------------------------------------------------------------------//
 //----------------------------------------------------------------------------//
 // Canonical, qualified type template
 // Canonical, qualified type template
@@ -46,8 +62,6 @@ template<typename T> struct CanProxyAdaptor;
 /// converted to @c CanQual<ReferenceType>. Note that any @c CanQual type can
 /// converted to @c CanQual<ReferenceType>. Note that any @c CanQual type can
 /// be implicitly converted to a QualType, but the reverse operation requires
 /// be implicitly converted to a QualType, but the reverse operation requires
 /// a call to ASTContext::getCanonicalType().
 /// a call to ASTContext::getCanonicalType().
-///
-///
 template<typename T = Type>
 template<typename T = Type>
 class CanQual {
 class CanQual {
   /// \brief The actual, canonical type.
   /// \brief The actual, canonical type.
@@ -55,7 +69,7 @@ class CanQual {
 
 
 public:
 public:
   /// \brief Constructs a NULL canonical type.
   /// \brief Constructs a NULL canonical type.
-  CanQual() : Stored() { }
+  CanQual() = default;
 
 
   /// \brief Converting constructor that permits implicit upcasting of
   /// \brief Converting constructor that permits implicit upcasting of
   /// canonical type pointers.
   /// canonical type pointers.
@@ -66,12 +80,11 @@ public:
   /// \brief Retrieve the underlying type pointer, which refers to a
   /// \brief Retrieve the underlying type pointer, which refers to a
   /// canonical type.
   /// canonical type.
   ///
   ///
-  /// The underlying pointer must not be NULL.
+  /// The underlying pointer must not be nullptr.
   const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
   const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
 
 
   /// \brief Retrieve the underlying type pointer, which refers to a
   /// \brief Retrieve the underlying type pointer, which refers to a
-  /// canonical type, or NULL.
-  ///
+  /// canonical type, or nullptr.
   const T *getTypePtrOrNull() const { 
   const T *getTypePtrOrNull() const { 
     return cast_or_null<T>(Stored.getTypePtrOrNull()); 
     return cast_or_null<T>(Stored.getTypePtrOrNull()); 
   }
   }
@@ -125,9 +138,11 @@ public:
   bool isConstQualified() const {
   bool isConstQualified() const {
     return Stored.isLocalConstQualified();
     return Stored.isLocalConstQualified();
   }
   }
+
   bool isVolatileQualified() const {
   bool isVolatileQualified() const {
     return Stored.isLocalVolatileQualified();
     return Stored.isLocalVolatileQualified();
   }
   }
+
   bool isRestrictQualified() const {
   bool isRestrictQualified() const {
     return Stored.isLocalRestrictQualified();
     return Stored.isLocalRestrictQualified();
   }
   }
@@ -195,7 +210,7 @@ inline bool operator!=(CanQual<T> x, CanQual<U> y) {
 }
 }
 
 
 /// \brief Represents a canonical, potentially-qualified type.
 /// \brief Represents a canonical, potentially-qualified type.
-typedef CanQual<Type> CanQualType;
+using CanQualType = CanQual<Type>;
 
 
 inline CanQualType Type::getCanonicalTypeUnqualified() const {
 inline CanQualType Type::getCanonicalTypeUnqualified() const {
   return CanQualType::CreateUnsafe(getCanonicalTypeInternal());
   return CanQualType::CreateUnsafe(getCanonicalTypeInternal());
@@ -320,7 +335,7 @@ public:
 /// than the more typical @c QualType, to propagate the notion of "canonical"
 /// than the more typical @c QualType, to propagate the notion of "canonical"
 /// through the system.
 /// through the system.
 template<typename T>
 template<typename T>
-struct CanProxyAdaptor : CanProxyBase<T> { };
+struct CanProxyAdaptor : CanProxyBase<T> {};
 
 
 /// \brief Canonical proxy type returned when retrieving the members of a
 /// \brief Canonical proxy type returned when retrieving the members of a
 /// canonical type or as the result of the @c CanQual<T>::getAs member
 /// canonical type or as the result of the @c CanQual<T>::getAs member
@@ -333,7 +348,7 @@ template<typename T>
 class CanProxy : public CanProxyAdaptor<T> {
 class CanProxy : public CanProxyAdaptor<T> {
 public:
 public:
   /// \brief Build a NULL proxy.
   /// \brief Build a NULL proxy.
-  CanProxy() { }
+  CanProxy() = default;
 
 
   /// \brief Build a proxy to the given canonical type.
   /// \brief Build a proxy to the given canonical type.
   CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
   CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
@@ -342,7 +357,7 @@ public:
   operator CanQual<T>() const { return this->Stored; }
   operator CanQual<T>() const { return this->Stored; }
 };
 };
 
 
-} // end namespace clang
+} // namespace clang
 
 
 namespace llvm {
 namespace llvm {
 
 
@@ -350,8 +365,9 @@ namespace llvm {
 /// CanQual<T> to a specific Type class. We're prefer isa/dyn_cast/cast/etc.
 /// CanQual<T> to a specific Type class. We're prefer isa/dyn_cast/cast/etc.
 /// to return smart pointer (proxies?).
 /// to return smart pointer (proxies?).
 template<typename T>
 template<typename T>
-struct simplify_type< ::clang::CanQual<T> > {
-  typedef const T *SimpleType;
+struct simplify_type< ::clang::CanQual<T>> {
+  using SimpleType = const T *;
+
   static SimpleType getSimplifiedValue(::clang::CanQual<T> Val) {
   static SimpleType getSimplifiedValue(::clang::CanQual<T> Val) {
     return Val.getTypePtr();
     return Val.getTypePtr();
   }
   }
@@ -359,18 +375,20 @@ struct simplify_type< ::clang::CanQual<T> > {
 
 
 // Teach SmallPtrSet that CanQual<T> is "basically a pointer".
 // Teach SmallPtrSet that CanQual<T> is "basically a pointer".
 template<typename T>
 template<typename T>
-struct PointerLikeTypeTraits<clang::CanQual<T> > {
-  static inline void *getAsVoidPointer(clang::CanQual<T> P) {
+struct PointerLikeTypeTraits<clang::CanQual<T>> {
+  static void *getAsVoidPointer(clang::CanQual<T> P) {
     return P.getAsOpaquePtr();
     return P.getAsOpaquePtr();
   }
   }
-  static inline clang::CanQual<T> getFromVoidPointer(void *P) {
+
+  static clang::CanQual<T> getFromVoidPointer(void *P) {
     return clang::CanQual<T>::getFromOpaquePtr(P);
     return clang::CanQual<T>::getFromOpaquePtr(P);
   }
   }
+
   // qualifier information is encoded in the low bits.
   // qualifier information is encoded in the low bits.
   enum { NumLowBitsAvailable = 0 };
   enum { NumLowBitsAvailable = 0 };
 };
 };
 
 
-} // end namespace llvm
+} // namespace llvm
 
 
 namespace clang {
 namespace clang {
 
 
@@ -388,7 +406,7 @@ struct CanTypeIterator
           CanQualType,
           CanQualType,
           typename std::iterator_traits<InputIterator>::difference_type,
           typename std::iterator_traits<InputIterator>::difference_type,
           CanProxy<Type>, CanQualType> {
           CanProxy<Type>, CanQualType> {
-  CanTypeIterator() {}
+  CanTypeIterator() = default;
   explicit CanTypeIterator(InputIterator Iter)
   explicit CanTypeIterator(InputIterator Iter)
       : CanTypeIterator::iterator_adaptor_base(std::move(Iter)) {}
       : CanTypeIterator::iterator_adaptor_base(std::move(Iter)) {}
 
 
@@ -486,6 +504,7 @@ struct CanProxyAdaptor<FunctionProtoType>
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasExtParameterInfos)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasExtParameterInfos)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(
             ArrayRef<FunctionProtoType::ExtParameterInfo>, getExtParameterInfos)
             ArrayRef<FunctionProtoType::ExtParameterInfo>, getExtParameterInfos)
+
   CanQualType getParamType(unsigned i) const {
   CanQualType getParamType(unsigned i) const {
     return CanQualType::CreateUnsafe(this->getTypePtr()->getParamType(i));
     return CanQualType::CreateUnsafe(this->getTypePtr()->getParamType(i));
   }
   }
@@ -493,8 +512,8 @@ struct CanProxyAdaptor<FunctionProtoType>
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVariadic)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVariadic)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getTypeQuals)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getTypeQuals)
 
 
-  typedef CanTypeIterator<FunctionProtoType::param_type_iterator>
-  param_type_iterator;
+  using param_type_iterator =
+      CanTypeIterator<FunctionProtoType::param_type_iterator>;
 
 
   param_type_iterator param_type_begin() const {
   param_type_iterator param_type_begin() const {
     return param_type_iterator(this->getTypePtr()->param_type_begin());
     return param_type_iterator(this->getTypePtr()->param_type_begin());
@@ -566,7 +585,8 @@ struct CanProxyAdaptor<ObjCObjectType>
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedId)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedId)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClass)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClass)
 
 
-  typedef ObjCObjectPointerType::qual_iterator qual_iterator;
+  using qual_iterator = ObjCObjectPointerType::qual_iterator;
+
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty)
@@ -584,7 +604,8 @@ struct CanProxyAdaptor<ObjCObjectPointerType>
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedIdType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedIdType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClassType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClassType)
 
 
-  typedef ObjCObjectPointerType::qual_iterator qual_iterator;
+  using qual_iterator = ObjCObjectPointerType::qual_iterator;
+
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty)
@@ -661,7 +682,6 @@ CanProxy<Type> CanTypeIterator<InputIterator>::operator->() const {
   return CanProxy<Type>(*this);
   return CanProxy<Type>(*this);
 }
 }
 
 
-}
-
+} // namespace clang
 
 
-#endif
+#endif // LLVM_CLANG_AST_CANONICALTYPE_H

+ 153 - 114
include/clang/AST/DeclBase.h

@@ -1,4 +1,4 @@
-//===-- DeclBase.h - Base Classes for representing declarations -*- C++ -*-===//
+//===- DeclBase.h - Base Classes for representing declarations --*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -16,33 +16,40 @@
 
 
 #include "clang/AST/AttrIterator.h"
 #include "clang/AST/AttrIterator.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Basic/VersionTuple.h"
 #include "clang/Basic/VersionTuple.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <iterator>
+#include <string>
+#include <type_traits>
+#include <utility>
 
 
 namespace clang {
 namespace clang {
+
+class ASTContext;
 class ASTMutationListener;
 class ASTMutationListener;
-class BlockDecl;
-class CXXRecordDecl;
-class CompoundStmt;
+class Attr;
 class DeclContext;
 class DeclContext;
-class DeclarationName;
-class DependentDiagnostic;
-class EnumDecl;
-class ExportDecl;
 class ExternalSourceSymbolAttr;
 class ExternalSourceSymbolAttr;
 class FunctionDecl;
 class FunctionDecl;
 class FunctionType;
 class FunctionType;
+class IdentifierInfo;
 enum Linkage : unsigned char;
 enum Linkage : unsigned char;
-class LinkageComputer;
 class LinkageSpecDecl;
 class LinkageSpecDecl;
 class Module;
 class Module;
 class NamedDecl;
 class NamedDecl;
-class NamespaceDecl;
 class ObjCCategoryDecl;
 class ObjCCategoryDecl;
 class ObjCCategoryImplDecl;
 class ObjCCategoryImplDecl;
 class ObjCContainerDecl;
 class ObjCContainerDecl;
@@ -53,23 +60,21 @@ class ObjCMethodDecl;
 class ObjCProtocolDecl;
 class ObjCProtocolDecl;
 struct PrintingPolicy;
 struct PrintingPolicy;
 class RecordDecl;
 class RecordDecl;
+class SourceManager;
 class Stmt;
 class Stmt;
 class StoredDeclsMap;
 class StoredDeclsMap;
 class TemplateDecl;
 class TemplateDecl;
 class TranslationUnitDecl;
 class TranslationUnitDecl;
 class UsingDirectiveDecl;
 class UsingDirectiveDecl;
-}
 
 
-namespace clang {
-
-  /// \brief Captures the result of checking the availability of a
-  /// declaration.
-  enum AvailabilityResult {
-    AR_Available = 0,
-    AR_NotYetIntroduced,
-    AR_Deprecated,
-    AR_Unavailable
-  };
+/// \brief Captures the result of checking the availability of a
+/// declaration.
+enum AvailabilityResult {
+  AR_Available = 0,
+  AR_NotYetIntroduced,
+  AR_Deprecated,
+  AR_Unavailable
+};
 
 
 /// Decl - This represents one declaration (or definition), e.g. a variable,
 /// Decl - This represents one declaration (or definition), e.g. a variable,
 /// typedef, function, struct, etc.
 /// typedef, function, struct, etc.
@@ -94,7 +99,7 @@ public:
   /// \brief A placeholder type used to construct an empty shell of a
   /// \brief A placeholder type used to construct an empty shell of a
   /// decl-derived type that will be filled in later (e.g., by some
   /// decl-derived type that will be filled in later (e.g., by some
   /// deserialization method).
   /// deserialization method).
-  struct EmptyShell { };
+  struct EmptyShell {};
 
 
   /// IdentifierNamespace - The different namespaces in which
   /// IdentifierNamespace - The different namespaces in which
   /// declarations may appear.  According to C99 6.2.3, there are
   /// declarations may appear.  According to C99 6.2.3, there are
@@ -208,15 +213,18 @@ public:
   enum class ModuleOwnershipKind : unsigned {
   enum class ModuleOwnershipKind : unsigned {
     /// This declaration is not owned by a module.
     /// This declaration is not owned by a module.
     Unowned,
     Unowned,
+
     /// This declaration has an owning module, but is globally visible
     /// This declaration has an owning module, but is globally visible
     /// (typically because its owning module is visible and we know that
     /// (typically because its owning module is visible and we know that
     /// modules cannot later become hidden in this compilation).
     /// modules cannot later become hidden in this compilation).
     /// After serialization and deserialization, this will be converted
     /// After serialization and deserialization, this will be converted
     /// to VisibleWhenImported.
     /// to VisibleWhenImported.
     Visible,
     Visible,
+
     /// This declaration has an owning module, and is visible when that
     /// This declaration has an owning module, and is visible when that
     /// module is imported.
     /// module is imported.
     VisibleWhenImported,
     VisibleWhenImported,
+
     /// This declaration has an owning module, but is only visible to
     /// This declaration has an owning module, but is only visible to
     /// lookups that occur within that module.
     /// lookups that occur within that module.
     ModulePrivate
     ModulePrivate
@@ -238,7 +246,6 @@ private:
     DeclContext *LexicalDC;
     DeclContext *LexicalDC;
   };
   };
 
 
-
   /// DeclCtx - Holds either a DeclContext* or a MultipleDC*.
   /// DeclCtx - Holds either a DeclContext* or a MultipleDC*.
   /// For declarations that don't contain C++ scope specifiers, it contains
   /// For declarations that don't contain C++ scope specifiers, it contains
   /// the DeclContext where the Decl was declared.
   /// the DeclContext where the Decl was declared.
@@ -254,12 +261,14 @@ private:
   ///                // LexicalDC == global namespace
   ///                // LexicalDC == global namespace
   llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
   llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
 
 
-  inline bool isInSemaDC() const    { return DeclCtx.is<DeclContext*>(); }
-  inline bool isOutOfSemaDC() const { return DeclCtx.is<MultipleDC*>(); }
-  inline MultipleDC *getMultipleDC() const {
+  bool isInSemaDC() const { return DeclCtx.is<DeclContext*>(); }
+  bool isOutOfSemaDC() const { return DeclCtx.is<MultipleDC*>(); }
+
+  MultipleDC *getMultipleDC() const {
     return DeclCtx.get<MultipleDC*>();
     return DeclCtx.get<MultipleDC*>();
   }
   }
-  inline DeclContext *getSemanticDC() const {
+
+  DeclContext *getSemanticDC() const {
     return DeclCtx.get<DeclContext*>();
     return DeclCtx.get<DeclContext*>();
   }
   }
 
 
@@ -298,10 +307,16 @@ private:
   static bool StatisticsEnabled;
   static bool StatisticsEnabled;
 
 
 protected:
 protected:
+  friend class ASTDeclReader;
+  friend class ASTDeclWriter;
+  friend class ASTReader;
+  friend class CXXClassMemberWrapper;
+  friend class LinkageComputer;
+  template<typename decl_type> friend class Redeclarable;
+
   /// Access - Used by C++ decls for the access specifier.
   /// Access - Used by C++ decls for the access specifier.
   // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum
   // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum
   unsigned Access : 2;
   unsigned Access : 2;
-  friend class CXXClassMemberWrapper;
 
 
   /// \brief Whether this declaration was loaded from an AST file.
   /// \brief Whether this declaration was loaded from an AST file.
   unsigned FromASTFile : 1;
   unsigned FromASTFile : 1;
@@ -313,13 +328,6 @@ protected:
   /// Otherwise, it is the linkage + 1.
   /// Otherwise, it is the linkage + 1.
   mutable unsigned CacheValidAndLinkage : 3;
   mutable unsigned CacheValidAndLinkage : 3;
 
 
-  friend class ASTDeclWriter;
-  friend class ASTDeclReader;
-  friend class ASTReader;
-  friend class LinkageComputer;
-
-  template<typename decl_type> friend class Redeclarable;
-
   /// \brief Allocate memory for a deserialized declaration.
   /// \brief Allocate memory for a deserialized declaration.
   ///
   ///
   /// This routine must be used to allocate memory for any declaration that is
   /// This routine must be used to allocate memory for any declaration that is
@@ -357,7 +365,7 @@ private:
 protected:
 protected:
   Decl(Kind DK, DeclContext *DC, SourceLocation L)
   Decl(Kind DK, DeclContext *DC, SourceLocation L)
       : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
       : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
-        DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(0), HasAttrs(false),
+        DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(false), HasAttrs(false),
         Implicit(false), Used(false), Referenced(false),
         Implicit(false), Used(false), Referenced(false),
         TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0),
         TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0),
         IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
         IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
@@ -366,9 +374,9 @@ protected:
   }
   }
 
 
   Decl(Kind DK, EmptyShell Empty)
   Decl(Kind DK, EmptyShell Empty)
-      : NextInContextAndBits(), DeclKind(DK), InvalidDecl(0), HasAttrs(false),
-        Implicit(false), Used(false), Referenced(false),
-        TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0),
+      : DeclKind(DK), InvalidDecl(false), HasAttrs(false), Implicit(false),
+        Used(false), Referenced(false), TopLevelDeclInObjCContainer(false),
+        Access(AS_none), FromASTFile(0),
         IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
         IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
         CacheValidAndLinkage(0) {
         CacheValidAndLinkage(0) {
     if (StatisticsEnabled) add(DK);
     if (StatisticsEnabled) add(DK);
@@ -392,14 +400,15 @@ protected:
   }
   }
 
 
 public:
 public:
-
   /// \brief Source range that this declaration covers.
   /// \brief Source range that this declaration covers.
   virtual SourceRange getSourceRange() const LLVM_READONLY {
   virtual SourceRange getSourceRange() const LLVM_READONLY {
     return SourceRange(getLocation(), getLocation());
     return SourceRange(getLocation(), getLocation());
   }
   }
+
   SourceLocation getLocStart() const LLVM_READONLY {
   SourceLocation getLocStart() const LLVM_READONLY {
     return getSourceRange().getBegin();
     return getSourceRange().getBegin();
   }
   }
+
   SourceLocation getLocEnd() const LLVM_READONLY {
   SourceLocation getLocEnd() const LLVM_READONLY {
     return getSourceRange().getEnd();
     return getSourceRange().getEnd();
   }
   }
@@ -460,12 +469,15 @@ public:
   }
   }
 
 
   bool hasAttrs() const { return HasAttrs; }
   bool hasAttrs() const { return HasAttrs; }
+
   void setAttrs(const AttrVec& Attrs) {
   void setAttrs(const AttrVec& Attrs) {
     return setAttrsImpl(Attrs, getASTContext());
     return setAttrsImpl(Attrs, getASTContext());
   }
   }
+
   AttrVec &getAttrs() {
   AttrVec &getAttrs() {
     return const_cast<AttrVec&>(const_cast<const Decl*>(this)->getAttrs());
     return const_cast<AttrVec&>(const_cast<const Decl*>(this)->getAttrs());
   }
   }
+
   const AttrVec &getAttrs() const;
   const AttrVec &getAttrs() const;
   void dropAttrs();
   void dropAttrs();
 
 
@@ -476,8 +488,8 @@ public:
       setAttrs(AttrVec(1, A));
       setAttrs(AttrVec(1, A));
   }
   }
 
 
-  typedef AttrVec::const_iterator attr_iterator;
-  typedef llvm::iterator_range<attr_iterator> attr_range;
+  using attr_iterator = AttrVec::const_iterator;
+  using attr_range = llvm::iterator_range<attr_iterator>;
 
 
   attr_range attrs() const {
   attr_range attrs() const {
     return attr_range(attr_begin(), attr_end());
     return attr_range(attr_begin(), attr_end());
@@ -510,6 +522,7 @@ public:
   specific_attr_iterator<T> specific_attr_begin() const {
   specific_attr_iterator<T> specific_attr_begin() const {
     return specific_attr_iterator<T>(attr_begin());
     return specific_attr_iterator<T>(attr_begin());
   }
   }
+
   template <typename T>
   template <typename T>
   specific_attr_iterator<T> specific_attr_end() const {
   specific_attr_iterator<T> specific_attr_end() const {
     return specific_attr_iterator<T>(attr_end());
     return specific_attr_iterator<T>(attr_end());
@@ -518,6 +531,7 @@ public:
   template<typename T> T *getAttr() const {
   template<typename T> T *getAttr() const {
     return hasAttrs() ? getSpecificAttr<T>(getAttrs()) : nullptr;
     return hasAttrs() ? getSpecificAttr<T>(getAttrs()) : nullptr;
   }
   }
+
   template<typename T> bool hasAttr() const {
   template<typename T> bool hasAttr() const {
     return hasAttrs() && hasSpecificAttr<T>(getAttrs());
     return hasAttrs() && hasSpecificAttr<T>(getAttrs());
   }
   }
@@ -616,7 +630,6 @@ protected:
   }
   }
   
   
 public:
 public:
-  
   /// \brief Determine the availability of the given declaration.
   /// \brief Determine the availability of the given declaration.
   ///
   ///
   /// This routine will determine the most restrictive availability of
   /// This routine will determine the most restrictive availability of
@@ -698,6 +711,7 @@ public:
 
 
 private:
 private:
   Module *getOwningModuleSlow() const;
   Module *getOwningModuleSlow() const;
+
 protected:
 protected:
   bool hasLocalOwningModuleStorage() const;
   bool hasLocalOwningModuleStorage() const;
 
 
@@ -777,14 +791,17 @@ public:
   unsigned getIdentifierNamespace() const {
   unsigned getIdentifierNamespace() const {
     return IdentifierNamespace;
     return IdentifierNamespace;
   }
   }
+
   bool isInIdentifierNamespace(unsigned NS) const {
   bool isInIdentifierNamespace(unsigned NS) const {
     return getIdentifierNamespace() & NS;
     return getIdentifierNamespace() & NS;
   }
   }
+
   static unsigned getIdentifierNamespaceForKind(Kind DK);
   static unsigned getIdentifierNamespaceForKind(Kind DK);
 
 
   bool hasTagIdentifierNamespace() const {
   bool hasTagIdentifierNamespace() const {
     return isTagIdentifierNamespace(getIdentifierNamespace());
     return isTagIdentifierNamespace(getIdentifierNamespace());
   }
   }
+
   static bool isTagIdentifierNamespace(unsigned NS) {
   static bool isTagIdentifierNamespace(unsigned NS) {
     // TagDecls have Tag and Type set and may also have TagFriend.
     // TagDecls have Tag and Type set and may also have TagFriend.
     return (NS & ~IDNS_TagFriend) == (IDNS_Tag | IDNS_Type);
     return (NS & ~IDNS_TagFriend) == (IDNS_Tag | IDNS_Type);
@@ -872,18 +889,18 @@ public:
   /// \brief Iterates through all the redeclarations of the same decl.
   /// \brief Iterates through all the redeclarations of the same decl.
   class redecl_iterator {
   class redecl_iterator {
     /// Current - The current declaration.
     /// Current - The current declaration.
-    Decl *Current;
+    Decl *Current = nullptr;
     Decl *Starter;
     Decl *Starter;
 
 
   public:
   public:
-    typedef Decl *value_type;
-    typedef const value_type &reference;
-    typedef const value_type *pointer;
-    typedef std::forward_iterator_tag iterator_category;
-    typedef std::ptrdiff_t difference_type;
+    using value_type = Decl *;
+    using reference = const value_type &;
+    using pointer = const value_type *;
+    using iterator_category = std::forward_iterator_tag;
+    using difference_type = std::ptrdiff_t;
 
 
-    redecl_iterator() : Current(nullptr) { }
-    explicit redecl_iterator(Decl *C) : Current(C), Starter(C) { }
+    redecl_iterator() = default;
+    explicit redecl_iterator(Decl *C) : Current(C), Starter(C) {}
 
 
     reference operator*() const { return Current; }
     reference operator*() const { return Current; }
     value_type operator->() const { return Current; }
     value_type operator->() const { return Current; }
@@ -906,12 +923,13 @@ public:
     friend bool operator==(redecl_iterator x, redecl_iterator y) {
     friend bool operator==(redecl_iterator x, redecl_iterator y) {
       return x.Current == y.Current;
       return x.Current == y.Current;
     }
     }
+
     friend bool operator!=(redecl_iterator x, redecl_iterator y) {
     friend bool operator!=(redecl_iterator x, redecl_iterator y) {
       return x.Current != y.Current;
       return x.Current != y.Current;
     }
     }
   };
   };
 
 
-  typedef llvm::iterator_range<redecl_iterator> redecl_range;
+  using redecl_range = llvm::iterator_range<redecl_iterator>;
 
 
   /// \brief Returns an iterator range for all the redeclarations of the same
   /// \brief Returns an iterator range for all the redeclarations of the same
   /// decl. It will iterate at least once (when this decl is the only one).
   /// decl. It will iterate at least once (when this decl is the only one).
@@ -922,6 +940,7 @@ public:
   redecl_iterator redecls_begin() const {
   redecl_iterator redecls_begin() const {
     return redecl_iterator(const_cast<Decl *>(this));
     return redecl_iterator(const_cast<Decl *>(this));
   }
   }
+
   redecl_iterator redecls_end() const { return redecl_iterator(); }
   redecl_iterator redecls_end() const { return redecl_iterator(); }
 
 
   /// \brief Retrieve the previous declaration that declares the same entity
   /// \brief Retrieve the previous declaration that declares the same entity
@@ -1103,10 +1122,13 @@ public:
   static void printGroup(Decl** Begin, unsigned NumDecls,
   static void printGroup(Decl** Begin, unsigned NumDecls,
                          raw_ostream &Out, const PrintingPolicy &Policy,
                          raw_ostream &Out, const PrintingPolicy &Policy,
                          unsigned Indentation = 0);
                          unsigned Indentation = 0);
+
   // Debuggers don't usually respect default arguments.
   // Debuggers don't usually respect default arguments.
   void dump() const;
   void dump() const;
+
   // Same as dump(), but forces color printing.
   // Same as dump(), but forces color printing.
   void dumpColor() const;
   void dumpColor() const;
+
   void dump(raw_ostream &Out, bool Deserialize = false) const;
   void dump(raw_ostream &Out, bool Deserialize = false) const;
 
 
   /// \brief Looks through the Decl's underlying type to extract a FunctionType
   /// \brief Looks through the Decl's underlying type to extract a FunctionType
@@ -1141,10 +1163,11 @@ class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry {
   SourceLocation Loc;
   SourceLocation Loc;
   SourceManager &SM;
   SourceManager &SM;
   const char *Message;
   const char *Message;
+
 public:
 public:
   PrettyStackTraceDecl(const Decl *theDecl, SourceLocation L,
   PrettyStackTraceDecl(const Decl *theDecl, SourceLocation L,
                        SourceManager &sm, const char *Msg)
                        SourceManager &sm, const char *Msg)
-  : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
+      : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
 
 
   void print(raw_ostream &OS) const override;
   void print(raw_ostream &OS) const override;
 };
 };
@@ -1153,30 +1176,35 @@ public:
 /// single result (with no stable storage) or a collection of results (with
 /// single result (with no stable storage) or a collection of results (with
 /// stable storage provided by the lookup table).
 /// stable storage provided by the lookup table).
 class DeclContextLookupResult {
 class DeclContextLookupResult {
-  typedef ArrayRef<NamedDecl *> ResultTy;
+  using ResultTy = ArrayRef<NamedDecl *>;
+
   ResultTy Result;
   ResultTy Result;
+
   // If there is only one lookup result, it would be invalidated by
   // If there is only one lookup result, it would be invalidated by
   // reallocations of the name table, so store it separately.
   // reallocations of the name table, so store it separately.
-  NamedDecl *Single;
+  NamedDecl *Single = nullptr;
 
 
   static NamedDecl *const SingleElementDummyList;
   static NamedDecl *const SingleElementDummyList;
 
 
 public:
 public:
-  DeclContextLookupResult() : Result(), Single() {}
+  DeclContextLookupResult() = default;
   DeclContextLookupResult(ArrayRef<NamedDecl *> Result)
   DeclContextLookupResult(ArrayRef<NamedDecl *> Result)
-      : Result(Result), Single() {}
+      : Result(Result) {}
   DeclContextLookupResult(NamedDecl *Single)
   DeclContextLookupResult(NamedDecl *Single)
       : Result(SingleElementDummyList), Single(Single) {}
       : Result(SingleElementDummyList), Single(Single) {}
 
 
   class iterator;
   class iterator;
-  typedef llvm::iterator_adaptor_base<iterator, ResultTy::iterator,
-                                      std::random_access_iterator_tag,
-                                      NamedDecl *const> IteratorBase;
+
+  using IteratorBase =
+      llvm::iterator_adaptor_base<iterator, ResultTy::iterator,
+                                  std::random_access_iterator_tag,
+                                  NamedDecl *const>;
+
   class iterator : public IteratorBase {
   class iterator : public IteratorBase {
     value_type SingleElement;
     value_type SingleElement;
 
 
   public:
   public:
-    iterator() : IteratorBase(), SingleElement() {}
+    iterator() = default;
     explicit iterator(pointer Pos, value_type Single = nullptr)
     explicit iterator(pointer Pos, value_type Single = nullptr)
         : IteratorBase(Pos), SingleElement(Single) {}
         : IteratorBase(Pos), SingleElement(Single) {}
 
 
@@ -1184,9 +1212,10 @@ public:
       return SingleElement ? SingleElement : IteratorBase::operator*();
       return SingleElement ? SingleElement : IteratorBase::operator*();
     }
     }
   };
   };
-  typedef iterator const_iterator;
-  typedef iterator::pointer pointer;
-  typedef iterator::reference reference;
+
+  using const_iterator = iterator;
+  using pointer = iterator::pointer;
+  using reference = iterator::reference;
 
 
   iterator begin() const { return iterator(Result.begin(), Single); }
   iterator begin() const { return iterator(Result.begin(), Single); }
   iterator end() const { return iterator(Result.end(), Single); }
   iterator end() const { return iterator(Result.end(), Single); }
@@ -1220,7 +1249,6 @@ public:
 ///   ExportDecl
 ///   ExportDecl
 ///   BlockDecl
 ///   BlockDecl
 ///   OMPDeclareReductionDecl
 ///   OMPDeclareReductionDecl
-///
 class DeclContext {
 class DeclContext {
   /// DeclKind - This indicates which class this is.
   /// DeclKind - This indicates which class this is.
   unsigned DeclKind : 8;
   unsigned DeclKind : 8;
@@ -1260,22 +1288,22 @@ class DeclContext {
   /// contains an entry for a DeclarationName (and we haven't lazily
   /// contains an entry for a DeclarationName (and we haven't lazily
   /// omitted anything), then it contains all relevant entries for that
   /// omitted anything), then it contains all relevant entries for that
   /// name (modulo the hasExternalDecls() flag).
   /// name (modulo the hasExternalDecls() flag).
-  mutable StoredDeclsMap *LookupPtr;
+  mutable StoredDeclsMap *LookupPtr = nullptr;
 
 
 protected:
 protected:
+  friend class ASTDeclReader;
+  friend class ASTWriter;
+  friend class ExternalASTSource;
+
   /// FirstDecl - The first declaration stored within this declaration
   /// FirstDecl - The first declaration stored within this declaration
   /// context.
   /// context.
-  mutable Decl *FirstDecl;
+  mutable Decl *FirstDecl = nullptr;
 
 
   /// LastDecl - The last declaration stored within this declaration
   /// LastDecl - The last declaration stored within this declaration
   /// context. FIXME: We could probably cache this value somewhere
   /// context. FIXME: We could probably cache this value somewhere
   /// outside of the DeclContext, to reduce the size of DeclContext by
   /// outside of the DeclContext, to reduce the size of DeclContext by
   /// another pointer.
   /// another pointer.
-  mutable Decl *LastDecl;
-
-  friend class ExternalASTSource;
-  friend class ASTDeclReader;
-  friend class ASTWriter;
+  mutable Decl *LastDecl = nullptr;
 
 
   /// \brief Build up a chain of declarations.
   /// \brief Build up a chain of declarations.
   ///
   ///
@@ -1288,8 +1316,7 @@ protected:
         ExternalVisibleStorage(false),
         ExternalVisibleStorage(false),
         NeedToReconcileExternalVisibleStorage(false),
         NeedToReconcileExternalVisibleStorage(false),
         HasLazyLocalLexicalLookups(false), HasLazyExternalLexicalLookups(false),
         HasLazyLocalLexicalLookups(false), HasLazyExternalLexicalLookups(false),
-        UseQualifiedLookup(false),
-        LookupPtr(nullptr), FirstDecl(nullptr), LastDecl(nullptr) {}
+        UseQualifiedLookup(false) {}
 
 
 public:
 public:
   ~DeclContext();
   ~DeclContext();
@@ -1297,6 +1324,7 @@ public:
   Decl::Kind getDeclKind() const {
   Decl::Kind getDeclKind() const {
     return static_cast<Decl::Kind>(DeclKind);
     return static_cast<Decl::Kind>(DeclKind);
   }
   }
+
   const char *getDeclKindName() const;
   const char *getDeclKindName() const;
 
 
   /// getParent - Returns the containing DeclContext.
   /// getParent - Returns the containing DeclContext.
@@ -1504,19 +1532,20 @@ public:
   /// within this context.
   /// within this context.
   class decl_iterator {
   class decl_iterator {
     /// Current - The current declaration.
     /// Current - The current declaration.
-    Decl *Current;
+    Decl *Current = nullptr;
 
 
   public:
   public:
-    typedef Decl *value_type;
-    typedef const value_type &reference;
-    typedef const value_type *pointer;
-    typedef std::forward_iterator_tag iterator_category;
-    typedef std::ptrdiff_t            difference_type;
+    using value_type = Decl *;
+    using reference = const value_type &;
+    using pointer = const value_type *;
+    using iterator_category = std::forward_iterator_tag;
+    using difference_type = std::ptrdiff_t;
 
 
-    decl_iterator() : Current(nullptr) { }
-    explicit decl_iterator(Decl *C) : Current(C) { }
+    decl_iterator() = default;
+    explicit decl_iterator(Decl *C) : Current(C) {}
 
 
     reference operator*() const { return Current; }
     reference operator*() const { return Current; }
+
     // This doesn't meet the iterator requirements, but it's convenient
     // This doesn't meet the iterator requirements, but it's convenient
     value_type operator->() const { return Current; }
     value_type operator->() const { return Current; }
 
 
@@ -1534,12 +1563,13 @@ public:
     friend bool operator==(decl_iterator x, decl_iterator y) {
     friend bool operator==(decl_iterator x, decl_iterator y) {
       return x.Current == y.Current;
       return x.Current == y.Current;
     }
     }
+
     friend bool operator!=(decl_iterator x, decl_iterator y) {
     friend bool operator!=(decl_iterator x, decl_iterator y) {
       return x.Current != y.Current;
       return x.Current != y.Current;
     }
     }
   };
   };
 
 
-  typedef llvm::iterator_range<decl_iterator> decl_range;
+  using decl_range = llvm::iterator_range<decl_iterator>;
 
 
   /// decls_begin/decls_end - Iterate over the declarations stored in
   /// decls_begin/decls_end - Iterate over the declarations stored in
   /// this context.
   /// this context.
@@ -1578,16 +1608,16 @@ public:
     }
     }
 
 
   public:
   public:
-    typedef SpecificDecl *value_type;
-    // TODO: Add reference and pointer typedefs (with some appropriate proxy
-    // type) if we ever have a need for them.
-    typedef void reference;
-    typedef void pointer;
-    typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
-      difference_type;
-    typedef std::forward_iterator_tag iterator_category;
+    using value_type = SpecificDecl *;
+    // TODO: Add reference and pointer types (with some appropriate proxy type)
+    // if we ever have a need for them.
+    using reference = void;
+    using pointer = void;
+    using difference_type =
+        std::iterator_traits<DeclContext::decl_iterator>::difference_type;
+    using iterator_category = std::forward_iterator_tag;
 
 
-    specific_decl_iterator() : Current() { }
+    specific_decl_iterator() = default;
 
 
     /// specific_decl_iterator - Construct a new iterator over a
     /// specific_decl_iterator - Construct a new iterator over a
     /// subset of the declarations the range [C,
     /// subset of the declarations the range [C,
@@ -1602,6 +1632,7 @@ public:
     }
     }
 
 
     value_type operator*() const { return cast<SpecificDecl>(*Current); }
     value_type operator*() const { return cast<SpecificDecl>(*Current); }
+
     // This doesn't meet the iterator requirements, but it's convenient
     // This doesn't meet the iterator requirements, but it's convenient
     value_type operator->() const { return **this; }
     value_type operator->() const { return **this; }
 
 
@@ -1655,16 +1686,16 @@ public:
     }
     }
 
 
   public:
   public:
-    typedef SpecificDecl *value_type;
-    // TODO: Add reference and pointer typedefs (with some appropriate proxy
-    // type) if we ever have a need for them.
-    typedef void reference;
-    typedef void pointer;
-    typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
-      difference_type;
-    typedef std::forward_iterator_tag iterator_category;
+    using value_type = SpecificDecl *;
+    // TODO: Add reference and pointer types (with some appropriate proxy type)
+    // if we ever have a need for them.
+    using reference = void;
+    using pointer = void;
+    using difference_type =
+        std::iterator_traits<DeclContext::decl_iterator>::difference_type;
+    using iterator_category = std::forward_iterator_tag;
 
 
-    filtered_decl_iterator() : Current() { }
+    filtered_decl_iterator() = default;
 
 
     /// filtered_decl_iterator - Construct a new iterator over a
     /// filtered_decl_iterator - Construct a new iterator over a
     /// subset of the declarations the range [C,
     /// subset of the declarations the range [C,
@@ -1742,8 +1773,8 @@ public:
   /// @brief Checks whether a declaration is in this context.
   /// @brief Checks whether a declaration is in this context.
   bool containsDecl(Decl *D) const;
   bool containsDecl(Decl *D) const;
 
 
-  typedef DeclContextLookupResult lookup_result;
-  typedef lookup_result::iterator lookup_iterator;
+  using lookup_result = DeclContextLookupResult;
+  using lookup_iterator = lookup_result::iterator;
 
 
   /// lookup - Find the declarations (if any) with the given Name in
   /// lookup - Find the declarations (if any) with the given Name in
   /// this context. Returns a range of iterators that contains all of
   /// this context. Returns a range of iterators that contains all of
@@ -1789,7 +1820,7 @@ public:
   /// of looking up every possible name.
   /// of looking up every possible name.
   class all_lookups_iterator;
   class all_lookups_iterator;
 
 
-  typedef llvm::iterator_range<all_lookups_iterator> lookups_range;
+  using lookups_range = llvm::iterator_range<all_lookups_iterator>;
 
 
   lookups_range lookups() const;
   lookups_range lookups() const;
   lookups_range noload_lookups() const;
   lookups_range noload_lookups() const;
@@ -1805,21 +1836,26 @@ public:
   all_lookups_iterator noload_lookups_end() const;
   all_lookups_iterator noload_lookups_end() const;
 
 
   struct udir_iterator;
   struct udir_iterator;
-  typedef llvm::iterator_adaptor_base<udir_iterator, lookup_iterator,
-                                      std::random_access_iterator_tag,
-                                      UsingDirectiveDecl *> udir_iterator_base;
+
+  using udir_iterator_base =
+      llvm::iterator_adaptor_base<udir_iterator, lookup_iterator,
+                                  std::random_access_iterator_tag,
+                                  UsingDirectiveDecl *>;
+
   struct udir_iterator : udir_iterator_base {
   struct udir_iterator : udir_iterator_base {
     udir_iterator(lookup_iterator I) : udir_iterator_base(I) {}
     udir_iterator(lookup_iterator I) : udir_iterator_base(I) {}
+
     UsingDirectiveDecl *operator*() const;
     UsingDirectiveDecl *operator*() const;
   };
   };
 
 
-  typedef llvm::iterator_range<udir_iterator> udir_range;
+  using udir_range = llvm::iterator_range<udir_iterator>;
 
 
   udir_range using_directives() const;
   udir_range using_directives() const;
 
 
   // These are all defined in DependentDiagnostic.h.
   // These are all defined in DependentDiagnostic.h.
   class ddiag_iterator;
   class ddiag_iterator;
-  typedef llvm::iterator_range<DeclContext::ddiag_iterator> ddiag_range;
+
+  using ddiag_range = llvm::iterator_range<DeclContext::ddiag_iterator>;
 
 
   inline ddiag_range ddiags() const;
   inline ddiag_range ddiags() const;
 
 
@@ -1892,6 +1928,8 @@ public:
                    bool Deserialize = false) const;
                    bool Deserialize = false) const;
 
 
 private:
 private:
+  friend class DependentDiagnostic;
+
   void reconcileExternalVisibleStorage() const;
   void reconcileExternalVisibleStorage() const;
   bool LoadLexicalDeclsFromExternalStorage() const;
   bool LoadLexicalDeclsFromExternalStorage() const;
 
 
@@ -1903,7 +1941,6 @@ private:
   /// use of addDeclInternal().
   /// use of addDeclInternal().
   void makeDeclVisibleInContextInternal(NamedDecl *D);
   void makeDeclVisibleInContextInternal(NamedDecl *D);
 
 
-  friend class DependentDiagnostic;
   StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const;
   StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const;
 
 
   void buildLookupImpl(DeclContext *DCtx, bool Internal);
   void buildLookupImpl(DeclContext *DCtx, bool Internal);
@@ -1942,8 +1979,7 @@ struct cast_convert_decl_context<ToTy, true> {
   }
   }
 };
 };
 
 
-
-} // end clang.
+} // namespace clang
 
 
 namespace llvm {
 namespace llvm {
 
 
@@ -1963,12 +1999,14 @@ struct cast_convert_val<ToTy,
     return *::clang::cast_convert_decl_context<ToTy>::doit(&Val);
     return *::clang::cast_convert_decl_context<ToTy>::doit(&Val);
   }
   }
 };
 };
+
 template<class ToTy>
 template<class ToTy>
 struct cast_convert_val<ToTy, ::clang::DeclContext, ::clang::DeclContext> {
 struct cast_convert_val<ToTy, ::clang::DeclContext, ::clang::DeclContext> {
   static ToTy &doit(::clang::DeclContext &Val) {
   static ToTy &doit(::clang::DeclContext &Val) {
     return *::clang::cast_convert_decl_context<ToTy>::doit(&Val);
     return *::clang::cast_convert_decl_context<ToTy>::doit(&Val);
   }
   }
 };
 };
+
 template<class ToTy>
 template<class ToTy>
 struct cast_convert_val<ToTy,
 struct cast_convert_val<ToTy,
                      const ::clang::DeclContext*, const ::clang::DeclContext*> {
                      const ::clang::DeclContext*, const ::clang::DeclContext*> {
@@ -1976,6 +2014,7 @@ struct cast_convert_val<ToTy,
     return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
     return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
   }
   }
 };
 };
+
 template<class ToTy>
 template<class ToTy>
 struct cast_convert_val<ToTy, ::clang::DeclContext*, ::clang::DeclContext*> {
 struct cast_convert_val<ToTy, ::clang::DeclContext*, ::clang::DeclContext*> {
   static ToTy *doit(::clang::DeclContext *Val) {
   static ToTy *doit(::clang::DeclContext *Val) {
@@ -2012,6 +2051,6 @@ struct cast_convert_val< const ::clang::DeclContext, FromTy*, FromTy*> {
   }
   }
 };
 };
 
 
-} // end namespace llvm
+} // namespace llvm
 
 
-#endif
+#endif // LLVM_CLANG_AST_DECLBASE_H

+ 66 - 37
include/clang/AST/ExternalASTSource.h

@@ -1,4 +1,4 @@
-//===--- ExternalASTSource.h - Abstract External AST Interface --*- C++ -*-===//
+//===- ExternalASTSource.h - Abstract External AST Interface ----*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -11,24 +11,44 @@
 //  construction of AST nodes from some external source.
 //  construction of AST nodes from some external source.
 //
 //
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CLANG_AST_EXTERNALASTSOURCE_H
 #ifndef LLVM_CLANG_AST_EXTERNALASTSOURCE_H
 #define LLVM_CLANG_AST_EXTERNALASTSOURCE_H
 #define LLVM_CLANG_AST_EXTERNALASTSOURCE_H
 
 
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/Module.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/Support/PointerLikeTypeTraits.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <iterator>
+#include <string>
+#include <utility>
 
 
 namespace clang {
 namespace clang {
 
 
 class ASTConsumer;
 class ASTConsumer;
+class ASTContext;
 class CXXBaseSpecifier;
 class CXXBaseSpecifier;
 class CXXCtorInitializer;
 class CXXCtorInitializer;
+class CXXRecordDecl;
 class DeclarationName;
 class DeclarationName;
-class ExternalSemaSource; // layering violation required for downcasting
 class FieldDecl;
 class FieldDecl;
-class Module;
+class IdentifierInfo;
 class NamedDecl;
 class NamedDecl;
+class ObjCInterfaceDecl;
 class RecordDecl;
 class RecordDecl;
 class Selector;
 class Selector;
 class Stmt;
 class Stmt;
@@ -42,30 +62,31 @@ class TagDecl;
 /// actual type and declaration nodes, and read parts of declaration
 /// actual type and declaration nodes, and read parts of declaration
 /// contexts.
 /// contexts.
 class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
 class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
+  friend class ExternalSemaSource;
+
   /// Generation number for this external AST source. Must be increased
   /// Generation number for this external AST source. Must be increased
   /// whenever we might have added new redeclarations for existing decls.
   /// whenever we might have added new redeclarations for existing decls.
-  uint32_t CurrentGeneration;
+  uint32_t CurrentGeneration = 0;
 
 
   /// \brief Whether this AST source also provides information for
   /// \brief Whether this AST source also provides information for
   /// semantic analysis.
   /// semantic analysis.
-  bool SemaSource;
-
-  friend class ExternalSemaSource;
+  bool SemaSource = false;
 
 
 public:
 public:
-  ExternalASTSource() : CurrentGeneration(0), SemaSource(false) { }
-
+  ExternalASTSource() = default;
   virtual ~ExternalASTSource();
   virtual ~ExternalASTSource();
 
 
   /// \brief RAII class for safely pairing a StartedDeserializing call
   /// \brief RAII class for safely pairing a StartedDeserializing call
   /// with FinishedDeserializing.
   /// with FinishedDeserializing.
   class Deserializing {
   class Deserializing {
     ExternalASTSource *Source;
     ExternalASTSource *Source;
+
   public:
   public:
     explicit Deserializing(ExternalASTSource *source) : Source(source) {
     explicit Deserializing(ExternalASTSource *source) : Source(source) {
       assert(Source);
       assert(Source);
       Source->StartedDeserializing();
       Source->StartedDeserializing();
     }
     }
+
     ~Deserializing() {
     ~Deserializing() {
       Source->FinishedDeserializing();
       Source->FinishedDeserializing();
     }
     }
@@ -122,7 +143,7 @@ public:
   virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);
   virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);
 
 
   /// \brief Update an out-of-date identifier.
   /// \brief Update an out-of-date identifier.
-  virtual void updateOutOfDateIdentifier(IdentifierInfo &II) { }
+  virtual void updateOutOfDateIdentifier(IdentifierInfo &II) {}
 
 
   /// \brief Find all declarations with the given name in the given context,
   /// \brief Find all declarations with the given name in the given context,
   /// and add them to the context by calling SetExternalVisibleDeclsForName
   /// and add them to the context by calling SetExternalVisibleDeclsForName
@@ -154,12 +175,13 @@ public:
     const Module *ClangModule = nullptr;
     const Module *ClangModule = nullptr;
 
 
   public:
   public:
-    ASTSourceDescriptor(){};
+    ASTSourceDescriptor() = default;
     ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
     ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
                         ASTFileSignature Signature)
                         ASTFileSignature Signature)
         : PCHModuleName(std::move(Name)), Path(std::move(Path)),
         : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-          ASTFile(std::move(ASTFile)), Signature(Signature){};
+          ASTFile(std::move(ASTFile)), Signature(Signature) {}
     ASTSourceDescriptor(const Module &M);
     ASTSourceDescriptor(const Module &M);
+
     std::string getModuleName() const;
     std::string getModuleName() const;
     StringRef getPath() const { return Path; }
     StringRef getPath() const { return Path; }
     StringRef getASTFile() const { return ASTFile; }
     StringRef getASTFile() const { return ASTFile; }
@@ -246,7 +268,6 @@ public:
   /// The default implementation of this method is a no-op.
   /// The default implementation of this method is a no-op.
   virtual void PrintStats();
   virtual void PrintStats();
   
   
-  
   /// \brief Perform layout on the given record.
   /// \brief Perform layout on the given record.
   ///
   ///
   /// This routine allows the external AST source to provide an specific 
   /// This routine allows the external AST source to provide an specific 
@@ -289,7 +310,7 @@ public:
     size_t mmap_bytes;
     size_t mmap_bytes;
     
     
     MemoryBufferSizes(size_t malloc_bytes, size_t mmap_bytes)
     MemoryBufferSizes(size_t malloc_bytes, size_t mmap_bytes)
-    : malloc_bytes(malloc_bytes), mmap_bytes(mmap_bytes) {}
+        : malloc_bytes(malloc_bytes), mmap_bytes(mmap_bytes) {}
   };
   };
   
   
   /// Return the amount of memory used by memory buffers, breaking down
   /// Return the amount of memory used by memory buffers, breaking down
@@ -329,12 +350,12 @@ struct LazyOffsetPtr {
   ///
   ///
   /// If the low bit is clear, a pointer to the AST node. If the low
   /// If the low bit is clear, a pointer to the AST node. If the low
   /// bit is set, the upper 63 bits are the offset.
   /// bit is set, the upper 63 bits are the offset.
-  mutable uint64_t Ptr;
+  mutable uint64_t Ptr = 0;
 
 
 public:
 public:
-  LazyOffsetPtr() : Ptr(0) { }
+  LazyOffsetPtr() = default;
+  explicit LazyOffsetPtr(T *Ptr) : Ptr(reinterpret_cast<uint64_t>(Ptr)) {}
 
 
-  explicit LazyOffsetPtr(T *Ptr) : Ptr(reinterpret_cast<uint64_t>(Ptr)) { }
   explicit LazyOffsetPtr(uint64_t Offset) : Ptr((Offset << 1) | 0x01) {
   explicit LazyOffsetPtr(uint64_t Offset) : Ptr((Offset << 1) | 0x01) {
     assert((Offset << 1 >> 1) == Offset && "Offsets must require < 63 bits");
     assert((Offset << 1 >> 1) == Offset && "Offsets must require < 63 bits");
     if (Offset == 0)
     if (Offset == 0)
@@ -392,15 +413,16 @@ struct LazyGenerationalUpdatePtr {
   /// A cache of the value of this pointer, in the most recent generation in
   /// A cache of the value of this pointer, in the most recent generation in
   /// which we queried it.
   /// which we queried it.
   struct LazyData {
   struct LazyData {
-    LazyData(ExternalASTSource *Source, T Value)
-        : ExternalSource(Source), LastGeneration(0), LastValue(Value) {}
     ExternalASTSource *ExternalSource;
     ExternalASTSource *ExternalSource;
-    uint32_t LastGeneration;
+    uint32_t LastGeneration = 0;
     T LastValue;
     T LastValue;
+
+    LazyData(ExternalASTSource *Source, T Value)
+        : ExternalSource(Source), LastValue(Value) {}
   };
   };
 
 
   // Our value is represented as simply T if there is no external AST source.
   // Our value is represented as simply T if there is no external AST source.
-  typedef llvm::PointerUnion<T, LazyData*> ValueType;
+  using ValueType = llvm::PointerUnion<T, LazyData*>;
   ValueType Value;
   ValueType Value;
 
 
   LazyGenerationalUpdatePtr(ValueType V) : Value(V) {}
   LazyGenerationalUpdatePtr(ValueType V) : Value(V) {}
@@ -459,25 +481,31 @@ public:
     return LazyGenerationalUpdatePtr(ValueType::getFromOpaqueValue(Ptr));
     return LazyGenerationalUpdatePtr(ValueType::getFromOpaqueValue(Ptr));
   }
   }
 };
 };
-} // end namespace clang
+
+} // namespace clang
 
 
 /// Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be
 /// Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be
 /// placed into a PointerUnion.
 /// placed into a PointerUnion.
 namespace llvm {
 namespace llvm {
+
 template<typename Owner, typename T,
 template<typename Owner, typename T,
          void (clang::ExternalASTSource::*Update)(Owner)>
          void (clang::ExternalASTSource::*Update)(Owner)>
 struct PointerLikeTypeTraits<
 struct PointerLikeTypeTraits<
     clang::LazyGenerationalUpdatePtr<Owner, T, Update>> {
     clang::LazyGenerationalUpdatePtr<Owner, T, Update>> {
-  typedef clang::LazyGenerationalUpdatePtr<Owner, T, Update> Ptr;
+  using Ptr = clang::LazyGenerationalUpdatePtr<Owner, T, Update>;
+
   static void *getAsVoidPointer(Ptr P) { return P.getOpaqueValue(); }
   static void *getAsVoidPointer(Ptr P) { return P.getOpaqueValue(); }
   static Ptr getFromVoidPointer(void *P) { return Ptr::getFromOpaqueValue(P); }
   static Ptr getFromVoidPointer(void *P) { return Ptr::getFromOpaqueValue(P); }
+
   enum {
   enum {
     NumLowBitsAvailable = PointerLikeTypeTraits<T>::NumLowBitsAvailable - 1
     NumLowBitsAvailable = PointerLikeTypeTraits<T>::NumLowBitsAvailable - 1
   };
   };
 };
 };
-}
+
+} // namespace llvm
 
 
 namespace clang {
 namespace clang {
+
 /// \brief Represents a lazily-loaded vector of data.
 /// \brief Represents a lazily-loaded vector of data.
 ///
 ///
 /// The lazily-loaded vector of data contains data that is partially loaded
 /// The lazily-loaded vector of data contains data that is partially loaded
@@ -511,13 +539,14 @@ public:
   class iterator
   class iterator
       : public llvm::iterator_adaptor_base<
       : public llvm::iterator_adaptor_base<
             iterator, int, std::random_access_iterator_tag, T, int, T *, T &> {
             iterator, int, std::random_access_iterator_tag, T, int, T *, T &> {
+    friend class LazyVector;
+
     LazyVector *Self;
     LazyVector *Self;
 
 
     iterator(LazyVector *Self, int Position)
     iterator(LazyVector *Self, int Position)
         : iterator::iterator_adaptor_base(Position), Self(Self) {}
         : iterator::iterator_adaptor_base(Position), Self(Self) {}
 
 
     bool isLoaded() const { return this->I < 0; }
     bool isLoaded() const { return this->I < 0; }
-    friend class LazyVector;
 
 
   public:
   public:
     iterator() : iterator(nullptr, 0) {}
     iterator() : iterator(nullptr, 0) {}
@@ -562,23 +591,23 @@ public:
 };
 };
 
 
 /// \brief A lazy pointer to a statement.
 /// \brief A lazy pointer to a statement.
-typedef LazyOffsetPtr<Stmt, uint64_t, &ExternalASTSource::GetExternalDeclStmt>
-  LazyDeclStmtPtr;
+using LazyDeclStmtPtr =
+    LazyOffsetPtr<Stmt, uint64_t, &ExternalASTSource::GetExternalDeclStmt>;
 
 
 /// \brief A lazy pointer to a declaration.
 /// \brief A lazy pointer to a declaration.
-typedef LazyOffsetPtr<Decl, uint32_t, &ExternalASTSource::GetExternalDecl>
-  LazyDeclPtr;
+using LazyDeclPtr =
+    LazyOffsetPtr<Decl, uint32_t, &ExternalASTSource::GetExternalDecl>;
 
 
 /// \brief A lazy pointer to a set of CXXCtorInitializers.
 /// \brief A lazy pointer to a set of CXXCtorInitializers.
-typedef LazyOffsetPtr<CXXCtorInitializer *, uint64_t,
-                      &ExternalASTSource::GetExternalCXXCtorInitializers>
-  LazyCXXCtorInitializersPtr;
+using LazyCXXCtorInitializersPtr =
+    LazyOffsetPtr<CXXCtorInitializer *, uint64_t,
+                  &ExternalASTSource::GetExternalCXXCtorInitializers>;
 
 
 /// \brief A lazy pointer to a set of CXXBaseSpecifiers.
 /// \brief A lazy pointer to a set of CXXBaseSpecifiers.
-typedef LazyOffsetPtr<CXXBaseSpecifier, uint64_t,
-                      &ExternalASTSource::GetExternalCXXBaseSpecifiers>
-  LazyCXXBaseSpecifiersPtr;
+using LazyCXXBaseSpecifiersPtr =
+    LazyOffsetPtr<CXXBaseSpecifier, uint64_t,
+                  &ExternalASTSource::GetExternalCXXBaseSpecifiers>;
 
 
-} // end namespace clang
+} // namespace clang
 
 
-#endif
+#endif // LLVM_CLANG_AST_EXTERNALASTSOURCE_H

+ 37 - 39
include/clang/AST/PrettyPrinter.h

@@ -30,8 +30,8 @@ public:
   virtual bool handledStmt(Stmt* E, raw_ostream& OS) = 0;
   virtual bool handledStmt(Stmt* E, raw_ostream& OS) = 0;
 };
 };
 
 
-/// \brief Describes how types, statements, expressions, and
-/// declarations should be printed.
+/// Describes how types, statements, expressions, and declarations should be
+/// printed.
 ///
 ///
 /// This type is intended to be small and suitable for passing by value.
 /// This type is intended to be small and suitable for passing by value.
 /// It is very frequently copied.
 /// It is very frequently copied.
@@ -53,20 +53,20 @@ struct PrintingPolicy {
       IncludeNewlines(true), MSVCFormatting(false),
       IncludeNewlines(true), MSVCFormatting(false),
       ConstantsAsWritten(false), SuppressImplicitBase(false) { }
       ConstantsAsWritten(false), SuppressImplicitBase(false) { }
 
 
-  /// \brief Adjust this printing policy for cases where it's known that
-  /// we're printing C++ code (for instance, if AST dumping reaches a
-  /// C++-only construct). This should not be used if a real LangOptions
-  /// object is available.
+  /// Adjust this printing policy for cases where it's known that we're
+  /// printing C++ code (for instance, if AST dumping reaches a C++-only
+  /// construct). This should not be used if a real LangOptions object is
+  /// available.
   void adjustForCPlusPlus() {
   void adjustForCPlusPlus() {
     SuppressTagKeyword = true;
     SuppressTagKeyword = true;
     Bool = true;
     Bool = true;
     UseVoidForZeroParams = false;
     UseVoidForZeroParams = false;
   }
   }
 
 
-  /// \brief The number of spaces to use to indent each line.
+  /// The number of spaces to use to indent each line.
   unsigned Indentation : 8;
   unsigned Indentation : 8;
 
 
-  /// \brief Whether we should suppress printing of the actual specifiers for
+  /// Whether we should suppress printing of the actual specifiers for
   /// the given type or declaration.
   /// the given type or declaration.
   ///
   ///
   /// This flag is only used when we are printing declarators beyond
   /// This flag is only used when we are printing declarators beyond
@@ -82,7 +82,7 @@ struct PrintingPolicy {
   /// "const int" type specifier and instead only print the "*y".
   /// "const int" type specifier and instead only print the "*y".
   bool SuppressSpecifiers : 1;
   bool SuppressSpecifiers : 1;
 
 
-  /// \brief Whether type printing should skip printing the tag keyword.
+  /// Whether type printing should skip printing the tag keyword.
   ///
   ///
   /// This is used when printing the inner type of elaborated types,
   /// This is used when printing the inner type of elaborated types,
   /// (as the tag keyword is part of the elaborated type):
   /// (as the tag keyword is part of the elaborated type):
@@ -92,7 +92,7 @@ struct PrintingPolicy {
   /// \endcode
   /// \endcode
   bool SuppressTagKeyword : 1;
   bool SuppressTagKeyword : 1;
 
 
-  /// \brief When true, include the body of a tag definition.
+  /// When true, include the body of a tag definition.
   ///
   ///
   /// This is used to place the definition of a struct
   /// This is used to place the definition of a struct
   /// in the middle of another declaration as with:
   /// in the middle of another declaration as with:
@@ -102,14 +102,14 @@ struct PrintingPolicy {
   /// \endcode
   /// \endcode
   bool IncludeTagDefinition : 1;
   bool IncludeTagDefinition : 1;
 
 
-  /// \brief Suppresses printing of scope specifiers.
+  /// Suppresses printing of scope specifiers.
   bool SuppressScope : 1;
   bool SuppressScope : 1;
 
 
-  /// \brief Suppress printing parts of scope specifiers that don't need
+  /// Suppress printing parts of scope specifiers that don't need
   /// to be written, e.g., for inline or anonymous namespaces.
   /// to be written, e.g., for inline or anonymous namespaces.
   bool SuppressUnwrittenScope : 1;
   bool SuppressUnwrittenScope : 1;
   
   
-  /// \brief Suppress printing of variable initializers.
+  /// Suppress printing of variable initializers.
   ///
   ///
   /// This flag is used when printing the loop variable in a for-range
   /// This flag is used when printing the loop variable in a for-range
   /// statement. For example, given:
   /// statement. For example, given:
@@ -122,8 +122,8 @@ struct PrintingPolicy {
   /// internal initializer constructed for x will not be printed.
   /// internal initializer constructed for x will not be printed.
   bool SuppressInitializers : 1;
   bool SuppressInitializers : 1;
 
 
-  /// \brief Whether we should print the sizes of constant array expressions
-  /// as written in the sources.
+  /// Whether we should print the sizes of constant array expressions as written
+  /// in the sources.
   ///
   ///
   /// This flag determines whether array types declared as
   /// This flag determines whether array types declared as
   ///
   ///
@@ -140,69 +140,67 @@ struct PrintingPolicy {
   /// \endcode
   /// \endcode
   bool ConstantArraySizeAsWritten : 1;
   bool ConstantArraySizeAsWritten : 1;
   
   
-  /// \brief When printing an anonymous tag name, also print the location of
-  /// that entity (e.g., "enum <anonymous at t.h:10:5>"). Otherwise, just 
-  /// prints "(anonymous)" for the name.
+  /// When printing an anonymous tag name, also print the location of that
+  /// entity (e.g., "enum <anonymous at t.h:10:5>"). Otherwise, just prints
+  /// "(anonymous)" for the name.
   bool AnonymousTagLocations : 1;
   bool AnonymousTagLocations : 1;
   
   
-  /// \brief When true, suppress printing of the __strong lifetime qualifier in
-  /// ARC.
+  /// When true, suppress printing of the __strong lifetime qualifier in ARC.
   unsigned SuppressStrongLifetime : 1;
   unsigned SuppressStrongLifetime : 1;
   
   
-  /// \brief When true, suppress printing of lifetime qualifier in
-  /// ARC.
+  /// When true, suppress printing of lifetime qualifier in ARC.
   unsigned SuppressLifetimeQualifiers : 1;
   unsigned SuppressLifetimeQualifiers : 1;
 
 
   /// When true, suppresses printing template arguments in names of C++
   /// When true, suppresses printing template arguments in names of C++
   /// constructors.
   /// constructors.
   unsigned SuppressTemplateArgsInCXXConstructors : 1;
   unsigned SuppressTemplateArgsInCXXConstructors : 1;
 
 
-  /// \brief Whether we can use 'bool' rather than '_Bool' (even if the language
+  /// Whether we can use 'bool' rather than '_Bool' (even if the language
   /// doesn't actually have 'bool', because, e.g., it is defined as a macro).
   /// doesn't actually have 'bool', because, e.g., it is defined as a macro).
   unsigned Bool : 1;
   unsigned Bool : 1;
 
 
-  /// \brief Whether we can use 'restrict' rather than '__restrict'.
+  /// Whether we can use 'restrict' rather than '__restrict'.
   unsigned Restrict : 1;
   unsigned Restrict : 1;
 
 
-  /// \brief Whether we can use 'alignof' rather than '__alignof'.
+  /// Whether we can use 'alignof' rather than '__alignof'.
   unsigned Alignof : 1;
   unsigned Alignof : 1;
 
 
-  /// \brief Whether we can use '_Alignof' rather than '__alignof'.
+  /// Whether we can use '_Alignof' rather than '__alignof'.
   unsigned UnderscoreAlignof : 1;
   unsigned UnderscoreAlignof : 1;
 
 
-  /// \brief Whether we should use '(void)' rather than '()' for a function
-  /// prototype with zero parameters.
+  /// Whether we should use '(void)' rather than '()' for a function prototype
+  /// with zero parameters.
   unsigned UseVoidForZeroParams : 1;
   unsigned UseVoidForZeroParams : 1;
 
 
-  /// \brief Provide a 'terse' output.
+  /// Provide a 'terse' output.
   ///
   ///
   /// For example, in this mode we don't print function bodies, class members,
   /// For example, in this mode we don't print function bodies, class members,
   /// declarations inside namespaces etc.  Effectively, this should print
   /// declarations inside namespaces etc.  Effectively, this should print
   /// only the requested declaration.
   /// only the requested declaration.
   unsigned TerseOutput : 1;
   unsigned TerseOutput : 1;
   
   
-  /// \brief When true, do certain refinement needed for producing proper
-  /// declaration tag; such as, do not print attributes attached to the declaration.
+  /// When true, do certain refinement needed for producing proper declaration
+  /// tag; such as, do not print attributes attached to the declaration.
   ///
   ///
   unsigned PolishForDeclaration : 1;
   unsigned PolishForDeclaration : 1;
 
 
-  /// \brief When true, print the half-precision floating-point type as 'half'
+  /// When true, print the half-precision floating-point type as 'half'
   /// instead of '__fp16'
   /// instead of '__fp16'
   unsigned Half : 1;
   unsigned Half : 1;
 
 
-  /// \brief When true, print the built-in wchar_t type as __wchar_t. For use in
+  /// When true, print the built-in wchar_t type as __wchar_t. For use in
   /// Microsoft mode when wchar_t is not available.
   /// Microsoft mode when wchar_t is not available.
   unsigned MSWChar : 1;
   unsigned MSWChar : 1;
 
 
-  /// \brief When true, include newlines after statements like "break", etc.
+  /// When true, include newlines after statements like "break", etc.
   unsigned IncludeNewlines : 1;
   unsigned IncludeNewlines : 1;
 
 
-  /// \brief Use whitespace and punctuation like MSVC does. In particular, this
-  /// prints anonymous namespaces as `anonymous namespace' and does not insert
-  /// spaces after template arguments.
+  /// Use whitespace and punctuation like MSVC does. In particular, this prints
+  /// anonymous namespaces as `anonymous namespace' and does not insert spaces
+  /// after template arguments.
   bool MSVCFormatting : 1;
   bool MSVCFormatting : 1;
 
 
-  /// \brief Whether we should print the constant expressions as written in the
+  /// Whether we should print the constant expressions as written in the
   /// sources.
   /// sources.
   ///
   ///
   /// This flag determines whether constants expressions like
   /// This flag determines whether constants expressions like
@@ -220,7 +218,7 @@ struct PrintingPolicy {
   /// \endcode
   /// \endcode
   bool ConstantsAsWritten : 1;
   bool ConstantsAsWritten : 1;
 
 
-  /// \brief When true, don't print the implicit 'self' or 'this' expressions.
+  /// When true, don't print the implicit 'self' or 'this' expressions.
   bool SuppressImplicitBase : 1;
   bool SuppressImplicitBase : 1;
 };
 };
 
 

+ 18 - 7
include/clang/Tooling/Core/QualTypeNames.h → include/clang/AST/QualTypeNames.h

@@ -56,8 +56,8 @@
 //
 //
 // ===----------------------------------------------------------------------===//
 // ===----------------------------------------------------------------------===//
 
 
-#ifndef LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H
-#define LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H
+#ifndef LLVM_CLANG_AST_QUALTYPENAMES_H
+#define LLVM_CLANG_AST_QUALTYPENAMES_H
 
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTContext.h"
 
 
@@ -71,9 +71,20 @@ namespace TypeName {
 /// \param[in] Ctx - the ASTContext to be used.
 /// \param[in] Ctx - the ASTContext to be used.
 /// \param[in] WithGlobalNsPrefix - If true, then the global namespace
 /// \param[in] WithGlobalNsPrefix - If true, then the global namespace
 /// specifier "::" will be prepended to the fully qualified name.
 /// specifier "::" will be prepended to the fully qualified name.
-std::string getFullyQualifiedName(QualType QT,
-                                  const ASTContext &Ctx,
+std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx,
                                   bool WithGlobalNsPrefix = false);
                                   bool WithGlobalNsPrefix = false);
-}  // end namespace TypeName
-}  // end namespace clang
-#endif  // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H
+
+/// \brief Generates a QualType that can be used to name the same type
+/// if used at the end of the current translation unit. This ignores
+/// issues such as type shadowing.
+///
+/// \param[in] QT - the type for which the fully qualified type will be
+/// returned.
+/// \param[in] Ctx - the ASTContext to be used.
+/// \param[in] WithGlobalNsPrefix - Indicate whether the global namespace
+/// specifier "::" should be prepended or not.
+QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
+                               bool WithGlobalNsPrefix = false);
+} // end namespace TypeName
+} // end namespace clang
+#endif // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H

+ 133 - 129
include/clang/Basic/Builtins.def

@@ -103,9 +103,9 @@
 #endif
 #endif
 
 
 // Standard libc/libm functions:
 // Standard libc/libm functions:
-BUILTIN(__builtin_atan2 , "ddd"  , "Fnc")
-BUILTIN(__builtin_atan2f, "fff"  , "Fnc")
-BUILTIN(__builtin_atan2l, "LdLdLd", "Fnc")
+BUILTIN(__builtin_atan2 , "ddd"  , "Fne")
+BUILTIN(__builtin_atan2f, "fff"  , "Fne")
+BUILTIN(__builtin_atan2l, "LdLdLd", "Fne")
 BUILTIN(__builtin_abs  , "ii"  , "ncF")
 BUILTIN(__builtin_abs  , "ii"  , "ncF")
 BUILTIN(__builtin_copysign, "ddd", "ncF")
 BUILTIN(__builtin_copysign, "ddd", "ncF")
 BUILTIN(__builtin_copysignf, "fff", "ncF")
 BUILTIN(__builtin_copysignf, "fff", "ncF")
@@ -113,9 +113,9 @@ BUILTIN(__builtin_copysignl, "LdLdLd", "ncF")
 BUILTIN(__builtin_fabs , "dd"  , "ncF")
 BUILTIN(__builtin_fabs , "dd"  , "ncF")
 BUILTIN(__builtin_fabsf, "ff"  , "ncF")
 BUILTIN(__builtin_fabsf, "ff"  , "ncF")
 BUILTIN(__builtin_fabsl, "LdLd", "ncF")
 BUILTIN(__builtin_fabsl, "LdLd", "ncF")
-BUILTIN(__builtin_fmod , "ddd"  , "Fnc")
-BUILTIN(__builtin_fmodf, "fff"  , "Fnc")
-BUILTIN(__builtin_fmodl, "LdLdLd", "Fnc")
+BUILTIN(__builtin_fmod , "ddd"  , "Fne")
+BUILTIN(__builtin_fmodf, "fff"  , "Fne")
+BUILTIN(__builtin_fmodl, "LdLdLd", "Fne")
 BUILTIN(__builtin_frexp , "ddi*"  , "Fn")
 BUILTIN(__builtin_frexp , "ddi*"  , "Fn")
 BUILTIN(__builtin_frexpf, "ffi*"  , "Fn")
 BUILTIN(__builtin_frexpf, "ffi*"  , "Fn")
 BUILTIN(__builtin_frexpl, "LdLdi*", "Fn")
 BUILTIN(__builtin_frexpl, "LdLdi*", "Fn")
@@ -127,9 +127,9 @@ BUILTIN(__builtin_inff , "f"   , "nc")
 BUILTIN(__builtin_infl , "Ld"  , "nc")
 BUILTIN(__builtin_infl , "Ld"  , "nc")
 BUILTIN(__builtin_labs , "LiLi"  , "Fnc")
 BUILTIN(__builtin_labs , "LiLi"  , "Fnc")
 BUILTIN(__builtin_llabs, "LLiLLi", "Fnc")
 BUILTIN(__builtin_llabs, "LLiLLi", "Fnc")
-BUILTIN(__builtin_ldexp , "ddi"  , "Fnc")
-BUILTIN(__builtin_ldexpf, "ffi"  , "Fnc")
-BUILTIN(__builtin_ldexpl, "LdLdi", "Fnc")
+BUILTIN(__builtin_ldexp , "ddi"  , "Fne")
+BUILTIN(__builtin_ldexpf, "ffi"  , "Fne")
+BUILTIN(__builtin_ldexpl, "LdLdi", "Fne")
 BUILTIN(__builtin_modf , "ddd*"  , "Fn")
 BUILTIN(__builtin_modf , "ddd*"  , "Fn")
 BUILTIN(__builtin_modff, "fff*"  , "Fn")
 BUILTIN(__builtin_modff, "fff*"  , "Fn")
 BUILTIN(__builtin_modfl, "LdLdLd*", "Fn")
 BUILTIN(__builtin_modfl, "LdLdLd*", "Fn")
@@ -142,119 +142,119 @@ BUILTIN(__builtin_nansl, "LdcC*", "ncF")
 BUILTIN(__builtin_powi , "ddi"  , "Fnc")
 BUILTIN(__builtin_powi , "ddi"  , "Fnc")
 BUILTIN(__builtin_powif, "ffi"  , "Fnc")
 BUILTIN(__builtin_powif, "ffi"  , "Fnc")
 BUILTIN(__builtin_powil, "LdLdi", "Fnc")
 BUILTIN(__builtin_powil, "LdLdi", "Fnc")
-BUILTIN(__builtin_pow , "ddd"  , "Fnc")
-BUILTIN(__builtin_powf, "fff"  , "Fnc")
-BUILTIN(__builtin_powl, "LdLdLd", "Fnc")
+BUILTIN(__builtin_pow , "ddd"  , "Fne")
+BUILTIN(__builtin_powf, "fff"  , "Fne")
+BUILTIN(__builtin_powl, "LdLdLd", "Fne")
 
 
 // Standard unary libc/libm functions with double/float/long double variants:
 // Standard unary libc/libm functions with double/float/long double variants:
-BUILTIN(__builtin_acos , "dd"  , "Fnc")
-BUILTIN(__builtin_acosf, "ff"  , "Fnc")
-BUILTIN(__builtin_acosl, "LdLd", "Fnc")
-BUILTIN(__builtin_acosh , "dd"  , "Fnc")
-BUILTIN(__builtin_acoshf, "ff"  , "Fnc")
-BUILTIN(__builtin_acoshl, "LdLd", "Fnc")
-BUILTIN(__builtin_asin , "dd"  , "Fnc")
-BUILTIN(__builtin_asinf, "ff"  , "Fnc")
-BUILTIN(__builtin_asinl, "LdLd", "Fnc")
-BUILTIN(__builtin_asinh , "dd"  , "Fnc")
-BUILTIN(__builtin_asinhf, "ff"  , "Fnc")
-BUILTIN(__builtin_asinhl, "LdLd", "Fnc")
-BUILTIN(__builtin_atan , "dd"  , "Fnc")
-BUILTIN(__builtin_atanf, "ff"  , "Fnc")
-BUILTIN(__builtin_atanl, "LdLd", "Fnc")
-BUILTIN(__builtin_atanh , "dd", "Fnc")
-BUILTIN(__builtin_atanhf, "ff", "Fnc")
-BUILTIN(__builtin_atanhl, "LdLd", "Fnc")
-BUILTIN(__builtin_cbrt , "dd", "Fnc")
-BUILTIN(__builtin_cbrtf, "ff", "Fnc")
-BUILTIN(__builtin_cbrtl, "LdLd", "Fnc")
+BUILTIN(__builtin_acos , "dd"  , "Fne")
+BUILTIN(__builtin_acosf, "ff"  , "Fne")
+BUILTIN(__builtin_acosl, "LdLd", "Fne")
+BUILTIN(__builtin_acosh , "dd"  , "Fne")
+BUILTIN(__builtin_acoshf, "ff"  , "Fne")
+BUILTIN(__builtin_acoshl, "LdLd", "Fne")
+BUILTIN(__builtin_asin , "dd"  , "Fne")
+BUILTIN(__builtin_asinf, "ff"  , "Fne")
+BUILTIN(__builtin_asinl, "LdLd", "Fne")
+BUILTIN(__builtin_asinh , "dd"  , "Fne")
+BUILTIN(__builtin_asinhf, "ff"  , "Fne")
+BUILTIN(__builtin_asinhl, "LdLd", "Fne")
+BUILTIN(__builtin_atan , "dd"  , "Fne")
+BUILTIN(__builtin_atanf, "ff"  , "Fne")
+BUILTIN(__builtin_atanl, "LdLd", "Fne")
+BUILTIN(__builtin_atanh , "dd", "Fne")
+BUILTIN(__builtin_atanhf, "ff", "Fne")
+BUILTIN(__builtin_atanhl, "LdLd", "Fne")
+BUILTIN(__builtin_cbrt , "dd", "Fne")
+BUILTIN(__builtin_cbrtf, "ff", "Fne")
+BUILTIN(__builtin_cbrtl, "LdLd", "Fne")
 BUILTIN(__builtin_ceil , "dd"  , "Fnc")
 BUILTIN(__builtin_ceil , "dd"  , "Fnc")
 BUILTIN(__builtin_ceilf, "ff"  , "Fnc")
 BUILTIN(__builtin_ceilf, "ff"  , "Fnc")
 BUILTIN(__builtin_ceill, "LdLd", "Fnc")
 BUILTIN(__builtin_ceill, "LdLd", "Fnc")
-BUILTIN(__builtin_cos , "dd"  , "Fnc")
-BUILTIN(__builtin_cosf, "ff"  , "Fnc")
-BUILTIN(__builtin_cosh , "dd"  , "Fnc")
-BUILTIN(__builtin_coshf, "ff"  , "Fnc")
-BUILTIN(__builtin_coshl, "LdLd", "Fnc")
-BUILTIN(__builtin_cosl, "LdLd", "Fnc")
-BUILTIN(__builtin_erf , "dd", "Fnc")
-BUILTIN(__builtin_erff, "ff", "Fnc")
-BUILTIN(__builtin_erfl, "LdLd", "Fnc")
-BUILTIN(__builtin_erfc , "dd", "Fnc")
-BUILTIN(__builtin_erfcf, "ff", "Fnc")
-BUILTIN(__builtin_erfcl, "LdLd", "Fnc")
-BUILTIN(__builtin_exp , "dd"  , "Fnc")
-BUILTIN(__builtin_expf, "ff"  , "Fnc")
-BUILTIN(__builtin_expl, "LdLd", "Fnc")
-BUILTIN(__builtin_exp2 , "dd"  , "Fnc")
-BUILTIN(__builtin_exp2f, "ff"  , "Fnc")
-BUILTIN(__builtin_exp2l, "LdLd", "Fnc")
-BUILTIN(__builtin_expm1 , "dd", "Fnc")
-BUILTIN(__builtin_expm1f, "ff", "Fnc")
-BUILTIN(__builtin_expm1l, "LdLd", "Fnc")
-BUILTIN(__builtin_fdim, "ddd", "Fnc")
-BUILTIN(__builtin_fdimf, "fff", "Fnc")
-BUILTIN(__builtin_fdiml, "LdLdLd", "Fnc")
+BUILTIN(__builtin_cos , "dd"  , "Fne")
+BUILTIN(__builtin_cosf, "ff"  , "Fne")
+BUILTIN(__builtin_cosh , "dd"  , "Fne")
+BUILTIN(__builtin_coshf, "ff"  , "Fne")
+BUILTIN(__builtin_coshl, "LdLd", "Fne")
+BUILTIN(__builtin_cosl, "LdLd", "Fne")
+BUILTIN(__builtin_erf , "dd", "Fne")
+BUILTIN(__builtin_erff, "ff", "Fne")
+BUILTIN(__builtin_erfl, "LdLd", "Fne")
+BUILTIN(__builtin_erfc , "dd", "Fne")
+BUILTIN(__builtin_erfcf, "ff", "Fne")
+BUILTIN(__builtin_erfcl, "LdLd", "Fne")
+BUILTIN(__builtin_exp , "dd"  , "Fne")
+BUILTIN(__builtin_expf, "ff"  , "Fne")
+BUILTIN(__builtin_expl, "LdLd", "Fne")
+BUILTIN(__builtin_exp2 , "dd"  , "Fne")
+BUILTIN(__builtin_exp2f, "ff"  , "Fne")
+BUILTIN(__builtin_exp2l, "LdLd", "Fne")
+BUILTIN(__builtin_expm1 , "dd", "Fne")
+BUILTIN(__builtin_expm1f, "ff", "Fne")
+BUILTIN(__builtin_expm1l, "LdLd", "Fne")
+BUILTIN(__builtin_fdim, "ddd", "Fne")
+BUILTIN(__builtin_fdimf, "fff", "Fne")
+BUILTIN(__builtin_fdiml, "LdLdLd", "Fne")
 BUILTIN(__builtin_floor , "dd"  , "Fnc")
 BUILTIN(__builtin_floor , "dd"  , "Fnc")
 BUILTIN(__builtin_floorf, "ff"  , "Fnc")
 BUILTIN(__builtin_floorf, "ff"  , "Fnc")
 BUILTIN(__builtin_floorl, "LdLd", "Fnc")
 BUILTIN(__builtin_floorl, "LdLd", "Fnc")
-BUILTIN(__builtin_fma, "dddd", "Fnc")
-BUILTIN(__builtin_fmaf, "ffff", "Fnc")
-BUILTIN(__builtin_fmal, "LdLdLdLd", "Fnc")
+BUILTIN(__builtin_fma, "dddd", "Fne")
+BUILTIN(__builtin_fmaf, "ffff", "Fne")
+BUILTIN(__builtin_fmal, "LdLdLdLd", "Fne")
 BUILTIN(__builtin_fmax, "ddd", "Fnc")
 BUILTIN(__builtin_fmax, "ddd", "Fnc")
 BUILTIN(__builtin_fmaxf, "fff", "Fnc")
 BUILTIN(__builtin_fmaxf, "fff", "Fnc")
 BUILTIN(__builtin_fmaxl, "LdLdLd", "Fnc")
 BUILTIN(__builtin_fmaxl, "LdLdLd", "Fnc")
 BUILTIN(__builtin_fmin, "ddd", "Fnc")
 BUILTIN(__builtin_fmin, "ddd", "Fnc")
 BUILTIN(__builtin_fminf, "fff", "Fnc")
 BUILTIN(__builtin_fminf, "fff", "Fnc")
 BUILTIN(__builtin_fminl, "LdLdLd", "Fnc")
 BUILTIN(__builtin_fminl, "LdLdLd", "Fnc")
-BUILTIN(__builtin_hypot , "ddd"  , "Fnc")
-BUILTIN(__builtin_hypotf, "fff"  , "Fnc")
-BUILTIN(__builtin_hypotl, "LdLdLd", "Fnc")
-BUILTIN(__builtin_ilogb , "id", "Fnc")
-BUILTIN(__builtin_ilogbf, "if", "Fnc")
-BUILTIN(__builtin_ilogbl, "iLd", "Fnc")
-BUILTIN(__builtin_lgamma , "dd", "Fnc")
-BUILTIN(__builtin_lgammaf, "ff", "Fnc")
-BUILTIN(__builtin_lgammal, "LdLd", "Fnc")
-BUILTIN(__builtin_llrint, "LLid", "Fnc")
-BUILTIN(__builtin_llrintf, "LLif", "Fnc")
-BUILTIN(__builtin_llrintl, "LLiLd", "Fnc")
-BUILTIN(__builtin_llround , "LLid", "Fnc")
-BUILTIN(__builtin_llroundf, "LLif", "Fnc")
-BUILTIN(__builtin_llroundl, "LLiLd", "Fnc")
-BUILTIN(__builtin_log , "dd"  , "Fnc")
-BUILTIN(__builtin_log10 , "dd"  , "Fnc")
-BUILTIN(__builtin_log10f, "ff"  , "Fnc")
-BUILTIN(__builtin_log10l, "LdLd", "Fnc")
-BUILTIN(__builtin_log1p , "dd"  , "Fnc")
-BUILTIN(__builtin_log1pf, "ff"  , "Fnc")
-BUILTIN(__builtin_log1pl, "LdLd", "Fnc")
-BUILTIN(__builtin_log2, "dd"  , "Fnc")
-BUILTIN(__builtin_log2f, "ff"  , "Fnc")
-BUILTIN(__builtin_log2l, "LdLd"  , "Fnc")
-BUILTIN(__builtin_logb , "dd", "Fnc")
-BUILTIN(__builtin_logbf, "ff", "Fnc")
-BUILTIN(__builtin_logbl, "LdLd", "Fnc")
-BUILTIN(__builtin_logf, "ff"  , "Fnc")
-BUILTIN(__builtin_logl, "LdLd", "Fnc")
-BUILTIN(__builtin_lrint , "Lid", "Fnc")
-BUILTIN(__builtin_lrintf, "Lif", "Fnc")
-BUILTIN(__builtin_lrintl, "LiLd", "Fnc")
-BUILTIN(__builtin_lround , "Lid", "Fnc")
-BUILTIN(__builtin_lroundf, "Lif", "Fnc")
-BUILTIN(__builtin_lroundl, "LiLd", "Fnc")
+BUILTIN(__builtin_hypot , "ddd"  , "Fne")
+BUILTIN(__builtin_hypotf, "fff"  , "Fne")
+BUILTIN(__builtin_hypotl, "LdLdLd", "Fne")
+BUILTIN(__builtin_ilogb , "id", "Fne")
+BUILTIN(__builtin_ilogbf, "if", "Fne")
+BUILTIN(__builtin_ilogbl, "iLd", "Fne")
+BUILTIN(__builtin_lgamma , "dd", "Fn")
+BUILTIN(__builtin_lgammaf, "ff", "Fn")
+BUILTIN(__builtin_lgammal, "LdLd", "Fn")
+BUILTIN(__builtin_llrint, "LLid", "Fne")
+BUILTIN(__builtin_llrintf, "LLif", "Fne")
+BUILTIN(__builtin_llrintl, "LLiLd", "Fne")
+BUILTIN(__builtin_llround , "LLid", "Fne")
+BUILTIN(__builtin_llroundf, "LLif", "Fne")
+BUILTIN(__builtin_llroundl, "LLiLd", "Fne")
+BUILTIN(__builtin_log , "dd"  , "Fne")
+BUILTIN(__builtin_log10 , "dd"  , "Fne")
+BUILTIN(__builtin_log10f, "ff"  , "Fne")
+BUILTIN(__builtin_log10l, "LdLd", "Fne")
+BUILTIN(__builtin_log1p , "dd"  , "Fne")
+BUILTIN(__builtin_log1pf, "ff"  , "Fne")
+BUILTIN(__builtin_log1pl, "LdLd", "Fne")
+BUILTIN(__builtin_log2, "dd"  , "Fne")
+BUILTIN(__builtin_log2f, "ff"  , "Fne")
+BUILTIN(__builtin_log2l, "LdLd"  , "Fne")
+BUILTIN(__builtin_logb , "dd", "Fne")
+BUILTIN(__builtin_logbf, "ff", "Fne")
+BUILTIN(__builtin_logbl, "LdLd", "Fne")
+BUILTIN(__builtin_logf, "ff"  , "Fne")
+BUILTIN(__builtin_logl, "LdLd", "Fne")
+BUILTIN(__builtin_lrint , "Lid", "Fne")
+BUILTIN(__builtin_lrintf, "Lif", "Fne")
+BUILTIN(__builtin_lrintl, "LiLd", "Fne")
+BUILTIN(__builtin_lround , "Lid", "Fne")
+BUILTIN(__builtin_lroundf, "Lif", "Fne")
+BUILTIN(__builtin_lroundl, "LiLd", "Fne")
 BUILTIN(__builtin_nearbyint , "dd", "Fnc")
 BUILTIN(__builtin_nearbyint , "dd", "Fnc")
 BUILTIN(__builtin_nearbyintf, "ff", "Fnc")
 BUILTIN(__builtin_nearbyintf, "ff", "Fnc")
 BUILTIN(__builtin_nearbyintl, "LdLd", "Fnc")
 BUILTIN(__builtin_nearbyintl, "LdLd", "Fnc")
-BUILTIN(__builtin_nextafter , "ddd", "Fnc")
-BUILTIN(__builtin_nextafterf, "fff", "Fnc")
-BUILTIN(__builtin_nextafterl, "LdLdLd", "Fnc")
-BUILTIN(__builtin_nexttoward , "ddLd", "Fnc")
-BUILTIN(__builtin_nexttowardf, "ffLd", "Fnc")
-BUILTIN(__builtin_nexttowardl, "LdLdLd", "Fnc")
-BUILTIN(__builtin_remainder , "ddd", "Fnc")
-BUILTIN(__builtin_remainderf, "fff", "Fnc")
-BUILTIN(__builtin_remainderl, "LdLdLd", "Fnc")
+BUILTIN(__builtin_nextafter , "ddd", "Fne")
+BUILTIN(__builtin_nextafterf, "fff", "Fne")
+BUILTIN(__builtin_nextafterl, "LdLdLd", "Fne")
+BUILTIN(__builtin_nexttoward , "ddLd", "Fne")
+BUILTIN(__builtin_nexttowardf, "ffLd", "Fne")
+BUILTIN(__builtin_nexttowardl, "LdLdLd", "Fne")
+BUILTIN(__builtin_remainder , "ddd", "Fne")
+BUILTIN(__builtin_remainderf, "fff", "Fne")
+BUILTIN(__builtin_remainderl, "LdLdLd", "Fne")
 BUILTIN(__builtin_remquo , "dddi*", "Fn")
 BUILTIN(__builtin_remquo , "dddi*", "Fn")
 BUILTIN(__builtin_remquof, "fffi*", "Fn")
 BUILTIN(__builtin_remquof, "fffi*", "Fn")
 BUILTIN(__builtin_remquol, "LdLdLdi*", "Fn")
 BUILTIN(__builtin_remquol, "LdLdLdi*", "Fn")
@@ -264,30 +264,30 @@ BUILTIN(__builtin_rintl, "LdLd", "Fnc")
 BUILTIN(__builtin_round, "dd"  , "Fnc")
 BUILTIN(__builtin_round, "dd"  , "Fnc")
 BUILTIN(__builtin_roundf, "ff"  , "Fnc")
 BUILTIN(__builtin_roundf, "ff"  , "Fnc")
 BUILTIN(__builtin_roundl, "LdLd"  , "Fnc")
 BUILTIN(__builtin_roundl, "LdLd"  , "Fnc")
-BUILTIN(__builtin_scalbln , "ddLi", "Fnc")
-BUILTIN(__builtin_scalblnf, "ffLi", "Fnc")
-BUILTIN(__builtin_scalblnl, "LdLdLi", "Fnc")
-BUILTIN(__builtin_scalbn , "ddi", "Fnc")
-BUILTIN(__builtin_scalbnf, "ffi", "Fnc")
-BUILTIN(__builtin_scalbnl, "LdLdi", "Fnc")
-BUILTIN(__builtin_sin , "dd"  , "Fnc")
-BUILTIN(__builtin_sinf, "ff"  , "Fnc")
-BUILTIN(__builtin_sinh , "dd"  , "Fnc")
-BUILTIN(__builtin_sinhf, "ff"  , "Fnc")
-BUILTIN(__builtin_sinhl, "LdLd", "Fnc")
-BUILTIN(__builtin_sinl, "LdLd", "Fnc")
-BUILTIN(__builtin_sqrt , "dd"  , "Fnc")
-BUILTIN(__builtin_sqrtf, "ff"  , "Fnc")
-BUILTIN(__builtin_sqrtl, "LdLd", "Fnc")
-BUILTIN(__builtin_tan , "dd"  , "Fnc")
-BUILTIN(__builtin_tanf, "ff"  , "Fnc")
-BUILTIN(__builtin_tanh , "dd"  , "Fnc")
-BUILTIN(__builtin_tanhf, "ff"  , "Fnc")
-BUILTIN(__builtin_tanhl, "LdLd", "Fnc")
-BUILTIN(__builtin_tanl, "LdLd", "Fnc")
-BUILTIN(__builtin_tgamma , "dd", "Fnc")
-BUILTIN(__builtin_tgammaf, "ff", "Fnc")
-BUILTIN(__builtin_tgammal, "LdLd", "Fnc")
+BUILTIN(__builtin_scalbln , "ddLi", "Fne")
+BUILTIN(__builtin_scalblnf, "ffLi", "Fne")
+BUILTIN(__builtin_scalblnl, "LdLdLi", "Fne")
+BUILTIN(__builtin_scalbn , "ddi", "Fne")
+BUILTIN(__builtin_scalbnf, "ffi", "Fne")
+BUILTIN(__builtin_scalbnl, "LdLdi", "Fne")
+BUILTIN(__builtin_sin , "dd"  , "Fne")
+BUILTIN(__builtin_sinf, "ff"  , "Fne")
+BUILTIN(__builtin_sinh , "dd"  , "Fne")
+BUILTIN(__builtin_sinhf, "ff"  , "Fne")
+BUILTIN(__builtin_sinhl, "LdLd", "Fne")
+BUILTIN(__builtin_sinl, "LdLd", "Fne")
+BUILTIN(__builtin_sqrt , "dd"  , "Fne")
+BUILTIN(__builtin_sqrtf, "ff"  , "Fne")
+BUILTIN(__builtin_sqrtl, "LdLd", "Fne")
+BUILTIN(__builtin_tan , "dd"  , "Fne")
+BUILTIN(__builtin_tanf, "ff"  , "Fne")
+BUILTIN(__builtin_tanh , "dd"  , "Fne")
+BUILTIN(__builtin_tanhf, "ff"  , "Fne")
+BUILTIN(__builtin_tanhl, "LdLd", "Fne")
+BUILTIN(__builtin_tanl, "LdLd", "Fne")
+BUILTIN(__builtin_tgamma , "dd", "Fne")
+BUILTIN(__builtin_tgammaf, "ff", "Fne")
+BUILTIN(__builtin_tgammal, "LdLd", "Fne")
 BUILTIN(__builtin_trunc , "dd", "Fnc")
 BUILTIN(__builtin_trunc , "dd", "Fnc")
 BUILTIN(__builtin_truncf, "ff", "Fnc")
 BUILTIN(__builtin_truncf, "ff", "Fnc")
 BUILTIN(__builtin_truncl, "LdLd", "Fnc")
 BUILTIN(__builtin_truncl, "LdLd", "Fnc")
@@ -1162,6 +1162,10 @@ LIBBUILTIN(remainder, "ddd", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(remainderf, "fff", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(remainderf, "fff", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(remainderl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(remainderl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
 
 
+LIBBUILTIN(remquo, "dddi*", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(remquof, "fffi*", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(remquol, "LdLdLdi*", "fn", "math.h", ALL_LANGUAGES)
+
 LIBBUILTIN(rint, "dd", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(rint, "dd", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(rintf, "ff", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(rintf, "ff", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(rintl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(rintl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)

+ 1 - 1
include/clang/Basic/BuiltinsNVPTX.def

@@ -481,7 +481,7 @@ TARGET_BUILTIN(__nvvm_atom_cta_add_gen_f, "ffD*f", "n", "satom")
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_f, "ffD*f", "n", "satom")
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_f, "ffD*f", "n", "satom")
 BUILTIN(__nvvm_atom_add_g_d, "ddD*1d", "n")
 BUILTIN(__nvvm_atom_add_g_d, "ddD*1d", "n")
 BUILTIN(__nvvm_atom_add_s_d, "ddD*3d", "n")
 BUILTIN(__nvvm_atom_add_s_d, "ddD*3d", "n")
-BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n")
+TARGET_BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n", "satom")
 TARGET_BUILTIN(__nvvm_atom_cta_add_gen_d, "ddD*d", "n", "satom")
 TARGET_BUILTIN(__nvvm_atom_cta_add_gen_d, "ddD*d", "n", "satom")
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_d, "ddD*d", "n", "satom")
 TARGET_BUILTIN(__nvvm_atom_sys_add_gen_d, "ddD*d", "n", "satom")
 
 

+ 1 - 36
include/clang/Basic/BuiltinsX86.def

@@ -910,39 +910,10 @@ TARGET_BUILTIN(__builtin_ia32_cvttps2dq512_mask, "V16iV16fV16iUsIi", "", "avx512
 TARGET_BUILTIN(__builtin_ia32_cvttps2udq512_mask, "V16iV16fV16iUsIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvttps2udq512_mask, "V16iV16fV16iUsIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2dq512_mask, "V8iV8dV8iUcIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2dq512_mask, "V8iV8dV8iUcIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2udq512_mask, "V8iV8dV8iUcIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2udq512_mask, "V8iV8dV8iUcIi", "", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_cmpps512_mask,   "UsV16fV16fIiUsIi", "", "avx512f")
 
 
+TARGET_BUILTIN(__builtin_ia32_cmpps512_mask,   "UsV16fV16fIiUsIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_cmpps256_mask,   "UcV8fV8fIiUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cmpps256_mask,   "UcV8fV8fIiUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cmpps128_mask,   "UcV4fV4fIiUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cmpps128_mask,   "UcV4fV4fIiUc", "", "avx512vl")
-
-TARGET_BUILTIN(__builtin_ia32_pcmpeqb512_mask, "LLiV64cV64cLLi", "", "avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqd512_mask, "sV16iV16is", "", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqq512_mask, "cV8LLiV8LLic", "", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqw512_mask, "iV32sV32si", "", "avx512bw")
-
-TARGET_BUILTIN(__builtin_ia32_pcmpeqb256_mask, "iV32cV32ci", "", "avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqd256_mask, "cV8iV8ic", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqq256_mask, "cV4LLiV4LLic", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqw256_mask, "sV16sV16ss", "", "avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqb128_mask, "sV16cV16cs", "", "avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqd128_mask, "cV4iV4ic", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqq128_mask, "cV2LLiV2LLic", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pcmpeqw128_mask, "cV8sV8sc", "", "avx512vl,avx512bw")
-
-TARGET_BUILTIN(__builtin_ia32_pcmpgtb512_mask, "LLiV64cV64cLLi", "", "avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtd512_mask, "sV16iV16is", "", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtq512_mask, "cV8LLiV8LLic", "", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtw512_mask, "iV32sV32si", "", "avx512bw")
-
-TARGET_BUILTIN(__builtin_ia32_pcmpgtb256_mask, "iV32cV32ci", "", "avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtd256_mask, "cV8iV8ic", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtq256_mask, "cV4LLiV4LLic", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtw256_mask, "sV16sV16ss", "", "avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtb128_mask, "sV16cV16cs", "", "avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtd128_mask, "cV4iV4ic", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtq128_mask, "cV2LLiV2LLic", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pcmpgtw128_mask, "cV8sV8sc", "", "avx512vl,avx512bw")
-
 TARGET_BUILTIN(__builtin_ia32_cmppd512_mask, "UcV8dV8dIiUcIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_cmppd512_mask, "UcV8dV8dIiUcIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_cmppd256_mask, "UcV4dV4dIiUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cmppd256_mask, "UcV4dV4dIiUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cmppd128_mask, "UcV2dV2dIiUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cmppd128_mask, "UcV2dV2dIiUc", "", "avx512vl")
@@ -1580,12 +1551,6 @@ TARGET_BUILTIN(__builtin_ia32_cvtmask2q128, "V2LLiUc","","avx512dq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtmask2q256, "V4LLiUc","","avx512dq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtmask2q256, "V4LLiUc","","avx512dq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtq2mask128, "UcV2LLi","","avx512dq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtq2mask128, "UcV2LLi","","avx512dq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtq2mask256, "UcV4LLi","","avx512dq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtq2mask256, "UcV4LLi","","avx512dq,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_broadcastmb512, "V8LLiUc","","avx512cd")
-TARGET_BUILTIN(__builtin_ia32_broadcastmw512, "V16iUs","","avx512cd")
-TARGET_BUILTIN(__builtin_ia32_broadcastmb128, "V2LLiUc","","avx512cd,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_broadcastmb256, "V4LLiUc","","avx512cd,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_broadcastmw128, "V4iUs","","avx512cd,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_broadcastmw256, "V8iUs","","avx512cd,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmovsdb512_mask, "V16cV16iV16cUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_pmovsdb512_mask, "V16cV16iV16cUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_pmovsdb512mem_mask, "vV16c*V16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_pmovsdb512mem_mask, "vV16c*V16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_pmovswb512mem_mask, "vV32c*V32sUi","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmovswb512mem_mask, "vV32c*V32sUi","","avx512bw")

+ 1 - 1
include/clang/Basic/DiagnosticSemaKinds.td

@@ -2778,7 +2778,7 @@ def err_attribute_weakref_not_global_context : Error<
 def err_attribute_weakref_without_alias : Error<
 def err_attribute_weakref_without_alias : Error<
   "weakref declaration of %0 must also have an alias attribute">;
   "weakref declaration of %0 must also have an alias attribute">;
 def err_alias_not_supported_on_darwin : Error <
 def err_alias_not_supported_on_darwin : Error <
-  "only weak aliases are supported on darwin">;
+  "aliases are not supported on darwin">;
 def err_alias_to_undefined : Error<
 def err_alias_to_undefined : Error<
   "%select{alias|ifunc}0 must point to a defined %select{variable or |}1function">;
   "%select{alias|ifunc}0 must point to a defined %select{variable or |}1function">;
 def warn_alias_to_weak_alias : Warning<
 def warn_alias_to_weak_alias : Warning<

+ 41 - 42
include/clang/Basic/IdentifierTable.h

@@ -1,4 +1,4 @@
-//===--- IdentifierTable.h - Hash table for identifier lookup ---*- C++ -*-===//
+//===- IdentifierTable.h - Hash table for identifier lookup -----*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -6,11 +6,11 @@
 // License. See LICENSE.TXT for details.
 // License. See LICENSE.TXT for details.
 //
 //
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
-///
+//
 /// \file
 /// \file
 /// \brief Defines the clang::IdentifierInfo, clang::IdentifierTable, and
 /// \brief Defines the clang::IdentifierInfo, clang::IdentifierTable, and
 /// clang::Selector interfaces.
 /// clang::Selector interfaces.
-///
+//
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
 #ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
 #ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
@@ -18,35 +18,29 @@
 
 
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/PointerLikeTypeTraits.h"
+#include "llvm/Support/type_traits.h"
 #include <cassert>
 #include <cassert>
 #include <cstddef>
 #include <cstddef>
 #include <cstdint>
 #include <cstdint>
 #include <cstring>
 #include <cstring>
-#include <new>
 #include <string>
 #include <string>
 #include <utility>
 #include <utility>
 
 
-namespace llvm {
-
-  template <typename T> struct DenseMapInfo;
-
-} // end namespace llvm
-
 namespace clang {
 namespace clang {
 
 
-  class LangOptions;
-  class IdentifierInfo;
-  class IdentifierTable;
-  class SourceLocation;
-  class MultiKeywordSelector; // private class used by Selector
-  class DeclarationName;      // AST class that stores declaration names
+class IdentifierInfo;
+class LangOptions;
+class MultiKeywordSelector;
+class SourceLocation;
 
 
-  /// \brief A simple pair of identifier info and location.
-  typedef std::pair<IdentifierInfo*, SourceLocation> IdentifierLocPair;
+/// \brief A simple pair of identifier info and location.
+using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>;
 
 
 /// One of these records is kept for each identifier that
 /// One of these records is kept for each identifier that
 /// is lexed.  This contains information about whether the token was \#define'd,
 /// is lexed.  This contains information about whether the token was \#define'd,
@@ -85,8 +79,10 @@ class IdentifierInfo {
                                    // keyword.
                                    // keyword.
   // 29 bit left in 64-bit word.
   // 29 bit left in 64-bit word.
 
 
-  void *FETokenInfo;               // Managed by the language front-end.
-  llvm::StringMapEntry<IdentifierInfo*> *Entry;
+  // Managed by the language front-end.
+  void *FETokenInfo = nullptr;
+
+  llvm::StringMapEntry<IdentifierInfo *> *Entry = nullptr;
 
 
 public:
 public:
   IdentifierInfo();
   IdentifierInfo();
@@ -104,7 +100,6 @@ public:
 
 
   /// \brief Return the beginning of the actual null-terminated string for this
   /// \brief Return the beginning of the actual null-terminated string for this
   /// identifier.
   /// identifier.
-  ///
   const char *getNameStart() const {
   const char *getNameStart() const {
     if (Entry) return Entry->getKeyData();
     if (Entry) return Entry->getKeyData();
     // FIXME: This is gross. It would be best not to embed specific details
     // FIXME: This is gross. It would be best not to embed specific details
@@ -112,12 +107,12 @@ public:
     // The 'this' pointer really points to a
     // The 'this' pointer really points to a
     // std::pair<IdentifierInfo, const char*>, where internal pointer
     // std::pair<IdentifierInfo, const char*>, where internal pointer
     // points to the external string data.
     // points to the external string data.
-    typedef std::pair<IdentifierInfo, const char*> actualtype;
+    using actualtype = std::pair<IdentifierInfo, const char *>;
+
     return ((const actualtype*) this)->second;
     return ((const actualtype*) this)->second;
   }
   }
 
 
   /// \brief Efficiently return the length of this identifier info.
   /// \brief Efficiently return the length of this identifier info.
-  ///
   unsigned getLength() const {
   unsigned getLength() const {
     if (Entry) return Entry->getKeyLength();
     if (Entry) return Entry->getKeyLength();
     // FIXME: This is gross. It would be best not to embed specific details
     // FIXME: This is gross. It would be best not to embed specific details
@@ -125,7 +120,8 @@ public:
     // The 'this' pointer really points to a
     // The 'this' pointer really points to a
     // std::pair<IdentifierInfo, const char*>, where internal pointer
     // std::pair<IdentifierInfo, const char*>, where internal pointer
     // points to the external string data.
     // points to the external string data.
-    typedef std::pair<IdentifierInfo, const char*> actualtype;
+    using actualtype = std::pair<IdentifierInfo, const char *>;
+
     const char* p = ((const actualtype*) this)->second - 2;
     const char* p = ((const actualtype*) this)->second - 2;
     return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
     return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
   }
   }
@@ -465,7 +461,7 @@ public:
 class IdentifierTable {
 class IdentifierTable {
   // Shark shows that using MallocAllocator is *much* slower than using this
   // Shark shows that using MallocAllocator is *much* slower than using this
   // BumpPtrAllocator!
   // BumpPtrAllocator!
-  typedef llvm::StringMap<IdentifierInfo*, llvm::BumpPtrAllocator> HashTableTy;
+  using HashTableTy = llvm::StringMap<IdentifierInfo *, llvm::BumpPtrAllocator>;
   HashTableTy HashTable;
   HashTableTy HashTable;
 
 
   IdentifierInfoLookup* ExternalLookup;
   IdentifierInfoLookup* ExternalLookup;
@@ -551,8 +547,8 @@ public:
     return *II;
     return *II;
   }
   }
 
 
-  typedef HashTableTy::const_iterator iterator;
-  typedef HashTableTy::const_iterator const_iterator;
+  using iterator = HashTableTy::const_iterator;
+  using const_iterator = HashTableTy::const_iterator;
 
 
   iterator begin() const { return HashTable.begin(); }
   iterator begin() const { return HashTable.begin(); }
   iterator end() const   { return HashTable.end(); }
   iterator end() const   { return HashTable.end(); }
@@ -654,7 +650,9 @@ class Selector {
     MultiArg = 0x3,
     MultiArg = 0x3,
     ArgFlags = ZeroArg|OneArg
     ArgFlags = ZeroArg|OneArg
   };
   };
-  uintptr_t InfoPtr; // a pointer to the MultiKeywordSelector or IdentifierInfo.
+
+  // a pointer to the MultiKeywordSelector or IdentifierInfo.
+  uintptr_t InfoPtr = 0;
 
 
   Selector(IdentifierInfo *II, unsigned nArgs) {
   Selector(IdentifierInfo *II, unsigned nArgs) {
     InfoPtr = reinterpret_cast<uintptr_t>(II);
     InfoPtr = reinterpret_cast<uintptr_t>(II);
@@ -662,6 +660,7 @@ class Selector {
     assert(nArgs < 2 && "nArgs not equal to 0/1");
     assert(nArgs < 2 && "nArgs not equal to 0/1");
     InfoPtr |= nArgs+1;
     InfoPtr |= nArgs+1;
   }
   }
+
   Selector(MultiKeywordSelector *SI) {
   Selector(MultiKeywordSelector *SI) {
     InfoPtr = reinterpret_cast<uintptr_t>(SI);
     InfoPtr = reinterpret_cast<uintptr_t>(SI);
     assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
     assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
@@ -692,7 +691,7 @@ public:
 
 
   /// The default ctor should only be used when creating data structures that
   /// The default ctor should only be used when creating data structures that
   ///  will contain selectors.
   ///  will contain selectors.
-  Selector() : InfoPtr(0) {}
+  Selector() = default;
   Selector(uintptr_t V) : InfoPtr(V) {}
   Selector(uintptr_t V) : InfoPtr(V) {}
 
 
   /// operator==/!= - Indicate whether the specified selectors are identical.
   /// operator==/!= - Indicate whether the specified selectors are identical.
@@ -776,7 +775,8 @@ public:
 /// \brief This table allows us to fully hide how we implement
 /// \brief This table allows us to fully hide how we implement
 /// multi-keyword caching.
 /// multi-keyword caching.
 class SelectorTable {
 class SelectorTable {
-  void *Impl;  // Actually a SelectorTableImpl
+  // Actually a SelectorTableImpl
+  void *Impl;
 
 
 public:
 public:
   SelectorTable();
   SelectorTable();
@@ -793,6 +793,7 @@ public:
   Selector getUnarySelector(IdentifierInfo *ID) {
   Selector getUnarySelector(IdentifierInfo *ID) {
     return Selector(ID, 1);
     return Selector(ID, 1);
   }
   }
+
   Selector getNullarySelector(IdentifierInfo *ID) {
   Selector getNullarySelector(IdentifierInfo *ID) {
     return Selector(ID, 0);
     return Selector(ID, 0);
   }
   }
@@ -848,7 +849,7 @@ public:
   unsigned ExtraKindOrNumArgs;
   unsigned ExtraKindOrNumArgs;
 };
 };
 
 
-}  // end namespace clang
+}  // namespace clang
 
 
 namespace llvm {
 namespace llvm {
 
 
@@ -856,11 +857,11 @@ namespace llvm {
 /// DenseSets.
 /// DenseSets.
 template <>
 template <>
 struct DenseMapInfo<clang::Selector> {
 struct DenseMapInfo<clang::Selector> {
-  static inline clang::Selector getEmptyKey() {
+  static clang::Selector getEmptyKey() {
     return clang::Selector::getEmptyMarker();
     return clang::Selector::getEmptyMarker();
   }
   }
 
 
-  static inline clang::Selector getTombstoneKey() {
+  static clang::Selector getTombstoneKey() {
     return clang::Selector::getTombstoneMarker();
     return clang::Selector::getTombstoneMarker();
   }
   }
 
 
@@ -874,15 +875,13 @@ struct DenseMapInfo<clang::Selector> {
 template <>
 template <>
 struct isPodLike<clang::Selector> { static const bool value = true; };
 struct isPodLike<clang::Selector> { static const bool value = true; };
 
 
-template <typename T> struct PointerLikeTypeTraits;
-
 template<>
 template<>
 struct PointerLikeTypeTraits<clang::Selector> {
 struct PointerLikeTypeTraits<clang::Selector> {
-  static inline const void *getAsVoidPointer(clang::Selector P) {
+  static const void *getAsVoidPointer(clang::Selector P) {
     return P.getAsOpaquePtr();
     return P.getAsOpaquePtr();
   }
   }
 
 
-  static inline clang::Selector getFromVoidPointer(const void *P) {
+  static clang::Selector getFromVoidPointer(const void *P) {
     return clang::Selector(reinterpret_cast<uintptr_t>(P));
     return clang::Selector(reinterpret_cast<uintptr_t>(P));
   }
   }
 
 
@@ -893,11 +892,11 @@ struct PointerLikeTypeTraits<clang::Selector> {
 // are not guaranteed to be 8-byte aligned.
 // are not guaranteed to be 8-byte aligned.
 template<>
 template<>
 struct PointerLikeTypeTraits<clang::IdentifierInfo*> {
 struct PointerLikeTypeTraits<clang::IdentifierInfo*> {
-  static inline void *getAsVoidPointer(clang::IdentifierInfo* P) {
+  static void *getAsVoidPointer(clang::IdentifierInfo* P) {
     return P;
     return P;
   }
   }
 
 
-  static inline clang::IdentifierInfo *getFromVoidPointer(void *P) {
+  static clang::IdentifierInfo *getFromVoidPointer(void *P) {
     return static_cast<clang::IdentifierInfo*>(P);
     return static_cast<clang::IdentifierInfo*>(P);
   }
   }
 
 
@@ -906,17 +905,17 @@ struct PointerLikeTypeTraits<clang::IdentifierInfo*> {
 
 
 template<>
 template<>
 struct PointerLikeTypeTraits<const clang::IdentifierInfo*> {
 struct PointerLikeTypeTraits<const clang::IdentifierInfo*> {
-  static inline const void *getAsVoidPointer(const clang::IdentifierInfo* P) {
+  static const void *getAsVoidPointer(const clang::IdentifierInfo* P) {
     return P;
     return P;
   }
   }
 
 
-  static inline const clang::IdentifierInfo *getFromVoidPointer(const void *P) {
+  static const clang::IdentifierInfo *getFromVoidPointer(const void *P) {
     return static_cast<const clang::IdentifierInfo*>(P);
     return static_cast<const clang::IdentifierInfo*>(P);
   }
   }
 
 
   enum { NumLowBitsAvailable = 1 };
   enum { NumLowBitsAvailable = 1 };
 };
 };
 
 
-} // end namespace llvm
+} // namespace llvm
 
 
 #endif // LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
 #endif // LLVM_CLANG_BASIC_IDENTIFIERTABLE_H

+ 2 - 1
include/clang/Basic/LangOptions.h

@@ -77,7 +77,8 @@ public:
     DCC_CDecl,
     DCC_CDecl,
     DCC_FastCall,
     DCC_FastCall,
     DCC_StdCall,
     DCC_StdCall,
-    DCC_VectorCall
+    DCC_VectorCall,
+    DCC_RegCall
   };
   };
 
 
   enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
   enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };

+ 35 - 27
include/clang/Basic/Module.h

@@ -1,4 +1,4 @@
-//===--- Module.h - Describe a module ---------------------------*- C++ -*-===//
+//===- Module.h - Describe a module -----------------------------*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -6,12 +6,13 @@
 // License. See LICENSE.TXT for details.
 // License. See LICENSE.TXT for details.
 //
 //
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
-///
+//
 /// \file
 /// \file
 /// \brief Defines the clang::Module class, which describes a module in the
 /// \brief Defines the clang::Module class, which describes a module in the
 /// source code.
 /// source code.
-///
+//
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CLANG_BASIC_MODULE_H
 #ifndef LLVM_CLANG_BASIC_MODULE_H
 #define LLVM_CLANG_BASIC_MODULE_H
 #define LLVM_CLANG_BASIC_MODULE_H
 
 
@@ -19,6 +20,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SetVector.h"
@@ -26,22 +28,28 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include <array>
+#include <cassert>
+#include <cstdint>
+#include <ctime>
 #include <string>
 #include <string>
 #include <utility>
 #include <utility>
 #include <vector>
 #include <vector>
 
 
 namespace llvm {
 namespace llvm {
-  class raw_ostream;
-}
+
+class raw_ostream;
+
+} // namespace llvm
 
 
 namespace clang {
 namespace clang {
   
   
 class LangOptions;
 class LangOptions;
 class TargetInfo;
 class TargetInfo;
-class IdentifierInfo;
-  
+
 /// \brief Describes the name of a module.
 /// \brief Describes the name of a module.
-typedef SmallVector<std::pair<std::string, SourceLocation>, 2> ModuleId;
+using ModuleId = SmallVector<std::pair<std::string, SourceLocation>, 2>;
 
 
 /// The signature of a module, which is a hash of the AST content.
 /// The signature of a module, which is a hash of the AST content.
 struct ASTFileSignature : std::array<uint32_t, 5> {
 struct ASTFileSignature : std::array<uint32_t, 5> {
@@ -85,7 +93,7 @@ public:
   /// \brief The build directory of this module. This is the directory in
   /// \brief The build directory of this module. This is the directory in
   /// which the module is notionally built, and relative to which its headers
   /// which the module is notionally built, and relative to which its headers
   /// are found.
   /// are found.
-  const DirectoryEntry *Directory;
+  const DirectoryEntry *Directory = nullptr;
 
 
   /// \brief The presumed file name for the module map defining this module.
   /// \brief The presumed file name for the module map defining this module.
   /// Only non-empty when building from preprocessed source.
   /// Only non-empty when building from preprocessed source.
@@ -114,7 +122,7 @@ private:
 
 
   /// \brief The AST file if this is a top-level module which has a
   /// \brief The AST file if this is a top-level module which has a
   /// corresponding serialized AST file, or null otherwise.
   /// corresponding serialized AST file, or null otherwise.
-  const FileEntry *ASTFile;
+  const FileEntry *ASTFile = nullptr;
 
 
   /// \brief The top-level headers associated with this module.
   /// \brief The top-level headers associated with this module.
   llvm::SmallSetVector<const FileEntry *, 2> TopHeaders;
   llvm::SmallSetVector<const FileEntry *, 2> TopHeaders;
@@ -181,7 +189,7 @@ public:
 
 
   /// \brief An individual requirement: a feature name and a flag indicating
   /// \brief An individual requirement: a feature name and a flag indicating
   /// the required state of that feature.
   /// the required state of that feature.
-  typedef std::pair<std::string, bool> Requirement;
+  using Requirement = std::pair<std::string, bool>;
 
 
   /// \brief The set of language features required to use this module.
   /// \brief The set of language features required to use this module.
   ///
   ///
@@ -270,7 +278,7 @@ public:
   ///
   ///
   /// The pointer is the module being re-exported, while the bit will be true
   /// The pointer is the module being re-exported, while the bit will be true
   /// to indicate that this is a wildcard export.
   /// to indicate that this is a wildcard export.
-  typedef llvm::PointerIntPair<Module *, 1, bool> ExportDecl;
+  using ExportDecl = llvm::PointerIntPair<Module *, 1, bool>;
   
   
   /// \brief The set of export declarations.
   /// \brief The set of export declarations.
   SmallVector<ExportDecl, 2> Exports;
   SmallVector<ExportDecl, 2> Exports;
@@ -302,9 +310,9 @@ public:
   /// \brief A library or framework to link against when an entity from this
   /// \brief A library or framework to link against when an entity from this
   /// module is used.
   /// module is used.
   struct LinkLibrary {
   struct LinkLibrary {
-    LinkLibrary() : IsFramework(false) { }
+    LinkLibrary() = default;
     LinkLibrary(const std::string &Library, bool IsFramework)
     LinkLibrary(const std::string &Library, bool IsFramework)
-      : Library(Library), IsFramework(IsFramework) { }
+        : Library(Library), IsFramework(IsFramework) {}
     
     
     /// \brief The library to link against.
     /// \brief The library to link against.
     ///
     ///
@@ -313,7 +321,7 @@ public:
     std::string Library;
     std::string Library;
 
 
     /// \brief Whether this is a framework rather than a library.
     /// \brief Whether this is a framework rather than a library.
-    bool IsFramework;
+    bool IsFramework = false;
   };
   };
 
 
   /// \brief The set of libraries or frameworks to link against when
   /// \brief The set of libraries or frameworks to link against when
@@ -432,7 +440,6 @@ public:
   const Module *getTopLevelModule() const;
   const Module *getTopLevelModule() const;
   
   
   /// \brief Retrieve the name of the top-level module.
   /// \brief Retrieve the name of the top-level module.
-  ///
   StringRef getTopLevelModuleName() const {
   StringRef getTopLevelModuleName() const {
     return getTopLevelModule()->Name;
     return getTopLevelModule()->Name;
   }
   }
@@ -525,8 +532,8 @@ public:
 
 
   unsigned getVisibilityID() const { return VisibilityID; }
   unsigned getVisibilityID() const { return VisibilityID; }
 
 
-  typedef std::vector<Module *>::iterator submodule_iterator;
-  typedef std::vector<Module *>::const_iterator submodule_const_iterator;
+  using submodule_iterator = std::vector<Module *>::iterator;
+  using submodule_const_iterator = std::vector<Module *>::const_iterator;
   
   
   submodule_iterator submodule_begin() { return SubModules.begin(); }
   submodule_iterator submodule_begin() { return SubModules.begin(); }
   submodule_const_iterator submodule_begin() const {return SubModules.begin();}
   submodule_const_iterator submodule_begin() const {return SubModules.begin();}
@@ -551,7 +558,6 @@ public:
   }
   }
 
 
   /// \brief Print the module map for this module to the given stream. 
   /// \brief Print the module map for this module to the given stream. 
-  ///
   void print(raw_ostream &OS, unsigned Indent = 0) const;
   void print(raw_ostream &OS, unsigned Indent = 0) const;
   
   
   /// \brief Dump the contents of this module to the given output stream.
   /// \brief Dump the contents of this module to the given output stream.
@@ -564,7 +570,7 @@ private:
 /// \brief A set of visible modules.
 /// \brief A set of visible modules.
 class VisibleModuleSet {
 class VisibleModuleSet {
 public:
 public:
-  VisibleModuleSet() : Generation(0) {}
+  VisibleModuleSet() = default;
   VisibleModuleSet(VisibleModuleSet &&O)
   VisibleModuleSet(VisibleModuleSet &&O)
       : ImportLocs(std::move(O.ImportLocs)), Generation(O.Generation ? 1 : 0) {
       : ImportLocs(std::move(O.ImportLocs)), Generation(O.Generation ? 1 : 0) {
     O.ImportLocs.clear();
     O.ImportLocs.clear();
@@ -599,13 +605,15 @@ public:
 
 
   /// \brief A callback to call when a module is made visible (directly or
   /// \brief A callback to call when a module is made visible (directly or
   /// indirectly) by a call to \ref setVisible.
   /// indirectly) by a call to \ref setVisible.
-  typedef llvm::function_ref<void(Module *M)> VisibleCallback;
+  using VisibleCallback = llvm::function_ref<void(Module *M)>;
+
   /// \brief A callback to call when a module conflict is found. \p Path
   /// \brief A callback to call when a module conflict is found. \p Path
   /// consists of a sequence of modules from the conflicting module to the one
   /// consists of a sequence of modules from the conflicting module to the one
   /// made visible, where each was exported by the next.
   /// made visible, where each was exported by the next.
-  typedef llvm::function_ref<void(ArrayRef<Module *> Path,
-                                  Module *Conflict, StringRef Message)>
-      ConflictCallback;
+  using ConflictCallback =
+      llvm::function_ref<void(ArrayRef<Module *> Path, Module *Conflict,
+                         StringRef Message)>;
+
   /// \brief Make a specific module visible.
   /// \brief Make a specific module visible.
   void setVisible(Module *M, SourceLocation Loc,
   void setVisible(Module *M, SourceLocation Loc,
                   VisibleCallback Vis = [](Module *) {},
                   VisibleCallback Vis = [](Module *) {},
@@ -616,11 +624,11 @@ private:
   /// Import locations for each visible module. Indexed by the module's
   /// Import locations for each visible module. Indexed by the module's
   /// VisibilityID.
   /// VisibilityID.
   std::vector<SourceLocation> ImportLocs;
   std::vector<SourceLocation> ImportLocs;
+
   /// Visibility generation, bumped every time the visibility state changes.
   /// Visibility generation, bumped every time the visibility state changes.
-  unsigned Generation;
+  unsigned Generation = 0;
 };
 };
 
 
-} // end namespace clang
-
+} // namespace clang
 
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
 #endif // LLVM_CLANG_BASIC_MODULE_H

+ 3 - 0
include/clang/Basic/Sanitizers.def

@@ -135,6 +135,9 @@ SANITIZER("efficiency-working-set", EfficiencyWorkingSet)
 SANITIZER_GROUP("efficiency-all", Efficiency,
 SANITIZER_GROUP("efficiency-all", Efficiency,
                 EfficiencyCacheFrag | EfficiencyWorkingSet)
                 EfficiencyCacheFrag | EfficiencyWorkingSet)
 
 
+// Scudo hardened allocator
+SANITIZER("scudo", Scudo)
+
 // Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
 // Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
 // can be used to disable all the sanitizers.
 // can be used to disable all the sanitizers.
 SANITIZER_GROUP("all", All, ~0ULL)
 SANITIZER_GROUP("all", All, ~0ULL)

+ 35 - 37
include/clang/Basic/SourceManager.h

@@ -1,4 +1,4 @@
-//===--- SourceManager.h - Track and cache source files ---------*- C++ -*-===//
+//===- SourceManager.h - Track and cache source files -----------*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -6,7 +6,7 @@
 // License. See LICENSE.TXT for details.
 // License. See LICENSE.TXT for details.
 //
 //
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
-///
+//
 /// \file
 /// \file
 /// \brief Defines the SourceManager interface.
 /// \brief Defines the SourceManager interface.
 ///
 ///
@@ -29,14 +29,13 @@
 /// location in the source where the macro was originally defined,
 /// location in the source where the macro was originally defined,
 /// and the presumed location is where the line directive states that
 /// and the presumed location is where the line directive states that
 /// the line is 17, or any other line.
 /// the line is 17, or any other line.
-///
+//
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
 #ifndef LLVM_CLANG_BASIC_SOURCEMANAGER_H
 #ifndef LLVM_CLANG_BASIC_SOURCEMANAGER_H
 #define LLVM_CLANG_BASIC_SOURCEMANAGER_H
 #define LLVM_CLANG_BASIC_SOURCEMANAGER_H
 
 
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileManager.h"
-#include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/BitVector.h"
@@ -49,10 +48,8 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include <algorithm>
 #include <cassert>
 #include <cassert>
 #include <cstddef>
 #include <cstddef>
-#include <cstdint>
 #include <map>
 #include <map>
 #include <memory>
 #include <memory>
 #include <string>
 #include <string>
@@ -69,7 +66,6 @@ class SourceManager;
 
 
 /// \brief Public enums and private classes that are part of the
 /// \brief Public enums and private classes that are part of the
 /// SourceManager implementation.
 /// SourceManager implementation.
-///
 namespace SrcMgr {
 namespace SrcMgr {
 
 
   /// \brief Indicates whether a file or directory holds normal user code,
   /// \brief Indicates whether a file or directory holds normal user code,
@@ -100,6 +96,7 @@ namespace SrcMgr {
     enum CCFlags {
     enum CCFlags {
       /// \brief Whether the buffer is invalid.
       /// \brief Whether the buffer is invalid.
       InvalidFlag = 0x01,
       InvalidFlag = 0x01,
+
       /// \brief Whether the buffer should not be freed on destruction.
       /// \brief Whether the buffer should not be freed on destruction.
       DoNotFreeFlag = 0x02
       DoNotFreeFlag = 0x02
     };
     };
@@ -130,12 +127,12 @@ namespace SrcMgr {
     ///
     ///
     /// This is lazily computed.  This is owned by the SourceManager
     /// This is lazily computed.  This is owned by the SourceManager
     /// BumpPointerAllocator object.
     /// BumpPointerAllocator object.
-    unsigned *SourceLineCache;
+    unsigned *SourceLineCache = nullptr;
 
 
     /// \brief The number of lines in this ContentCache.
     /// \brief The number of lines in this ContentCache.
     ///
     ///
     /// This is only valid if SourceLineCache is non-null.
     /// This is only valid if SourceLineCache is non-null.
-    unsigned NumLines;
+    unsigned NumLines = 0;
 
 
     /// \brief Indicates whether the buffer itself was provided to override
     /// \brief Indicates whether the buffer itself was provided to override
     /// the actual file contents.
     /// the actual file contents.
@@ -157,15 +154,14 @@ namespace SrcMgr {
 
 
     ContentCache(const FileEntry *Ent, const FileEntry *contentEnt)
     ContentCache(const FileEntry *Ent, const FileEntry *contentEnt)
       : Buffer(nullptr, false), OrigEntry(Ent), ContentsEntry(contentEnt),
       : Buffer(nullptr, false), OrigEntry(Ent), ContentsEntry(contentEnt),
-        SourceLineCache(nullptr), NumLines(0), BufferOverridden(false),
-        IsSystemFile(false), IsTransient(false) {}
+        BufferOverridden(false), IsSystemFile(false), IsTransient(false) {}
     
     
     /// The copy ctor does not allow copies where source object has either
     /// The copy ctor does not allow copies where source object has either
     /// a non-NULL Buffer or SourceLineCache.  Ownership of allocated memory
     /// a non-NULL Buffer or SourceLineCache.  Ownership of allocated memory
     /// is not transferred, so this is a logical error.
     /// is not transferred, so this is a logical error.
     ContentCache(const ContentCache &RHS)
     ContentCache(const ContentCache &RHS)
-      : Buffer(nullptr, false), SourceLineCache(nullptr),
-        BufferOverridden(false), IsSystemFile(false), IsTransient(false) {
+      : Buffer(nullptr, false), BufferOverridden(false), IsSystemFile(false),
+        IsTransient(false) {
       OrigEntry = RHS.OrigEntry;
       OrigEntry = RHS.OrigEntry;
       ContentsEntry = RHS.ContentsEntry;
       ContentsEntry = RHS.ContentsEntry;
 
 
@@ -246,6 +242,10 @@ namespace SrcMgr {
   /// FileInfos contain a "ContentCache *", with the contents of the file.
   /// FileInfos contain a "ContentCache *", with the contents of the file.
   ///
   ///
   class FileInfo {
   class FileInfo {
+    friend class clang::SourceManager;
+    friend class clang::ASTWriter;
+    friend class clang::ASTReader;
+
     /// \brief The location of the \#include that brought in this file.
     /// \brief The location of the \#include that brought in this file.
     ///
     ///
     /// This is an invalid SLOC for the main file (top of the \#include chain).
     /// This is an invalid SLOC for the main file (top of the \#include chain).
@@ -264,10 +264,6 @@ namespace SrcMgr {
     llvm::PointerIntPair<const ContentCache*, 3, CharacteristicKind>
     llvm::PointerIntPair<const ContentCache*, 3, CharacteristicKind>
         ContentAndKind;
         ContentAndKind;
 
 
-    friend class clang::SourceManager;
-    friend class clang::ASTWriter;
-    friend class clang::ASTReader;
-
   public:
   public:
     /// \brief Return a FileInfo object.
     /// \brief Return a FileInfo object.
     static FileInfo get(SourceLocation IL, const ContentCache *Con,
     static FileInfo get(SourceLocation IL, const ContentCache *Con,
@@ -448,7 +444,7 @@ namespace SrcMgr {
     }
     }
   };
   };
 
 
-}  // end SrcMgr namespace.
+} // namespace SrcMgr
 
 
 /// \brief External source of source location entries.
 /// \brief External source of source location entries.
 class ExternalSLocEntrySource {
 class ExternalSLocEntrySource {
@@ -546,7 +542,7 @@ public:
 /// \brief The stack used when building modules on demand, which is used
 /// \brief The stack used when building modules on demand, which is used
 /// to provide a link between the source managers of the different compiler
 /// to provide a link between the source managers of the different compiler
 /// instances.
 /// instances.
-typedef ArrayRef<std::pair<std::string, FullSourceLoc>> ModuleBuildStack;
+using ModuleBuildStack = ArrayRef<std::pair<std::string, FullSourceLoc>>;
 
 
 /// \brief This class handles loading and caching of source files into memory.
 /// \brief This class handles loading and caching of source files into memory.
 ///
 ///
@@ -578,7 +574,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
 
 
   /// \brief True if the ContentCache for files that are overridden by other
   /// \brief True if the ContentCache for files that are overridden by other
   /// files, should report the original file name. Defaults to true.
   /// files, should report the original file name. Defaults to true.
-  bool OverridenFilesKeepOriginalName;
+  bool OverridenFilesKeepOriginalName = true;
 
 
   /// \brief True if non-system source files should be treated as volatile
   /// \brief True if non-system source files should be treated as volatile
   /// (likely to change while trying to use them). Defaults to false.
   /// (likely to change while trying to use them). Defaults to false.
@@ -587,12 +583,13 @@ class SourceManager : public RefCountedBase<SourceManager> {
   /// \brief True if all files read during this compilation should be treated
   /// \brief True if all files read during this compilation should be treated
   /// as transient (may not be present in later compilations using a module
   /// as transient (may not be present in later compilations using a module
   /// file created from this compilation). Defaults to false.
   /// file created from this compilation). Defaults to false.
-  bool FilesAreTransient;
+  bool FilesAreTransient = false;
 
 
   struct OverriddenFilesInfoTy {
   struct OverriddenFilesInfoTy {
     /// \brief Files that have been overridden with the contents from another
     /// \brief Files that have been overridden with the contents from another
     /// file.
     /// file.
     llvm::DenseMap<const FileEntry *, const FileEntry *> OverriddenFiles;
     llvm::DenseMap<const FileEntry *, const FileEntry *> OverriddenFiles;
+
     /// \brief Files that were overridden with a memory buffer.
     /// \brief Files that were overridden with a memory buffer.
     llvm::DenseSet<const FileEntry *> OverriddenFilesWithBuffer;
     llvm::DenseSet<const FileEntry *> OverriddenFilesWithBuffer;
   };
   };
@@ -647,7 +644,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
   llvm::BitVector SLocEntryLoaded;
   llvm::BitVector SLocEntryLoaded;
 
 
   /// \brief An external source for source location entries.
   /// \brief An external source for source location entries.
-  ExternalSLocEntrySource *ExternalSLocEntries;
+  ExternalSLocEntrySource *ExternalSLocEntries = nullptr;
 
 
   /// \brief A one-entry cache to speed up getFileID.
   /// \brief A one-entry cache to speed up getFileID.
   ///
   ///
@@ -658,7 +655,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
   /// \brief Holds information for \#line directives.
   /// \brief Holds information for \#line directives.
   ///
   ///
   /// This is referenced by indices from SLocEntryTable.
   /// This is referenced by indices from SLocEntryTable.
-  LineTableInfo *LineTable;
+  LineTableInfo *LineTable = nullptr;
 
 
   /// \brief These ivars serve as a cache used in the getLineNumber
   /// \brief These ivars serve as a cache used in the getLineNumber
   /// method which is used to speedup getLineNumber calls to nearby locations.
   /// method which is used to speedup getLineNumber calls to nearby locations.
@@ -674,7 +671,8 @@ class SourceManager : public RefCountedBase<SourceManager> {
   FileID PreambleFileID;
   FileID PreambleFileID;
 
 
   // Statistics for -print-stats.
   // Statistics for -print-stats.
-  mutable unsigned NumLinearScans, NumBinaryProbes;
+  mutable unsigned NumLinearScans = 0;
+  mutable unsigned NumBinaryProbes = 0;
 
 
   /// \brief Associates a FileID with its "included/expanded in" decomposed
   /// \brief Associates a FileID with its "included/expanded in" decomposed
   /// location.
   /// location.
@@ -684,12 +682,12 @@ class SourceManager : public RefCountedBase<SourceManager> {
   mutable llvm::DenseMap<FileID, std::pair<FileID, unsigned>> IncludedLocMap;
   mutable llvm::DenseMap<FileID, std::pair<FileID, unsigned>> IncludedLocMap;
 
 
   /// The key value into the IsBeforeInTUCache table.
   /// The key value into the IsBeforeInTUCache table.
-  typedef std::pair<FileID, FileID> IsBeforeInTUCacheKey;
+  using IsBeforeInTUCacheKey = std::pair<FileID, FileID>;
 
 
   /// The IsBeforeInTranslationUnitCache is a mapping from FileID pairs
   /// The IsBeforeInTranslationUnitCache is a mapping from FileID pairs
   /// to cache results.
   /// to cache results.
-  typedef llvm::DenseMap<IsBeforeInTUCacheKey, InBeforeInTUCacheEntry>
-          InBeforeInTUCache;
+  using InBeforeInTUCache =
+      llvm::DenseMap<IsBeforeInTUCacheKey, InBeforeInTUCacheEntry>;
 
 
   /// Cache results for the isBeforeInTranslationUnit method.
   /// Cache results for the isBeforeInTranslationUnit method.
   mutable InBeforeInTUCache IBTUCache;
   mutable InBeforeInTUCache IBTUCache;
@@ -706,7 +704,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
 
 
   /// \brief Lazily computed map of macro argument chunks to their expanded
   /// \brief Lazily computed map of macro argument chunks to their expanded
   /// source location.
   /// source location.
-  typedef std::map<unsigned, SourceLocation> MacroArgsMap;
+  using MacroArgsMap = std::map<unsigned, SourceLocation>;
 
 
   mutable llvm::DenseMap<FileID, std::unique_ptr<MacroArgsMap>>
   mutable llvm::DenseMap<FileID, std::unique_ptr<MacroArgsMap>>
       MacroArgsCacheMap;
       MacroArgsCacheMap;
@@ -1417,7 +1415,6 @@ public:
   //===--------------------------------------------------------------------===//
   //===--------------------------------------------------------------------===//
 
 
   /// \brief Return the uniqued ID for the specified filename.
   /// \brief Return the uniqued ID for the specified filename.
-  ///
   unsigned getLineTableFilenameID(StringRef Str);
   unsigned getLineTableFilenameID(StringRef Str);
 
 
   /// \brief Add a line note to the line table for the FileID and offset
   /// \brief Add a line note to the line table for the FileID and offset
@@ -1538,8 +1535,9 @@ public:
   }
   }
 
 
   // Iterators over FileInfos.
   // Iterators over FileInfos.
-  typedef llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*>
-      ::const_iterator fileinfo_iterator;
+  using fileinfo_iterator =
+      llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*>::const_iterator;
+
   fileinfo_iterator fileinfo_begin() const { return FileInfos.begin(); }
   fileinfo_iterator fileinfo_begin() const { return FileInfos.begin(); }
   fileinfo_iterator fileinfo_end() const { return FileInfos.end(); }
   fileinfo_iterator fileinfo_end() const { return FileInfos.end(); }
   bool hasFileInfo(const FileEntry *File) const {
   bool hasFileInfo(const FileEntry *File) const {
@@ -1547,7 +1545,6 @@ public:
   }
   }
 
 
   /// \brief Print statistics to stderr.
   /// \brief Print statistics to stderr.
-  ///
   void PrintStats() const;
   void PrintStats() const;
 
 
   void dump() const;
   void dump() const;
@@ -1638,6 +1635,9 @@ public:
   }
   }
 
 
 private:
 private:
+  friend class ASTReader;
+  friend class ASTWriter;
+
   llvm::MemoryBuffer *getFakeBufferForRecovery() const;
   llvm::MemoryBuffer *getFakeBufferForRecovery() const;
   const SrcMgr::ContentCache *getFakeContentCacheForRecovery() const;
   const SrcMgr::ContentCache *getFakeContentCacheForRecovery() const;
 
 
@@ -1729,8 +1729,6 @@ private:
                                          SourceLocation SpellLoc,
                                          SourceLocation SpellLoc,
                                          SourceLocation ExpansionLoc,
                                          SourceLocation ExpansionLoc,
                                          unsigned ExpansionLength) const;
                                          unsigned ExpansionLength) const;
-  friend class ASTReader;
-  friend class ASTWriter;
 };
 };
 
 
 /// \brief Comparison function object.
 /// \brief Comparison function object.
@@ -1743,7 +1741,7 @@ class BeforeThanCompare<SourceLocation> {
   SourceManager &SM;
   SourceManager &SM;
 
 
 public:
 public:
-  explicit BeforeThanCompare(SourceManager &SM) : SM(SM) { }
+  explicit BeforeThanCompare(SourceManager &SM) : SM(SM) {}
 
 
   bool operator()(SourceLocation LHS, SourceLocation RHS) const {
   bool operator()(SourceLocation LHS, SourceLocation RHS) const {
     return SM.isBeforeInTranslationUnit(LHS, RHS);
     return SM.isBeforeInTranslationUnit(LHS, RHS);
@@ -1756,13 +1754,13 @@ class BeforeThanCompare<SourceRange> {
   SourceManager &SM;
   SourceManager &SM;
 
 
 public:
 public:
-  explicit BeforeThanCompare(SourceManager &SM) : SM(SM) { }
+  explicit BeforeThanCompare(SourceManager &SM) : SM(SM) {}
 
 
   bool operator()(SourceRange LHS, SourceRange RHS) const {
   bool operator()(SourceRange LHS, SourceRange RHS) const {
     return SM.isBeforeInTranslationUnit(LHS.getBegin(), RHS.getBegin());
     return SM.isBeforeInTranslationUnit(LHS.getBegin(), RHS.getBegin());
   }
   }
 };
 };
 
 
-} // end namespace clang
+} // namespace clang
 
 
 #endif // LLVM_CLANG_BASIC_SOURCEMANAGER_H
 #endif // LLVM_CLANG_BASIC_SOURCEMANAGER_H

+ 15 - 7
include/clang/Basic/SourceManagerInternals.h

@@ -1,4 +1,4 @@
-//===--- SourceManagerInternals.h - SourceManager Internals -----*- C++ -*-===//
+//===- SourceManagerInternals.h - SourceManager Internals -------*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -6,10 +6,10 @@
 // License. See LICENSE.TXT for details.
 // License. See LICENSE.TXT for details.
 //
 //
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
-///
+//
 /// \file
 /// \file
 /// \brief Defines implementation details of the clang::SourceManager class.
 /// \brief Defines implementation details of the clang::SourceManager class.
-///
+//
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
 #ifndef LLVM_CLANG_BASIC_SOURCEMANAGERINTERNALS_H
 #ifndef LLVM_CLANG_BASIC_SOURCEMANAGERINTERNALS_H
@@ -18,7 +18,11 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
+#include <cassert>
 #include <map>
 #include <map>
+#include <vector>
 
 
 namespace clang {
 namespace clang {
 
 
@@ -86,7 +90,8 @@ class LineTableInfo {
 
 
   /// \brief Map from FileIDs to a list of line entries (sorted by the offset
   /// \brief Map from FileIDs to a list of line entries (sorted by the offset
   /// at which they occur in the file).
   /// at which they occur in the file).
-  std::map<FileID, std::vector<LineEntry> > LineEntries;
+  std::map<FileID, std::vector<LineEntry>> LineEntries;
+
 public:
 public:
   void clear() {
   void clear() {
     FilenameIDs.clear();
     FilenameIDs.clear();
@@ -95,10 +100,12 @@ public:
   }
   }
 
 
   unsigned getLineTableFilenameID(StringRef Str);
   unsigned getLineTableFilenameID(StringRef Str);
+
   StringRef getFilename(unsigned ID) const {
   StringRef getFilename(unsigned ID) const {
     assert(ID < FilenamesByID.size() && "Invalid FilenameID");
     assert(ID < FilenamesByID.size() && "Invalid FilenameID");
     return FilenamesByID[ID]->getKey();
     return FilenamesByID[ID]->getKey();
   }
   }
+
   unsigned getNumFilenames() const { return FilenamesByID.size(); }
   unsigned getNumFilenames() const { return FilenamesByID.size(); }
 
 
   void AddLineNote(FileID FID, unsigned Offset,
   void AddLineNote(FileID FID, unsigned Offset,
@@ -112,7 +119,8 @@ public:
   const LineEntry *FindNearestLineEntry(FileID FID, unsigned Offset);
   const LineEntry *FindNearestLineEntry(FileID FID, unsigned Offset);
 
 
   // Low-level access
   // Low-level access
-  typedef std::map<FileID, std::vector<LineEntry> >::iterator iterator;
+  using iterator = std::map<FileID, std::vector<LineEntry>>::iterator;
+
   iterator begin() { return LineEntries.begin(); }
   iterator begin() { return LineEntries.begin(); }
   iterator end() { return LineEntries.end(); }
   iterator end() { return LineEntries.end(); }
 
 
@@ -121,6 +129,6 @@ public:
   void AddEntry(FileID FID, const std::vector<LineEntry> &Entries);
   void AddEntry(FileID FID, const std::vector<LineEntry> &Entries);
 };
 };
 
 
-} // end namespace clang
+} // namespace clang
 
 
-#endif
+#endif // LLVM_CLANG_BASIC_SOURCEMANAGERINTERNALS_H

+ 1 - 1
include/clang/Driver/CC1Options.td

@@ -704,7 +704,7 @@ def fnative_half_arguments_and_returns : Flag<["-"], "fnative-half-arguments-and
 def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">,
 def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">,
   HelpText<"Allow function arguments and returns of type half">;
   HelpText<"Allow function arguments and returns of type half">;
 def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
 def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
-  HelpText<"Set default MS calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall">;
+  HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">;
 def finclude_default_header : Flag<["-"], "finclude-default-header">,
 def finclude_default_header : Flag<["-"], "finclude-default-header">,
   HelpText<"Include the default header file for OpenCL">;
   HelpText<"Include the default header file for OpenCL">;
 def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,
 def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,

+ 2 - 0
include/clang/Driver/CLCompatOptions.td

@@ -302,6 +302,8 @@ def _SLASH_Gz : CLFlag<"Gz">,
   HelpText<"Set __stdcall as a default calling convention">;
   HelpText<"Set __stdcall as a default calling convention">;
 def _SLASH_Gv : CLFlag<"Gv">,
 def _SLASH_Gv : CLFlag<"Gv">,
   HelpText<"Set __vectorcall as a default calling convention">;
   HelpText<"Set __vectorcall as a default calling convention">;
+def _SLASH_Gregcall : CLFlag<"Gregcall">,
+  HelpText<"Set __regcall as a default calling convention">;
 
 
 // Ignored:
 // Ignored:
 
 

+ 5 - 1
include/clang/Driver/Options.td

@@ -519,7 +519,7 @@ def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-round
 def client__name : JoinedOrSeparate<["-"], "client_name">;
 def client__name : JoinedOrSeparate<["-"], "client_name">;
 def combine : Flag<["-", "--"], "combine">, Flags<[DriverOption, Unsupported]>;
 def combine : Flag<["-", "--"], "combine">, Flags<[DriverOption, Unsupported]>;
 def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">;
 def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">;
-def coverage : Flag<["-", "--"], "coverage">;
+def coverage : Flag<["-", "--"], "coverage">, Flags<[CoreOption]>;
 def cpp_precomp : Flag<["-"], "cpp-precomp">, Group<clang_ignored_f_Group>;
 def cpp_precomp : Flag<["-"], "cpp-precomp">, Group<clang_ignored_f_Group>;
 def current__version : JoinedOrSeparate<["-"], "current_version">;
 def current__version : JoinedOrSeparate<["-"], "current_version">;
 def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group<clang_i_Group>,
 def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group<clang_i_Group>,
@@ -1384,6 +1384,10 @@ def fpic : Flag<["-"], "fpic">, Group<f_Group>;
 def fno_pic : Flag<["-"], "fno-pic">, Group<f_Group>;
 def fno_pic : Flag<["-"], "fno-pic">, Group<f_Group>;
 def fpie : Flag<["-"], "fpie">, Group<f_Group>;
 def fpie : Flag<["-"], "fpie">, Group<f_Group>;
 def fno_pie : Flag<["-"], "fno-pie">, Group<f_Group>;
 def fno_pie : Flag<["-"], "fno-pie">, Group<f_Group>;
+def fplt : Flag<["-"], "fplt">, Group<f_Group>, Flags<[CC1Option]>,
+  HelpText<"Use the PLT to make function calls">;
+def fno_plt : Flag<["-"], "fno-plt">, Group<f_Group>, Flags<[CC1Option]>,
+  HelpText<"Do not use the PLT to make function calls">;
 def fropi : Flag<["-"], "fropi">, Group<f_Group>;
 def fropi : Flag<["-"], "fropi">, Group<f_Group>;
 def fno_ropi : Flag<["-"], "fno-ropi">, Group<f_Group>;
 def fno_ropi : Flag<["-"], "fno-ropi">, Group<f_Group>;
 def frwpi : Flag<["-"], "frwpi">, Group<f_Group>;
 def frwpi : Flag<["-"], "frwpi">, Group<f_Group>;

+ 1 - 0
include/clang/Driver/SanitizerArgs.h

@@ -72,6 +72,7 @@ class SanitizerArgs {
   bool needsEsanRt() const {
   bool needsEsanRt() const {
     return Sanitizers.hasOneOf(SanitizerKind::Efficiency);
     return Sanitizers.hasOneOf(SanitizerKind::Efficiency);
   }
   }
+  bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
 
 
   bool requiresPIE() const;
   bool requiresPIE() const;
   bool needsUnwindTables() const;
   bool needsUnwindTables() const;

+ 2 - 0
include/clang/Frontend/CodeGenOptions.def

@@ -297,6 +297,8 @@ CODEGENOPT(PreserveVec3Type, 1, 0)
 /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
 /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
 CODEGENOPT(GnuPubnames, 1, 0)
 CODEGENOPT(GnuPubnames, 1, 0)
 
 
+CODEGENOPT(NoPLT, 1, 0)
+
 #undef CODEGENOPT
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
 #undef VALUE_CODEGENOPT

+ 7 - 0
include/clang/Lex/Lexer.h

@@ -466,6 +466,13 @@ public:
                                         const LangOptions &LangOpts,
                                         const LangOptions &LangOpts,
                                         unsigned MaxLines = 0);
                                         unsigned MaxLines = 0);
 
 
+  /// Finds the token that comes right after the given location.
+  ///
+  /// Returns the next token, or none if the location is inside a macro.
+  static Optional<Token> findNextToken(SourceLocation Loc,
+                                       const SourceManager &SM,
+                                       const LangOptions &LangOpts);
+
   /// \brief Checks that the given token is the first token that occurs after
   /// \brief Checks that the given token is the first token that occurs after
   /// the given location (this excludes comments and whitespace). Returns the
   /// the given location (this excludes comments and whitespace). Returns the
   /// location immediately after the specified token. If the token is not found
   /// location immediately after the specified token. If the token is not found

+ 31 - 2
include/clang/Lex/Preprocessor.h

@@ -286,6 +286,23 @@ class Preprocessor {
   /// This is used when loading a precompiled preamble.
   /// This is used when loading a precompiled preamble.
   std::pair<int, bool> SkipMainFilePreamble;
   std::pair<int, bool> SkipMainFilePreamble;
 
 
+public:
+  struct PreambleSkipInfo {
+    PreambleSkipInfo(SourceLocation HashTokenLoc, SourceLocation IfTokenLoc,
+                     bool FoundNonSkipPortion, bool FoundElse,
+                     SourceLocation ElseLoc)
+        : HashTokenLoc(HashTokenLoc), IfTokenLoc(IfTokenLoc),
+          FoundNonSkipPortion(FoundNonSkipPortion), FoundElse(FoundElse),
+          ElseLoc(ElseLoc) {}
+
+    SourceLocation HashTokenLoc;
+    SourceLocation IfTokenLoc;
+    bool FoundNonSkipPortion;
+    bool FoundElse;
+    SourceLocation ElseLoc;
+  };
+
+private:
   class PreambleConditionalStackStore {
   class PreambleConditionalStackStore {
     enum State {
     enum State {
       Off = 0,
       Off = 0,
@@ -319,6 +336,12 @@ class Preprocessor {
 
 
     bool hasRecordedPreamble() const { return !ConditionalStack.empty(); }
     bool hasRecordedPreamble() const { return !ConditionalStack.empty(); }
 
 
+    bool reachedEOFWhileSkipping() const { return SkipInfo.hasValue(); }
+
+    void clearSkipInfo() { SkipInfo.reset(); }
+
+    llvm::Optional<PreambleSkipInfo> SkipInfo;
+
   private:
   private:
     SmallVector<PPConditionalInfo, 4> ConditionalStack;
     SmallVector<PPConditionalInfo, 4> ConditionalStack;
     State ConditionalStackState;
     State ConditionalStackState;
@@ -1839,7 +1862,7 @@ private:
   /// \p FoundElse is false, then \#else directives are ok, if not, then we have
   /// \p FoundElse is false, then \#else directives are ok, if not, then we have
   /// already seen one so a \#else directive is a duplicate.  When this returns,
   /// already seen one so a \#else directive is a duplicate.  When this returns,
   /// the caller can lex the first valid token.
   /// the caller can lex the first valid token.
-  void SkipExcludedConditionalBlock(const Token &HashToken,
+  void SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
                                     SourceLocation IfTokenLoc,
                                     SourceLocation IfTokenLoc,
                                     bool FoundNonSkipPortion, bool FoundElse,
                                     bool FoundNonSkipPortion, bool FoundElse,
                                     SourceLocation ElseLoc = SourceLocation());
                                     SourceLocation ElseLoc = SourceLocation());
@@ -2019,9 +2042,15 @@ public:
     PreambleConditionalStack.setStack(s);
     PreambleConditionalStack.setStack(s);
   }
   }
 
 
-  void setReplayablePreambleConditionalStack(ArrayRef<PPConditionalInfo> s) {
+  void setReplayablePreambleConditionalStack(ArrayRef<PPConditionalInfo> s,
+                                             llvm::Optional<PreambleSkipInfo> SkipInfo) {
     PreambleConditionalStack.startReplaying();
     PreambleConditionalStack.startReplaying();
     PreambleConditionalStack.setStack(s);
     PreambleConditionalStack.setStack(s);
+    PreambleConditionalStack.SkipInfo = SkipInfo;
+  }
+
+  llvm::Optional<PreambleSkipInfo> getPreambleSkipInfo() const {
+    return PreambleConditionalStack.SkipInfo;
   }
   }
 
 
 private:
 private:

File diff suppressed because it is too large
+ 303 - 31
include/clang/Serialization/ASTBitCodes.h


+ 184 - 136
include/clang/Serialization/ASTReader.h

@@ -1,4 +1,4 @@
-//===--- ASTReader.h - AST File Reader --------------------------*- C++ -*-===//
+//===- ASTReader.h - AST File Reader ----------------------------*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -17,13 +17,21 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateBase.h"
+#include "clang/AST/TemplateName.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/Module.h"
+#include "clang/Basic/OpenCLOptions.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Version.h"
 #include "clang/Basic/Version.h"
+#include "clang/Basic/VersionTuple.h"
 #include "clang/Lex/ExternalPreprocessorSource.h"
 #include "clang/Lex/ExternalPreprocessorSource.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Lex/PreprocessingRecord.h"
+#include "clang/Lex/Token.h"
 #include "clang/Sema/ExternalSemaSource.h"
 #include "clang/Sema/ExternalSemaSource.h"
 #include "clang/Sema/IdentifierResolver.h"
 #include "clang/Sema/IdentifierResolver.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTBitCodes.h"
@@ -31,70 +39,86 @@
 #include "clang/Serialization/Module.h"
 #include "clang/Serialization/Module.h"
 #include "clang/Serialization/ModuleFileExtension.h"
 #include "clang/Serialization/ModuleFileExtension.h"
 #include "clang/Serialization/ModuleManager.h"
 #include "clang/Serialization/ModuleManager.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/TinyPtrVector.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/Timer.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <ctime>
 #include <deque>
 #include <deque>
 #include <memory>
 #include <memory>
+#include <set>
 #include <string>
 #include <string>
 #include <utility>
 #include <utility>
 #include <vector>
 #include <vector>
 
 
-namespace llvm {
-  class BitstreamCursor;
-  class MemoryBuffer;
-  class APInt;
-  class APSInt;
-  class APFloat;
-}
-
 namespace clang {
 namespace clang {
 
 
-class SourceManager;
-class HeaderSearchOptions;
-class FileManager;
-class AddrLabelExpr;
 class ASTConsumer;
 class ASTConsumer;
 class ASTContext;
 class ASTContext;
-class ASTIdentifierIterator;
-class ASTUnit; // FIXME: Layering violation and egregious hack.
-class Attr;
-class Decl;
-class DeclContext;
-class DefMacroDirective;
-class DiagnosticOptions;
-class NestedNameSpecifier;
+class ASTDeserializationListener;
+class ASTReader;
+class ASTRecordReader;
 class CXXBaseSpecifier;
 class CXXBaseSpecifier;
 class CXXConstructorDecl;
 class CXXConstructorDecl;
 class CXXCtorInitializer;
 class CXXCtorInitializer;
+class CXXTemporary;
+class Decl;
+class DeclaratorDecl;
+class DeclContext;
+class EnumDecl;
+class Expr;
+class FieldDecl;
+class FileEntry;
+class FileManager;
+class FileSystemOptions;
+class FunctionDecl;
 class GlobalModuleIndex;
 class GlobalModuleIndex;
-class GotoStmt;
-class MacroDefinition;
-class MacroDirective;
-class ModuleMacro;
+struct HeaderFileInfo;
+class HeaderSearchOptions;
+class LangOptions;
+class LazyASTUnresolvedSet;
+class MacroInfo;
+class MemoryBufferCache;
 class NamedDecl;
 class NamedDecl;
-class OpaqueValueExpr;
+class NamespaceDecl;
+class NestedNameSpecifier;
+class ObjCCategoryDecl;
+class ObjCInterfaceDecl;
+class PCHContainerReader;
 class Preprocessor;
 class Preprocessor;
 class PreprocessorOptions;
 class PreprocessorOptions;
+struct QualifierInfo;
 class Sema;
 class Sema;
+class SourceManager;
+class Stmt;
 class SwitchCase;
 class SwitchCase;
-class ASTDeserializationListener;
-class ASTWriter;
-class ASTReader;
-class ASTDeclReader;
-class ASTStmtReader;
-class ASTRecordReader;
-class TypeLocReader;
-struct HeaderFileInfo;
-class VersionTuple;
 class TargetOptions;
 class TargetOptions;
-class LazyASTUnresolvedSet;
+class TemplateParameterList;
+class TypedefNameDecl;
+class TypeSourceInfo;
+class ValueDecl;
+class VarDecl;
 
 
 /// \brief Abstract interface for callback invocations by the ASTReader.
 /// \brief Abstract interface for callback invocations by the ASTReader.
 ///
 ///
@@ -189,9 +213,11 @@ public:
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// input files of the AST file via \c visitInputFile, false otherwise.
   /// input files of the AST file via \c visitInputFile, false otherwise.
   virtual bool needsInputFileVisitation() { return false; }
   virtual bool needsInputFileVisitation() { return false; }
+
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// system input files of the AST file via \c visitInputFile, false otherwise.
   /// system input files of the AST file via \c visitInputFile, false otherwise.
   virtual bool needsSystemInputFileVisitation() { return false; }
   virtual bool needsSystemInputFileVisitation() { return false; }
+
   /// \brief if \c needsInputFileVisitation returns true, this is called for
   /// \brief if \c needsInputFileVisitation returns true, this is called for
   /// each non-system input file of the AST File. If
   /// each non-system input file of the AST File. If
   /// \c needsSystemInputFileVisitation is true, then it is called for all
   /// \c needsSystemInputFileVisitation is true, then it is called for all
@@ -206,6 +232,7 @@ public:
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// imports of the AST file via \c visitImport, false otherwise.
   /// imports of the AST file via \c visitImport, false otherwise.
   virtual bool needsImportVisitation() const { return false; }
   virtual bool needsImportVisitation() const { return false; }
+
   /// \brief If needsImportVisitation returns \c true, this is called for each
   /// \brief If needsImportVisitation returns \c true, this is called for each
   /// AST file imported by this AST file.
   /// AST file imported by this AST file.
   virtual void visitImport(StringRef Filename) {}
   virtual void visitImport(StringRef Filename) {}
@@ -306,12 +333,15 @@ namespace serialization {
 class ReadMethodPoolVisitor;
 class ReadMethodPoolVisitor;
 
 
 namespace reader {
 namespace reader {
-  class ASTIdentifierLookupTrait;
-  /// \brief The on-disk hash table(s) used for DeclContext name lookup.
-  struct DeclContextLookupTable;
-}
 
 
-} // end namespace serialization
+class ASTIdentifierLookupTrait;
+
+/// \brief The on-disk hash table(s) used for DeclContext name lookup.
+struct DeclContextLookupTable;
+
+} // namespace reader
+
+} // namespace serialization
 
 
 /// \brief Reads an AST files chain containing the contents of a translation
 /// \brief Reads an AST files chain containing the contents of a translation
 /// unit.
 /// unit.
@@ -334,8 +364,20 @@ class ASTReader
     public ExternalSLocEntrySource
     public ExternalSLocEntrySource
 {
 {
 public:
 public:
-  typedef SmallVector<uint64_t, 64> RecordData;
-  typedef SmallVectorImpl<uint64_t> RecordDataImpl;
+  /// \brief Types of AST files.
+  friend class ASTDeclReader;
+  friend class ASTIdentifierIterator;
+  friend class ASTRecordReader;
+  friend class ASTStmtReader;
+  friend class ASTUnit; // ASTUnit needs to remap source locations.
+  friend class ASTWriter;
+  friend class PCHValidator;
+  friend class serialization::reader::ASTIdentifierLookupTrait;
+  friend class serialization::ReadMethodPoolVisitor;
+  friend class TypeLocReader;
+
+  using RecordData = SmallVector<uint64_t, 64>;
+  using RecordDataImpl = SmallVectorImpl<uint64_t>;
 
 
   /// \brief The result of reading the control block of an AST file, which
   /// \brief The result of reading the control block of an AST file, which
   /// can fail for various reasons.
   /// can fail for various reasons.
@@ -343,41 +385,34 @@ public:
     /// \brief The control block was read successfully. Aside from failures,
     /// \brief The control block was read successfully. Aside from failures,
     /// the AST file is safe to read into the current context.
     /// the AST file is safe to read into the current context.
     Success,
     Success,
+
     /// \brief The AST file itself appears corrupted.
     /// \brief The AST file itself appears corrupted.
     Failure,
     Failure,
+
     /// \brief The AST file was missing.
     /// \brief The AST file was missing.
     Missing,
     Missing,
+
     /// \brief The AST file is out-of-date relative to its input files,
     /// \brief The AST file is out-of-date relative to its input files,
     /// and needs to be regenerated.
     /// and needs to be regenerated.
     OutOfDate,
     OutOfDate,
+
     /// \brief The AST file was written by a different version of Clang.
     /// \brief The AST file was written by a different version of Clang.
     VersionMismatch,
     VersionMismatch,
+
     /// \brief The AST file was writtten with a different language/target
     /// \brief The AST file was writtten with a different language/target
     /// configuration.
     /// configuration.
     ConfigurationMismatch,
     ConfigurationMismatch,
+
     /// \brief The AST file has errors.
     /// \brief The AST file has errors.
     HadErrors
     HadErrors
   };
   };
 
 
-  /// \brief Types of AST files.
-  friend class PCHValidator;
-  friend class ASTDeclReader;
-  friend class ASTStmtReader;
-  friend class ASTIdentifierIterator;
-  friend class serialization::reader::ASTIdentifierLookupTrait;
-  friend class TypeLocReader;
-  friend class ASTRecordReader;
-  friend class ASTWriter;
-  friend class ASTUnit; // ASTUnit needs to remap source locations.
-  friend class serialization::ReadMethodPoolVisitor;
-
-  typedef serialization::ModuleFile ModuleFile;
-  typedef serialization::ModuleKind ModuleKind;
-  typedef serialization::ModuleManager ModuleManager;
-
-  typedef ModuleManager::ModuleIterator ModuleIterator;
-  typedef ModuleManager::ModuleConstIterator ModuleConstIterator;
-  typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator;
+  using ModuleFile = serialization::ModuleFile;
+  using ModuleKind = serialization::ModuleKind;
+  using ModuleManager = serialization::ModuleManager;
+  using ModuleIterator = ModuleManager::ModuleIterator;
+  using ModuleConstIterator = ModuleManager::ModuleConstIterator;
+  using ModuleReverseIterator = ModuleManager::ModuleReverseIterator;
 
 
 private:
 private:
   /// \brief The receiver of some callbacks invoked by ASTReader.
   /// \brief The receiver of some callbacks invoked by ASTReader.
@@ -385,6 +420,7 @@ private:
 
 
   /// \brief The receiver of deserialization events.
   /// \brief The receiver of deserialization events.
   ASTDeserializationListener *DeserializationListener = nullptr;
   ASTDeserializationListener *DeserializationListener = nullptr;
+
   bool OwnsDeserializationListener = false;
   bool OwnsDeserializationListener = false;
 
 
   SourceManager &SourceMgr;
   SourceManager &SourceMgr;
@@ -436,7 +472,8 @@ private:
   /// \brief A map of negated SLocEntryIDs to the modules containing them.
   /// \brief A map of negated SLocEntryIDs to the modules containing them.
   ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap;
   ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap;
 
 
-  typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType;
+  using GlobalSLocOffsetMapType =
+      ContinuousRangeMap<unsigned, ModuleFile *, 64>;
 
 
   /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
   /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
   /// SourceLocation offsets to the modules containing them.
   /// SourceLocation offsets to the modules containing them.
@@ -448,8 +485,8 @@ private:
   /// ID = (I + 1) << FastQual::Width has already been loaded
   /// ID = (I + 1) << FastQual::Width has already been loaded
   std::vector<QualType> TypesLoaded;
   std::vector<QualType> TypesLoaded;
 
 
-  typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4>
-    GlobalTypeMapType;
+  using GlobalTypeMapType =
+      ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4>;
 
 
   /// \brief Mapping from global type IDs to the module in which the
   /// \brief Mapping from global type IDs to the module in which the
   /// type resides along with the offset that should be added to the
   /// type resides along with the offset that should be added to the
@@ -462,17 +499,17 @@ private:
   /// = I + 1 has already been loaded.
   /// = I + 1 has already been loaded.
   std::vector<Decl *> DeclsLoaded;
   std::vector<Decl *> DeclsLoaded;
 
 
-  typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4>
-    GlobalDeclMapType;
+  using GlobalDeclMapType =
+      ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4>;
 
 
   /// \brief Mapping from global declaration IDs to the module in which the
   /// \brief Mapping from global declaration IDs to the module in which the
   /// declaration resides.
   /// declaration resides.
   GlobalDeclMapType GlobalDeclMap;
   GlobalDeclMapType GlobalDeclMap;
 
 
-  typedef std::pair<ModuleFile *, uint64_t> FileOffset;
-  typedef SmallVector<FileOffset, 2> FileOffsetsTy;
-  typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
-      DeclUpdateOffsetsMap;
+  using FileOffset = std::pair<ModuleFile *, uint64_t>;
+  using FileOffsetsTy = SmallVector<FileOffset, 2>;
+  using DeclUpdateOffsetsMap =
+      llvm::DenseMap<serialization::DeclID, FileOffsetsTy>;
 
 
   /// \brief Declarations that have modifications residing in a later file
   /// \brief Declarations that have modifications residing in a later file
   /// in the chain.
   /// in the chain.
@@ -481,12 +518,15 @@ private:
   struct PendingUpdateRecord {
   struct PendingUpdateRecord {
     Decl *D;
     Decl *D;
     serialization::GlobalDeclID ID;
     serialization::GlobalDeclID ID;
+
     // Whether the declaration was just deserialized.
     // Whether the declaration was just deserialized.
     bool JustLoaded;
     bool JustLoaded;
+
     PendingUpdateRecord(serialization::GlobalDeclID ID, Decl *D,
     PendingUpdateRecord(serialization::GlobalDeclID ID, Decl *D,
                         bool JustLoaded)
                         bool JustLoaded)
         : D(D), ID(ID), JustLoaded(JustLoaded) {}
         : D(D), ID(ID), JustLoaded(JustLoaded) {}
   };
   };
+
   /// \brief Declaration updates for already-loaded declarations that we need
   /// \brief Declaration updates for already-loaded declarations that we need
   /// to apply once we finish processing an import.
   /// to apply once we finish processing an import.
   llvm::SmallVector<PendingUpdateRecord, 16> PendingUpdateRecords;
   llvm::SmallVector<PendingUpdateRecord, 16> PendingUpdateRecords;
@@ -505,7 +545,7 @@ private:
 
 
   /// \brief Declarations that have been imported and have typedef names for
   /// \brief Declarations that have been imported and have typedef names for
   /// linkage purposes.
   /// linkage purposes.
-  llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*>
+  llvm::DenseMap<std::pair<DeclContext *, IdentifierInfo *>, NamedDecl *>
       ImportedTypedefNamesForLinkage;
       ImportedTypedefNamesForLinkage;
 
 
   /// \brief Mergeable declaration contexts that have anonymous declarations
   /// \brief Mergeable declaration contexts that have anonymous declarations
@@ -514,10 +554,10 @@ private:
     AnonymousDeclarationsForMerging;
     AnonymousDeclarationsForMerging;
 
 
   struct FileDeclsInfo {
   struct FileDeclsInfo {
-    ModuleFile *Mod;
+    ModuleFile *Mod = nullptr;
     ArrayRef<serialization::LocalDeclID> Decls;
     ArrayRef<serialization::LocalDeclID> Decls;
 
 
-    FileDeclsInfo() : Mod(nullptr) {}
+    FileDeclsInfo() = default;
     FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
     FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
       : Mod(Mod), Decls(Decls) {}
       : Mod(Mod), Decls(Decls) {}
   };
   };
@@ -527,7 +567,7 @@ private:
 
 
   /// \brief An array of lexical contents of a declaration context, as a sequence of
   /// \brief An array of lexical contents of a declaration context, as a sequence of
   /// Decl::Kind, DeclID pairs.
   /// Decl::Kind, DeclID pairs.
-  typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents;
+  using LexicalContents = ArrayRef<llvm::support::unaligned_uint32_t>;
 
 
   /// \brief Map from a DeclContext to its lexical contents.
   /// \brief Map from a DeclContext to its lexical contents.
   llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
   llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
@@ -548,7 +588,7 @@ private:
     ModuleFile *Mod;
     ModuleFile *Mod;
     const unsigned char *Data;
     const unsigned char *Data;
   };
   };
-  typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates;
+  using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate, 1>;
 
 
   /// \brief Updates to the visible declarations of declaration contexts that
   /// \brief Updates to the visible declarations of declaration contexts that
   /// haven't been loaded yet.
   /// haven't been loaded yet.
@@ -559,22 +599,23 @@ private:
   /// declarations that have not yet been linked to their definitions.
   /// declarations that have not yet been linked to their definitions.
   llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
   llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
 
 
-  typedef llvm::MapVector<Decl *, uint64_t,
-                          llvm::SmallDenseMap<Decl *, unsigned, 4>,
-                          SmallVector<std::pair<Decl *, uint64_t>, 4> >
-    PendingBodiesMap;
+  using PendingBodiesMap =
+      llvm::MapVector<Decl *, uint64_t,
+                      llvm::SmallDenseMap<Decl *, unsigned, 4>,
+                      SmallVector<std::pair<Decl *, uint64_t>, 4>>;
 
 
   /// \brief Functions or methods that have bodies that will be attached.
   /// \brief Functions or methods that have bodies that will be attached.
   PendingBodiesMap PendingBodies;
   PendingBodiesMap PendingBodies;
 
 
   /// \brief Definitions for which we have added merged definitions but not yet
   /// \brief Definitions for which we have added merged definitions but not yet
   /// performed deduplication.
   /// performed deduplication.
-  llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate;
+  llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate;
 
 
   /// \brief Read the record that describes the lexical contents of a DC.
   /// \brief Read the record that describes the lexical contents of a DC.
   bool ReadLexicalDeclContextStorage(ModuleFile &M,
   bool ReadLexicalDeclContextStorage(ModuleFile &M,
                                      llvm::BitstreamCursor &Cursor,
                                      llvm::BitstreamCursor &Cursor,
                                      uint64_t Offset, DeclContext *DC);
                                      uint64_t Offset, DeclContext *DC);
+
   /// \brief Read the record that describes the visible contents of a DC.
   /// \brief Read the record that describes the visible contents of a DC.
   bool ReadVisibleDeclContextStorage(ModuleFile &M,
   bool ReadVisibleDeclContextStorage(ModuleFile &M,
                                      llvm::BitstreamCursor &Cursor,
                                      llvm::BitstreamCursor &Cursor,
@@ -588,8 +629,8 @@ private:
   /// been loaded.
   /// been loaded.
   std::vector<IdentifierInfo *> IdentifiersLoaded;
   std::vector<IdentifierInfo *> IdentifiersLoaded;
 
 
-  typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>
-    GlobalIdentifierMapType;
+  using GlobalIdentifierMapType =
+      ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>;
 
 
   /// \brief Mapping from global identifier IDs to the module in which the
   /// \brief Mapping from global identifier IDs to the module in which the
   /// identifier resides along with the offset that should be added to the
   /// identifier resides along with the offset that should be added to the
@@ -604,16 +645,16 @@ private:
   /// been loaded.
   /// been loaded.
   std::vector<MacroInfo *> MacrosLoaded;
   std::vector<MacroInfo *> MacrosLoaded;
 
 
-  typedef std::pair<IdentifierInfo *, serialization::SubmoduleID>
-      LoadedMacroInfo;
+  using LoadedMacroInfo =
+      std::pair<IdentifierInfo *, serialization::SubmoduleID>;
 
 
   /// \brief A set of #undef directives that we have loaded; used to
   /// \brief A set of #undef directives that we have loaded; used to
   /// deduplicate the same #undef information coming from multiple module
   /// deduplicate the same #undef information coming from multiple module
   /// files.
   /// files.
   llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
   llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
 
 
-  typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
-    GlobalMacroMapType;
+  using GlobalMacroMapType =
+      ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>;
 
 
   /// \brief Mapping from global macro IDs to the module in which the
   /// \brief Mapping from global macro IDs to the module in which the
   /// macro resides along with the offset that should be added to the
   /// macro resides along with the offset that should be added to the
@@ -626,8 +667,8 @@ private:
   /// indicate that the particular submodule ID has not yet been loaded.
   /// indicate that the particular submodule ID has not yet been loaded.
   SmallVector<Module *, 2> SubmodulesLoaded;
   SmallVector<Module *, 2> SubmodulesLoaded;
   
   
-  typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>
-    GlobalSubmoduleMapType;
+  using GlobalSubmoduleMapType =
+      ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>;
   
   
   /// \brief Mapping from global submodule IDs to the module file in which the
   /// \brief Mapping from global submodule IDs to the module file in which the
   /// submodule resides along with the offset that should be added to the
   /// submodule resides along with the offset that should be added to the
@@ -635,14 +676,13 @@ private:
   GlobalSubmoduleMapType GlobalSubmoduleMap;
   GlobalSubmoduleMapType GlobalSubmoduleMap;
 
 
   /// \brief A set of hidden declarations.
   /// \brief A set of hidden declarations.
-  typedef SmallVector<Decl*, 2> HiddenNames;
-  typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;
+  using HiddenNames = SmallVector<Decl *, 2>;
+  using HiddenNamesMapType = llvm::DenseMap<Module *, HiddenNames>;
 
 
   /// \brief A mapping from each of the hidden submodules to the deserialized
   /// \brief A mapping from each of the hidden submodules to the deserialized
   /// declarations in that submodule that could be made visible.
   /// declarations in that submodule that could be made visible.
   HiddenNamesMapType HiddenNamesMap;
   HiddenNamesMapType HiddenNamesMap;
   
   
-  
   /// \brief A module import, export, or conflict that hasn't yet been resolved.
   /// \brief A module import, export, or conflict that hasn't yet been resolved.
   struct UnresolvedModuleRef {
   struct UnresolvedModuleRef {
     /// \brief The file in which this module resides.
     /// \brief The file in which this module resides.
@@ -675,11 +715,10 @@ private:
   /// been loaded.
   /// been loaded.
   SmallVector<Selector, 16> SelectorsLoaded;
   SmallVector<Selector, 16> SelectorsLoaded;
 
 
-  typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>
-    GlobalSelectorMapType;
+  using GlobalSelectorMapType =
+      ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>;
 
 
   /// \brief Mapping from global selector IDs to the module in which the
   /// \brief Mapping from global selector IDs to the module in which the
-
   /// global selector ID to produce a local ID.
   /// global selector ID to produce a local ID.
   GlobalSelectorMapType GlobalSelectorMap;
   GlobalSelectorMapType GlobalSelectorMap;
 
 
@@ -699,15 +738,15 @@ private:
         : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
         : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
   };
   };
 
 
-  typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> >
-    PendingMacroIDsMap;
+  using PendingMacroIDsMap =
+      llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2>>;
 
 
   /// \brief Mapping from identifiers that have a macro history to the global
   /// \brief Mapping from identifiers that have a macro history to the global
   /// IDs have not yet been deserialized to the global IDs of those macros.
   /// IDs have not yet been deserialized to the global IDs of those macros.
   PendingMacroIDsMap PendingMacroIDs;
   PendingMacroIDsMap PendingMacroIDs;
 
 
-  typedef ContinuousRangeMap<unsigned, ModuleFile *, 4>
-    GlobalPreprocessedEntityMapType;
+  using GlobalPreprocessedEntityMapType =
+      ContinuousRangeMap<unsigned, ModuleFile *, 4>;
 
 
   /// \brief Mapping from global preprocessing entity IDs to the module in
   /// \brief Mapping from global preprocessing entity IDs to the module in
   /// which the preprocessed entity resides along with the offset that should be
   /// which the preprocessed entity resides along with the offset that should be
@@ -895,7 +934,8 @@ private:
   ///\brief Whether we are currently processing update records.
   ///\brief Whether we are currently processing update records.
   bool ProcessingUpdateRecords = false;
   bool ProcessingUpdateRecords = false;
 
 
-  typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy;
+  using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>;
+
   /// \brief Mapping from switch-case IDs in the chain to switch-case statements
   /// \brief Mapping from switch-case IDs in the chain to switch-case statements
   ///
   ///
   /// Statements usually don't have IDs, but switch cases need them, so that the
   /// Statements usually don't have IDs, but switch cases need them, so that the
@@ -979,7 +1019,7 @@ private:
   ///
   ///
   /// The declarations on the identifier chain for these identifiers will be
   /// The declarations on the identifier chain for these identifiers will be
   /// loaded once the recursive loading has completed.
   /// loaded once the recursive loading has completed.
-  llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> >
+  llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4>>
     PendingIdentifierInfos;
     PendingIdentifierInfos;
 
 
   /// \brief The set of lookup results that we have faked in order to support
   /// \brief The set of lookup results that we have faked in order to support
@@ -998,7 +1038,9 @@ private:
   public:
   public:
     InterestingDecl(Decl *D, bool HasBody)
     InterestingDecl(Decl *D, bool HasBody)
         : D(D), DeclHasPendingBody(HasBody) {}
         : D(D), DeclHasPendingBody(HasBody) {}
+
     Decl *getDecl() { return D; }
     Decl *getDecl() { return D; }
+
     /// Whether the declaration has a pending body.
     /// Whether the declaration has a pending body.
     bool hasPendingBody() { return DeclHasPendingBody; }
     bool hasPendingBody() { return DeclHasPendingBody; }
   };
   };
@@ -1062,8 +1104,8 @@ private:
   /// module is loaded.
   /// module is loaded.
   SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
   SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
 
 
-  typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> >
-    KeyDeclsMap;
+  using KeyDeclsMap =
+      llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2>>;
     
     
   /// \brief A mapping from canonical declarations to the set of global
   /// \brief A mapping from canonical declarations to the set of global
   /// declaration IDs for key declaration that have been merged with that
   /// declaration IDs for key declaration that have been merged with that
@@ -1097,15 +1139,14 @@ private:
     ASTReader &Reader;
     ASTReader &Reader;
     enum ReadingKind PrevKind;
     enum ReadingKind PrevKind;
 
 
-    ReadingKindTracker(const ReadingKindTracker &) = delete;
-    void operator=(const ReadingKindTracker &) = delete;
-
   public:
   public:
     ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader)
     ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader)
       : Reader(reader), PrevKind(Reader.ReadingKind) {
       : Reader(reader), PrevKind(Reader.ReadingKind) {
       Reader.ReadingKind = newKind;
       Reader.ReadingKind = newKind;
     }
     }
 
 
+    ReadingKindTracker(const ReadingKindTracker &) = delete;
+    ReadingKindTracker &operator=(const ReadingKindTracker &) = delete;
     ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
     ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
   };
   };
 
 
@@ -1114,15 +1155,15 @@ private:
     ASTReader &Reader;
     ASTReader &Reader;
     bool PrevState;
     bool PrevState;
 
 
-    ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete;
-    void operator=(const ProcessingUpdatesRAIIObj &) = delete;
-
   public:
   public:
     ProcessingUpdatesRAIIObj(ASTReader &reader)
     ProcessingUpdatesRAIIObj(ASTReader &reader)
       : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
       : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
       Reader.ProcessingUpdateRecords = true;
       Reader.ProcessingUpdateRecords = true;
     }
     }
 
 
+    ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete;
+    ProcessingUpdatesRAIIObj &
+    operator=(const ProcessingUpdatesRAIIObj &) = delete;
     ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
     ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
   };
   };
 
 
@@ -1205,7 +1246,7 @@ private:
     ImportedModule(ModuleFile *Mod,
     ImportedModule(ModuleFile *Mod,
                    ModuleFile *ImportedBy,
                    ModuleFile *ImportedBy,
                    SourceLocation ImportLoc)
                    SourceLocation ImportLoc)
-      : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { }
+      : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) {}
   };
   };
 
 
   ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
   ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
@@ -1266,10 +1307,11 @@ private:
                                        std::string &SuggestedPredefines);
                                        std::string &SuggestedPredefines);
 
 
   struct RecordLocation {
   struct RecordLocation {
-    RecordLocation(ModuleFile *M, uint64_t O)
-      : F(M), Offset(O) {}
     ModuleFile *F;
     ModuleFile *F;
     uint64_t Offset;
     uint64_t Offset;
+
+    RecordLocation(ModuleFile *M, uint64_t O)
+      : F(M), Offset(O) {}
   };
   };
 
 
   QualType readTypeRecord(unsigned Index);
   QualType readTypeRecord(unsigned Index);
@@ -1328,12 +1370,11 @@ public:
             ModuleDeclIterator, const serialization::LocalDeclID *,
             ModuleDeclIterator, const serialization::LocalDeclID *,
             std::random_access_iterator_tag, const Decl *, ptrdiff_t,
             std::random_access_iterator_tag, const Decl *, ptrdiff_t,
             const Decl *, const Decl *> {
             const Decl *, const Decl *> {
-    ASTReader *Reader;
-    ModuleFile *Mod;
+    ASTReader *Reader = nullptr;
+    ModuleFile *Mod = nullptr;
 
 
   public:
   public:
-    ModuleDeclIterator()
-        : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {}
+    ModuleDeclIterator() : iterator_adaptor_base(nullptr) {}
 
 
     ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod,
     ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod,
                        const serialization::LocalDeclID *Pos)
                        const serialization::LocalDeclID *Pos)
@@ -1342,6 +1383,7 @@ public:
     value_type operator*() const {
     value_type operator*() const {
       return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I));
       return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I));
     }
     }
+
     value_type operator->() const { return **this; }
     value_type operator->() const { return **this; }
 
 
     bool operator==(const ModuleDeclIterator &RHS) const {
     bool operator==(const ModuleDeclIterator &RHS) const {
@@ -1378,8 +1420,6 @@ private:
   void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
   void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
              StringRef Arg2 = StringRef()) const;
              StringRef Arg2 = StringRef()) const;
 
 
-  ASTReader(const ASTReader &) = delete;
-  void operator=(const ASTReader &) = delete;
 public:
 public:
   /// \brief Load the AST file and validate its contents against the given
   /// \brief Load the AST file and validate its contents against the given
   /// Preprocessor.
   /// Preprocessor.
@@ -1428,7 +1468,8 @@ public:
             bool AllowConfigurationMismatch = false,
             bool AllowConfigurationMismatch = false,
             bool ValidateSystemInputs = false, bool UseGlobalIndex = true,
             bool ValidateSystemInputs = false, bool UseGlobalIndex = true,
             std::unique_ptr<llvm::Timer> ReadTimer = {});
             std::unique_ptr<llvm::Timer> ReadTimer = {});
-
+  ASTReader(const ASTReader &) = delete;
+  ASTReader &operator=(const ASTReader &) = delete;
   ~ASTReader() override;
   ~ASTReader() override;
 
 
   SourceManager &getSourceManager() const { return SourceMgr; }
   SourceManager &getSourceManager() const { return SourceMgr; }
@@ -1443,15 +1484,19 @@ public:
   enum LoadFailureCapabilities {
   enum LoadFailureCapabilities {
     /// \brief The client can't handle any AST loading failures.
     /// \brief The client can't handle any AST loading failures.
     ARR_None = 0,
     ARR_None = 0,
+
     /// \brief The client can handle an AST file that cannot load because it
     /// \brief The client can handle an AST file that cannot load because it
     /// is missing.
     /// is missing.
     ARR_Missing = 0x1,
     ARR_Missing = 0x1,
+
     /// \brief The client can handle an AST file that cannot load because it
     /// \brief The client can handle an AST file that cannot load because it
     /// is out-of-date relative to its input files.
     /// is out-of-date relative to its input files.
     ARR_OutOfDate = 0x2,
     ARR_OutOfDate = 0x2,
+
     /// \brief The client can handle an AST file that cannot load because it
     /// \brief The client can handle an AST file that cannot load because it
     /// was built with a different version of Clang.
     /// was built with a different version of Clang.
     ARR_VersionMismatch = 0x4,
     ARR_VersionMismatch = 0x4,
+
     /// \brief The client can handle an AST file that cannot load because it's
     /// \brief The client can handle an AST file that cannot load because it's
     /// compiled configuration doesn't match that of the context it was
     /// compiled configuration doesn't match that of the context it was
     /// loaded into.
     /// loaded into.
@@ -1522,11 +1567,11 @@ public:
   /// RAII object to temporarily add an AST callback listener.
   /// RAII object to temporarily add an AST callback listener.
   class ListenerScope {
   class ListenerScope {
     ASTReader &Reader;
     ASTReader &Reader;
-    bool Chained;
+    bool Chained = false;
 
 
   public:
   public:
     ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L)
     ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L)
-        : Reader(Reader), Chained(false) {
+        : Reader(Reader) {
       auto Old = Reader.takeListener();
       auto Old = Reader.takeListener();
       if (Old) {
       if (Old) {
         Chained = true;
         Chained = true;
@@ -1535,6 +1580,7 @@ public:
       }
       }
       Reader.setListener(std::move(L));
       Reader.setListener(std::move(L));
     }
     }
+
     ~ListenerScope() {
     ~ListenerScope() {
       auto New = Reader.takeListener();
       auto New = Reader.takeListener();
       if (Chained)
       if (Chained)
@@ -1933,16 +1979,16 @@ public:
       llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override;
       llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override;
 
 
   void ReadReferencedSelectors(
   void ReadReferencedSelectors(
-          SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override;
+           SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) override;
 
 
   void ReadWeakUndeclaredIdentifiers(
   void ReadWeakUndeclaredIdentifiers(
-          SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) override;
+           SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WI) override;
 
 
   void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override;
   void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override;
 
 
   void ReadPendingInstantiations(
   void ReadPendingInstantiations(
-                 SmallVectorImpl<std::pair<ValueDecl *,
-                                           SourceLocation> > &Pending) override;
+                  SmallVectorImpl<std::pair<ValueDecl *,
+                                            SourceLocation>> &Pending) override;
 
 
   void ReadLateParsedTemplates(
   void ReadLateParsedTemplates(
       llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
       llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
@@ -2275,20 +2321,19 @@ public:
 
 
 /// \brief An object for streaming information from a record.
 /// \brief An object for streaming information from a record.
 class ASTRecordReader {
 class ASTRecordReader {
-  typedef serialization::ModuleFile ModuleFile;
+  using ModuleFile = serialization::ModuleFile;
 
 
   ASTReader *Reader;
   ASTReader *Reader;
   ModuleFile *F;
   ModuleFile *F;
   unsigned Idx = 0;
   unsigned Idx = 0;
   ASTReader::RecordData Record;
   ASTReader::RecordData Record;
 
 
-  typedef ASTReader::RecordData RecordData;
-  typedef ASTReader::RecordDataImpl RecordDataImpl;
+  using RecordData = ASTReader::RecordData;
+  using RecordDataImpl = ASTReader::RecordDataImpl;
 
 
 public:
 public:
   /// Construct an ASTRecordReader that uses the default encoding scheme.
   /// Construct an ASTRecordReader that uses the default encoding scheme.
-  ASTRecordReader(ASTReader &Reader, ModuleFile &F)
-      : Reader(&Reader), F(&F) {}
+  ASTRecordReader(ASTReader &Reader, ModuleFile &F) : Reader(&Reader), F(&F) {}
 
 
   /// \brief Reads a record with id AbbrevID from Cursor, resetting the
   /// \brief Reads a record with id AbbrevID from Cursor, resetting the
   /// internal state.
   /// internal state.
@@ -2302,17 +2347,20 @@ public:
 
 
   /// \brief The current position in this record.
   /// \brief The current position in this record.
   unsigned getIdx() const { return Idx; }
   unsigned getIdx() const { return Idx; }
+
   /// \brief The length of this record.
   /// \brief The length of this record.
   size_t size() const { return Record.size(); }
   size_t size() const { return Record.size(); }
 
 
   /// \brief An arbitrary index in this record.
   /// \brief An arbitrary index in this record.
   const uint64_t &operator[](size_t N) { return Record[N]; }
   const uint64_t &operator[](size_t N) { return Record[N]; }
+
   /// \brief The last element in this record.
   /// \brief The last element in this record.
   const uint64_t &back() const { return Record.back(); }
   const uint64_t &back() const { return Record.back(); }
 
 
   /// \brief Returns the current value in this record, and advances to the
   /// \brief Returns the current value in this record, and advances to the
   /// next value.
   /// next value.
   const uint64_t &readInt() { return Record[Idx++]; }
   const uint64_t &readInt() { return Record[Idx++]; }
+
   /// \brief Returns the current value in this record, without advancing.
   /// \brief Returns the current value in this record, without advancing.
   const uint64_t &peekInt() { return Record[Idx]; }
   const uint64_t &peekInt() { return Record[Idx]; }
 
 
@@ -2566,7 +2614,7 @@ public:
 /// then restores it when destroyed.
 /// then restores it when destroyed.
 struct SavedStreamPosition {
 struct SavedStreamPosition {
   explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
   explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
-    : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { }
+    : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {}
 
 
   ~SavedStreamPosition() {
   ~SavedStreamPosition() {
     Cursor.JumpToBit(Offset);
     Cursor.JumpToBit(Offset);
@@ -2581,6 +2629,6 @@ inline void PCHValidator::Error(const char *Msg) {
   Reader.Error(Msg);
   Reader.Error(Msg);
 }
 }
 
 
-} // end namespace clang
+} // namespace clang
 
 
-#endif
+#endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H

+ 18 - 16
include/clang/Serialization/ContinuousRangeMap.h

@@ -1,4 +1,4 @@
-//===--- ContinuousRangeMap.h - Map with int range as key -------*- C++ -*-===//
+//===- ContinuousRangeMap.h - Map with int range as key ---------*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -18,6 +18,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/SmallVector.h"
 #include <algorithm>
 #include <algorithm>
+#include <cassert>
 #include <utility>
 #include <utility>
 
 
 namespace clang {
 namespace clang {
@@ -35,14 +36,15 @@ namespace clang {
 template <typename Int, typename V, unsigned InitialCapacity>
 template <typename Int, typename V, unsigned InitialCapacity>
 class ContinuousRangeMap {
 class ContinuousRangeMap {
 public:
 public:
-  typedef std::pair<Int, V> value_type;
-  typedef value_type &reference;
-  typedef const value_type &const_reference;
-  typedef value_type *pointer;
-  typedef const value_type *const_pointer;
+  using value_type = std::pair<Int, V>;
+  using reference = value_type &;
+  using const_reference = const value_type &;
+  using pointer = value_type *;
+  using const_pointer = const value_type *;
 
 
 private:
 private:
-  typedef SmallVector<value_type, InitialCapacity> Representation;
+  using Representation = SmallVector<value_type, InitialCapacity>;
+
   Representation Rep;
   Representation Rep;
 
 
   struct Compare {
   struct Compare {
@@ -52,7 +54,7 @@ private:
     bool operator ()(Int L, const_reference R) const {
     bool operator ()(Int L, const_reference R) const {
       return L < R.first;
       return L < R.first;
     }
     }
-    bool operator ()(Int L, Int R) const { 
+    bool operator ()(Int L, Int R) const {
       return L < R;
       return L < R;
     }
     }
     bool operator ()(const_reference L, const_reference R) const {
     bool operator ()(const_reference L, const_reference R) const {
@@ -80,8 +82,8 @@ public:
     Rep.insert(I, Val);
     Rep.insert(I, Val);
   }
   }
 
 
-  typedef typename Representation::iterator iterator;
-  typedef typename Representation::const_iterator const_iterator;
+  using iterator = typename Representation::iterator;
+  using const_iterator = typename Representation::const_iterator;
 
 
   iterator begin() { return Rep.begin(); }
   iterator begin() { return Rep.begin(); }
   iterator end() { return Rep.end(); }
   iterator end() { return Rep.end(); }
@@ -108,13 +110,12 @@ public:
   /// from a set of values.
   /// from a set of values.
   class Builder {
   class Builder {
     ContinuousRangeMap &Self;
     ContinuousRangeMap &Self;
-    
+
+  public:
+    explicit Builder(ContinuousRangeMap &Self) : Self(Self) {}
     Builder(const Builder&) = delete;
     Builder(const Builder&) = delete;
     Builder &operator=(const Builder&) = delete;
     Builder &operator=(const Builder&) = delete;
     
     
-  public:
-    explicit Builder(ContinuousRangeMap &Self) : Self(Self) { }
-    
     ~Builder() {
     ~Builder() {
       std::sort(Self.Rep.begin(), Self.Rep.end(), Compare());
       std::sort(Self.Rep.begin(), Self.Rep.end(), Compare());
       std::unique(Self.Rep.begin(), Self.Rep.end(),
       std::unique(Self.Rep.begin(), Self.Rep.end(),
@@ -131,9 +132,10 @@ public:
       Self.Rep.push_back(Val);
       Self.Rep.push_back(Val);
     }
     }
   };
   };
+
   friend class Builder;
   friend class Builder;
 };
 };
 
 
-}
+} // namespace clang
 
 
-#endif
+#endif // LLVM_CLANG_SERIALIZATION_CONTINUOUSRANGEMAP_H

+ 0 - 3
include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h

@@ -103,9 +103,6 @@ public:
     return *static_cast<const T *>(this);
     return *static_cast<const T *>(this);
   }
   }
 
 
-  /// BufferTy - A temporary buffer to hold a set of SVals.
-  typedef SmallVector<SVal,5> BufferTy;
-
   inline unsigned getRawKind() const { return Kind; }
   inline unsigned getRawKind() const { return Kind; }
   inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
   inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
   inline unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
   inline unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }

+ 7 - 0
include/clang/Tooling/Execution.h

@@ -162,6 +162,13 @@ createExecutorFromCommandLineArgs(int &argc, const char **argv,
                                   llvm::cl::OptionCategory &Category,
                                   llvm::cl::OptionCategory &Category,
                                   const char *Overview = nullptr);
                                   const char *Overview = nullptr);
 
 
+namespace internal {
+llvm::Expected<std::unique_ptr<ToolExecutor>>
+createExecutorFromCommandLineArgsImpl(int &argc, const char **argv,
+                                      llvm::cl::OptionCategory &Category,
+                                      const char *Overview = nullptr);
+} // end namespace internal
+
 } // end namespace tooling
 } // end namespace tooling
 } // end namespace clang
 } // end namespace clang
 
 

+ 12 - 0
include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h

@@ -70,6 +70,18 @@ public:
     return visit(Expr->getFoundDecl().getDecl(), Expr->getMemberLoc());
     return visit(Expr->getFoundDecl().getDecl(), Expr->getMemberLoc());
   }
   }
 
 
+  bool VisitOffsetOfExpr(const OffsetOfExpr *S) {
+    for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) {
+      const OffsetOfNode &Component = S->getComponent(I);
+      if (Component.getKind() == OffsetOfNode::Field) {
+        if (!visit(Component.getField(), Component.getLocEnd()))
+          return false;
+      }
+      // FIXME: Try to resolve dependent field references.
+    }
+    return true;
+  }
+
   // Other visitors:
   // Other visitors:
 
 
   bool VisitTypeLoc(const TypeLoc Loc) {
   bool VisitTypeLoc(const TypeLoc Loc) {

+ 22 - 0
include/clang/Tooling/Refactoring/Rename/RenamingAction.h

@@ -66,6 +66,28 @@ private:
   std::string NewName;
   std::string NewName;
 };
 };
 
 
+class QualifiedRenameRule final : public SourceChangeRefactoringRule {
+public:
+  static Expected<QualifiedRenameRule> initiate(RefactoringRuleContext &Context,
+                                                std::string OldQualifiedName,
+                                                std::string NewQualifiedName);
+
+  static const RefactoringDescriptor &describe();
+
+private:
+  QualifiedRenameRule(const NamedDecl *ND,
+                      std::string NewQualifiedName)
+      : ND(ND), NewQualifiedName(std::move(NewQualifiedName)) {}
+
+  Expected<AtomicChanges>
+  createSourceReplacements(RefactoringRuleContext &Context) override;
+
+  // A NamedDecl which indentifies the the symbol being renamed.
+  const NamedDecl *ND;
+  // The new qualified name to change the symbol to.
+  std::string NewQualifiedName;
+};
+
 /// Returns source replacements that correspond to the rename of the given
 /// Returns source replacements that correspond to the rename of the given
 /// symbol occurrences.
 /// symbol occurrences.
 llvm::Expected<std::vector<AtomicChange>>
 llvm::Expected<std::vector<AtomicChange>>

+ 5 - 0
lib/AST/ASTContext.cpp

@@ -9281,6 +9281,11 @@ CallingConv ASTContext::getDefaultCallingConvention(bool IsVariadic,
     if (!IsVariadic)
     if (!IsVariadic)
       return CC_X86VectorCall;
       return CC_X86VectorCall;
     break;
     break;
+  case LangOptions::DCC_RegCall:
+    // __regcall cannot be applied to variadic functions.
+    if (!IsVariadic)
+      return CC_X86RegCall;
+    break;
   }
   }
   return Target->getDefaultCallingConv(TargetInfo::CCMT_Unknown);
   return Target->getDefaultCallingConv(TargetInfo::CCMT_Unknown);
 }
 }

+ 1 - 0
lib/AST/CMakeLists.txt

@@ -49,6 +49,7 @@ add_clang_library(clangAST
   ODRHash.cpp
   ODRHash.cpp
   OpenMPClause.cpp
   OpenMPClause.cpp
   ParentMap.cpp
   ParentMap.cpp
+  QualTypeNames.cpp
   RawCommentList.cpp
   RawCommentList.cpp
   RecordLayout.cpp
   RecordLayout.cpp
   RecordLayoutBuilder.cpp
   RecordLayoutBuilder.cpp

+ 27 - 12
lib/AST/DeclBase.cpp

@@ -1,4 +1,4 @@
-//===--- DeclBase.cpp - Declaration AST Node Implementation ---------------===//
+//===- DeclBase.cpp - Declaration AST Node Implementation -----------------===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -15,6 +15,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/AttrIterator.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclContextInternals.h"
 #include "clang/AST/DeclContextInternals.h"
@@ -25,11 +26,30 @@
 #include "clang/AST/DependentDiagnostic.h"
 #include "clang/AST/DependentDiagnostic.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/Stmt.h"
-#include "clang/AST/StmtCXX.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/ObjCRuntime.h"
+#include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/VersionTuple.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <string>
+#include <tuple>
+#include <utility>
+
 using namespace clang;
 using namespace clang;
 
 
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
@@ -230,7 +250,6 @@ const DeclContext *Decl::getParentFunctionOrMethod() const {
   return nullptr;
   return nullptr;
 }
 }
 
 
-
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 // PrettyStackTraceDecl Implementation
 // PrettyStackTraceDecl Implementation
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
@@ -260,7 +279,7 @@ void PrettyStackTraceDecl::print(raw_ostream &OS) const {
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
 // Out-of-line virtual method providing a home for Decl.
 // Out-of-line virtual method providing a home for Decl.
-Decl::~Decl() { }
+Decl::~Decl() = default;
 
 
 void Decl::setDeclContext(DeclContext *DC) {
 void Decl::setDeclContext(DeclContext *DC) {
   DeclCtx = DC;
   DeclCtx = DC;
@@ -913,7 +932,6 @@ const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
   return Ty->getAs<FunctionType>();
   return Ty->getAs<FunctionType>();
 }
 }
 
 
-
 /// Starting at a given context (a Decl or DeclContext), look for a
 /// Starting at a given context (a Decl or DeclContext), look for a
 /// code context that is not a closure (a lambda, block, etc.).
 /// code context that is not a closure (a lambda, block, etc.).
 template <class T> static Decl *getNonClosureContext(T *D) {
 template <class T> static Decl *getNonClosureContext(T *D) {
@@ -966,7 +984,7 @@ bool DeclContext::classof(const Decl *D) {
   }
   }
 }
 }
 
 
-DeclContext::~DeclContext() { }
+DeclContext::~DeclContext() = default;
 
 
 /// \brief Find the parent context of this context that will be
 /// \brief Find the parent context of this context that will be
 /// used for unqualified name lookup.
 /// used for unqualified name lookup.
@@ -1057,15 +1075,14 @@ static bool isLinkageSpecContext(const DeclContext *DC,
 }
 }
 
 
 bool DeclContext::isExternCContext() const {
 bool DeclContext::isExternCContext() const {
-  return isLinkageSpecContext(this, clang::LinkageSpecDecl::lang_c);
+  return isLinkageSpecContext(this, LinkageSpecDecl::lang_c);
 }
 }
 
 
 const LinkageSpecDecl *DeclContext::getExternCContext() const {
 const LinkageSpecDecl *DeclContext::getExternCContext() const {
   const DeclContext *DC = this;
   const DeclContext *DC = this;
   while (DC->getDeclKind() != Decl::TranslationUnit) {
   while (DC->getDeclKind() != Decl::TranslationUnit) {
     if (DC->getDeclKind() == Decl::LinkageSpec &&
     if (DC->getDeclKind() == Decl::LinkageSpec &&
-        cast<LinkageSpecDecl>(DC)->getLanguage() ==
-            clang::LinkageSpecDecl::lang_c)
+        cast<LinkageSpecDecl>(DC)->getLanguage() == LinkageSpecDecl::lang_c)
       return cast<LinkageSpecDecl>(DC);
       return cast<LinkageSpecDecl>(DC);
     DC = DC->getLexicalParent();
     DC = DC->getLexicalParent();
   }
   }
@@ -1073,7 +1090,7 @@ const LinkageSpecDecl *DeclContext::getExternCContext() const {
 }
 }
 
 
 bool DeclContext::isExternCXXContext() const {
 bool DeclContext::isExternCXXContext() const {
-  return isLinkageSpecContext(this, clang::LinkageSpecDecl::lang_cxx);
+  return isLinkageSpecContext(this, LinkageSpecDecl::lang_cxx);
 }
 }
 
 
 bool DeclContext::Encloses(const DeclContext *DC) const {
 bool DeclContext::Encloses(const DeclContext *DC) const {
@@ -1108,13 +1125,11 @@ DeclContext *DeclContext::getPrimaryContext() {
   case Decl::ObjCInterface:
   case Decl::ObjCInterface:
     if (ObjCInterfaceDecl *Def = cast<ObjCInterfaceDecl>(this)->getDefinition())
     if (ObjCInterfaceDecl *Def = cast<ObjCInterfaceDecl>(this)->getDefinition())
       return Def;
       return Def;
-      
     return this;
     return this;
       
       
   case Decl::ObjCProtocol:
   case Decl::ObjCProtocol:
     if (ObjCProtocolDecl *Def = cast<ObjCProtocolDecl>(this)->getDefinition())
     if (ObjCProtocolDecl *Def = cast<ObjCProtocolDecl>(this)->getDefinition())
       return Def;
       return Def;
-    
     return this;
     return this;
       
       
   case Decl::ObjCCategory:
   case Decl::ObjCCategory:

+ 7 - 3
lib/AST/ExternalASTSource.cpp

@@ -1,4 +1,4 @@
-//===- ExternalASTSource.cpp - Abstract External AST Interface --*- C++ -*-===//
+//===- ExternalASTSource.cpp - Abstract External AST Interface ------------===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -16,12 +16,16 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/Module.h"
+#include "llvm/ADT/None.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorHandling.h"
+#include <cstdint>
 
 
 using namespace clang;
 using namespace clang;
 
 
-ExternalASTSource::~ExternalASTSource() { }
+ExternalASTSource::~ExternalASTSource() = default;
 
 
 llvm::Optional<ExternalASTSource::ASTSourceDescriptor>
 llvm::Optional<ExternalASTSource::ASTSourceDescriptor>
 ExternalASTSource::getSourceDescriptor(unsigned ID) {
 ExternalASTSource::getSourceDescriptor(unsigned ID) {
@@ -66,7 +70,7 @@ void ExternalASTSource::FinishedDeserializing() {}
 
 
 void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
 void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
 
 
-void ExternalASTSource::PrintStats() { }
+void ExternalASTSource::PrintStats() {}
 
 
 bool ExternalASTSource::layoutRecordType(
 bool ExternalASTSource::layoutRecordType(
     const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
     const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,

+ 1 - 12
lib/Tooling/Core/QualTypeNames.cpp → lib/AST/QualTypeNames.cpp

@@ -9,11 +9,11 @@
 //
 //
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
-#include "clang/Tooling/Core/QualTypeNames.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/GlobalDecl.h"
 #include "clang/AST/GlobalDecl.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/Mangle.h"
+#include "clang/AST/QualTypeNames.h"
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <memory>
 #include <memory>
@@ -21,17 +21,6 @@
 namespace clang {
 namespace clang {
 
 
 namespace TypeName {
 namespace TypeName {
-/// \brief Generates a QualType that can be used to name the same type
-/// if used at the end of the current translation unit. This ignores
-/// issues such as type shadowing.
-///
-/// \param[in] QT - the type for which the fully qualified type will be
-/// returned.
-/// \param[in] Ctx - the ASTContext to be used.
-/// \param[in] WithGlobalNsPrefix - Indicate whether the global namespace
-/// specifier "::" should be prepended or not.
-static QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
-                                      bool WithGlobalNsPrefix);
 
 
 /// \brief Create a NestedNameSpecifier for Namesp and its enclosing
 /// \brief Create a NestedNameSpecifier for Namesp and its enclosing
 /// scopes.
 /// scopes.

+ 32 - 29
lib/Analysis/BodyFarm.cpp

@@ -96,8 +96,8 @@ public:
   /// Create a Return statement.
   /// Create a Return statement.
   ReturnStmt *makeReturn(const Expr *RetVal);
   ReturnStmt *makeReturn(const Expr *RetVal);
   
   
-  /// Create an integer literal.
-  IntegerLiteral *makeIntegerLiteral(uint64_t value);
+  /// Create an integer literal expression of the given type.
+  IntegerLiteral *makeIntegerLiteral(uint64_t Value, QualType Ty);
 
 
   /// Create a member expression.
   /// Create a member expression.
   MemberExpr *makeMemberExpression(Expr *base, ValueDecl *MemberDecl,
   MemberExpr *makeMemberExpression(Expr *base, ValueDecl *MemberDecl,
@@ -206,11 +206,9 @@ ReturnStmt *ASTMaker::makeReturn(const Expr *RetVal) {
                             nullptr);
                             nullptr);
 }
 }
 
 
-IntegerLiteral *ASTMaker::makeIntegerLiteral(uint64_t value) {
-  return IntegerLiteral::Create(C,
-                                llvm::APInt(
-                                    /*numBits=*/C.getTypeSize(C.IntTy), value),
-                                /*QualType=*/C.IntTy, SourceLocation());
+IntegerLiteral *ASTMaker::makeIntegerLiteral(uint64_t Value, QualType Ty) {
+  llvm::APInt APValue = llvm::APInt(C.getTypeSize(Ty), Value);
+  return IntegerLiteral::Create(C, APValue, Ty, SourceLocation());
 }
 }
 
 
 MemberExpr *ASTMaker::makeMemberExpression(Expr *base, ValueDecl *MemberDecl,
 MemberExpr *ASTMaker::makeMemberExpression(Expr *base, ValueDecl *MemberDecl,
@@ -325,6 +323,16 @@ static Stmt *create_call_once(ASTContext &C, const FunctionDecl *D) {
 
 
   const ParmVarDecl *Flag = D->getParamDecl(0);
   const ParmVarDecl *Flag = D->getParamDecl(0);
   const ParmVarDecl *Callback = D->getParamDecl(1);
   const ParmVarDecl *Callback = D->getParamDecl(1);
+
+  if (!Callback->getType()->isReferenceType()) {
+    llvm::dbgs() << "libcxx03 std::call_once implementation, skipping.\n";
+    return nullptr;
+  }
+  if (!Flag->getType()->isReferenceType()) {
+    llvm::dbgs() << "unknown std::call_once implementation, skipping.\n";
+    return nullptr;
+  }
+
   QualType CallbackType = Callback->getType().getNonReferenceType();
   QualType CallbackType = Callback->getType().getNonReferenceType();
 
 
   // Nullable pointer, non-null iff function is a CXXRecordDecl.
   // Nullable pointer, non-null iff function is a CXXRecordDecl.
@@ -346,15 +354,13 @@ static Stmt *create_call_once(ASTContext &C, const FunctionDecl *D) {
   // Otherwise, try libstdc++ implementation, with a field
   // Otherwise, try libstdc++ implementation, with a field
   // `_M_once`
   // `_M_once`
   if (!FlagFieldDecl) {
   if (!FlagFieldDecl) {
-    DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-                       << "assuming libstdc++ implementation\n");
     FlagFieldDecl = M.findMemberField(FlagRecordDecl, "_M_once");
     FlagFieldDecl = M.findMemberField(FlagRecordDecl, "_M_once");
   }
   }
 
 
   if (!FlagFieldDecl) {
   if (!FlagFieldDecl) {
-    DEBUG(llvm::dbgs() << "No field _M_once found on std::once flag struct: "
-                       << "unknown std::call_once implementation, "
-                       << "ignoring the call");
+    DEBUG(llvm::dbgs() << "No field _M_once or __state_ found on "
+                       << "std::once_flag struct: unknown std::call_once "
+                       << "implementation, ignoring the call.");
     return nullptr;
     return nullptr;
   }
   }
 
 
@@ -388,9 +394,9 @@ static Stmt *create_call_once(ASTContext &C, const FunctionDecl *D) {
 
 
   // First two arguments are used for the flag and for the callback.
   // First two arguments are used for the flag and for the callback.
   if (D->getNumParams() != CallbackFunctionType->getNumParams() + 2) {
   if (D->getNumParams() != CallbackFunctionType->getNumParams() + 2) {
-    DEBUG(llvm::dbgs() << "Number of params of the callback does not match "
-                       << "the number of params passed to std::call_once, "
-                       << "ignoring the call");
+    DEBUG(llvm::dbgs() << "Types of params of the callback do not match "
+                       << "params passed to std::call_once, "
+                       << "ignoring the call\n");
     return nullptr;
     return nullptr;
   }
   }
 
 
@@ -439,7 +445,8 @@ static Stmt *create_call_once(ASTContext &C, const FunctionDecl *D) {
 
 
   // Create assignment.
   // Create assignment.
   BinaryOperator *FlagAssignment = M.makeAssignment(
   BinaryOperator *FlagAssignment = M.makeAssignment(
-      Deref, M.makeIntegralCast(M.makeIntegerLiteral(1), DerefType), DerefType);
+      Deref, M.makeIntegralCast(M.makeIntegerLiteral(1, C.IntTy), DerefType),
+      DerefType);
 
 
   IfStmt *Out = new (C)
   IfStmt *Out = new (C)
       IfStmt(C, SourceLocation(),
       IfStmt(C, SourceLocation(),
@@ -478,8 +485,8 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) {
   // sets it, and calls the block.  Basically, an AST dump of:
   // sets it, and calls the block.  Basically, an AST dump of:
   //
   //
   // void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block) {
   // void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block) {
-  //  if (!*predicate) {
-  //    *predicate = 1;
+  //  if (*predicate != ~0l) {
+  //    *predicate = ~0l;
   //    block();
   //    block();
   //  }
   //  }
   // }
   // }
@@ -496,7 +503,9 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) {
       /*SourceLocation=*/SourceLocation());
       /*SourceLocation=*/SourceLocation());
 
 
   // (2) Create the assignment to the predicate.
   // (2) Create the assignment to the predicate.
-  IntegerLiteral *IL = M.makeIntegerLiteral(1);
+  Expr *DoneValue =
+      new (C) UnaryOperator(M.makeIntegerLiteral(0, C.LongTy), UO_Not, C.LongTy,
+                            VK_RValue, OK_Ordinary, SourceLocation());
 
 
   BinaryOperator *B =
   BinaryOperator *B =
     M.makeAssignment(
     M.makeAssignment(
@@ -504,7 +513,7 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) {
           M.makeLvalueToRvalue(
           M.makeLvalueToRvalue(
             M.makeDeclRefExpr(Predicate), PredicateQPtrTy),
             M.makeDeclRefExpr(Predicate), PredicateQPtrTy),
             PredicateTy),
             PredicateTy),
-       M.makeIntegralCast(IL, PredicateTy),
+       M.makeIntegralCast(DoneValue, PredicateTy),
        PredicateTy);
        PredicateTy);
   
   
   // (3) Create the compound statement.
   // (3) Create the compound statement.
@@ -520,20 +529,14 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) {
           PredicateQPtrTy),
           PredicateQPtrTy),
         PredicateTy),
         PredicateTy),
     PredicateTy);
     PredicateTy);
-  
-  UnaryOperator *UO = new (C) UnaryOperator(
-      /* input=*/ LValToRval,
-      /* opc=*/ UO_LNot,
-      /* QualType=*/ C.IntTy,
-      /* ExprValueKind=*/ VK_RValue,
-      /* ExprObjectKind=*/ OK_Ordinary, SourceLocation());
-  
+
+  Expr *GuardCondition = M.makeComparison(LValToRval, DoneValue, BO_NE);
   // (5) Create the 'if' statement.
   // (5) Create the 'if' statement.
   IfStmt *If = new (C) IfStmt(C, SourceLocation(),
   IfStmt *If = new (C) IfStmt(C, SourceLocation(),
                               /* IsConstexpr=*/ false,
                               /* IsConstexpr=*/ false,
                               /* init=*/ nullptr,
                               /* init=*/ nullptr,
                               /* var=*/ nullptr,
                               /* var=*/ nullptr,
-                              /* cond=*/ UO,
+                              /* cond=*/ GuardCondition,
                               /* then=*/ CS);
                               /* then=*/ CS);
   return If;
   return If;
 }
 }

+ 43 - 25
lib/Basic/IdentifierTable.cpp

@@ -1,4 +1,4 @@
-//===--- IdentifierTable.cpp - Hash table for identifier lookup -----------===//
+//===- IdentifierTable.cpp - Hash table for identifier lookup -------------===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -12,17 +12,24 @@
 //
 //
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
-#include "clang/Basic/CharInfo.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Basic/Specifiers.h"
-#include "llvm/ADT/DenseMap.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/raw_ostream.h"
+#include <cassert>
 #include <cstdio>
 #include <cstdio>
+#include <cstring>
+#include <string>
 
 
 using namespace clang;
 using namespace clang;
 
 
@@ -46,27 +53,27 @@ IdentifierInfo::IdentifierInfo() {
   RevertedTokenID = false;
   RevertedTokenID = false;
   OutOfDate = false;
   OutOfDate = false;
   IsModulesImport = false;
   IsModulesImport = false;
-  FETokenInfo = nullptr;
-  Entry = nullptr;
 }
 }
 
 
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 // IdentifierTable Implementation
 // IdentifierTable Implementation
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
-IdentifierIterator::~IdentifierIterator() { }
+IdentifierIterator::~IdentifierIterator() = default;
 
 
-IdentifierInfoLookup::~IdentifierInfoLookup() {}
+IdentifierInfoLookup::~IdentifierInfoLookup() = default;
 
 
 namespace {
 namespace {
-  /// \brief A simple identifier lookup iterator that represents an
-  /// empty sequence of identifiers.
-  class EmptyLookupIterator : public IdentifierIterator
-  {
-  public:
-    StringRef Next() override { return StringRef(); }
-  };
-}
+
+/// \brief A simple identifier lookup iterator that represents an
+/// empty sequence of identifiers.
+class EmptyLookupIterator : public IdentifierIterator
+{
+public:
+  StringRef Next() override { return StringRef(); }
+};
+
+} // namespace
 
 
 IdentifierIterator *IdentifierInfoLookup::getIdentifiers() {
 IdentifierIterator *IdentifierInfoLookup::getIdentifiers() {
   return new EmptyLookupIterator();
   return new EmptyLookupIterator();
@@ -76,11 +83,9 @@ IdentifierTable::IdentifierTable(const LangOptions &LangOpts,
                                  IdentifierInfoLookup* externalLookup)
                                  IdentifierInfoLookup* externalLookup)
   : HashTable(8192), // Start with space for 8K identifiers.
   : HashTable(8192), // Start with space for 8K identifiers.
     ExternalLookup(externalLookup) {
     ExternalLookup(externalLookup) {
-
   // Populate the identifier table with info about keywords for the current
   // Populate the identifier table with info about keywords for the current
   // language.
   // language.
   AddKeywords(LangOpts);
   AddKeywords(LangOpts);
-      
 
 
   // Add the '_experimental_modules_import' contextual keyword.
   // Add the '_experimental_modules_import' contextual keyword.
   get("import").setModulesImport(true);
   get("import").setModulesImport(true);
@@ -92,6 +97,7 @@ IdentifierTable::IdentifierTable(const LangOptions &LangOpts,
 
 
 // Constants for TokenKinds.def
 // Constants for TokenKinds.def
 namespace {
 namespace {
+
   enum {
   enum {
     KEYC99 = 0x1,
     KEYC99 = 0x1,
     KEYCXX = 0x2,
     KEYCXX = 0x2,
@@ -127,7 +133,8 @@ namespace {
     KS_Enabled,     // Enabled
     KS_Enabled,     // Enabled
     KS_Future       // Is a keyword in future standard
     KS_Future       // Is a keyword in future standard
   };
   };
-}
+
+} // namespace
 
 
 /// \brief Translates flags as specified in TokenKinds.def into keyword status
 /// \brief Translates flags as specified in TokenKinds.def into keyword status
 /// in the given language standard.
 /// in the given language standard.
@@ -366,6 +373,7 @@ unsigned llvm::DenseMapInfo<clang::Selector>::getHashValue(clang::Selector S) {
 }
 }
 
 
 namespace clang {
 namespace clang {
+
 /// MultiKeywordSelector - One of these variable length records is kept for each
 /// MultiKeywordSelector - One of these variable length records is kept for each
 /// selector containing more than one keyword. We use a folding set
 /// selector containing more than one keyword. We use a folding set
 /// to unique aggregate names (keyword selectors in ObjC parlance). Access to
 /// to unique aggregate names (keyword selectors in ObjC parlance). Access to
@@ -375,6 +383,7 @@ class MultiKeywordSelector
   MultiKeywordSelector(unsigned nKeys) {
   MultiKeywordSelector(unsigned nKeys) {
     ExtraKindOrNumArgs = NUM_EXTRA_KINDS + nKeys;
     ExtraKindOrNumArgs = NUM_EXTRA_KINDS + nKeys;
   }
   }
+
 public:
 public:
   // Constructor for keyword selectors.
   // Constructor for keyword selectors.
   MultiKeywordSelector(unsigned nKeys, IdentifierInfo **IIV) {
   MultiKeywordSelector(unsigned nKeys, IdentifierInfo **IIV) {
@@ -392,28 +401,34 @@ public:
 
 
   unsigned getNumArgs() const { return ExtraKindOrNumArgs - NUM_EXTRA_KINDS; }
   unsigned getNumArgs() const { return ExtraKindOrNumArgs - NUM_EXTRA_KINDS; }
 
 
-  typedef IdentifierInfo *const *keyword_iterator;
+  using keyword_iterator = IdentifierInfo *const *;
+
   keyword_iterator keyword_begin() const {
   keyword_iterator keyword_begin() const {
     return reinterpret_cast<keyword_iterator>(this+1);
     return reinterpret_cast<keyword_iterator>(this+1);
   }
   }
+
   keyword_iterator keyword_end() const {
   keyword_iterator keyword_end() const {
     return keyword_begin()+getNumArgs();
     return keyword_begin()+getNumArgs();
   }
   }
+
   IdentifierInfo *getIdentifierInfoForSlot(unsigned i) const {
   IdentifierInfo *getIdentifierInfoForSlot(unsigned i) const {
     assert(i < getNumArgs() && "getIdentifierInfoForSlot(): illegal index");
     assert(i < getNumArgs() && "getIdentifierInfoForSlot(): illegal index");
     return keyword_begin()[i];
     return keyword_begin()[i];
   }
   }
+
   static void Profile(llvm::FoldingSetNodeID &ID,
   static void Profile(llvm::FoldingSetNodeID &ID,
                       keyword_iterator ArgTys, unsigned NumArgs) {
                       keyword_iterator ArgTys, unsigned NumArgs) {
     ID.AddInteger(NumArgs);
     ID.AddInteger(NumArgs);
     for (unsigned i = 0; i != NumArgs; ++i)
     for (unsigned i = 0; i != NumArgs; ++i)
       ID.AddPointer(ArgTys[i]);
       ID.AddPointer(ArgTys[i]);
   }
   }
+
   void Profile(llvm::FoldingSetNodeID &ID) {
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, keyword_begin(), getNumArgs());
     Profile(ID, keyword_begin(), getNumArgs());
   }
   }
 };
 };
-} // end namespace clang.
+
+} // namespace clang.
 
 
 unsigned Selector::getNumArgs() const {
 unsigned Selector::getNumArgs() const {
   unsigned IIF = getIdentifierInfoFlag();
   unsigned IIF = getIdentifierInfoFlag();
@@ -431,6 +446,7 @@ IdentifierInfo *Selector::getIdentifierInfoForSlot(unsigned argIndex) const {
     assert(argIndex == 0 && "illegal keyword index");
     assert(argIndex == 0 && "illegal keyword index");
     return getAsIdentifierInfo();
     return getAsIdentifierInfo();
   }
   }
+
   // We point to a MultiKeywordSelector.
   // We point to a MultiKeywordSelector.
   MultiKeywordSelector *SI = getMultiKeywordSelector();
   MultiKeywordSelector *SI = getMultiKeywordSelector();
   return SI->getIdentifierInfoForSlot(argIndex);
   return SI->getIdentifierInfoForSlot(argIndex);
@@ -592,11 +608,13 @@ ObjCStringFormatFamily Selector::getStringFormatFamilyImpl(Selector sel) {
 }
 }
 
 
 namespace {
 namespace {
-  struct SelectorTableImpl {
-    llvm::FoldingSet<MultiKeywordSelector> Table;
-    llvm::BumpPtrAllocator Allocator;
-  };
-} // end anonymous namespace.
+
+struct SelectorTableImpl {
+  llvm::FoldingSet<MultiKeywordSelector> Table;
+  llvm::BumpPtrAllocator Allocator;
+};
+
+} // namespace
 
 
 static SelectorTableImpl &getSelectorTableImpl(void *P) {
 static SelectorTableImpl &getSelectorTableImpl(void *P) {
   return *static_cast<SelectorTableImpl*>(P);
   return *static_cast<SelectorTableImpl*>(P);

+ 18 - 7
lib/Basic/Module.cpp

@@ -1,4 +1,4 @@
-//===--- Module.cpp - Describe a module -----------------------------------===//
+//===- Module.cpp - Describe a module -------------------------------------===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -16,23 +16,33 @@
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
+#include <functional>
+#include <string>
+#include <utility>
+#include <vector>
 
 
 using namespace clang;
 using namespace clang;
 
 
 Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
 Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
                bool IsFramework, bool IsExplicit, unsigned VisibilityID)
                bool IsFramework, bool IsExplicit, unsigned VisibilityID)
-    : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), Directory(),
-      Umbrella(), ASTFile(nullptr), VisibilityID(VisibilityID),
-      IsMissingRequirement(false), HasIncompatibleModuleFile(false),
-      IsAvailable(true), IsFromModuleFile(false), IsFramework(IsFramework),
-      IsExplicit(IsExplicit), IsSystem(false), IsExternC(false),
-      IsInferred(false), InferSubmodules(false), InferExplicitSubmodules(false),
+    : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent),
+      VisibilityID(VisibilityID), IsMissingRequirement(false),
+      HasIncompatibleModuleFile(false), IsAvailable(true),
+      IsFromModuleFile(false), IsFramework(IsFramework), IsExplicit(IsExplicit),
+      IsSystem(false), IsExternC(false), IsInferred(false),
+      InferSubmodules(false), InferExplicitSubmodules(false),
       InferExportWildcard(false), ConfigMacrosExhaustive(false),
       InferExportWildcard(false), ConfigMacrosExhaustive(false),
       NoUndeclaredIncludes(false), NameVisibility(Hidden) {
       NoUndeclaredIncludes(false), NameVisibility(Hidden) {
   if (Parent) {
   if (Parent) {
@@ -130,6 +140,7 @@ static StringRef getModuleNameFromComponent(
     const std::pair<std::string, SourceLocation> &IdComponent) {
     const std::pair<std::string, SourceLocation> &IdComponent) {
   return IdComponent.first;
   return IdComponent.first;
 }
 }
+
 static StringRef getModuleNameFromComponent(StringRef R) { return R; }
 static StringRef getModuleNameFromComponent(StringRef R) { return R; }
 
 
 template<typename InputIter>
 template<typename InputIter>

+ 1 - 1
lib/Basic/SanitizerSpecialCaseList.cpp

@@ -57,7 +57,7 @@ bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, StringRef Prefix,
                                          StringRef Category) const {
                                          StringRef Category) const {
   for (auto &S : SanitizerSections)
   for (auto &S : SanitizerSections)
     if ((S.Mask & Mask) &&
     if ((S.Mask & Mask) &&
-        SpecialCaseList::inSection(S.Entries, Prefix, Query, Category))
+        SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))
       return true;
       return true;
 
 
   return false;
   return false;

+ 30 - 25
lib/Basic/SourceManager.cpp

@@ -1,4 +1,4 @@
-//===--- SourceManager.cpp - Track and cache source files -----------------===//
+//===- SourceManager.cpp - Track and cache source files -------------------===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -14,17 +14,33 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManagerInternals.h"
 #include "clang/Basic/SourceManagerInternals.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Capacity.h"
 #include "llvm/Support/Capacity.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <algorithm>
-#include <cstring>
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <tuple>
+#include <utility>
+#include <vector>
 
 
 using namespace clang;
 using namespace clang;
 using namespace SrcMgr;
 using namespace SrcMgr;
@@ -222,7 +238,6 @@ void LineTableInfo::AddLineNote(FileID FID, unsigned Offset, unsigned LineNo,
                                    IncludeOffset));
                                    IncludeOffset));
 }
 }
 
 
-
 /// FindNearestLineEntry - Find the line entry nearest to FID that is before
 /// FindNearestLineEntry - Find the line entry nearest to FID that is before
 /// it.  If there is no line entry before Offset in FID, return null.
 /// it.  If there is no line entry before Offset in FID, return null.
 const LineEntry *LineTableInfo::FindNearestLineEntry(FileID FID,
 const LineEntry *LineTableInfo::FindNearestLineEntry(FileID FID,
@@ -250,7 +265,6 @@ void LineTableInfo::AddEntry(FileID FID,
 }
 }
 
 
 /// getLineTableFilenameID - Return the uniqued ID for the specified filename.
 /// getLineTableFilenameID - Return the uniqued ID for the specified filename.
-///
 unsigned SourceManager::getLineTableFilenameID(StringRef Name) {
 unsigned SourceManager::getLineTableFilenameID(StringRef Name) {
   return getLineTable().getLineTableFilenameID(Name);
   return getLineTable().getLineTableFilenameID(Name);
 }
 }
@@ -298,10 +312,7 @@ LineTableInfo &SourceManager::getLineTable() {
 
 
 SourceManager::SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr,
 SourceManager::SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr,
                              bool UserFilesAreVolatile)
                              bool UserFilesAreVolatile)
-  : Diag(Diag), FileMgr(FileMgr), OverridenFilesKeepOriginalName(true),
-    UserFilesAreVolatile(UserFilesAreVolatile), FilesAreTransient(false),
-    ExternalSLocEntries(nullptr), LineTable(nullptr), NumLinearScans(0),
-    NumBinaryProbes(0) {
+  : Diag(Diag), FileMgr(FileMgr), UserFilesAreVolatile(UserFilesAreVolatile) {
   clearIDTables();
   clearIDTables();
   Diag.setSourceManager(this);
   Diag.setSourceManager(this);
 }
 }
@@ -342,7 +353,7 @@ void SourceManager::clearIDTables() {
   // Use up FileID #0 as an invalid expansion.
   // Use up FileID #0 as an invalid expansion.
   NextLocalOffset = 0;
   NextLocalOffset = 0;
   CurrentLoadedOffset = MaxLoadedOffset;
   CurrentLoadedOffset = MaxLoadedOffset;
-  createExpansionLoc(SourceLocation(),SourceLocation(),SourceLocation(), 1);
+  createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
 }
 }
 
 
 void SourceManager::initializeForReplay(const SourceManager &Old) {
 void SourceManager::initializeForReplay(const SourceManager &Old) {
@@ -408,7 +419,6 @@ SourceManager::getOrCreateContentCache(const FileEntry *FileEnt,
   return Entry;
   return Entry;
 }
 }
 
 
-
 /// Create a new ContentCache for the specified memory buffer.
 /// Create a new ContentCache for the specified memory buffer.
 /// This does no caching.
 /// This does no caching.
 const ContentCache *
 const ContentCache *
@@ -716,7 +726,7 @@ FileID SourceManager::getFileIDLocal(unsigned SLocOffset) const {
   // Find the FileID that contains this.  "I" is an iterator that points to a
   // Find the FileID that contains this.  "I" is an iterator that points to a
   // FileID whose offset is known to be larger than SLocOffset.
   // FileID whose offset is known to be larger than SLocOffset.
   unsigned NumProbes = 0;
   unsigned NumProbes = 0;
-  while (1) {
+  while (true) {
     --I;
     --I;
     if (I->getOffset() <= SLocOffset) {
     if (I->getOffset() <= SLocOffset) {
       FileID Res = FileID::get(int(I - LocalSLocEntryTable.begin()));
       FileID Res = FileID::get(int(I - LocalSLocEntryTable.begin()));
@@ -740,7 +750,7 @@ FileID SourceManager::getFileIDLocal(unsigned SLocOffset) const {
   // SLocOffset.
   // SLocOffset.
   unsigned LessIndex = 0;
   unsigned LessIndex = 0;
   NumProbes = 0;
   NumProbes = 0;
-  while (1) {
+  while (true) {
     bool Invalid = false;
     bool Invalid = false;
     unsigned MiddleIndex = (GreaterIndex-LessIndex)/2+LessIndex;
     unsigned MiddleIndex = (GreaterIndex-LessIndex)/2+LessIndex;
     unsigned MidOffset = getLocalSLocEntry(MiddleIndex, &Invalid).getOffset();
     unsigned MidOffset = getLocalSLocEntry(MiddleIndex, &Invalid).getOffset();
@@ -817,7 +827,7 @@ FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) const {
   unsigned GreaterIndex = I;
   unsigned GreaterIndex = I;
   unsigned LessIndex = LoadedSLocEntryTable.size();
   unsigned LessIndex = LoadedSLocEntryTable.size();
   NumProbes = 0;
   NumProbes = 0;
-  while (1) {
+  while (true) {
     ++NumProbes;
     ++NumProbes;
     unsigned MiddleIndex = (LessIndex - GreaterIndex) / 2 + GreaterIndex;
     unsigned MiddleIndex = (LessIndex - GreaterIndex) / 2 + GreaterIndex;
     const SrcMgr::SLocEntry &E = getLoadedSLocEntry(MiddleIndex);
     const SrcMgr::SLocEntry &E = getLoadedSLocEntry(MiddleIndex);
@@ -935,7 +945,6 @@ SourceLocation SourceManager::getImmediateSpellingLoc(SourceLocation Loc) const{
   return Loc.getLocWithOffset(LocInfo.second);
   return Loc.getLocWithOffset(LocInfo.second);
 }
 }
 
 
-
 /// getImmediateExpansionRange - Loc is required to be an expansion location.
 /// getImmediateExpansionRange - Loc is required to be an expansion location.
 /// Return the start/end of the expansion information.
 /// Return the start/end of the expansion information.
 std::pair<SourceLocation,SourceLocation>
 std::pair<SourceLocation,SourceLocation>
@@ -1055,7 +1064,6 @@ bool SourceManager::isAtEndOfImmediateMacroExpansion(SourceLocation Loc,
   return true;
   return true;
 }
 }
 
 
-
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 // Queries about the code at a SourceLocation.
 // Queries about the code at a SourceLocation.
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
@@ -1084,7 +1092,6 @@ const char *SourceManager::getCharacterData(SourceLocation SL,
   return Buffer->getBufferStart() + (CharDataInvalid? 0 : LocInfo.second);
   return Buffer->getBufferStart() + (CharDataInvalid? 0 : LocInfo.second);
 }
 }
 
 
-
 /// getColumnNumber - Return the column # for the specified file position.
 /// getColumnNumber - Return the column # for the specified file position.
 /// this is significantly cheaper to compute than the line number.
 /// this is significantly cheaper to compute than the line number.
 unsigned SourceManager::getColumnNumber(FileID FID, unsigned FilePos,
 unsigned SourceManager::getColumnNumber(FileID FID, unsigned FilePos,
@@ -1189,7 +1196,7 @@ static void ComputeLineNumbers(DiagnosticsEngine &Diag, ContentCache *FI,
   const unsigned char *Buf = (const unsigned char *)Buffer->getBufferStart();
   const unsigned char *Buf = (const unsigned char *)Buffer->getBufferStart();
   const unsigned char *End = (const unsigned char *)Buffer->getBufferEnd();
   const unsigned char *End = (const unsigned char *)Buffer->getBufferEnd();
   unsigned Offs = 0;
   unsigned Offs = 0;
-  while (1) {
+  while (true) {
     // Skip over the contents of the line.
     // Skip over the contents of the line.
     const unsigned char *NextBuf = (const unsigned char *)Buf;
     const unsigned char *NextBuf = (const unsigned char *)Buf;
 
 
@@ -1419,7 +1426,6 @@ StringRef SourceManager::getBufferName(SourceLocation Loc,
   return getBuffer(getFileID(Loc), Invalid)->getBufferIdentifier();
   return getBuffer(getFileID(Loc), Invalid)->getBufferIdentifier();
 }
 }
 
 
-
 /// getPresumedLoc - This method returns the "presumed" location of a
 /// getPresumedLoc - This method returns the "presumed" location of a
 /// SourceLocation specifies.  A "presumed location" can be modified by \#line
 /// SourceLocation specifies.  A "presumed location" can be modified by \#line
 /// or GNU line marker directives.  This provides a view on the data that a
 /// or GNU line marker directives.  This provides a view on the data that a
@@ -1767,7 +1773,7 @@ void SourceManager::computeMacroArgsCache(MacroArgsMap &MacroArgsCache,
   MacroArgsCache.insert(std::make_pair(0, SourceLocation()));
   MacroArgsCache.insert(std::make_pair(0, SourceLocation()));
 
 
   int ID = FID.ID;
   int ID = FID.ID;
-  while (1) {
+  while (true) {
     ++ID;
     ++ID;
     // Stop if there are no more FileIDs to check.
     // Stop if there are no more FileIDs to check.
     if (ID > 0) {
     if (ID > 0) {
@@ -1830,7 +1836,7 @@ void SourceManager::associateFileChunkWithMacroArgExp(
     FileID SpellFID; // Current FileID in the spelling range.
     FileID SpellFID; // Current FileID in the spelling range.
     unsigned SpellRelativeOffs;
     unsigned SpellRelativeOffs;
     std::tie(SpellFID, SpellRelativeOffs) = getDecomposedLoc(SpellLoc);
     std::tie(SpellFID, SpellRelativeOffs) = getDecomposedLoc(SpellLoc);
-    while (1) {
+    while (true) {
       const SLocEntry &Entry = getSLocEntry(SpellFID);
       const SLocEntry &Entry = getSLocEntry(SpellFID);
       unsigned SpellFIDBeginOffs = Entry.getOffset();
       unsigned SpellFIDBeginOffs = Entry.getOffset();
       unsigned SpellFIDSize = getFileIDSize(SpellFID);
       unsigned SpellFIDSize = getFileIDSize(SpellFID);
@@ -1857,7 +1863,6 @@ void SourceManager::associateFileChunkWithMacroArgExp(
       ++SpellFID.ID;
       ++SpellFID.ID;
       SpellRelativeOffs = 0;
       SpellRelativeOffs = 0;
     }
     }
-
   }
   }
 
 
   assert(SpellLoc.isFileID());
   assert(SpellLoc.isFileID());
@@ -1937,8 +1942,8 @@ SourceManager::getDecomposedIncludedLoc(FileID FID) const {
 
 
   // Uses IncludedLocMap to retrieve/cache the decomposed loc.
   // Uses IncludedLocMap to retrieve/cache the decomposed loc.
 
 
-  typedef std::pair<FileID, unsigned> DecompTy;
-  typedef llvm::DenseMap<FileID, DecompTy> MapTy;
+  using DecompTy = std::pair<FileID, unsigned>;
+  using MapTy = llvm::DenseMap<FileID, DecompTy>;
   std::pair<MapTy::iterator, bool>
   std::pair<MapTy::iterator, bool>
     InsertOp = IncludedLocMap.insert(std::make_pair(FID, DecompTy()));
     InsertOp = IncludedLocMap.insert(std::make_pair(FID, DecompTy()));
   DecompTy &DecompLoc = InsertOp.first->second;
   DecompTy &DecompLoc = InsertOp.first->second;
@@ -2085,7 +2090,7 @@ std::pair<bool, bool> SourceManager::isInTheSameTranslationUnit(
   // of the other looking for a match.
   // of the other looking for a match.
   // We use a map from FileID to Offset to store the chain. Easier than writing
   // We use a map from FileID to Offset to store the chain. Easier than writing
   // a custom set hash info that only depends on the first part of a pair.
   // a custom set hash info that only depends on the first part of a pair.
-  typedef llvm::SmallDenseMap<FileID, unsigned, 16> LocSet;
+  using LocSet = llvm::SmallDenseMap<FileID, unsigned, 16>;
   LocSet LChain;
   LocSet LChain;
   do {
   do {
     LChain.insert(LOffs);
     LChain.insert(LOffs);
@@ -2197,7 +2202,7 @@ LLVM_DUMP_METHOD void SourceManager::dump() const {
   }
   }
 }
 }
 
 
-ExternalSLocEntrySource::~ExternalSLocEntrySource() { }
+ExternalSLocEntrySource::~ExternalSLocEntrySource() = default;
 
 
 /// Return the amount of memory used by memory buffers, breaking down
 /// Return the amount of memory used by memory buffers, breaking down
 /// by heap-backed versus mmap'ed memory.
 /// by heap-backed versus mmap'ed memory.

+ 2 - 0
lib/Basic/Targets/X86.cpp

@@ -1121,6 +1121,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
 
 
 bool X86TargetInfo::isValidFeatureName(StringRef Name) const {
 bool X86TargetInfo::isValidFeatureName(StringRef Name) const {
   return llvm::StringSwitch<bool>(Name)
   return llvm::StringSwitch<bool>(Name)
+      .Case("3dnow", true)
+      .Case("3dnowa", true)
       .Case("aes", true)
       .Case("aes", true)
       .Case("avx", true)
       .Case("avx", true)
       .Case("avx2", true)
       .Case("avx2", true)

+ 10 - 26
lib/CodeGen/CGBuiltin.cpp

@@ -8142,32 +8142,6 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
   case X86::BI__builtin_ia32_selectpd_256:
   case X86::BI__builtin_ia32_selectpd_256:
   case X86::BI__builtin_ia32_selectpd_512:
   case X86::BI__builtin_ia32_selectpd_512:
     return EmitX86Select(*this, Ops[0], Ops[1], Ops[2]);
     return EmitX86Select(*this, Ops[0], Ops[1], Ops[2]);
-  case X86::BI__builtin_ia32_pcmpeqb128_mask:
-  case X86::BI__builtin_ia32_pcmpeqb256_mask:
-  case X86::BI__builtin_ia32_pcmpeqb512_mask:
-  case X86::BI__builtin_ia32_pcmpeqw128_mask:
-  case X86::BI__builtin_ia32_pcmpeqw256_mask:
-  case X86::BI__builtin_ia32_pcmpeqw512_mask:
-  case X86::BI__builtin_ia32_pcmpeqd128_mask:
-  case X86::BI__builtin_ia32_pcmpeqd256_mask:
-  case X86::BI__builtin_ia32_pcmpeqd512_mask:
-  case X86::BI__builtin_ia32_pcmpeqq128_mask:
-  case X86::BI__builtin_ia32_pcmpeqq256_mask:
-  case X86::BI__builtin_ia32_pcmpeqq512_mask:
-    return EmitX86MaskedCompare(*this, 0, false, Ops);
-  case X86::BI__builtin_ia32_pcmpgtb128_mask:
-  case X86::BI__builtin_ia32_pcmpgtb256_mask:
-  case X86::BI__builtin_ia32_pcmpgtb512_mask:
-  case X86::BI__builtin_ia32_pcmpgtw128_mask:
-  case X86::BI__builtin_ia32_pcmpgtw256_mask:
-  case X86::BI__builtin_ia32_pcmpgtw512_mask:
-  case X86::BI__builtin_ia32_pcmpgtd128_mask:
-  case X86::BI__builtin_ia32_pcmpgtd256_mask:
-  case X86::BI__builtin_ia32_pcmpgtd512_mask:
-  case X86::BI__builtin_ia32_pcmpgtq128_mask:
-  case X86::BI__builtin_ia32_pcmpgtq256_mask:
-  case X86::BI__builtin_ia32_pcmpgtq512_mask:
-    return EmitX86MaskedCompare(*this, 6, true, Ops);
   case X86::BI__builtin_ia32_cmpb128_mask:
   case X86::BI__builtin_ia32_cmpb128_mask:
   case X86::BI__builtin_ia32_cmpb256_mask:
   case X86::BI__builtin_ia32_cmpb256_mask:
   case X86::BI__builtin_ia32_cmpb512_mask:
   case X86::BI__builtin_ia32_cmpb512_mask:
@@ -9580,6 +9554,16 @@ Value *CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID,
     return Builder.CreateCall(FnALAF32, {Ptr, Val});
     return Builder.CreateCall(FnALAF32, {Ptr, Val});
   }
   }
 
 
+  case NVPTX::BI__nvvm_atom_add_gen_d: {
+    Value *Ptr = EmitScalarExpr(E->getArg(0));
+    Value *Val = EmitScalarExpr(E->getArg(1));
+    // atomicrmw only deals with integer arguments, so we need to use
+    // LLVM's nvvm_atomic_load_add_f64 intrinsic.
+    Value *FnALAF64 =
+        CGM.getIntrinsic(Intrinsic::nvvm_atomic_load_add_f64, Ptr->getType());
+    return Builder.CreateCall(FnALAF64, {Ptr, Val});
+  }
+
   case NVPTX::BI__nvvm_atom_inc_gen_ui: {
   case NVPTX::BI__nvvm_atom_inc_gen_ui: {
     Value *Ptr = EmitScalarExpr(E->getArg(0));
     Value *Ptr = EmitScalarExpr(E->getArg(0));
     Value *Val = EmitScalarExpr(E->getArg(1));
     Value *Val = EmitScalarExpr(E->getArg(1));

+ 10 - 0
lib/CodeGen/CGCall.cpp

@@ -1855,6 +1855,16 @@ void CodeGenModule::ConstructAttributeList(
       !(TargetDecl && TargetDecl->hasAttr<NoSplitStackAttr>()))
       !(TargetDecl && TargetDecl->hasAttr<NoSplitStackAttr>()))
     FuncAttrs.addAttribute("split-stack");
     FuncAttrs.addAttribute("split-stack");
 
 
+  // Add NonLazyBind attribute to function declarations when -fno-plt
+  // is used.
+  if (TargetDecl && CodeGenOpts.NoPLT) {
+    if (auto *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
+      if (!Fn->isDefined() && !AttrOnCallSite) {
+        FuncAttrs.addAttribute(llvm::Attribute::NonLazyBind);
+      }
+    }
+  }
+
   if (!AttrOnCallSite) {
   if (!AttrOnCallSite) {
     bool DisableTailCalls =
     bool DisableTailCalls =
         CodeGenOpts.DisableTailCalls ||
         CodeGenOpts.DisableTailCalls ||

+ 47 - 47
lib/CodeGen/CGOpenMPRuntime.cpp

@@ -1451,7 +1451,9 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
       return ThreadID;
       return ThreadID;
   }
   }
   // If exceptions are enabled, do not use parameter to avoid possible crash.
   // If exceptions are enabled, do not use parameter to avoid possible crash.
-  if (!CGF.getInvokeDest()) {
+  if (!CGF.EHStack.requiresLandingPad() || !CGF.getLangOpts().Exceptions ||
+      !CGF.getLangOpts().CXXExceptions ||
+      CGF.Builder.GetInsertBlock() == CGF.AllocaInsertPt->getParent()) {
     if (auto *OMPRegionInfo =
     if (auto *OMPRegionInfo =
             dyn_cast_or_null<CGOpenMPRegionInfo>(CGF.CapturedStmtInfo)) {
             dyn_cast_or_null<CGOpenMPRegionInfo>(CGF.CapturedStmtInfo)) {
       if (OMPRegionInfo->getThreadIDVariable()) {
       if (OMPRegionInfo->getThreadIDVariable()) {
@@ -1475,12 +1477,13 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
   // function.
   // function.
   CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
   CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
   CGF.Builder.SetInsertPoint(CGF.AllocaInsertPt);
   CGF.Builder.SetInsertPoint(CGF.AllocaInsertPt);
-  ThreadID =
-      CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_global_thread_num),
-                          emitUpdateLocation(CGF, Loc));
+  auto *Call = CGF.Builder.CreateCall(
+      createRuntimeFunction(OMPRTL__kmpc_global_thread_num),
+      emitUpdateLocation(CGF, Loc));
+  Call->setCallingConv(CGF.getRuntimeCC());
   auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
   auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
-  Elem.second.ThreadID = ThreadID;
-  return ThreadID;
+  Elem.second.ThreadID = Call;
+  return Call;
 }
 }
 
 
 void CGOpenMPRuntime::functionFinished(CodeGenFunction &CGF) {
 void CGOpenMPRuntime::functionFinished(CodeGenFunction &CGF) {
@@ -5975,22 +5978,21 @@ public:
     /// \brief Delete the element from the device environment, ignoring the
     /// \brief Delete the element from the device environment, ignoring the
     /// current reference count associated with the element.
     /// current reference count associated with the element.
     OMP_MAP_DELETE = 0x08,
     OMP_MAP_DELETE = 0x08,
-    /// \brief The element being mapped is a pointer, therefore the pointee
-    /// should be mapped as well.
-    OMP_MAP_IS_PTR = 0x10,
-    /// \brief This flags signals that an argument is the first one relating to
-    /// a map/private clause expression. For some cases a single
-    /// map/privatization results in multiple arguments passed to the runtime
-    /// library.
-    OMP_MAP_FIRST_REF = 0x20,
+    /// \brief The element being mapped is a pointer-pointee pair; both the
+    /// pointer and the pointee should be mapped.
+    OMP_MAP_PTR_AND_OBJ = 0x10,
+    /// \brief This flags signals that the base address of an entry should be
+    /// passed to the target kernel as an argument.
+    OMP_MAP_TARGET_PARAM = 0x20,
     /// \brief Signal that the runtime library has to return the device pointer
     /// \brief Signal that the runtime library has to return the device pointer
-    /// in the current position for the data being mapped.
-    OMP_MAP_RETURN_PTR = 0x40,
+    /// in the current position for the data being mapped. Used when we have the
+    /// use_device_ptr clause.
+    OMP_MAP_RETURN_PARAM = 0x40,
     /// \brief This flag signals that the reference being passed is a pointer to
     /// \brief This flag signals that the reference being passed is a pointer to
     /// private data.
     /// private data.
-    OMP_MAP_PRIVATE_PTR = 0x80,
+    OMP_MAP_PRIVATE = 0x80,
     /// \brief Pass the element to the device by value.
     /// \brief Pass the element to the device by value.
-    OMP_MAP_PRIVATE_VAL = 0x100,
+    OMP_MAP_LITERAL = 0x100,
     /// Implicit map
     /// Implicit map
     OMP_MAP_IMPLICIT = 0x200,
     OMP_MAP_IMPLICIT = 0x200,
   };
   };
@@ -6081,7 +6083,7 @@ private:
   /// expression.
   /// expression.
   unsigned getMapTypeBits(OpenMPMapClauseKind MapType,
   unsigned getMapTypeBits(OpenMPMapClauseKind MapType,
                           OpenMPMapClauseKind MapTypeModifier, bool AddPtrFlag,
                           OpenMPMapClauseKind MapTypeModifier, bool AddPtrFlag,
-                          bool AddIsFirstFlag) const {
+                          bool AddIsTargetParamFlag) const {
     unsigned Bits = 0u;
     unsigned Bits = 0u;
     switch (MapType) {
     switch (MapType) {
     case OMPC_MAP_alloc:
     case OMPC_MAP_alloc:
@@ -6108,9 +6110,9 @@ private:
       break;
       break;
     }
     }
     if (AddPtrFlag)
     if (AddPtrFlag)
-      Bits |= OMP_MAP_IS_PTR;
-    if (AddIsFirstFlag)
-      Bits |= OMP_MAP_FIRST_REF;
+      Bits |= OMP_MAP_PTR_AND_OBJ;
+    if (AddIsTargetParamFlag)
+      Bits |= OMP_MAP_TARGET_PARAM;
     if (MapTypeModifier == OMPC_MAP_always)
     if (MapTypeModifier == OMPC_MAP_always)
       Bits |= OMP_MAP_ALWAYS;
       Bits |= OMP_MAP_ALWAYS;
     return Bits;
     return Bits;
@@ -6217,28 +6219,28 @@ private:
     //
     //
     // map(s.p[:22], s.a s.b)
     // map(s.p[:22], s.a s.b)
     // &s, &(s.p), sizeof(double*), noflags
     // &s, &(s.p), sizeof(double*), noflags
-    // &(s.p), &(s.p[0]), 22*sizeof(double), ptr_flag + extra_flag
+    // &(s.p), &(s.p[0]), 22*sizeof(double), ptr_flag
     //
     //
     // map(s.ps)
     // map(s.ps)
     // &s, &(s.ps), sizeof(S2*), noflags
     // &s, &(s.ps), sizeof(S2*), noflags
     //
     //
     // map(s.ps->s.i)
     // map(s.ps->s.i)
     // &s, &(s.ps), sizeof(S2*), noflags
     // &s, &(s.ps), sizeof(S2*), noflags
-    // &(s.ps), &(s.ps->s.i), sizeof(int), ptr_flag + extra_flag
+    // &(s.ps), &(s.ps->s.i), sizeof(int), ptr_flag
     //
     //
     // map(s.ps->ps)
     // map(s.ps->ps)
     // &s, &(s.ps), sizeof(S2*), noflags
     // &s, &(s.ps), sizeof(S2*), noflags
-    // &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
+    // &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
     //
     //
     // map(s.ps->ps->ps)
     // map(s.ps->ps->ps)
     // &s, &(s.ps), sizeof(S2*), noflags
     // &s, &(s.ps), sizeof(S2*), noflags
-    // &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
-    // &(s.ps->ps), &(s.ps->ps->ps), sizeof(S2*), ptr_flag + extra_flag
+    // &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
+    // &(s.ps->ps), &(s.ps->ps->ps), sizeof(S2*), ptr_flag
     //
     //
     // map(s.ps->ps->s.f[:22])
     // map(s.ps->ps->s.f[:22])
     // &s, &(s.ps), sizeof(S2*), noflags
     // &s, &(s.ps), sizeof(S2*), noflags
-    // &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag + extra_flag
-    // &(s.ps->ps), &(s.ps->ps->s.f[0]), 22*sizeof(float), ptr_flag + extra_flag
+    // &(s.ps), &(s.ps->ps), sizeof(S2*), ptr_flag
+    // &(s.ps->ps), &(s.ps->ps->s.f[0]), 22*sizeof(float), ptr_flag
     //
     //
     // map(ps)
     // map(ps)
     // &ps, &ps, sizeof(S2*), noflags
     // &ps, &ps, sizeof(S2*), noflags
@@ -6254,29 +6256,28 @@ private:
     //
     //
     // map(ps->p[:22])
     // map(ps->p[:22])
     // ps, &(ps->p), sizeof(double*), noflags
     // ps, &(ps->p), sizeof(double*), noflags
-    // &(ps->p), &(ps->p[0]), 22*sizeof(double), ptr_flag + extra_flag
+    // &(ps->p), &(ps->p[0]), 22*sizeof(double), ptr_flag
     //
     //
     // map(ps->ps)
     // map(ps->ps)
     // ps, &(ps->ps), sizeof(S2*), noflags
     // ps, &(ps->ps), sizeof(S2*), noflags
     //
     //
     // map(ps->ps->s.i)
     // map(ps->ps->s.i)
     // ps, &(ps->ps), sizeof(S2*), noflags
     // ps, &(ps->ps), sizeof(S2*), noflags
-    // &(ps->ps), &(ps->ps->s.i), sizeof(int), ptr_flag + extra_flag
+    // &(ps->ps), &(ps->ps->s.i), sizeof(int), ptr_flag
     //
     //
     // map(ps->ps->ps)
     // map(ps->ps->ps)
     // ps, &(ps->ps), sizeof(S2*), noflags
     // ps, &(ps->ps), sizeof(S2*), noflags
-    // &(ps->ps), &(ps->ps->ps), sizeof(S2*), ptr_flag + extra_flag
+    // &(ps->ps), &(ps->ps->ps), sizeof(S2*), ptr_flag
     //
     //
     // map(ps->ps->ps->ps)
     // map(ps->ps->ps->ps)
     // ps, &(ps->ps), sizeof(S2*), noflags
     // ps, &(ps->ps), sizeof(S2*), noflags
-    // &(ps->ps), &(ps->ps->ps), sizeof(S2*), ptr_flag + extra_flag
-    // &(ps->ps->ps), &(ps->ps->ps->ps), sizeof(S2*), ptr_flag + extra_flag
+    // &(ps->ps), &(ps->ps->ps), sizeof(S2*), ptr_flag
+    // &(ps->ps->ps), &(ps->ps->ps->ps), sizeof(S2*), ptr_flag
     //
     //
     // map(ps->ps->ps->s.f[:22])
     // map(ps->ps->ps->s.f[:22])
     // ps, &(ps->ps), sizeof(S2*), noflags
     // ps, &(ps->ps), sizeof(S2*), noflags
-    // &(ps->ps), &(ps->ps->ps), sizeof(S2*), ptr_flag + extra_flag
-    // &(ps->ps->ps), &(ps->ps->ps->s.f[0]), 22*sizeof(float), ptr_flag +
-    // extra_flag
+    // &(ps->ps), &(ps->ps->ps), sizeof(S2*), ptr_flag
+    // &(ps->ps->ps), &(ps->ps->ps->s.f[0]), 22*sizeof(float), ptr_flag
 
 
     // Track if the map information being generated is the first for a capture.
     // Track if the map information being generated is the first for a capture.
     bool IsCaptureFirstInfo = IsFirstComponentList;
     bool IsCaptureFirstInfo = IsFirstComponentList;
@@ -6416,7 +6417,7 @@ private:
     // 'private ptr' and 'map to' flag. Return the right flags if the captured
     // 'private ptr' and 'map to' flag. Return the right flags if the captured
     // declaration is known as first-private in this handler.
     // declaration is known as first-private in this handler.
     if (FirstPrivateDecls.count(Cap.getCapturedVar()))
     if (FirstPrivateDecls.count(Cap.getCapturedVar()))
-      return MappableExprsHandler::OMP_MAP_PRIVATE_PTR |
+      return MappableExprsHandler::OMP_MAP_PRIVATE |
              MappableExprsHandler::OMP_MAP_TO;
              MappableExprsHandler::OMP_MAP_TO;
 
 
     // We didn't modify anything.
     // We didn't modify anything.
@@ -6557,7 +6558,7 @@ public:
         BasePointers.push_back({Ptr, VD});
         BasePointers.push_back({Ptr, VD});
         Pointers.push_back(Ptr);
         Pointers.push_back(Ptr);
         Sizes.push_back(llvm::Constant::getNullValue(this->CGF.SizeTy));
         Sizes.push_back(llvm::Constant::getNullValue(this->CGF.SizeTy));
-        Types.push_back(OMP_MAP_RETURN_PTR | OMP_MAP_FIRST_REF);
+        Types.push_back(OMP_MAP_RETURN_PARAM | OMP_MAP_TARGET_PARAM);
       }
       }
 
 
     for (auto &M : Info) {
     for (auto &M : Info) {
@@ -6595,7 +6596,7 @@ public:
                  "No relevant declaration related with device pointer??");
                  "No relevant declaration related with device pointer??");
 
 
           BasePointers[CurrentBasePointersIdx].setDevicePtrDecl(RelevantVD);
           BasePointers[CurrentBasePointersIdx].setDevicePtrDecl(RelevantVD);
-          Types[CurrentBasePointersIdx] |= OMP_MAP_RETURN_PTR;
+          Types[CurrentBasePointersIdx] |= OMP_MAP_RETURN_PARAM;
         }
         }
         IsFirstComponentList = false;
         IsFirstComponentList = false;
       }
       }
@@ -6647,7 +6648,7 @@ public:
       BasePointers.push_back({Arg, VD});
       BasePointers.push_back({Arg, VD});
       Pointers.push_back(Arg);
       Pointers.push_back(Arg);
       Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy));
       Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy));
-      Types.push_back(OMP_MAP_PRIVATE_VAL | OMP_MAP_FIRST_REF);
+      Types.push_back(OMP_MAP_LITERAL | OMP_MAP_TARGET_PARAM);
       return;
       return;
     }
     }
 
 
@@ -6690,7 +6691,7 @@ public:
       if (!RI.getType()->isAnyPointerType()) {
       if (!RI.getType()->isAnyPointerType()) {
         // We have to signal to the runtime captures passed by value that are
         // We have to signal to the runtime captures passed by value that are
         // not pointers.
         // not pointers.
-        CurMapTypes.push_back(OMP_MAP_PRIVATE_VAL);
+        CurMapTypes.push_back(OMP_MAP_LITERAL);
         CurSizes.push_back(CGF.getTypeSize(RI.getType()));
         CurSizes.push_back(CGF.getTypeSize(RI.getType()));
       } else {
       } else {
         // Pointers are implicitly mapped with a zero size and no flags
         // Pointers are implicitly mapped with a zero size and no flags
@@ -6720,9 +6721,8 @@ public:
       CurMapTypes.back() =
       CurMapTypes.back() =
           adjustMapModifiersForPrivateClauses(CI, CurMapTypes.back());
           adjustMapModifiersForPrivateClauses(CI, CurMapTypes.back());
     }
     }
-    // Every default map produces a single argument, so, it is always the
-    // first one.
-    CurMapTypes.back() |= OMP_MAP_FIRST_REF;
+    // Every default map produces a single argument which is a target parameter.
+    CurMapTypes.back() |= OMP_MAP_TARGET_PARAM;
   }
   }
 };
 };
 
 
@@ -6922,8 +6922,8 @@ void CGOpenMPRuntime::emitTargetCall(CodeGenFunction &CGF,
       CurPointers.push_back(*CV);
       CurPointers.push_back(*CV);
       CurSizes.push_back(CGF.getTypeSize(RI->getType()));
       CurSizes.push_back(CGF.getTypeSize(RI->getType()));
       // Copy to the device as an argument. No need to retrieve it.
       // Copy to the device as an argument. No need to retrieve it.
-      CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_PRIVATE_VAL |
-                            MappableExprsHandler::OMP_MAP_FIRST_REF);
+      CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_LITERAL |
+                            MappableExprsHandler::OMP_MAP_TARGET_PARAM);
     } else {
     } else {
       // If we have any information in the map clause, we use it, otherwise we
       // If we have any information in the map clause, we use it, otherwise we
       // just do a default mapping.
       // just do a default mapping.

+ 1 - 1
lib/CodeGen/CodeGenFunction.cpp

@@ -87,7 +87,7 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
 
 
   llvm::FastMathFlags FMF;
   llvm::FastMathFlags FMF;
   if (CGM.getLangOpts().FastMath)
   if (CGM.getLangOpts().FastMath)
-    FMF.setUnsafeAlgebra();
+    FMF.setFast();
   if (CGM.getLangOpts().FiniteMathOnly) {
   if (CGM.getLangOpts().FiniteMathOnly) {
     FMF.setNoNaNs();
     FMF.setNoNaNs();
     FMF.setNoInfs();
     FMF.setNoInfs();

+ 9 - 10
lib/CodeGen/CodeGenModule.cpp

@@ -2284,7 +2284,8 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name,
       F->setCallingConv(getRuntimeCC());
       F->setCallingConv(getRuntimeCC());
 
 
       if (!Local && getTriple().isOSBinFormatCOFF() &&
       if (!Local && getTriple().isOSBinFormatCOFF() &&
-          !getCodeGenOpts().LTOVisibilityPublicStd) {
+          !getCodeGenOpts().LTOVisibilityPublicStd &&
+          !getTriple().isWindowsGNUEnvironment()) {
         const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
         const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
         if (!FD || FD->hasAttr<DLLImportAttr>()) {
         if (!FD || FD->hasAttr<DLLImportAttr>()) {
           F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
           F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
@@ -4030,6 +4031,13 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
   case Decl::Namespace:
   case Decl::Namespace:
     EmitDeclContext(cast<NamespaceDecl>(D));
     EmitDeclContext(cast<NamespaceDecl>(D));
     break;
     break;
+  case Decl::ClassTemplateSpecialization: {
+    const auto *Spec = cast<ClassTemplateSpecializationDecl>(D);
+    if (DebugInfo &&
+        Spec->getSpecializationKind() == TSK_ExplicitInstantiationDefinition &&
+        Spec->hasDefinition())
+      DebugInfo->completeTemplateDefinition(*Spec);
+  } LLVM_FALLTHROUGH;
   case Decl::CXXRecord:
   case Decl::CXXRecord:
     if (DebugInfo) {
     if (DebugInfo) {
       if (auto *ES = D->getASTContext().getExternalSource())
       if (auto *ES = D->getASTContext().getExternalSource())
@@ -4216,15 +4224,6 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     EmitOMPThreadPrivateDecl(cast<OMPThreadPrivateDecl>(D));
     EmitOMPThreadPrivateDecl(cast<OMPThreadPrivateDecl>(D));
     break;
     break;
 
 
-  case Decl::ClassTemplateSpecialization: {
-    const auto *Spec = cast<ClassTemplateSpecializationDecl>(D);
-    if (DebugInfo &&
-        Spec->getSpecializationKind() == TSK_ExplicitInstantiationDefinition &&
-        Spec->hasDefinition())
-      DebugInfo->completeTemplateDefinition(*Spec);
-    break;
-  }
-
   case Decl::OMPDeclareReduction:
   case Decl::OMPDeclareReduction:
     EmitOMPDeclareReduction(cast<OMPDeclareReductionDecl>(D));
     EmitOMPDeclareReduction(cast<OMPDeclareReductionDecl>(D));
     break;
     break;

+ 1 - 1
lib/CodeGen/TargetInfo.cpp

@@ -6319,7 +6319,7 @@ public:
     return occupiesMoreThan(CGT, scalars, /*total*/ 4);
     return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
   }
   bool isSwiftErrorInRegister() const override {
   bool isSwiftErrorInRegister() const override {
-    return true;
+    return false;
   }
   }
 };
 };
 
 

+ 7 - 1
lib/Driver/Driver.cpp

@@ -3880,7 +3880,13 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
         break;
         break;
       case llvm::Triple::MSVC:
       case llvm::Triple::MSVC:
       case llvm::Triple::UnknownEnvironment:
       case llvm::Triple::UnknownEnvironment:
-        TC = llvm::make_unique<toolchains::MSVCToolChain>(*this, Target, Args);
+        if (Args.getLastArgValue(options::OPT_fuse_ld_EQ)
+                .startswith_lower("bfd"))
+          TC = llvm::make_unique<toolchains::CrossWindowsToolChain>(
+              *this, Target, Args);
+        else
+          TC =
+              llvm::make_unique<toolchains::MSVCToolChain>(*this, Target, Args);
         break;
         break;
       }
       }
       break;
       break;

+ 10 - 13
lib/Driver/SanitizerArgs.cpp

@@ -30,7 +30,7 @@ enum : SanitizerMask {
   NeedsUbsanCxxRt = Vptr | CFI,
   NeedsUbsanCxxRt = Vptr | CFI,
   NotAllowedWithTrap = Vptr,
   NotAllowedWithTrap = Vptr,
   NotAllowedWithMinimalRuntime = Vptr,
   NotAllowedWithMinimalRuntime = Vptr,
-  RequiresPIE = DataFlow,
+  RequiresPIE = DataFlow | Scudo,
   NeedsUnwindTables = Address | Thread | Memory | DataFlow,
   NeedsUnwindTables = Address | Thread | Memory | DataFlow,
   SupportsCoverage = Address | KernelAddress | Memory | Leak | Undefined |
   SupportsCoverage = Address | KernelAddress | Memory | Leak | Undefined |
                      Integer | Nullability | DataFlow | Fuzzer | FuzzerNoLink,
                      Integer | Nullability | DataFlow | Fuzzer | FuzzerNoLink,
@@ -173,7 +173,7 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
 bool SanitizerArgs::needsUbsanRt() const {
 bool SanitizerArgs::needsUbsanRt() const {
   // All of these include ubsan.
   // All of these include ubsan.
   if (needsAsanRt() || needsMsanRt() || needsTsanRt() || needsDfsanRt() ||
   if (needsAsanRt() || needsMsanRt() || needsTsanRt() || needsDfsanRt() ||
-      needsLsanRt() || needsCfiDiagRt())
+      needsLsanRt() || needsCfiDiagRt() || needsScudoRt())
     return false;
     return false;
 
 
   return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) ||
   return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) ||
@@ -370,17 +370,14 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
 
 
   // Warn about incompatible groups of sanitizers.
   // Warn about incompatible groups of sanitizers.
   std::pair<SanitizerMask, SanitizerMask> IncompatibleGroups[] = {
   std::pair<SanitizerMask, SanitizerMask> IncompatibleGroups[] = {
-      std::make_pair(Address, Thread), std::make_pair(Address, Memory),
-      std::make_pair(Thread, Memory), std::make_pair(Leak, Thread),
-      std::make_pair(Leak, Memory), std::make_pair(KernelAddress, Address),
-      std::make_pair(KernelAddress, Leak),
-      std::make_pair(KernelAddress, Thread),
-      std::make_pair(KernelAddress, Memory),
-      std::make_pair(Efficiency, Address),
-      std::make_pair(Efficiency, Leak),
-      std::make_pair(Efficiency, Thread),
-      std::make_pair(Efficiency, Memory),
-      std::make_pair(Efficiency, KernelAddress)};
+      std::make_pair(Address, Thread | Memory),
+      std::make_pair(Thread, Memory),
+      std::make_pair(Leak, Thread | Memory),
+      std::make_pair(KernelAddress, Address| Leak | Thread | Memory),
+      std::make_pair(Efficiency, Address | Leak | Thread | Memory |
+                                 KernelAddress),
+      std::make_pair(Scudo, Address | Leak | Thread | Memory | KernelAddress |
+                            Efficiency) };
   for (auto G : IncompatibleGroups) {
   for (auto G : IncompatibleGroups) {
     SanitizerMask Group = G.first;
     SanitizerMask Group = G.first;
     if (Kinds & Group) {
     if (Kinds & Group) {

+ 10 - 1
lib/Driver/ToolChains/Clang.cpp

@@ -3423,6 +3423,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("-mpie-copy-relocations");
     CmdArgs.push_back("-mpie-copy-relocations");
   }
   }
 
 
+  if (Args.hasFlag(options::OPT_fno_plt, options::OPT_fplt, false)) {
+    CmdArgs.push_back("-fno-plt");
+  }
+
   // -fhosted is default.
   // -fhosted is default.
   // TODO: Audit uses of KernelOrKext and see where it'd be more appropriate to
   // TODO: Audit uses of KernelOrKext and see where it'd be more appropriate to
   // use Freestanding.
   // use Freestanding.
@@ -4972,7 +4976,8 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
   // Parse the default calling convention options.
   // Parse the default calling convention options.
   if (Arg *CCArg =
   if (Arg *CCArg =
           Args.getLastArg(options::OPT__SLASH_Gd, options::OPT__SLASH_Gr,
           Args.getLastArg(options::OPT__SLASH_Gd, options::OPT__SLASH_Gr,
-                          options::OPT__SLASH_Gz, options::OPT__SLASH_Gv)) {
+                          options::OPT__SLASH_Gz, options::OPT__SLASH_Gv,
+                          options::OPT__SLASH_Gregcall)) {
     unsigned DCCOptId = CCArg->getOption().getID();
     unsigned DCCOptId = CCArg->getOption().getID();
     const char *DCCFlag = nullptr;
     const char *DCCFlag = nullptr;
     bool ArchSupported = true;
     bool ArchSupported = true;
@@ -4993,6 +4998,10 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
       ArchSupported = Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64;
       ArchSupported = Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64;
       DCCFlag = "-fdefault-calling-conv=vectorcall";
       DCCFlag = "-fdefault-calling-conv=vectorcall";
       break;
       break;
+    case options::OPT__SLASH_Gregcall:
+      ArchSupported = Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64;
+      DCCFlag = "-fdefault-calling-conv=regcall";
+      break;
     }
     }
 
 
     // MSVC doesn't warn if /Gr or /Gz is used on x64, so we don't either.
     // MSVC doesn't warn if /Gr or /Gz is used on x64, so we don't either.

+ 7 - 1
lib/Driver/ToolChains/CommonArgs.cpp

@@ -566,7 +566,6 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
       if (!Args.hasArg(options::OPT_shared) && !TC.getTriple().isAndroid())
       if (!Args.hasArg(options::OPT_shared) && !TC.getTriple().isAndroid())
         HelperStaticRuntimes.push_back("asan-preinit");
         HelperStaticRuntimes.push_back("asan-preinit");
     }
     }
-
     if (SanArgs.needsUbsanRt()) {
     if (SanArgs.needsUbsanRt()) {
       if (SanArgs.requiresMinimalRuntime()) {
       if (SanArgs.requiresMinimalRuntime()) {
         SharedRuntimes.push_back("ubsan_minimal");
         SharedRuntimes.push_back("ubsan_minimal");
@@ -574,6 +573,8 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
         SharedRuntimes.push_back("ubsan_standalone");
         SharedRuntimes.push_back("ubsan_standalone");
       }
       }
     }
     }
+    if (SanArgs.needsScudoRt())
+      SharedRuntimes.push_back("scudo");
   }
   }
 
 
   // The stats_client library is also statically linked into DSOs.
   // The stats_client library is also statically linked into DSOs.
@@ -630,6 +631,11 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
   }
   }
   if (SanArgs.needsEsanRt())
   if (SanArgs.needsEsanRt())
     StaticRuntimes.push_back("esan");
     StaticRuntimes.push_back("esan");
+  if (SanArgs.needsScudoRt()) {
+    StaticRuntimes.push_back("scudo");
+    if (SanArgs.linkCXXRuntimes())
+      StaticRuntimes.push_back("scudo_cxx");
+  }
 }
 }
 
 
 // Should be called before we add system libraries (C++ ABI, libstdc++/libc++,
 // Should be called before we add system libraries (C++ ABI, libstdc++/libc++,

+ 1 - 0
lib/Driver/ToolChains/Cuda.h

@@ -157,6 +157,7 @@ public:
   bool isPICDefaultForced() const override { return false; }
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
   bool SupportsProfiling() const override { return false; }
   bool SupportsObjCGC() const override { return false; }
   bool SupportsObjCGC() const override { return false; }
+  bool IsMathErrnoDefault() const override { return false; }
 
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
                           llvm::opt::ArgStringList &CC1Args) const override;
                           llvm::opt::ArgStringList &CC1Args) const override;

+ 3 - 2
lib/Driver/ToolChains/Linux.cpp

@@ -845,9 +845,10 @@ SanitizerMask Linux::getSupportedSanitizers() const {
     Res |= SanitizerKind::Memory;
     Res |= SanitizerKind::Memory;
   if (IsX86_64 || IsMIPS64)
   if (IsX86_64 || IsMIPS64)
     Res |= SanitizerKind::Efficiency;
     Res |= SanitizerKind::Efficiency;
-  if (IsX86 || IsX86_64) {
+  if (IsX86 || IsX86_64)
     Res |= SanitizerKind::Function;
     Res |= SanitizerKind::Function;
-  }
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch)
+    Res |= SanitizerKind::Scudo;
   return Res;
   return Res;
 }
 }
 
 

+ 2 - 10
lib/Driver/ToolChains/MinGW.cpp

@@ -107,14 +107,6 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   // handled somewhere else.
   // handled somewhere else.
   Args.ClaimAllArgs(options::OPT_w);
   Args.ClaimAllArgs(options::OPT_w);
 
 
-  StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld");
-  if (LinkerName.equals_lower("lld")) {
-    CmdArgs.push_back("-flavor");
-    CmdArgs.push_back("gnu");
-  } else if (!LinkerName.equals_lower("ld")) {
-    D.Diag(diag::err_drv_unsupported_linker) << LinkerName;
-  }
-
   if (!D.SysRoot.empty())
   if (!D.SysRoot.empty())
     CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
     CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
 
@@ -244,7 +236,7 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
 
       if (Args.hasArg(options::OPT_static))
       if (Args.hasArg(options::OPT_static))
         CmdArgs.push_back("--end-group");
         CmdArgs.push_back("--end-group");
-      else if (!LinkerName.equals_lower("lld"))
+      else
         AddLibGCC(Args, CmdArgs);
         AddLibGCC(Args, CmdArgs);
     }
     }
 
 
@@ -255,7 +247,7 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
       CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
       CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
     }
     }
   }
   }
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath(LinkerName.data()));
+  const char *Exec = Args.MakeArgString(TC.GetLinkerPath());
   C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
   C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
 }
 }
 
 

+ 2 - 1
lib/Format/TokenAnnotator.cpp

@@ -696,7 +696,8 @@ private:
           CurrentToken->Type = TT_PointerOrReference;
           CurrentToken->Type = TT_PointerOrReference;
         consumeToken();
         consumeToken();
         if (CurrentToken &&
         if (CurrentToken &&
-            CurrentToken->Previous->isOneOf(TT_BinaryOperator, tok::comma))
+            CurrentToken->Previous->isOneOf(TT_BinaryOperator, TT_UnaryOperator,
+                                            tok::comma))
           CurrentToken->Previous->Type = TT_OverloadedOperator;
           CurrentToken->Previous->Type = TT_OverloadedOperator;
       }
       }
       if (CurrentToken) {
       if (CurrentToken) {

+ 21 - 2
lib/Format/UsingDeclarationsSorter.cpp

@@ -33,8 +33,27 @@ struct UsingDeclaration {
   UsingDeclaration(const AnnotatedLine *Line, const std::string &Label)
   UsingDeclaration(const AnnotatedLine *Line, const std::string &Label)
       : Line(Line), Label(Label) {}
       : Line(Line), Label(Label) {}
 
 
+  // Compares lexicographically with the exception that '_' is just before 'A'.
   bool operator<(const UsingDeclaration &Other) const {
   bool operator<(const UsingDeclaration &Other) const {
-    return StringRef(Label).compare_lower(Other.Label) < 0;
+    size_t Size = Label.size();
+    size_t OtherSize = Other.Label.size();
+    for (size_t I = 0, E = std::min(Size, OtherSize); I < E; ++I) {
+      char Rank = rank(Label[I]);
+      char OtherRank = rank(Other.Label[I]);
+      if (Rank != OtherRank)
+        return Rank < OtherRank;
+    }
+    return Size < OtherSize;
+  }
+
+  // Returns the position of c in a lexicographic ordering with the exception
+  // that '_' is just before 'A'.
+  static char rank(char c) {
+    if (c == '_')
+      return 'A';
+    if ('A' <= c && c < '_')
+      return c + 1;
+    return c;
   }
   }
 };
 };
 
 
@@ -77,7 +96,7 @@ void endUsingDeclarationBlock(
     SmallVectorImpl<UsingDeclaration> *UsingDeclarations,
     SmallVectorImpl<UsingDeclaration> *UsingDeclarations,
     const SourceManager &SourceMgr, tooling::Replacements *Fixes) {
     const SourceManager &SourceMgr, tooling::Replacements *Fixes) {
   bool BlockAffected = false;
   bool BlockAffected = false;
-  for (const UsingDeclaration& Declaration : *UsingDeclarations) {
+  for (const UsingDeclaration &Declaration : *UsingDeclarations) {
     if (Declaration.Line->Affected) {
     if (Declaration.Line->Affected) {
       BlockAffected = true;
       BlockAffected = true;
       break;
       break;

+ 5 - 3
lib/Frontend/CompilerInvocation.cpp

@@ -653,6 +653,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
       Args.hasArg(OPT_mincremental_linker_compatible);
       Args.hasArg(OPT_mincremental_linker_compatible);
   Opts.PIECopyRelocations =
   Opts.PIECopyRelocations =
       Args.hasArg(OPT_mpie_copy_relocations);
       Args.hasArg(OPT_mpie_copy_relocations);
+  Opts.NoPLT = Args.hasArg(OPT_fno_plt);
   Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
   Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
   Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels);
   Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels);
   Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm);
   Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm);
@@ -2310,12 +2311,12 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   // Check for MS default calling conventions being specified.
   // Check for MS default calling conventions being specified.
   if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
   if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
     LangOptions::DefaultCallingConvention DefaultCC =
     LangOptions::DefaultCallingConvention DefaultCC =
-        llvm::StringSwitch<LangOptions::DefaultCallingConvention>(
-            A->getValue())
+        llvm::StringSwitch<LangOptions::DefaultCallingConvention>(A->getValue())
             .Case("cdecl", LangOptions::DCC_CDecl)
             .Case("cdecl", LangOptions::DCC_CDecl)
             .Case("fastcall", LangOptions::DCC_FastCall)
             .Case("fastcall", LangOptions::DCC_FastCall)
             .Case("stdcall", LangOptions::DCC_StdCall)
             .Case("stdcall", LangOptions::DCC_StdCall)
             .Case("vectorcall", LangOptions::DCC_VectorCall)
             .Case("vectorcall", LangOptions::DCC_VectorCall)
+            .Case("regcall", LangOptions::DCC_RegCall)
             .Default(LangOptions::DCC_None);
             .Default(LangOptions::DCC_None);
     if (DefaultCC == LangOptions::DCC_None)
     if (DefaultCC == LangOptions::DCC_None)
       Diags.Report(diag::err_drv_invalid_value)
       Diags.Report(diag::err_drv_invalid_value)
@@ -2326,7 +2327,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
     bool emitError = (DefaultCC == LangOptions::DCC_FastCall ||
     bool emitError = (DefaultCC == LangOptions::DCC_FastCall ||
                       DefaultCC == LangOptions::DCC_StdCall) &&
                       DefaultCC == LangOptions::DCC_StdCall) &&
                      Arch != llvm::Triple::x86;
                      Arch != llvm::Triple::x86;
-    emitError |= DefaultCC == LangOptions::DCC_VectorCall &&
+    emitError |= (DefaultCC == LangOptions::DCC_VectorCall ||
+                  DefaultCC == LangOptions::DCC_RegCall) &&
                  !(Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64);
                  !(Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64);
     if (emitError)
     if (emitError)
       Diags.Report(diag::err_drv_argument_not_allowed_with)
       Diags.Report(diag::err_drv_argument_not_allowed_with)

+ 131 - 319
lib/Headers/avx512bwintrin.h

@@ -56,293 +56,145 @@ _mm512_setzero_hi(void) {
 
 
 /* Integer compare */
 /* Integer compare */
 
 
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmpeq_epi8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_pcmpeqb512_mask((__v64qi)__a, (__v64qi)__b,
-                                                   (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpeq_epi8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_pcmpeqb512_mask((__v64qi)__a, (__v64qi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmpeq_epu8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 0,
-                                                 (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpeq_epu8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 0,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmpeq_epi16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_pcmpeqw512_mask((__v32hi)__a, (__v32hi)__b,
-                                                   (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpeq_epi16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_pcmpeqw512_mask((__v32hi)__a, (__v32hi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmpeq_epu16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 0,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpeq_epu16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 0,
-                                                 __u);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmpge_epi8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)__a, (__v64qi)__b, 5,
-                                                (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpge_epi8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)__a, (__v64qi)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmpge_epu8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 5,
-                                                 (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpge_epu8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 5,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmpge_epi16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)__a, (__v32hi)__b, 5,
-                                                (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpge_epi16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)__a, (__v32hi)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmpge_epu16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 5,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpge_epu16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 5,
-                                                 __u);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmpgt_epi8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_pcmpgtb512_mask((__v64qi)__a, (__v64qi)__b,
-                                                   (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpgt_epi8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_pcmpgtb512_mask((__v64qi)__a, (__v64qi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmpgt_epu8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 6,
-                                                 (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpgt_epu8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 6,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmpgt_epi16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_pcmpgtw512_mask((__v32hi)__a, (__v32hi)__b,
-                                                   (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpgt_epi16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_pcmpgtw512_mask((__v32hi)__a, (__v32hi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmpgt_epu16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 6,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpgt_epu16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 6,
-                                                 __u);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmple_epi8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)__a, (__v64qi)__b, 2,
-                                                (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmple_epi8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)__a, (__v64qi)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmple_epu8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 2,
-                                                 (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmple_epu8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 2,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmple_epi16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)__a, (__v32hi)__b, 2,
-                                                (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmple_epi16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)__a, (__v32hi)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmple_epu16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 2,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmple_epu16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 2,
-                                                 __u);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmplt_epi8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)__a, (__v64qi)__b, 1,
-                                                (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmplt_epi8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)__a, (__v64qi)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmplt_epu8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 1,
-                                                 (__mmask64)-1);
-}
-
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmplt_epu8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 1,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmplt_epi16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)__a, (__v32hi)__b, 1,
-                                                (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmplt_epi16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)__a, (__v32hi)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmplt_epu16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 1,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmplt_epu16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 1,
-                                                 __u);
-}
+#define _mm512_cmp_epi8_mask(a, b, p) __extension__ ({ \
+  (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)(__m512i)(a), \
+                                         (__v64qi)(__m512i)(b), (int)(p), \
+                                         (__mmask64)-1); })
 
 
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmpneq_epi8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)__a, (__v64qi)__b, 4,
-                                                (__mmask64)-1);
-}
+#define _mm512_mask_cmp_epi8_mask(m, a, b, p) __extension__ ({ \
+  (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)(__m512i)(a), \
+                                         (__v64qi)(__m512i)(b), (int)(p), \
+                                         (__mmask64)(m)); })
 
 
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpneq_epi8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)__a, (__v64qi)__b, 4,
-                                                __u);
-}
+#define _mm512_cmp_epu8_mask(a, b, p) __extension__ ({ \
+  (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)(__m512i)(a), \
+                                          (__v64qi)(__m512i)(b), (int)(p), \
+                                          (__mmask64)-1); })
 
 
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_cmpneq_epu8_mask(__m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 4,
-                                                 (__mmask64)-1);
-}
+#define _mm512_mask_cmp_epu8_mask(m, a, b, p) __extension__ ({ \
+  (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)(__m512i)(a), \
+                                          (__v64qi)(__m512i)(b), (int)(p), \
+                                          (__mmask64)(m)); })
 
 
-static __inline__ __mmask64 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpneq_epu8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
-  return (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)__a, (__v64qi)__b, 4,
-                                                 __u);
-}
+#define _mm512_cmp_epi16_mask(a, b, p) __extension__ ({ \
+  (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)(__m512i)(a), \
+                                         (__v32hi)(__m512i)(b), (int)(p), \
+                                         (__mmask32)-1); })
 
 
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmpneq_epi16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)__a, (__v32hi)__b, 4,
-                                                (__mmask32)-1);
-}
+#define _mm512_mask_cmp_epi16_mask(m, a, b, p) __extension__ ({ \
+  (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)(__m512i)(a), \
+                                         (__v32hi)(__m512i)(b), (int)(p), \
+                                         (__mmask32)(m)); })
 
 
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpneq_epi16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)__a, (__v32hi)__b, 4,
-                                                __u);
-}
+#define _mm512_cmp_epu16_mask(a, b, p) __extension__ ({ \
+  (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)(__m512i)(a), \
+                                          (__v32hi)(__m512i)(b), (int)(p), \
+                                          (__mmask32)-1); })
 
 
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_cmpneq_epu16_mask(__m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 4,
-                                                 (__mmask32)-1);
-}
+#define _mm512_mask_cmp_epu16_mask(m, a, b, p) __extension__ ({ \
+  (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)(__m512i)(a), \
+                                          (__v32hi)(__m512i)(b), (int)(p), \
+                                          (__mmask32)(m)); })
 
 
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpneq_epu16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
-  return (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)__a, (__v32hi)__b, 4,
-                                                 __u);
-}
+#define _mm512_cmpeq_epi8_mask(A, B) \
+    _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm512_mask_cmpeq_epi8_mask(k, A, B) \
+    _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm512_cmpge_epi8_mask(A, B) \
+    _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_GE)
+#define _mm512_mask_cmpge_epi8_mask(k, A, B) \
+    _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm512_cmpgt_epi8_mask(A, B) \
+    _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_GT)
+#define _mm512_mask_cmpgt_epi8_mask(k, A, B) \
+    _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm512_cmple_epi8_mask(A, B) \
+    _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_LE)
+#define _mm512_mask_cmple_epi8_mask(k, A, B) \
+    _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm512_cmplt_epi8_mask(A, B) \
+    _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_LT)
+#define _mm512_mask_cmplt_epi8_mask(k, A, B) \
+    _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm512_cmpneq_epi8_mask(A, B) \
+    _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_NE)
+#define _mm512_mask_cmpneq_epi8_mask(k, A, B) \
+    _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm512_cmpeq_epu8_mask(A, B) \
+    _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm512_mask_cmpeq_epu8_mask(k, A, B) \
+    _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm512_cmpge_epu8_mask(A, B) \
+    _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_GE)
+#define _mm512_mask_cmpge_epu8_mask(k, A, B) \
+    _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm512_cmpgt_epu8_mask(A, B) \
+    _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_GT)
+#define _mm512_mask_cmpgt_epu8_mask(k, A, B) \
+    _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm512_cmple_epu8_mask(A, B) \
+    _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_LE)
+#define _mm512_mask_cmple_epu8_mask(k, A, B) \
+    _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm512_cmplt_epu8_mask(A, B) \
+    _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_LT)
+#define _mm512_mask_cmplt_epu8_mask(k, A, B) \
+    _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm512_cmpneq_epu8_mask(A, B) \
+    _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_NE)
+#define _mm512_mask_cmpneq_epu8_mask(k, A, B) \
+    _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm512_cmpeq_epi16_mask(A, B) \
+    _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm512_mask_cmpeq_epi16_mask(k, A, B) \
+    _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm512_cmpge_epi16_mask(A, B) \
+    _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_GE)
+#define _mm512_mask_cmpge_epi16_mask(k, A, B) \
+    _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm512_cmpgt_epi16_mask(A, B) \
+    _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_GT)
+#define _mm512_mask_cmpgt_epi16_mask(k, A, B) \
+    _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm512_cmple_epi16_mask(A, B) \
+    _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_LE)
+#define _mm512_mask_cmple_epi16_mask(k, A, B) \
+    _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm512_cmplt_epi16_mask(A, B) \
+    _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_LT)
+#define _mm512_mask_cmplt_epi16_mask(k, A, B) \
+    _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm512_cmpneq_epi16_mask(A, B) \
+    _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_NE)
+#define _mm512_mask_cmpneq_epi16_mask(k, A, B) \
+    _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm512_cmpeq_epu16_mask(A, B) \
+    _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm512_mask_cmpeq_epu16_mask(k, A, B) \
+    _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm512_cmpge_epu16_mask(A, B) \
+    _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_GE)
+#define _mm512_mask_cmpge_epu16_mask(k, A, B) \
+    _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm512_cmpgt_epu16_mask(A, B) \
+    _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_GT)
+#define _mm512_mask_cmpgt_epu16_mask(k, A, B) \
+    _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm512_cmple_epu16_mask(A, B) \
+    _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_LE)
+#define _mm512_mask_cmple_epu16_mask(k, A, B) \
+    _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm512_cmplt_epu16_mask(A, B) \
+    _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_LT)
+#define _mm512_mask_cmplt_epu16_mask(k, A, B) \
+    _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm512_cmpneq_epu16_mask(A, B) \
+    _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_NE)
+#define _mm512_mask_cmpneq_epu16_mask(k, A, B) \
+    _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_NE)
 
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_add_epi8 (__m512i __A, __m512i __B) {
 _mm512_add_epi8 (__m512i __A, __m512i __B) {
@@ -1541,46 +1393,6 @@ _mm512_maskz_cvtepu8_epi16(__mmask32 __U, __m256i __A)
 }
 }
 
 
 
 
-#define _mm512_cmp_epi8_mask(a, b, p) __extension__ ({ \
-  (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)(__m512i)(a), \
-                                         (__v64qi)(__m512i)(b), (int)(p), \
-                                         (__mmask64)-1); })
-
-#define _mm512_mask_cmp_epi8_mask(m, a, b, p) __extension__ ({ \
-  (__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)(__m512i)(a), \
-                                         (__v64qi)(__m512i)(b), (int)(p), \
-                                         (__mmask64)(m)); })
-
-#define _mm512_cmp_epu8_mask(a, b, p) __extension__ ({ \
-  (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)(__m512i)(a), \
-                                          (__v64qi)(__m512i)(b), (int)(p), \
-                                          (__mmask64)-1); })
-
-#define _mm512_mask_cmp_epu8_mask(m, a, b, p) __extension__ ({ \
-  (__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)(__m512i)(a), \
-                                          (__v64qi)(__m512i)(b), (int)(p), \
-                                          (__mmask64)(m)); })
-
-#define _mm512_cmp_epi16_mask(a, b, p) __extension__ ({ \
-  (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)(__m512i)(a), \
-                                         (__v32hi)(__m512i)(b), (int)(p), \
-                                         (__mmask32)-1); })
-
-#define _mm512_mask_cmp_epi16_mask(m, a, b, p) __extension__ ({ \
-  (__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)(__m512i)(a), \
-                                         (__v32hi)(__m512i)(b), (int)(p), \
-                                         (__mmask32)(m)); })
-
-#define _mm512_cmp_epu16_mask(a, b, p) __extension__ ({ \
-  (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)(__m512i)(a), \
-                                          (__v32hi)(__m512i)(b), (int)(p), \
-                                          (__mmask32)-1); })
-
-#define _mm512_mask_cmp_epu16_mask(m, a, b, p) __extension__ ({ \
-  (__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)(__m512i)(a), \
-                                          (__v32hi)(__m512i)(b), (int)(p), \
-                                          (__mmask32)(m)); })
-
 #define _mm512_shufflehi_epi16(A, imm) __extension__ ({ \
 #define _mm512_shufflehi_epi16(A, imm) __extension__ ({ \
   (__m512i)__builtin_shufflevector((__v32hi)(__m512i)(A), \
   (__m512i)__builtin_shufflevector((__v32hi)(__m512i)(A), \
                                    (__v32hi)_mm512_undefined_epi32(), \
                                    (__v32hi)_mm512_undefined_epi32(), \

+ 3 - 2
lib/Headers/avx512cdintrin.h

@@ -130,13 +130,14 @@ _mm512_maskz_lzcnt_epi64 (__mmask8 __U, __m512i __A)
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_broadcastmb_epi64 (__mmask8 __A)
 _mm512_broadcastmb_epi64 (__mmask8 __A)
 {
 {
-  return (__m512i) __builtin_ia32_broadcastmb512 (__A);
+  return (__m512i) _mm512_set1_epi64((long long) __A);
 }
 }
 
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_broadcastmw_epi32 (__mmask16 __A)
 _mm512_broadcastmw_epi32 (__mmask16 __A)
 {
 {
-  return (__m512i) __builtin_ia32_broadcastmw512 (__A);
+  return (__m512i) _mm512_set1_epi32((int) __A);
+
 }
 }
 
 
 #undef __DEFAULT_FN_ATTRS
 #undef __DEFAULT_FN_ATTRS

+ 99 - 287
lib/Headers/avx512fintrin.h

@@ -4844,293 +4844,105 @@ _mm512_knot(__mmask16 __M)
 
 
 /* Integer compare */
 /* Integer compare */
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmpeq_epi32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_pcmpeqd512_mask((__v16si)__a, (__v16si)__b,
-                                                   (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpeq_epi32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_pcmpeqd512_mask((__v16si)__a, (__v16si)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmpeq_epu32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 0,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpeq_epu32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 0,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpeq_epi64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqq512_mask((__v8di)__a, (__v8di)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmpeq_epi64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqq512_mask((__v8di)__a, (__v8di)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmpeq_epu64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 0,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpeq_epu64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 0,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmpge_epi32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_cmpd512_mask((__v16si)__a, (__v16si)__b, 5,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpge_epi32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_cmpd512_mask((__v16si)__a, (__v16si)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmpge_epu32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 5,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpge_epu32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 5,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmpge_epi64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_cmpq512_mask((__v8di)__a, (__v8di)__b, 5,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpge_epi64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_cmpq512_mask((__v8di)__a, (__v8di)__b, 5,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmpge_epu64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 5,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpge_epu64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmpgt_epi32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_pcmpgtd512_mask((__v16si)__a, (__v16si)__b,
-                                                   (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpgt_epi32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_pcmpgtd512_mask((__v16si)__a, (__v16si)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmpgt_epu32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 6,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpgt_epu32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 6,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpgt_epi64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtq512_mask((__v8di)__a, (__v8di)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmpgt_epi64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtq512_mask((__v8di)__a, (__v8di)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmpgt_epu64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 6,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpgt_epu64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 6,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmple_epi32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_cmpd512_mask((__v16si)__a, (__v16si)__b, 2,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmple_epi32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_cmpd512_mask((__v16si)__a, (__v16si)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmple_epu32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 2,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmple_epu32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 2,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmple_epi64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_cmpq512_mask((__v8di)__a, (__v8di)__b, 2,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmple_epi64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_cmpq512_mask((__v8di)__a, (__v8di)__b, 2,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmple_epu64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 2,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmple_epu64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmplt_epi32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_cmpd512_mask((__v16si)__a, (__v16si)__b, 1,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmplt_epi32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_cmpd512_mask((__v16si)__a, (__v16si)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmplt_epu32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 1,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmplt_epu32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 1,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmplt_epi64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_cmpq512_mask((__v8di)__a, (__v8di)__b, 1,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmplt_epi64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_cmpq512_mask((__v8di)__a, (__v8di)__b, 1,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmplt_epu64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 1,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmplt_epu64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmpneq_epi32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_cmpd512_mask((__v16si)__a, (__v16si)__b, 4,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpneq_epi32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_cmpd512_mask((__v16si)__a, (__v16si)__b, 4,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_cmpneq_epu32_mask(__m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 4,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpneq_epu32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
-  return (__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)__a, (__v16si)__b, 4,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmpneq_epi64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_cmpq512_mask((__v8di)__a, (__v8di)__b, 4,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpneq_epi64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_cmpq512_mask((__v8di)__a, (__v8di)__b, 4,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_cmpneq_epu64_mask(__m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 4,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm512_mask_cmpneq_epu64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)__a, (__v8di)__b, 4,
-                                                __u);
-}
+#define _mm512_cmpeq_epi32_mask(A, B) \
+    _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm512_mask_cmpeq_epi32_mask(k, A, B) \
+    _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm512_cmpge_epi32_mask(A, B) \
+    _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_GE)
+#define _mm512_mask_cmpge_epi32_mask(k, A, B) \
+    _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm512_cmpgt_epi32_mask(A, B) \
+    _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_GT)
+#define _mm512_mask_cmpgt_epi32_mask(k, A, B) \
+    _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm512_cmple_epi32_mask(A, B) \
+    _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_LE)
+#define _mm512_mask_cmple_epi32_mask(k, A, B) \
+    _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm512_cmplt_epi32_mask(A, B) \
+    _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_LT)
+#define _mm512_mask_cmplt_epi32_mask(k, A, B) \
+    _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm512_cmpneq_epi32_mask(A, B) \
+    _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_NE)
+#define _mm512_mask_cmpneq_epi32_mask(k, A, B) \
+    _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm512_cmpeq_epu32_mask(A, B) \
+    _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm512_mask_cmpeq_epu32_mask(k, A, B) \
+    _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm512_cmpge_epu32_mask(A, B) \
+    _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_GE)
+#define _mm512_mask_cmpge_epu32_mask(k, A, B) \
+    _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm512_cmpgt_epu32_mask(A, B) \
+    _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_GT)
+#define _mm512_mask_cmpgt_epu32_mask(k, A, B) \
+    _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm512_cmple_epu32_mask(A, B) \
+    _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_LE)
+#define _mm512_mask_cmple_epu32_mask(k, A, B) \
+    _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm512_cmplt_epu32_mask(A, B) \
+    _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_LT)
+#define _mm512_mask_cmplt_epu32_mask(k, A, B) \
+    _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm512_cmpneq_epu32_mask(A, B) \
+    _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_NE)
+#define _mm512_mask_cmpneq_epu32_mask(k, A, B) \
+    _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm512_cmpeq_epi64_mask(A, B) \
+    _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm512_mask_cmpeq_epi64_mask(k, A, B) \
+    _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm512_cmpge_epi64_mask(A, B) \
+    _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_GE)
+#define _mm512_mask_cmpge_epi64_mask(k, A, B) \
+    _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm512_cmpgt_epi64_mask(A, B) \
+    _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_GT)
+#define _mm512_mask_cmpgt_epi64_mask(k, A, B) \
+    _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm512_cmple_epi64_mask(A, B) \
+    _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_LE)
+#define _mm512_mask_cmple_epi64_mask(k, A, B) \
+    _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm512_cmplt_epi64_mask(A, B) \
+    _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_LT)
+#define _mm512_mask_cmplt_epi64_mask(k, A, B) \
+    _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm512_cmpneq_epi64_mask(A, B) \
+    _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_NE)
+#define _mm512_mask_cmpneq_epi64_mask(k, A, B) \
+    _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm512_cmpeq_epu64_mask(A, B) \
+    _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm512_mask_cmpeq_epu64_mask(k, A, B) \
+    _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm512_cmpge_epu64_mask(A, B) \
+    _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_GE)
+#define _mm512_mask_cmpge_epu64_mask(k, A, B) \
+    _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm512_cmpgt_epu64_mask(A, B) \
+    _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_GT)
+#define _mm512_mask_cmpgt_epu64_mask(k, A, B) \
+    _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm512_cmple_epu64_mask(A, B) \
+    _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_LE)
+#define _mm512_mask_cmple_epu64_mask(k, A, B) \
+    _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm512_cmplt_epu64_mask(A, B) \
+    _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_LT)
+#define _mm512_mask_cmplt_epu64_mask(k, A, B) \
+    _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm512_cmpneq_epu64_mask(A, B) \
+    _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_NE)
+#define _mm512_mask_cmpneq_epu64_mask(k, A, B) \
+    _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_NE)
 
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_cvtepi8_epi32(__m128i __A)
 _mm512_cvtepi8_epi32(__m128i __A)

+ 263 - 639
lib/Headers/avx512vlbwintrin.h

@@ -38,581 +38,285 @@ _mm_setzero_hi(void){
 
 
 /* Integer compare */
 /* Integer compare */
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmpeq_epi8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_pcmpeqb128_mask((__v16qi)__a, (__v16qi)__b,
-                                                   (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmpeq_epi8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_pcmpeqb128_mask((__v16qi)__a, (__v16qi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmpeq_epu8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 0,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmpeq_epu8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 0,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmpeq_epi8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_pcmpeqb256_mask((__v32qi)__a, (__v32qi)__b,
-                                                   (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpeq_epi8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_pcmpeqb256_mask((__v32qi)__a, (__v32qi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmpeq_epu8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 0,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpeq_epu8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 0,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpeq_epi16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqw128_mask((__v8hi)__a, (__v8hi)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpeq_epi16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqw128_mask((__v8hi)__a, (__v8hi)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpeq_epu16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 0,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpeq_epu16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 0,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmpeq_epi16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_pcmpeqw256_mask((__v16hi)__a, (__v16hi)__b,
-                                                   (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpeq_epi16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_pcmpeqw256_mask((__v16hi)__a, (__v16hi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmpeq_epu16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 0,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpeq_epu16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 0,
-                                                 __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmpge_epi8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)__a, (__v16qi)__b, 5,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmpge_epi8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)__a, (__v16qi)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmpge_epu8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 5,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmpge_epu8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 5,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmpge_epi8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)__a, (__v32qi)__b, 5,
-                                                (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpge_epi8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)__a, (__v32qi)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmpge_epu8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 5,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpge_epu8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 5,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpge_epi16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)__a, (__v8hi)__b, 5,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpge_epi16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)__a, (__v8hi)__b, 5,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpge_epu16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 5,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpge_epu16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmpge_epi16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)__a, (__v16hi)__b, 5,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpge_epi16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)__a, (__v16hi)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmpge_epu16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 5,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpge_epu16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 5,
-                                                 __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmpgt_epi8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_pcmpgtb128_mask((__v16qi)__a, (__v16qi)__b,
-                                                   (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmpgt_epi8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_pcmpgtb128_mask((__v16qi)__a, (__v16qi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmpgt_epu8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 6,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmpgt_epu8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 6,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmpgt_epi8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_pcmpgtb256_mask((__v32qi)__a, (__v32qi)__b,
-                                                   (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpgt_epi8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_pcmpgtb256_mask((__v32qi)__a, (__v32qi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmpgt_epu8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 6,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpgt_epu8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 6,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpgt_epi16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtw128_mask((__v8hi)__a, (__v8hi)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpgt_epi16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtw128_mask((__v8hi)__a, (__v8hi)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpgt_epu16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 6,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpgt_epu16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 6,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmpgt_epi16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_pcmpgtw256_mask((__v16hi)__a, (__v16hi)__b,
-                                                   (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpgt_epi16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_pcmpgtw256_mask((__v16hi)__a, (__v16hi)__b,
-                                                   __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmpgt_epu16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 6,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpgt_epu16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 6,
-                                                 __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmple_epi8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)__a, (__v16qi)__b, 2,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmple_epi8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)__a, (__v16qi)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmple_epu8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 2,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmple_epu8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 2,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmple_epi8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)__a, (__v32qi)__b, 2,
-                                                (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmple_epi8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)__a, (__v32qi)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmple_epu8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 2,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmple_epu8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 2,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmple_epi16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)__a, (__v8hi)__b, 2,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmple_epi16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)__a, (__v8hi)__b, 2,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmple_epu16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 2,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmple_epu16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmple_epi16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)__a, (__v16hi)__b, 2,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmple_epi16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)__a, (__v16hi)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmple_epu16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 2,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmple_epu16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 2,
-                                                 __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmplt_epi8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)__a, (__v16qi)__b, 1,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmplt_epi8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)__a, (__v16qi)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmplt_epu8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 1,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmplt_epu8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 1,
-                                                 __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmplt_epi8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)__a, (__v32qi)__b, 1,
-                                                (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmplt_epi8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)__a, (__v32qi)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmplt_epu8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 1,
-                                                 (__mmask32)-1);
-}
-
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmplt_epu8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 1,
-                                                 __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmplt_epi16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)__a, (__v8hi)__b, 1,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmplt_epi16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)__a, (__v8hi)__b, 1,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmplt_epu16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 1,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmplt_epu16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmplt_epi16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)__a, (__v16hi)__b, 1,
-                                                (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmplt_epi16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)__a, (__v16hi)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmplt_epu16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 1,
-                                                 (__mmask16)-1);
-}
-
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmplt_epu16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 1,
-                                                 __u);
-}
+#define _mm_cmp_epi8_mask(a, b, p) __extension__ ({ \
+  (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)(__m128i)(a), \
+                                         (__v16qi)(__m128i)(b), (int)(p), \
+                                         (__mmask16)-1); })
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmpneq_epi8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)__a, (__v16qi)__b, 4,
-                                                (__mmask16)-1);
-}
+#define _mm_mask_cmp_epi8_mask(m, a, b, p) __extension__ ({ \
+  (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)(__m128i)(a), \
+                                         (__v16qi)(__m128i)(b), (int)(p), \
+                                         (__mmask16)(m)); })
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmpneq_epi8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)__a, (__v16qi)__b, 4,
-                                                __u);
-}
+#define _mm_cmp_epu8_mask(a, b, p) __extension__ ({ \
+  (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)(__m128i)(a), \
+                                          (__v16qi)(__m128i)(b), (int)(p), \
+                                          (__mmask16)-1); })
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_cmpneq_epu8_mask(__m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 4,
-                                                 (__mmask16)-1);
-}
+#define _mm_mask_cmp_epu8_mask(m, a, b, p) __extension__ ({ \
+  (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)(__m128i)(a), \
+                                          (__v16qi)(__m128i)(b), (int)(p), \
+                                          (__mmask16)(m)); })
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm_mask_cmpneq_epu8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
-  return (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)__a, (__v16qi)__b, 4,
-                                                 __u);
-}
+#define _mm256_cmp_epi8_mask(a, b, p) __extension__ ({ \
+  (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)(__m256i)(a), \
+                                         (__v32qi)(__m256i)(b), (int)(p), \
+                                         (__mmask32)-1); })
 
 
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmpneq_epi8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)__a, (__v32qi)__b, 4,
-                                                (__mmask32)-1);
-}
+#define _mm256_mask_cmp_epi8_mask(m, a, b, p) __extension__ ({ \
+  (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)(__m256i)(a), \
+                                         (__v32qi)(__m256i)(b), (int)(p), \
+                                         (__mmask32)(m)); })
 
 
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpneq_epi8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)__a, (__v32qi)__b, 4,
-                                                __u);
-}
+#define _mm256_cmp_epu8_mask(a, b, p) __extension__ ({ \
+  (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)(__m256i)(a), \
+                                          (__v32qi)(__m256i)(b), (int)(p), \
+                                          (__mmask32)-1); })
 
 
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_cmpneq_epu8_mask(__m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 4,
-                                                 (__mmask32)-1);
-}
+#define _mm256_mask_cmp_epu8_mask(m, a, b, p) __extension__ ({ \
+  (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)(__m256i)(a), \
+                                          (__v32qi)(__m256i)(b), (int)(p), \
+                                          (__mmask32)(m)); })
 
 
-static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpneq_epu8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
-  return (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)__a, (__v32qi)__b, 4,
-                                                 __u);
-}
+#define _mm_cmp_epi16_mask(a, b, p) __extension__ ({ \
+  (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)(__m128i)(a), \
+                                        (__v8hi)(__m128i)(b), (int)(p), \
+                                        (__mmask8)-1); })
 
 
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpneq_epi16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)__a, (__v8hi)__b, 4,
-                                               (__mmask8)-1);
-}
+#define _mm_mask_cmp_epi16_mask(m, a, b, p) __extension__ ({ \
+  (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)(__m128i)(a), \
+                                        (__v8hi)(__m128i)(b), (int)(p), \
+                                        (__mmask8)(m)); })
 
 
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpneq_epi16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)__a, (__v8hi)__b, 4,
-                                               __u);
-}
+#define _mm_cmp_epu16_mask(a, b, p) __extension__ ({ \
+  (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)(__m128i)(a), \
+                                         (__v8hi)(__m128i)(b), (int)(p), \
+                                         (__mmask8)-1); })
 
 
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpneq_epu16_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 4,
-                                                (__mmask8)-1);
-}
+#define _mm_mask_cmp_epu16_mask(m, a, b, p) __extension__ ({ \
+  (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)(__m128i)(a), \
+                                         (__v8hi)(__m128i)(b), (int)(p), \
+                                         (__mmask8)(m)); })
 
 
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpneq_epu16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)__a, (__v8hi)__b, 4,
-                                                __u);
-}
+#define _mm256_cmp_epi16_mask(a, b, p) __extension__ ({ \
+  (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)(__m256i)(a), \
+                                         (__v16hi)(__m256i)(b), (int)(p), \
+                                         (__mmask16)-1); })
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmpneq_epi16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)__a, (__v16hi)__b, 4,
-                                                (__mmask16)-1);
-}
+#define _mm256_mask_cmp_epi16_mask(m, a, b, p) __extension__ ({ \
+  (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)(__m256i)(a), \
+                                         (__v16hi)(__m256i)(b), (int)(p), \
+                                         (__mmask16)(m)); })
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpneq_epi16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)__a, (__v16hi)__b, 4,
-                                                __u);
-}
+#define _mm256_cmp_epu16_mask(a, b, p) __extension__ ({ \
+  (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)(__m256i)(a), \
+                                          (__v16hi)(__m256i)(b), (int)(p), \
+                                          (__mmask16)-1); })
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_cmpneq_epu16_mask(__m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 4,
-                                                 (__mmask16)-1);
-}
+#define _mm256_mask_cmp_epu16_mask(m, a, b, p) __extension__ ({ \
+  (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)(__m256i)(a), \
+                                          (__v16hi)(__m256i)(b), (int)(p), \
+                                          (__mmask16)(m)); })
 
 
-static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpneq_epu16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
-  return (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)__a, (__v16hi)__b, 4,
-                                                 __u);
-}
+#define _mm_cmpeq_epi8_mask(A, B) \
+    _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm_mask_cmpeq_epi8_mask(k, A, B) \
+    _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm_cmpge_epi8_mask(A, B) \
+    _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_GE)
+#define _mm_mask_cmpge_epi8_mask(k, A, B) \
+    _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm_cmpgt_epi8_mask(A, B) \
+    _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_GT)
+#define _mm_mask_cmpgt_epi8_mask(k, A, B) \
+    _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm_cmple_epi8_mask(A, B) \
+    _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_LE)
+#define _mm_mask_cmple_epi8_mask(k, A, B) \
+    _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm_cmplt_epi8_mask(A, B) \
+    _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_LT)
+#define _mm_mask_cmplt_epi8_mask(k, A, B) \
+    _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm_cmpneq_epi8_mask(A, B) \
+    _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_NE)
+#define _mm_mask_cmpneq_epi8_mask(k, A, B) \
+    _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm256_cmpeq_epi8_mask(A, B) \
+    _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm256_mask_cmpeq_epi8_mask(k, A, B) \
+    _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm256_cmpge_epi8_mask(A, B) \
+    _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_GE)
+#define _mm256_mask_cmpge_epi8_mask(k, A, B) \
+    _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm256_cmpgt_epi8_mask(A, B) \
+    _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_GT)
+#define _mm256_mask_cmpgt_epi8_mask(k, A, B) \
+    _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm256_cmple_epi8_mask(A, B) \
+    _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_LE)
+#define _mm256_mask_cmple_epi8_mask(k, A, B) \
+    _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm256_cmplt_epi8_mask(A, B) \
+    _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_LT)
+#define _mm256_mask_cmplt_epi8_mask(k, A, B) \
+    _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm256_cmpneq_epi8_mask(A, B) \
+    _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_NE)
+#define _mm256_mask_cmpneq_epi8_mask(k, A, B) \
+    _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm_cmpeq_epu8_mask(A, B) \
+    _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm_mask_cmpeq_epu8_mask(k, A, B) \
+    _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm_cmpge_epu8_mask(A, B) \
+    _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_GE)
+#define _mm_mask_cmpge_epu8_mask(k, A, B) \
+    _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm_cmpgt_epu8_mask(A, B) \
+    _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_GT)
+#define _mm_mask_cmpgt_epu8_mask(k, A, B) \
+    _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm_cmple_epu8_mask(A, B) \
+    _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_LE)
+#define _mm_mask_cmple_epu8_mask(k, A, B) \
+    _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm_cmplt_epu8_mask(A, B) \
+    _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_LT)
+#define _mm_mask_cmplt_epu8_mask(k, A, B) \
+    _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm_cmpneq_epu8_mask(A, B) \
+    _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_NE)
+#define _mm_mask_cmpneq_epu8_mask(k, A, B) \
+    _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm256_cmpeq_epu8_mask(A, B) \
+    _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm256_mask_cmpeq_epu8_mask(k, A, B) \
+    _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm256_cmpge_epu8_mask(A, B) \
+    _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_GE)
+#define _mm256_mask_cmpge_epu8_mask(k, A, B) \
+    _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm256_cmpgt_epu8_mask(A, B) \
+    _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_GT)
+#define _mm256_mask_cmpgt_epu8_mask(k, A, B) \
+    _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm256_cmple_epu8_mask(A, B) \
+    _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_LE)
+#define _mm256_mask_cmple_epu8_mask(k, A, B) \
+    _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm256_cmplt_epu8_mask(A, B) \
+    _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_LT)
+#define _mm256_mask_cmplt_epu8_mask(k, A, B) \
+    _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm256_cmpneq_epu8_mask(A, B) \
+    _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_NE)
+#define _mm256_mask_cmpneq_epu8_mask(k, A, B) \
+    _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm_cmpeq_epi16_mask(A, B) \
+    _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm_mask_cmpeq_epi16_mask(k, A, B) \
+    _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm_cmpge_epi16_mask(A, B) \
+    _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_GE)
+#define _mm_mask_cmpge_epi16_mask(k, A, B) \
+    _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm_cmpgt_epi16_mask(A, B) \
+    _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_GT)
+#define _mm_mask_cmpgt_epi16_mask(k, A, B) \
+    _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm_cmple_epi16_mask(A, B) \
+    _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_LE)
+#define _mm_mask_cmple_epi16_mask(k, A, B) \
+    _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm_cmplt_epi16_mask(A, B) \
+    _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_LT)
+#define _mm_mask_cmplt_epi16_mask(k, A, B) \
+    _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm_cmpneq_epi16_mask(A, B) \
+    _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_NE)
+#define _mm_mask_cmpneq_epi16_mask(k, A, B) \
+    _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm256_cmpeq_epi16_mask(A, B) \
+    _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm256_mask_cmpeq_epi16_mask(k, A, B) \
+    _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm256_cmpge_epi16_mask(A, B) \
+    _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_GE)
+#define _mm256_mask_cmpge_epi16_mask(k, A, B) \
+    _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm256_cmpgt_epi16_mask(A, B) \
+    _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_GT)
+#define _mm256_mask_cmpgt_epi16_mask(k, A, B) \
+    _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm256_cmple_epi16_mask(A, B) \
+    _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_LE)
+#define _mm256_mask_cmple_epi16_mask(k, A, B) \
+    _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm256_cmplt_epi16_mask(A, B) \
+    _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_LT)
+#define _mm256_mask_cmplt_epi16_mask(k, A, B) \
+    _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm256_cmpneq_epi16_mask(A, B) \
+    _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_NE)
+#define _mm256_mask_cmpneq_epi16_mask(k, A, B) \
+    _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm_cmpeq_epu16_mask(A, B) \
+    _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm_mask_cmpeq_epu16_mask(k, A, B) \
+    _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm_cmpge_epu16_mask(A, B) \
+    _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_GE)
+#define _mm_mask_cmpge_epu16_mask(k, A, B) \
+    _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm_cmpgt_epu16_mask(A, B) \
+    _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_GT)
+#define _mm_mask_cmpgt_epu16_mask(k, A, B) \
+    _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm_cmple_epu16_mask(A, B) \
+    _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_LE)
+#define _mm_mask_cmple_epu16_mask(k, A, B) \
+    _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm_cmplt_epu16_mask(A, B) \
+    _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_LT)
+#define _mm_mask_cmplt_epu16_mask(k, A, B) \
+    _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm_cmpneq_epu16_mask(A, B) \
+    _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_NE)
+#define _mm_mask_cmpneq_epu16_mask(k, A, B) \
+    _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm256_cmpeq_epu16_mask(A, B) \
+    _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm256_mask_cmpeq_epu16_mask(k, A, B) \
+    _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm256_cmpge_epu16_mask(A, B) \
+    _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_GE)
+#define _mm256_mask_cmpge_epu16_mask(k, A, B) \
+    _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm256_cmpgt_epu16_mask(A, B) \
+    _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_GT)
+#define _mm256_mask_cmpgt_epu16_mask(k, A, B) \
+    _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm256_cmple_epu16_mask(A, B) \
+    _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_LE)
+#define _mm256_mask_cmple_epu16_mask(k, A, B) \
+    _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm256_cmplt_epu16_mask(A, B) \
+    _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_LT)
+#define _mm256_mask_cmplt_epu16_mask(k, A, B) \
+    _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm256_cmpneq_epu16_mask(A, B) \
+    _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_NE)
+#define _mm256_mask_cmpneq_epu16_mask(k, A, B) \
+    _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_NE)
 
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_mask_add_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B){
 _mm256_mask_add_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B){
@@ -2146,86 +1850,6 @@ _mm256_maskz_cvtepu8_epi16 (__mmask16 __U, __m128i __A)
 }
 }
 
 
 
 
-#define _mm_cmp_epi8_mask(a, b, p) __extension__ ({ \
-  (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)(__m128i)(a), \
-                                         (__v16qi)(__m128i)(b), (int)(p), \
-                                         (__mmask16)-1); })
-
-#define _mm_mask_cmp_epi8_mask(m, a, b, p) __extension__ ({ \
-  (__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)(__m128i)(a), \
-                                         (__v16qi)(__m128i)(b), (int)(p), \
-                                         (__mmask16)(m)); })
-
-#define _mm_cmp_epu8_mask(a, b, p) __extension__ ({ \
-  (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)(__m128i)(a), \
-                                          (__v16qi)(__m128i)(b), (int)(p), \
-                                          (__mmask16)-1); })
-
-#define _mm_mask_cmp_epu8_mask(m, a, b, p) __extension__ ({ \
-  (__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)(__m128i)(a), \
-                                          (__v16qi)(__m128i)(b), (int)(p), \
-                                          (__mmask16)(m)); })
-
-#define _mm256_cmp_epi8_mask(a, b, p) __extension__ ({ \
-  (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)(__m256i)(a), \
-                                         (__v32qi)(__m256i)(b), (int)(p), \
-                                         (__mmask32)-1); })
-
-#define _mm256_mask_cmp_epi8_mask(m, a, b, p) __extension__ ({ \
-  (__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)(__m256i)(a), \
-                                         (__v32qi)(__m256i)(b), (int)(p), \
-                                         (__mmask32)(m)); })
-
-#define _mm256_cmp_epu8_mask(a, b, p) __extension__ ({ \
-  (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)(__m256i)(a), \
-                                          (__v32qi)(__m256i)(b), (int)(p), \
-                                          (__mmask32)-1); })
-
-#define _mm256_mask_cmp_epu8_mask(m, a, b, p) __extension__ ({ \
-  (__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)(__m256i)(a), \
-                                          (__v32qi)(__m256i)(b), (int)(p), \
-                                          (__mmask32)(m)); })
-
-#define _mm_cmp_epi16_mask(a, b, p) __extension__ ({ \
-  (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)(__m128i)(a), \
-                                        (__v8hi)(__m128i)(b), (int)(p), \
-                                        (__mmask8)-1); })
-
-#define _mm_mask_cmp_epi16_mask(m, a, b, p) __extension__ ({ \
-  (__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)(__m128i)(a), \
-                                        (__v8hi)(__m128i)(b), (int)(p), \
-                                        (__mmask8)(m)); })
-
-#define _mm_cmp_epu16_mask(a, b, p) __extension__ ({ \
-  (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)(__m128i)(a), \
-                                         (__v8hi)(__m128i)(b), (int)(p), \
-                                         (__mmask8)-1); })
-
-#define _mm_mask_cmp_epu16_mask(m, a, b, p) __extension__ ({ \
-  (__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)(__m128i)(a), \
-                                         (__v8hi)(__m128i)(b), (int)(p), \
-                                         (__mmask8)(m)); })
-
-#define _mm256_cmp_epi16_mask(a, b, p) __extension__ ({ \
-  (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)(__m256i)(a), \
-                                         (__v16hi)(__m256i)(b), (int)(p), \
-                                         (__mmask16)-1); })
-
-#define _mm256_mask_cmp_epi16_mask(m, a, b, p) __extension__ ({ \
-  (__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)(__m256i)(a), \
-                                         (__v16hi)(__m256i)(b), (int)(p), \
-                                         (__mmask16)(m)); })
-
-#define _mm256_cmp_epu16_mask(a, b, p) __extension__ ({ \
-  (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)(__m256i)(a), \
-                                          (__v16hi)(__m256i)(b), (int)(p), \
-                                          (__mmask16)-1); })
-
-#define _mm256_mask_cmp_epu16_mask(m, a, b, p) __extension__ ({ \
-  (__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)(__m256i)(a), \
-                                          (__v16hi)(__m256i)(b), (int)(p), \
-                                          (__mmask16)(m)); })
-
 #define _mm_mask_shufflehi_epi16(W, U, A, imm) __extension__ ({ \
 #define _mm_mask_shufflehi_epi16(W, U, A, imm) __extension__ ({ \
   (__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \
   (__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \
                                       (__v8hi)_mm_shufflehi_epi16((A), (imm)), \
                                       (__v8hi)_mm_shufflehi_epi16((A), (imm)), \

+ 5 - 5
lib/Headers/avx512vlcdintrin.h

@@ -33,26 +33,26 @@
 
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_broadcastmb_epi64 (__mmask8 __A)
 _mm_broadcastmb_epi64 (__mmask8 __A)
-{
-  return (__m128i) __builtin_ia32_broadcastmb128 (__A);
+{ 
+  return (__m128i) _mm_set1_epi64x((long long) __A);
 }
 }
 
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_broadcastmb_epi64 (__mmask8 __A)
 _mm256_broadcastmb_epi64 (__mmask8 __A)
 {
 {
-  return (__m256i) __builtin_ia32_broadcastmb256 (__A);
+  return (__m256i) _mm256_set1_epi64x((long long)__A);
 }
 }
 
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_broadcastmw_epi32 (__mmask16 __A)
 _mm_broadcastmw_epi32 (__mmask16 __A)
 {
 {
-  return (__m128i) __builtin_ia32_broadcastmw128 (__A);
+  return (__m128i) _mm_set1_epi32((int)__A);
 }
 }
 
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_broadcastmw_epi32 (__mmask16 __A)
 _mm256_broadcastmw_epi32 (__mmask16 __A)
 {
 {
-  return (__m256i) __builtin_ia32_broadcastmw256 (__A);
+  return (__m256i) _mm256_set1_epi32((int)__A);
 }
 }
 
 
 
 

+ 199 - 576
lib/Headers/avx512vlintrin.h

@@ -38,582 +38,205 @@ _mm_setzero_di(void) {
 
 
 /* Integer compare */
 /* Integer compare */
 
 
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpeq_epi32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqd128_mask((__v4si)__a, (__v4si)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpeq_epi32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqd128_mask((__v4si)__a, (__v4si)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpeq_epu32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 0,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpeq_epu32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 0,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpeq_epi32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqd256_mask((__v8si)__a, (__v8si)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpeq_epi32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqd256_mask((__v8si)__a, (__v8si)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpeq_epu32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 0,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpeq_epu32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 0,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpeq_epi64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqq128_mask((__v2di)__a, (__v2di)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpeq_epi64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqq128_mask((__v2di)__a, (__v2di)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpeq_epu64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 0,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpeq_epu64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 0,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpeq_epi64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqq256_mask((__v4di)__a, (__v4di)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpeq_epi64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_pcmpeqq256_mask((__v4di)__a, (__v4di)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpeq_epu64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 0,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpeq_epu64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 0,
-                                                __u);
-}
-
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpge_epi32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpd128_mask((__v4si)__a, (__v4si)__b, 5,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpge_epi32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpd128_mask((__v4si)__a, (__v4si)__b, 5,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpge_epu32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 5,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpge_epu32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpge_epi32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpd256_mask((__v8si)__a, (__v8si)__b, 5,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpge_epi32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpd256_mask((__v8si)__a, (__v8si)__b, 5,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpge_epu32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 5,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpge_epu32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpge_epi64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpq128_mask((__v2di)__a, (__v2di)__b, 5,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpge_epi64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpq128_mask((__v2di)__a, (__v2di)__b, 5,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpge_epu64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 5,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpge_epu64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpge_epi64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpq256_mask((__v4di)__a, (__v4di)__b, 5,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpge_epi64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpq256_mask((__v4di)__a, (__v4di)__b, 5,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpge_epu64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 5,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpge_epu64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 5,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpgt_epi32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtd128_mask((__v4si)__a, (__v4si)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpgt_epi32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtd128_mask((__v4si)__a, (__v4si)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpgt_epu32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 6,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpgt_epu32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 6,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpgt_epi32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtd256_mask((__v8si)__a, (__v8si)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpgt_epi32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtd256_mask((__v8si)__a, (__v8si)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpgt_epu32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 6,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpgt_epu32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 6,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpgt_epi64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtq128_mask((__v2di)__a, (__v2di)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpgt_epi64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtq128_mask((__v2di)__a, (__v2di)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpgt_epu64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 6,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpgt_epu64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 6,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpgt_epi64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtq256_mask((__v4di)__a, (__v4di)__b,
-                                                  (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpgt_epi64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_pcmpgtq256_mask((__v4di)__a, (__v4di)__b,
-                                                  __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpgt_epu64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 6,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpgt_epu64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 6,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmple_epi32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpd128_mask((__v4si)__a, (__v4si)__b, 2,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmple_epi32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpd128_mask((__v4si)__a, (__v4si)__b, 2,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmple_epu32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 2,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmple_epu32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmple_epi32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpd256_mask((__v8si)__a, (__v8si)__b, 2,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmple_epi32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpd256_mask((__v8si)__a, (__v8si)__b, 2,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmple_epu32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 2,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmple_epu32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmple_epi64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpq128_mask((__v2di)__a, (__v2di)__b, 2,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmple_epi64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpq128_mask((__v2di)__a, (__v2di)__b, 2,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmple_epu64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 2,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmple_epu64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmple_epi64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpq256_mask((__v4di)__a, (__v4di)__b, 2,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmple_epi64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpq256_mask((__v4di)__a, (__v4di)__b, 2,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmple_epu64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 2,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmple_epu64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 2,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmplt_epi32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpd128_mask((__v4si)__a, (__v4si)__b, 1,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmplt_epi32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpd128_mask((__v4si)__a, (__v4si)__b, 1,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmplt_epu32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 1,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmplt_epu32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmplt_epi32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpd256_mask((__v8si)__a, (__v8si)__b, 1,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmplt_epi32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpd256_mask((__v8si)__a, (__v8si)__b, 1,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmplt_epu32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 1,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmplt_epu32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmplt_epi64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpq128_mask((__v2di)__a, (__v2di)__b, 1,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmplt_epi64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpq128_mask((__v2di)__a, (__v2di)__b, 1,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmplt_epu64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 1,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmplt_epu64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmplt_epi64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpq256_mask((__v4di)__a, (__v4di)__b, 1,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmplt_epi64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpq256_mask((__v4di)__a, (__v4di)__b, 1,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmplt_epu64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 1,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmplt_epu64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 1,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpneq_epi32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpd128_mask((__v4si)__a, (__v4si)__b, 4,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpneq_epi32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpd128_mask((__v4si)__a, (__v4si)__b, 4,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpneq_epu32_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 4,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpneq_epu32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)__a, (__v4si)__b, 4,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpneq_epi32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpd256_mask((__v8si)__a, (__v8si)__b, 4,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpneq_epi32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpd256_mask((__v8si)__a, (__v8si)__b, 4,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpneq_epu32_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 4,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpneq_epu32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)__a, (__v8si)__b, 4,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpneq_epi64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpq128_mask((__v2di)__a, (__v2di)__b, 4,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpneq_epi64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_cmpq128_mask((__v2di)__a, (__v2di)__b, 4,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_cmpneq_epu64_mask(__m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 4,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm_mask_cmpneq_epu64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)__a, (__v2di)__b, 4,
-                                                __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpneq_epi64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpq256_mask((__v4di)__a, (__v4di)__b, 4,
-                                               (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpneq_epi64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_cmpq256_mask((__v4di)__a, (__v4di)__b, 4,
-                                               __u);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_cmpneq_epu64_mask(__m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 4,
-                                                (__mmask8)-1);
-}
-
-static __inline__ __mmask8 __DEFAULT_FN_ATTRS
-_mm256_mask_cmpneq_epu64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
-  return (__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)__a, (__v4di)__b, 4,
-                                                __u);
-}
+#define _mm_cmpeq_epi32_mask(A, B) \
+    _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm_mask_cmpeq_epi32_mask(k, A, B) \
+    _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm_cmpge_epi32_mask(A, B) \
+    _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_GE)
+#define _mm_mask_cmpge_epi32_mask(k, A, B) \
+    _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm_cmpgt_epi32_mask(A, B) \
+    _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_GT)
+#define _mm_mask_cmpgt_epi32_mask(k, A, B) \
+    _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm_cmple_epi32_mask(A, B) \
+    _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_LE)
+#define _mm_mask_cmple_epi32_mask(k, A, B) \
+    _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm_cmplt_epi32_mask(A, B) \
+    _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_LT)
+#define _mm_mask_cmplt_epi32_mask(k, A, B) \
+    _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm_cmpneq_epi32_mask(A, B) \
+    _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_NE)
+#define _mm_mask_cmpneq_epi32_mask(k, A, B) \
+    _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm256_cmpeq_epi32_mask(A, B) \
+    _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm256_mask_cmpeq_epi32_mask(k, A, B) \
+    _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm256_cmpge_epi32_mask(A, B) \
+    _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_GE)
+#define _mm256_mask_cmpge_epi32_mask(k, A, B) \
+    _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm256_cmpgt_epi32_mask(A, B) \
+    _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_GT)
+#define _mm256_mask_cmpgt_epi32_mask(k, A, B) \
+    _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm256_cmple_epi32_mask(A, B) \
+    _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_LE)
+#define _mm256_mask_cmple_epi32_mask(k, A, B) \
+    _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm256_cmplt_epi32_mask(A, B) \
+    _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_LT)
+#define _mm256_mask_cmplt_epi32_mask(k, A, B) \
+    _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm256_cmpneq_epi32_mask(A, B) \
+    _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_NE)
+#define _mm256_mask_cmpneq_epi32_mask(k, A, B) \
+    _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm_cmpeq_epu32_mask(A, B) \
+    _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm_mask_cmpeq_epu32_mask(k, A, B) \
+    _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm_cmpge_epu32_mask(A, B) \
+    _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_GE)
+#define _mm_mask_cmpge_epu32_mask(k, A, B) \
+    _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm_cmpgt_epu32_mask(A, B) \
+    _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_GT)
+#define _mm_mask_cmpgt_epu32_mask(k, A, B) \
+    _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm_cmple_epu32_mask(A, B) \
+    _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_LE)
+#define _mm_mask_cmple_epu32_mask(k, A, B) \
+    _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm_cmplt_epu32_mask(A, B) \
+    _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_LT)
+#define _mm_mask_cmplt_epu32_mask(k, A, B) \
+    _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm_cmpneq_epu32_mask(A, B) \
+    _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_NE)
+#define _mm_mask_cmpneq_epu32_mask(k, A, B) \
+    _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm256_cmpeq_epu32_mask(A, B) \
+    _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm256_mask_cmpeq_epu32_mask(k, A, B) \
+    _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm256_cmpge_epu32_mask(A, B) \
+    _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_GE)
+#define _mm256_mask_cmpge_epu32_mask(k, A, B) \
+    _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm256_cmpgt_epu32_mask(A, B) \
+    _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_GT)
+#define _mm256_mask_cmpgt_epu32_mask(k, A, B) \
+    _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm256_cmple_epu32_mask(A, B) \
+    _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_LE)
+#define _mm256_mask_cmple_epu32_mask(k, A, B) \
+    _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm256_cmplt_epu32_mask(A, B) \
+    _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_LT)
+#define _mm256_mask_cmplt_epu32_mask(k, A, B) \
+    _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm256_cmpneq_epu32_mask(A, B) \
+    _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_NE)
+#define _mm256_mask_cmpneq_epu32_mask(k, A, B) \
+    _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm_cmpeq_epi64_mask(A, B) \
+    _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm_mask_cmpeq_epi64_mask(k, A, B) \
+    _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm_cmpge_epi64_mask(A, B) \
+    _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_GE)
+#define _mm_mask_cmpge_epi64_mask(k, A, B) \
+    _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm_cmpgt_epi64_mask(A, B) \
+    _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_GT)
+#define _mm_mask_cmpgt_epi64_mask(k, A, B) \
+    _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm_cmple_epi64_mask(A, B) \
+    _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_LE)
+#define _mm_mask_cmple_epi64_mask(k, A, B) \
+    _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm_cmplt_epi64_mask(A, B) \
+    _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_LT)
+#define _mm_mask_cmplt_epi64_mask(k, A, B) \
+    _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm_cmpneq_epi64_mask(A, B) \
+    _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_NE)
+#define _mm_mask_cmpneq_epi64_mask(k, A, B) \
+    _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm256_cmpeq_epi64_mask(A, B) \
+    _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm256_mask_cmpeq_epi64_mask(k, A, B) \
+    _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm256_cmpge_epi64_mask(A, B) \
+    _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_GE)
+#define _mm256_mask_cmpge_epi64_mask(k, A, B) \
+    _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm256_cmpgt_epi64_mask(A, B) \
+    _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_GT)
+#define _mm256_mask_cmpgt_epi64_mask(k, A, B) \
+    _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm256_cmple_epi64_mask(A, B) \
+    _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_LE)
+#define _mm256_mask_cmple_epi64_mask(k, A, B) \
+    _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm256_cmplt_epi64_mask(A, B) \
+    _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_LT)
+#define _mm256_mask_cmplt_epi64_mask(k, A, B) \
+    _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm256_cmpneq_epi64_mask(A, B) \
+    _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_NE)
+#define _mm256_mask_cmpneq_epi64_mask(k, A, B) \
+    _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm_cmpeq_epu64_mask(A, B) \
+    _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm_mask_cmpeq_epu64_mask(k, A, B) \
+    _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm_cmpge_epu64_mask(A, B) \
+    _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_GE)
+#define _mm_mask_cmpge_epu64_mask(k, A, B) \
+    _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm_cmpgt_epu64_mask(A, B) \
+    _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_GT)
+#define _mm_mask_cmpgt_epu64_mask(k, A, B) \
+    _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm_cmple_epu64_mask(A, B) \
+    _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_LE)
+#define _mm_mask_cmple_epu64_mask(k, A, B) \
+    _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm_cmplt_epu64_mask(A, B) \
+    _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_LT)
+#define _mm_mask_cmplt_epu64_mask(k, A, B) \
+    _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm_cmpneq_epu64_mask(A, B) \
+    _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_NE)
+#define _mm_mask_cmpneq_epu64_mask(k, A, B) \
+    _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_NE)
+
+#define _mm256_cmpeq_epu64_mask(A, B) \
+    _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_EQ)
+#define _mm256_mask_cmpeq_epu64_mask(k, A, B) \
+    _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_EQ)
+#define _mm256_cmpge_epu64_mask(A, B) \
+    _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_GE)
+#define _mm256_mask_cmpge_epu64_mask(k, A, B) \
+    _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GE)
+#define _mm256_cmpgt_epu64_mask(A, B) \
+    _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_GT)
+#define _mm256_mask_cmpgt_epu64_mask(k, A, B) \
+    _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GT)
+#define _mm256_cmple_epu64_mask(A, B) \
+    _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_LE)
+#define _mm256_mask_cmple_epu64_mask(k, A, B) \
+    _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LE)
+#define _mm256_cmplt_epu64_mask(A, B) \
+    _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_LT)
+#define _mm256_mask_cmplt_epu64_mask(k, A, B) \
+    _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LT)
+#define _mm256_cmpneq_epu64_mask(A, B) \
+    _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_NE)
+#define _mm256_mask_cmpneq_epu64_mask(k, A, B) \
+    _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_NE)
 
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_mask_add_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B)
 _mm256_mask_add_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B)

+ 11 - 0
lib/Index/IndexBody.cpp

@@ -427,6 +427,17 @@ public:
 
 
     return true;
     return true;
   }
   }
+
+  bool VisitOffsetOfExpr(OffsetOfExpr *S) {
+    for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) {
+      const OffsetOfNode &Component = S->getComponent(I);
+      if (Component.getKind() == OffsetOfNode::Field)
+        IndexCtx.handleReference(Component.getField(), Component.getLocEnd(),
+                                 Parent, ParentDC, SymbolRoleSet(), {});
+      // FIXME: Try to resolve dependent field references.
+    }
+    return true;
+  }
 };
 };
 
 
 } // anonymous namespace
 } // anonymous namespace

+ 20 - 16
lib/Lex/Lexer.cpp

@@ -1212,18 +1212,12 @@ const char *Lexer::SkipEscapedNewLines(const char *P) {
   }
   }
 }
 }
 
 
-/// \brief Checks that the given token is the first token that occurs after the
-/// given location (this excludes comments and whitespace). Returns the location
-/// immediately after the specified token. If the token is not found or the
-/// location is inside a macro, the returned source location will be invalid.
-SourceLocation Lexer::findLocationAfterToken(SourceLocation Loc,
-                                        tok::TokenKind TKind,
-                                        const SourceManager &SM,
-                                        const LangOptions &LangOpts,
-                                        bool SkipTrailingWhitespaceAndNewLine) {
+Optional<Token> Lexer::findNextToken(SourceLocation Loc,
+                                     const SourceManager &SM,
+                                     const LangOptions &LangOpts) {
   if (Loc.isMacroID()) {
   if (Loc.isMacroID()) {
     if (!Lexer::isAtEndOfMacroExpansion(Loc, SM, LangOpts, &Loc))
     if (!Lexer::isAtEndOfMacroExpansion(Loc, SM, LangOpts, &Loc))
-      return SourceLocation();
+      return None;
   }
   }
   Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts);
   Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts);
 
 
@@ -1234,7 +1228,7 @@ SourceLocation Lexer::findLocationAfterToken(SourceLocation Loc,
   bool InvalidTemp = false;
   bool InvalidTemp = false;
   StringRef File = SM.getBufferData(LocInfo.first, &InvalidTemp);
   StringRef File = SM.getBufferData(LocInfo.first, &InvalidTemp);
   if (InvalidTemp)
   if (InvalidTemp)
-    return SourceLocation();
+    return None;
 
 
   const char *TokenBegin = File.data() + LocInfo.second;
   const char *TokenBegin = File.data() + LocInfo.second;
 
 
@@ -1244,15 +1238,25 @@ SourceLocation Lexer::findLocationAfterToken(SourceLocation Loc,
   // Find the token.
   // Find the token.
   Token Tok;
   Token Tok;
   lexer.LexFromRawLexer(Tok);
   lexer.LexFromRawLexer(Tok);
-  if (Tok.isNot(TKind))
+  return Tok;
+}
+
+/// \brief Checks that the given token is the first token that occurs after the
+/// given location (this excludes comments and whitespace). Returns the location
+/// immediately after the specified token. If the token is not found or the
+/// location is inside a macro, the returned source location will be invalid.
+SourceLocation Lexer::findLocationAfterToken(
+    SourceLocation Loc, tok::TokenKind TKind, const SourceManager &SM,
+    const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine) {
+  Optional<Token> Tok = findNextToken(Loc, SM, LangOpts);
+  if (!Tok || Tok->isNot(TKind))
     return SourceLocation();
     return SourceLocation();
-  SourceLocation TokenLoc = Tok.getLocation();
+  SourceLocation TokenLoc = Tok->getLocation();
 
 
   // Calculate how much whitespace needs to be skipped if any.
   // Calculate how much whitespace needs to be skipped if any.
   unsigned NumWhitespaceChars = 0;
   unsigned NumWhitespaceChars = 0;
   if (SkipTrailingWhitespaceAndNewLine) {
   if (SkipTrailingWhitespaceAndNewLine) {
-    const char *TokenEnd = SM.getCharacterData(TokenLoc) +
-                           Tok.getLength();
+    const char *TokenEnd = SM.getCharacterData(TokenLoc) + Tok->getLength();
     unsigned char C = *TokenEnd;
     unsigned char C = *TokenEnd;
     while (isHorizontalWhitespace(C)) {
     while (isHorizontalWhitespace(C)) {
       C = *(++TokenEnd);
       C = *(++TokenEnd);
@@ -1269,7 +1273,7 @@ SourceLocation Lexer::findLocationAfterToken(SourceLocation Loc,
     }
     }
   }
   }
 
 
-  return TokenLoc.getLocWithOffset(Tok.getLength() + NumWhitespaceChars);
+  return TokenLoc.getLocWithOffset(Tok->getLength() + NumWhitespaceChars);
 }
 }
 
 
 /// getCharAndSizeSlow - Peek a single 'character' from the specified buffer,
 /// getCharAndSizeSlow - Peek a single 'character' from the specified buffer,

+ 20 - 11
lib/Lex/PPDirectives.cpp

@@ -350,7 +350,7 @@ void Preprocessor::CheckEndOfDirective(const char *DirType, bool EnableMacros) {
 /// If ElseOk is true, then \#else directives are ok, if not, then we have
 /// If ElseOk is true, then \#else directives are ok, if not, then we have
 /// already seen one so a \#else directive is a duplicate.  When this returns,
 /// already seen one so a \#else directive is a duplicate.  When this returns,
 /// the caller can lex the first valid token.
 /// the caller can lex the first valid token.
-void Preprocessor::SkipExcludedConditionalBlock(const Token &HashToken,
+void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
                                                 SourceLocation IfTokenLoc,
                                                 SourceLocation IfTokenLoc,
                                                 bool FoundNonSkipPortion,
                                                 bool FoundNonSkipPortion,
                                                 bool FoundElse,
                                                 bool FoundElse,
@@ -358,8 +358,11 @@ void Preprocessor::SkipExcludedConditionalBlock(const Token &HashToken,
   ++NumSkipped;
   ++NumSkipped;
   assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
   assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
 
 
-  CurPPLexer->pushConditionalLevel(IfTokenLoc, /*isSkipping*/false,
-                                 FoundNonSkipPortion, FoundElse);
+  if (PreambleConditionalStack.reachedEOFWhileSkipping())
+    PreambleConditionalStack.clearSkipInfo();
+  else
+    CurPPLexer->pushConditionalLevel(IfTokenLoc, /*isSkipping*/ false,
+                                     FoundNonSkipPortion, FoundElse);
 
 
   if (CurPTHLexer) {
   if (CurPTHLexer) {
     PTHSkipExcludedConditionalBlock();
     PTHSkipExcludedConditionalBlock();
@@ -385,6 +388,9 @@ void Preprocessor::SkipExcludedConditionalBlock(const Token &HashToken,
       // We don't emit errors for unterminated conditionals here,
       // We don't emit errors for unterminated conditionals here,
       // Lexer::LexEndOfFile can do that propertly.
       // Lexer::LexEndOfFile can do that propertly.
       // Just return and let the caller lex after this #include.
       // Just return and let the caller lex after this #include.
+      if (PreambleConditionalStack.isRecording())
+        PreambleConditionalStack.SkipInfo.emplace(
+            HashTokenLoc, IfTokenLoc, FoundNonSkipPortion, FoundElse, ElseLoc);
       break;
       break;
     }
     }
 
 
@@ -554,7 +560,7 @@ void Preprocessor::SkipExcludedConditionalBlock(const Token &HashToken,
 
 
   if (Callbacks)
   if (Callbacks)
     Callbacks->SourceRangeSkipped(
     Callbacks->SourceRangeSkipped(
-        SourceRange(HashToken.getLocation(), CurPPLexer->getSourceLocation()),
+        SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()),
         Tok.getLocation());
         Tok.getLocation());
 }
 }
 
 
@@ -2676,7 +2682,8 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
   if (MacroNameTok.is(tok::eod)) {
   if (MacroNameTok.is(tok::eod)) {
     // Skip code until we get to #endif.  This helps with recovery by not
     // Skip code until we get to #endif.  This helps with recovery by not
     // emitting an error when the #endif is reached.
     // emitting an error when the #endif is reached.
-    SkipExcludedConditionalBlock(HashToken, DirectiveTok.getLocation(),
+    SkipExcludedConditionalBlock(HashToken.getLocation(),
+                                 DirectiveTok.getLocation(),
                                  /*Foundnonskip*/ false, /*FoundElse*/ false);
                                  /*Foundnonskip*/ false, /*FoundElse*/ false);
     return;
     return;
   }
   }
@@ -2725,7 +2732,8 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
                                      /*foundelse*/false);
                                      /*foundelse*/false);
   } else {
   } else {
     // No, skip the contents of this block.
     // No, skip the contents of this block.
-    SkipExcludedConditionalBlock(HashToken, DirectiveTok.getLocation(),
+    SkipExcludedConditionalBlock(HashToken.getLocation(),
+                                 DirectiveTok.getLocation(),
                                  /*Foundnonskip*/ false,
                                  /*Foundnonskip*/ false,
                                  /*FoundElse*/ false);
                                  /*FoundElse*/ false);
   }
   }
@@ -2772,7 +2780,7 @@ void Preprocessor::HandleIfDirective(Token &IfToken,
                                    /*foundnonskip*/true, /*foundelse*/false);
                                    /*foundnonskip*/true, /*foundelse*/false);
   } else {
   } else {
     // No, skip the contents of this block.
     // No, skip the contents of this block.
-    SkipExcludedConditionalBlock(HashToken, IfToken.getLocation(),
+    SkipExcludedConditionalBlock(HashToken.getLocation(), IfToken.getLocation(),
                                  /*Foundnonskip*/ false,
                                  /*Foundnonskip*/ false,
                                  /*FoundElse*/ false);
                                  /*FoundElse*/ false);
   }
   }
@@ -2837,7 +2845,8 @@ void Preprocessor::HandleElseDirective(Token &Result, const Token &HashToken) {
   }
   }
 
 
   // Finally, skip the rest of the contents of this block.
   // Finally, skip the rest of the contents of this block.
-  SkipExcludedConditionalBlock(HashToken, CI.IfLoc, /*Foundnonskip*/ true,
+  SkipExcludedConditionalBlock(HashToken.getLocation(), CI.IfLoc,
+                               /*Foundnonskip*/ true,
                                /*FoundElse*/ true, Result.getLocation());
                                /*FoundElse*/ true, Result.getLocation());
 }
 }
 
 
@@ -2881,7 +2890,7 @@ void Preprocessor::HandleElifDirective(Token &ElifToken,
   }
   }
 
 
   // Finally, skip the rest of the contents of this block.
   // Finally, skip the rest of the contents of this block.
-  SkipExcludedConditionalBlock(HashToken, CI.IfLoc, /*Foundnonskip*/ true,
-                               /*FoundElse*/ CI.FoundElse,
-                               ElifToken.getLocation());
+  SkipExcludedConditionalBlock(
+      HashToken.getLocation(), CI.IfLoc, /*Foundnonskip*/ true,
+      /*FoundElse*/ CI.FoundElse, ElifToken.getLocation());
 }
 }

+ 1 - 0
lib/Lex/PPMacroExpansion.cpp

@@ -1138,6 +1138,7 @@ static bool HasFeature(const Preprocessor &PP, StringRef Feature) {
       .Case("dataflow_sanitizer", LangOpts.Sanitize.has(SanitizerKind::DataFlow))
       .Case("dataflow_sanitizer", LangOpts.Sanitize.has(SanitizerKind::DataFlow))
       .Case("efficiency_sanitizer",
       .Case("efficiency_sanitizer",
             LangOpts.Sanitize.hasOneOf(SanitizerKind::Efficiency))
             LangOpts.Sanitize.hasOneOf(SanitizerKind::Efficiency))
+      .Case("scudo", LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo))
       // Objective-C features
       // Objective-C features
       .Case("objc_arr", LangOpts.ObjCAutoRefCount) // FIXME: REMOVE?
       .Case("objc_arr", LangOpts.ObjCAutoRefCount) // FIXME: REMOVE?
       .Case("objc_arc", LangOpts.ObjCAutoRefCount)
       .Case("objc_arc", LangOpts.ObjCAutoRefCount)

+ 7 - 0
lib/Lex/Preprocessor.cpp

@@ -550,6 +550,13 @@ void Preprocessor::replayPreambleConditionalStack() {
            "CurPPLexer is null when calling replayPreambleConditionalStack.");
            "CurPPLexer is null when calling replayPreambleConditionalStack.");
     CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack());
     CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack());
     PreambleConditionalStack.doneReplaying();
     PreambleConditionalStack.doneReplaying();
+    if (PreambleConditionalStack.reachedEOFWhileSkipping())
+      SkipExcludedConditionalBlock(
+          PreambleConditionalStack.SkipInfo->HashTokenLoc,
+          PreambleConditionalStack.SkipInfo->IfTokenLoc,
+          PreambleConditionalStack.SkipInfo->FoundNonSkipPortion,
+          PreambleConditionalStack.SkipInfo->FoundElse,
+          PreambleConditionalStack.SkipInfo->ElseLoc);
   }
   }
 }
 }
 
 

+ 22 - 15
lib/Parse/ParseExprCXX.cpp

@@ -249,7 +249,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
 
 
       if (Tok.is(tok::code_completion)) {
       if (Tok.is(tok::code_completion)) {
         // Code completion for a nested-name-specifier, where the code
         // Code completion for a nested-name-specifier, where the code
-        // code completion token follows the '::'.
+        // completion token follows the '::'.
         Actions.CodeCompleteQualifiedId(getCurScope(), SS, EnteringContext);
         Actions.CodeCompleteQualifiedId(getCurScope(), SS, EnteringContext);
         // Include code completion token into the range of the scope otherwise
         // Include code completion token into the range of the scope otherwise
         // when we try to annotate the scope tokens the dangling code completion
         // when we try to annotate the scope tokens the dangling code completion
@@ -991,27 +991,34 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
 ///
 ///
 /// Returns true if it hit something unexpected.
 /// Returns true if it hit something unexpected.
 bool Parser::TryParseLambdaIntroducer(LambdaIntroducer &Intro) {
 bool Parser::TryParseLambdaIntroducer(LambdaIntroducer &Intro) {
-  TentativeParsingAction PA(*this);
+  {
+    bool SkippedInits = false;
+    TentativeParsingAction PA1(*this);
 
 
-  bool SkippedInits = false;
-  Optional<unsigned> DiagID(ParseLambdaIntroducer(Intro, &SkippedInits));
+    if (ParseLambdaIntroducer(Intro, &SkippedInits)) {
+      PA1.Revert();
+      return true;
+    }
 
 
-  if (DiagID) {
-    PA.Revert();
-    return true;
+    if (!SkippedInits) {
+      PA1.Commit();
+      return false;
+    }
+
+    PA1.Revert();
   }
   }
 
 
-  if (SkippedInits) {
-    // Parse it again, but this time parse the init-captures too.
-    PA.Revert();
-    Intro = LambdaIntroducer();
-    DiagID = ParseLambdaIntroducer(Intro);
-    assert(!DiagID && "parsing lambda-introducer failed on reparse");
+  // Try to parse it again, but this time parse the init-captures too.
+  Intro = LambdaIntroducer();
+  TentativeParsingAction PA2(*this);
+
+  if (!ParseLambdaIntroducer(Intro)) {
+    PA2.Commit();
     return false;
     return false;
   }
   }
 
 
-  PA.Commit();
-  return false;
+  PA2.Revert();
+  return true;
 }
 }
 
 
 static void
 static void

+ 3 - 0
lib/Sema/SemaChecking.cpp

@@ -2312,7 +2312,10 @@ bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
     i = 1; l = -128; u = 255;
     i = 1; l = -128; u = 255;
     break;
     break;
   case X86::BI__builtin_ia32_vcvtps2ph:
   case X86::BI__builtin_ia32_vcvtps2ph:
+  case X86::BI__builtin_ia32_vcvtps2ph_mask:
   case X86::BI__builtin_ia32_vcvtps2ph256:
   case X86::BI__builtin_ia32_vcvtps2ph256:
+  case X86::BI__builtin_ia32_vcvtps2ph256_mask:
+  case X86::BI__builtin_ia32_vcvtps2ph512_mask:
   case X86::BI__builtin_ia32_rndscaleps_128_mask:
   case X86::BI__builtin_ia32_rndscaleps_128_mask:
   case X86::BI__builtin_ia32_rndscalepd_128_mask:
   case X86::BI__builtin_ia32_rndscalepd_128_mask:
   case X86::BI__builtin_ia32_rndscaleps_256_mask:
   case X86::BI__builtin_ia32_rndscaleps_256_mask:

+ 5 - 2
lib/Sema/SemaCodeComplete.cpp

@@ -14,6 +14,7 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprObjC.h"
+#include "clang/AST/QualTypeNames.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/MacroInfo.h"
@@ -1495,6 +1496,7 @@ static PrintingPolicy getCompletionPrintingPolicy(const ASTContext &Context,
   Policy.AnonymousTagLocations = false;
   Policy.AnonymousTagLocations = false;
   Policy.SuppressStrongLifetime = true;
   Policy.SuppressStrongLifetime = true;
   Policy.SuppressUnwrittenScope = true;
   Policy.SuppressUnwrittenScope = true;
+  Policy.SuppressScope = true;
   return Policy;
   return Policy;
 }
 }
 
 
@@ -2139,9 +2141,10 @@ static void AddResultTypeChunk(ASTContext &Context,
       T = Method->getSendResultType(BaseType);
       T = Method->getSendResultType(BaseType);
     else
     else
       T = Method->getReturnType();
       T = Method->getReturnType();
-  } else if (const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
+  } else if (const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
     T = Context.getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
     T = Context.getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
-  else if (isa<UnresolvedUsingValueDecl>(ND)) {
+    T = clang::TypeName::getFullyQualifiedType(T, Context);
+  } else if (isa<UnresolvedUsingValueDecl>(ND)) {
     /* Do nothing: ignore unresolved using declarations*/
     /* Do nothing: ignore unresolved using declarations*/
   } else if (const ObjCIvarDecl *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
   } else if (const ObjCIvarDecl *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
     if (!BaseType.isNull())
     if (!BaseType.isNull())

+ 7 - 0
lib/Sema/SemaDecl.cpp

@@ -9673,6 +9673,13 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) {
   assert(T->isFunctionType() && "function decl is not of function type");
   assert(T->isFunctionType() && "function decl is not of function type");
   const FunctionType* FT = T->castAs<FunctionType>();
   const FunctionType* FT = T->castAs<FunctionType>();
 
 
+  // Set default calling convention for main()
+  if (FT->getCallConv() != CC_C) {
+    FT = Context.adjustFunctionType(FT, FT->getExtInfo().withCallingConv(CC_C));
+    FD->setType(QualType(FT, 0));
+    T = Context.getCanonicalType(FD->getType());
+  }
+
   if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) {
   if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) {
     // In C with GNU extensions we allow main() to have non-integer return
     // In C with GNU extensions we allow main() to have non-integer return
     // type, but we should warn about the extension, and we disable the
     // type, but we should warn about the extension, and we disable the

+ 4 - 0
lib/Sema/SemaInit.cpp

@@ -6422,6 +6422,10 @@ static void CheckMoveOnConstruction(Sema &S, const Expr *InitExpr,
     if (!VD || !VD->hasLocalStorage())
     if (!VD || !VD->hasLocalStorage())
       return;
       return;
 
 
+    // __block variables are not moved implicitly.
+    if (VD->hasAttr<BlocksAttr>())
+      return;
+
     QualType SourceType = VD->getType();
     QualType SourceType = VD->getType();
     if (!SourceType->isRecordType())
     if (!SourceType->isRecordType())
       return;
       return;

+ 1 - 1
lib/Sema/SemaOpenMP.cpp

@@ -9711,7 +9711,7 @@ static bool ActOnOMPReductionKindClause(
     }
     }
 
 
     if ((OASE && !ConstantLengthOASE) ||
     if ((OASE && !ConstantLengthOASE) ||
-        (!ASE &&
+        (!OASE && !ASE &&
          D->getType().getNonReferenceType()->isVariablyModifiedType())) {
          D->getType().getNonReferenceType()->isVariablyModifiedType())) {
       // For arrays/array sections only:
       // For arrays/array sections only:
       // Create pseudo array type for private copy. The size for this array will
       // Create pseudo array type for private copy. The size for this array will

+ 1 - 2
lib/Sema/SemaPseudoObject.cpp

@@ -1442,8 +1442,7 @@ MSPropertyOpBuilder::getBaseMSProperty(MSPropertySubscriptExpr *E) {
 
 
 Expr *MSPropertyOpBuilder::rebuildAndCaptureObject(Expr *syntacticBase) {
 Expr *MSPropertyOpBuilder::rebuildAndCaptureObject(Expr *syntacticBase) {
   InstanceBase = capture(RefExpr->getBaseExpr());
   InstanceBase = capture(RefExpr->getBaseExpr());
-  std::for_each(CallArgs.begin(), CallArgs.end(),
-                [this](Expr *&Arg) { Arg = capture(Arg); });
+  llvm::for_each(CallArgs, [this](Expr *&Arg) { Arg = capture(Arg); });
   syntacticBase = Rebuilder(S, [=](Expr *, unsigned Idx) -> Expr * {
   syntacticBase = Rebuilder(S, [=](Expr *, unsigned Idx) -> Expr * {
                     switch (Idx) {
                     switch (Idx) {
                     case 0:
                     case 0:

+ 147 - 104
lib/Serialization/ASTReader.cpp

@@ -1,4 +1,4 @@
-//===-- ASTReader.cpp - AST File Reader -----------------------------------===//
+//===- ASTReader.cpp - AST File Reader ------------------------------------===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -19,28 +19,41 @@
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/ASTUnresolvedSet.h"
 #include "clang/AST/ASTUnresolvedSet.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclGroup.h"
 #include "clang/AST/DeclGroup.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/ODRHash.h"
 #include "clang/AST/ODRHash.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/AST/RawCommentList.h"
+#include "clang/AST/TemplateBase.h"
+#include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
 #include "clang/AST/TypeLocVisitor.h"
 #include "clang/AST/TypeLocVisitor.h"
 #include "clang/AST/UnresolvedSet.h"
 #include "clang/AST/UnresolvedSet.h"
 #include "clang/Basic/CommentOptions.h"
 #include "clang/Basic/CommentOptions.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/ExceptionSpecificationType.h"
 #include "clang/Basic/ExceptionSpecificationType.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/MemoryBufferCache.h"
 #include "clang/Basic/MemoryBufferCache.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/PragmaKinds.h"
 #include "clang/Basic/Sanitizers.h"
 #include "clang/Basic/Sanitizers.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/SourceManagerInternals.h"
 #include "clang/Basic/SourceManagerInternals.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Basic/Specifiers.h"
@@ -57,41 +70,61 @@
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Lex/Token.h"
+#include "clang/Sema/ObjCMethodList.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Weak.h"
 #include "clang/Sema/Weak.h"
+#include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTDeserializationListener.h"
 #include "clang/Serialization/ASTDeserializationListener.h"
+#include "clang/Serialization/ContinuousRangeMap.h"
 #include "clang/Serialization/GlobalModuleIndex.h"
 #include "clang/Serialization/GlobalModuleIndex.h"
+#include "clang/Serialization/Module.h"
+#include "clang/Serialization/ModuleFileExtension.h"
 #include "clang/Serialization/ModuleManager.h"
 #include "clang/Serialization/ModuleManager.h"
 #include "clang/Serialization/SerializationDiagnostic.h"
 #include "clang/Serialization/SerializationDiagnostic.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/Hashing.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Bitcode/BitstreamReader.h"
 #include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SaveAndRestore.h"
 #include "llvm/Support/SaveAndRestore.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <algorithm>
 #include <cassert>
 #include <cassert>
+#include <cstddef>
 #include <cstdint>
 #include <cstdint>
 #include <cstdio>
 #include <cstdio>
-#include <cstring>
 #include <ctime>
 #include <ctime>
 #include <iterator>
 #include <iterator>
 #include <limits>
 #include <limits>
 #include <map>
 #include <map>
 #include <memory>
 #include <memory>
-#include <new>
 #include <string>
 #include <string>
 #include <system_error>
 #include <system_error>
 #include <tuple>
 #include <tuple>
@@ -171,19 +204,23 @@ bool ChainedASTReaderListener::ReadPreprocessorOptions(
                                         SuggestedPredefines) ||
                                         SuggestedPredefines) ||
          Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
          Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
 }
 }
+
 void ChainedASTReaderListener::ReadCounter(const serialization::ModuleFile &M,
 void ChainedASTReaderListener::ReadCounter(const serialization::ModuleFile &M,
                                            unsigned Value) {
                                            unsigned Value) {
   First->ReadCounter(M, Value);
   First->ReadCounter(M, Value);
   Second->ReadCounter(M, Value);
   Second->ReadCounter(M, Value);
 }
 }
+
 bool ChainedASTReaderListener::needsInputFileVisitation() {
 bool ChainedASTReaderListener::needsInputFileVisitation() {
   return First->needsInputFileVisitation() ||
   return First->needsInputFileVisitation() ||
          Second->needsInputFileVisitation();
          Second->needsInputFileVisitation();
 }
 }
+
 bool ChainedASTReaderListener::needsSystemInputFileVisitation() {
 bool ChainedASTReaderListener::needsSystemInputFileVisitation() {
   return First->needsSystemInputFileVisitation() ||
   return First->needsSystemInputFileVisitation() ||
   Second->needsSystemInputFileVisitation();
   Second->needsSystemInputFileVisitation();
 }
 }
+
 void ChainedASTReaderListener::visitModuleFile(StringRef Filename,
 void ChainedASTReaderListener::visitModuleFile(StringRef Filename,
                                                ModuleKind Kind) {
                                                ModuleKind Kind) {
   First->visitModuleFile(Filename, Kind);
   First->visitModuleFile(Filename, Kind);
@@ -216,7 +253,7 @@ void ChainedASTReaderListener::readModuleFileExtension(
 // PCH validator implementation
 // PCH validator implementation
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
-ASTReaderListener::~ASTReaderListener() {}
+ASTReaderListener::~ASTReaderListener() = default;
 
 
 /// \brief Compare the given set of language options against an existing set of
 /// \brief Compare the given set of language options against an existing set of
 /// language options.
 /// language options.
@@ -409,17 +446,16 @@ bool PCHValidator::ReadTargetOptions(const TargetOptions &TargetOpts,
 
 
 namespace {
 namespace {
 
 
-  typedef llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/> >
-    MacroDefinitionsMap;
-  typedef llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8> >
-    DeclsMap;
+using MacroDefinitionsMap =
+    llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>;
+using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
 
 
-} // end anonymous namespace
+} // namespace
 
 
 static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
 static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
                                          DiagnosticsEngine &Diags,
                                          DiagnosticsEngine &Diags,
                                          bool Complain) {
                                          bool Complain) {
-  typedef DiagnosticsEngine::Level Level;
+  using Level = DiagnosticsEngine::Level;
 
 
   // Check current mappings for new -Werror mappings, and the stored mappings
   // Check current mappings for new -Werror mappings, and the stored mappings
   // for cases that were explicitly mapped to *not* be errors that are now
   // for cases that were explicitly mapped to *not* be errors that are now
@@ -603,8 +639,8 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
     std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
     std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
 
 
     // Check whether we know anything about this macro name or not.
     // Check whether we know anything about this macro name or not.
-    llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/> >::iterator Known
-      = ASTFileMacros.find(MacroName);
+    llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>::iterator Known =
+        ASTFileMacros.find(MacroName);
     if (!Validate || Known == ASTFileMacros.end()) {
     if (!Validate || Known == ASTFileMacros.end()) {
       // FIXME: Check whether this identifier was referenced anywhere in the
       // FIXME: Check whether this identifier was referenced anywhere in the
       // AST file. If so, we should reject the AST file. Unfortunately, this
       // AST file. If so, we should reject the AST file. Unfortunately, this
@@ -770,6 +806,7 @@ unsigned ASTSelectorLookupTrait::ComputeHash(Selector Sel) {
 std::pair<unsigned, unsigned>
 std::pair<unsigned, unsigned>
 ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) {
 ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
   return std::make_pair(KeyLen, DataLen);
   return std::make_pair(KeyLen, DataLen);
@@ -778,6 +815,7 @@ ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) {
 ASTSelectorLookupTrait::internal_key_type
 ASTSelectorLookupTrait::internal_key_type
 ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
 ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   SelectorTable &SelTable = Reader.getContext().Selectors;
   SelectorTable &SelTable = Reader.getContext().Selectors;
   unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
   IdentifierInfo *FirstII = Reader.getLocalIdentifier(
   IdentifierInfo *FirstII = Reader.getLocalIdentifier(
@@ -838,6 +876,7 @@ unsigned ASTIdentifierLookupTraitBase::ComputeHash(const internal_key_type& a) {
 std::pair<unsigned, unsigned>
 std::pair<unsigned, unsigned>
 ASTIdentifierLookupTraitBase::ReadKeyDataLength(const unsigned char*& d) {
 ASTIdentifierLookupTraitBase::ReadKeyDataLength(const unsigned char*& d) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
   return std::make_pair(KeyLen, DataLen);
   return std::make_pair(KeyLen, DataLen);
@@ -868,6 +907,7 @@ static bool readBit(unsigned &Bits) {
 
 
 IdentID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
 IdentID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
   unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
   return Reader.getGlobalIdentifierID(F, RawID >> 1);
   return Reader.getGlobalIdentifierID(F, RawID >> 1);
 }
 }
@@ -885,6 +925,7 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
                                                    const unsigned char* d,
                                                    const unsigned char* d,
                                                    unsigned DataLen) {
                                                    unsigned DataLen) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
   unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
   bool IsInteresting = RawID & 0x01;
   bool IsInteresting = RawID & 0x01;
 
 
@@ -1027,6 +1068,7 @@ unsigned DeclarationNameKey::getHash() const {
 ModuleFile *
 ModuleFile *
 ASTDeclContextNameLookupTrait::ReadFileRef(const unsigned char *&d) {
 ASTDeclContextNameLookupTrait::ReadFileRef(const unsigned char *&d) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
   uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
   return Reader.getLocalModuleFile(F, ModuleFileID);
   return Reader.getLocalModuleFile(F, ModuleFileID);
 }
 }
@@ -1034,6 +1076,7 @@ ASTDeclContextNameLookupTrait::ReadFileRef(const unsigned char *&d) {
 std::pair<unsigned, unsigned>
 std::pair<unsigned, unsigned>
 ASTDeclContextNameLookupTrait::ReadKeyDataLength(const unsigned char *&d) {
 ASTDeclContextNameLookupTrait::ReadKeyDataLength(const unsigned char *&d) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
   unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
   return std::make_pair(KeyLen, DataLen);
   return std::make_pair(KeyLen, DataLen);
@@ -1079,6 +1122,7 @@ void ASTDeclContextNameLookupTrait::ReadDataInto(internal_key_type,
                                                  unsigned DataLen,
                                                  unsigned DataLen,
                                                  data_type_builder &Val) {
                                                  data_type_builder &Val) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   for (unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
   for (unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
     uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
     uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
     Val.insert(Reader.getGlobalDeclID(F, LocalID));
     Val.insert(Reader.getGlobalDeclID(F, LocalID));
@@ -1278,7 +1322,9 @@ resolveFileRelativeToOriginalDir(const std::string &Filename,
                                  const std::string &CurrDir) {
                                  const std::string &CurrDir) {
   assert(OriginalDir != CurrDir &&
   assert(OriginalDir != CurrDir &&
          "No point trying to resolve the file if the PCH dir didn't change");
          "No point trying to resolve the file if the PCH dir didn't change");
+
   using namespace llvm::sys;
   using namespace llvm::sys;
+
   SmallString<128> filePath(Filename);
   SmallString<128> filePath(Filename);
   fs::make_absolute(filePath);
   fs::make_absolute(filePath);
   assert(path::is_absolute(OriginalDir));
   assert(path::is_absolute(OriginalDir));
@@ -1672,6 +1718,7 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
 std::pair<unsigned, unsigned>
 std::pair<unsigned, unsigned>
 HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) {
 HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little, unaligned>(d);
   unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little, unaligned>(d);
   unsigned DataLen = (unsigned) *d++;
   unsigned DataLen = (unsigned) *d++;
   return std::make_pair(KeyLen, DataLen);
   return std::make_pair(KeyLen, DataLen);
@@ -1680,6 +1727,7 @@ HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) {
 HeaderFileInfoTrait::internal_key_type
 HeaderFileInfoTrait::internal_key_type
 HeaderFileInfoTrait::ReadKey(const unsigned char *d, unsigned) {
 HeaderFileInfoTrait::ReadKey(const unsigned char *d, unsigned) {
   using namespace llvm::support;
   using namespace llvm::support;
+
   internal_key_type ikey;
   internal_key_type ikey;
   ikey.Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
   ikey.Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
   ikey.ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
   ikey.ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
@@ -1691,8 +1739,9 @@ HeaderFileInfoTrait::ReadKey(const unsigned char *d, unsigned) {
 HeaderFileInfoTrait::data_type
 HeaderFileInfoTrait::data_type
 HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
 HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
                               unsigned DataLen) {
                               unsigned DataLen) {
-  const unsigned char *End = d + DataLen;
   using namespace llvm::support;
   using namespace llvm::support;
+
+  const unsigned char *End = d + DataLen;
   HeaderFileInfo HFI;
   HeaderFileInfo HFI;
   unsigned Flags = *d++;
   unsigned Flags = *d++;
   // FIXME: Refactor with mergeHeaderFileInfo in HeaderSearch.cpp.
   // FIXME: Refactor with mergeHeaderFileInfo in HeaderSearch.cpp.
@@ -1813,7 +1862,7 @@ namespace {
     unsigned PriorGeneration;
     unsigned PriorGeneration;
     unsigned &NumIdentifierLookups;
     unsigned &NumIdentifierLookups;
     unsigned &NumIdentifierLookupHits;
     unsigned &NumIdentifierLookupHits;
-    IdentifierInfo *Found;
+    IdentifierInfo *Found = nullptr;
 
 
   public:
   public:
     IdentifierLookupVisitor(StringRef Name, unsigned PriorGeneration,
     IdentifierLookupVisitor(StringRef Name, unsigned PriorGeneration,
@@ -1822,10 +1871,7 @@ namespace {
       : Name(Name), NameHash(ASTIdentifierLookupTrait::ComputeHash(Name)),
       : Name(Name), NameHash(ASTIdentifierLookupTrait::ComputeHash(Name)),
         PriorGeneration(PriorGeneration),
         PriorGeneration(PriorGeneration),
         NumIdentifierLookups(NumIdentifierLookups),
         NumIdentifierLookups(NumIdentifierLookups),
-        NumIdentifierLookupHits(NumIdentifierLookupHits),
-        Found()
-    {
-    }
+        NumIdentifierLookupHits(NumIdentifierLookupHits) {}
 
 
     bool operator()(ModuleFile &M) {
     bool operator()(ModuleFile &M) {
       // If we've already searched this module file, skip it now.
       // If we've already searched this module file, skip it now.
@@ -1858,7 +1904,7 @@ namespace {
     IdentifierInfo *getIdentifierInfo() const { return Found; }
     IdentifierInfo *getIdentifierInfo() const { return Found; }
   };
   };
 
 
-} // end anonymous namespace
+} // namespace
 
 
 void ASTReader::updateOutOfDateIdentifier(IdentifierInfo &II) {
 void ASTReader::updateOutOfDateIdentifier(IdentifierInfo &II) {
   // Note that we are loading an identifier.
   // Note that we are loading an identifier.
@@ -1985,10 +2031,9 @@ void ASTReader::resolvePendingMacro(IdentifierInfo *II,
       MD = PP.AllocateDefMacroDirective(MI, Loc);
       MD = PP.AllocateDefMacroDirective(MI, Loc);
       break;
       break;
     }
     }
-    case MacroDirective::MD_Undefine: {
+    case MacroDirective::MD_Undefine:
       MD = PP.AllocateUndefMacroDirective(Loc);
       MD = PP.AllocateUndefMacroDirective(Loc);
       break;
       break;
-    }
     case MacroDirective::MD_Visibility:
     case MacroDirective::MD_Visibility:
       bool isPublic = Record[Idx++];
       bool isPublic = Record[Idx++];
       MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
       MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
@@ -2124,7 +2169,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
     if (Complain) {
     if (Complain) {
       // Build a list of the PCH imports that got us here (in reverse).
       // Build a list of the PCH imports that got us here (in reverse).
       SmallVector<ModuleFile *, 4> ImportStack(1, &F);
       SmallVector<ModuleFile *, 4> ImportStack(1, &F);
-      while (ImportStack.back()->ImportedBy.size() > 0)
+      while (!ImportStack.back()->ImportedBy.empty())
         ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
         ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
 
 
       // The top-level PCH is stale.
       // The top-level PCH is stale.
@@ -2622,7 +2667,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
     case llvm::BitstreamEntry::Error:
     case llvm::BitstreamEntry::Error:
       Error("error at end of module block in AST file");
       Error("error at end of module block in AST file");
       return Failure;
       return Failure;
-    case llvm::BitstreamEntry::EndBlock: {
+    case llvm::BitstreamEntry::EndBlock:
       // Outside of C++, we do not store a lookup map for the translation unit.
       // Outside of C++, we do not store a lookup map for the translation unit.
       // Instead, mark it as needing a lookup map to be built if this module
       // Instead, mark it as needing a lookup map to be built if this module
       // contains any declarations lexically within it (which it always does!).
       // contains any declarations lexically within it (which it always does!).
@@ -2635,7 +2680,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
       }
       }
 
 
       return Success;
       return Success;
-    }
     case llvm::BitstreamEntry::SubBlock:
     case llvm::BitstreamEntry::SubBlock:
       switch (Entry.ID) {
       switch (Entry.ID) {
       case DECLTYPES_BLOCK_ID:
       case DECLTYPES_BLOCK_ID:
@@ -2995,8 +3039,20 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
 
 
     case PP_CONDITIONAL_STACK:
     case PP_CONDITIONAL_STACK:
       if (!Record.empty()) {
       if (!Record.empty()) {
+        unsigned Idx = 0, End = Record.size() - 1;
+        bool ReachedEOFWhileSkipping = Record[Idx++];
+        llvm::Optional<Preprocessor::PreambleSkipInfo> SkipInfo;
+        if (ReachedEOFWhileSkipping) {
+          SourceLocation HashToken = ReadSourceLocation(F, Record, Idx);
+          SourceLocation IfTokenLoc = ReadSourceLocation(F, Record, Idx);
+          bool FoundNonSkipPortion = Record[Idx++];
+          bool FoundElse = Record[Idx++];
+          SourceLocation ElseLoc = ReadSourceLocation(F, Record, Idx);
+          SkipInfo.emplace(HashToken, IfTokenLoc, FoundNonSkipPortion,
+                           FoundElse, ElseLoc);
+        }
         SmallVector<PPConditionalInfo, 4> ConditionalStack;
         SmallVector<PPConditionalInfo, 4> ConditionalStack;
-        for (unsigned Idx = 0, N = Record.size() - 1; Idx < N; /* in loop */) {
+        while (Idx < End) {
           auto Loc = ReadSourceLocation(F, Record, Idx);
           auto Loc = ReadSourceLocation(F, Record, Idx);
           bool WasSkipping = Record[Idx++];
           bool WasSkipping = Record[Idx++];
           bool FoundNonSkip = Record[Idx++];
           bool FoundNonSkip = Record[Idx++];
@@ -3004,7 +3060,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
           ConditionalStack.push_back(
           ConditionalStack.push_back(
               {Loc, WasSkipping, FoundNonSkip, FoundElse});
               {Loc, WasSkipping, FoundNonSkip, FoundElse});
         }
         }
-        PP.setReplayablePreambleConditionalStack(ConditionalStack);
+        PP.setReplayablePreambleConditionalStack(ConditionalStack, SkipInfo);
       }
       }
       break;
       break;
 
 
@@ -3158,7 +3214,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
       break;
       break;
     }
     }
 
 
-    case DECL_UPDATE_OFFSETS: {
+    case DECL_UPDATE_OFFSETS:
       if (Record.size() % 2 != 0) {
       if (Record.size() % 2 != 0) {
         Error("invalid DECL_UPDATE_OFFSETS block in AST file");
         Error("invalid DECL_UPDATE_OFFSETS block in AST file");
         return Failure;
         return Failure;
@@ -3174,9 +3230,8 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
               PendingUpdateRecord(ID, D, /*JustLoaded=*/false));
               PendingUpdateRecord(ID, D, /*JustLoaded=*/false));
       }
       }
       break;
       break;
-    }
 
 
-    case OBJC_CATEGORIES_MAP: {
+    case OBJC_CATEGORIES_MAP:
       if (F.LocalNumObjCCategoriesInMap != 0) {
       if (F.LocalNumObjCCategoriesInMap != 0) {
         Error("duplicate OBJC_CATEGORIES_MAP record in AST file");
         Error("duplicate OBJC_CATEGORIES_MAP record in AST file");
         return Failure;
         return Failure;
@@ -3185,7 +3240,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
       F.LocalNumObjCCategoriesInMap = Record[0];
       F.LocalNumObjCCategoriesInMap = Record[0];
       F.ObjCCategoriesMap = (const ObjCCategoriesInfo *)Blob.data();
       F.ObjCCategoriesMap = (const ObjCCategoriesInfo *)Blob.data();
       break;
       break;
-    }
 
 
     case OBJC_CATEGORIES:
     case OBJC_CATEGORIES:
       F.ObjCCategories.swap(Record);
       F.ObjCCategories.swap(Record);
@@ -3199,7 +3253,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
         CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
         CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
       break;
       break;
 
 
-    case HEADER_SEARCH_TABLE: {
+    case HEADER_SEARCH_TABLE:
       F.HeaderFileInfoTableData = Blob.data();
       F.HeaderFileInfoTableData = Blob.data();
       F.LocalNumHeaderFileInfos = Record[1];
       F.LocalNumHeaderFileInfos = Record[1];
       if (Record[0]) {
       if (Record[0]) {
@@ -3216,7 +3270,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
           PP.getHeaderSearchInfo().SetExternalLookup(this);
           PP.getHeaderSearchInfo().SetExternalLookup(this);
       }
       }
       break;
       break;
-    }
 
 
     case FP_PRAGMA_OPTIONS:
     case FP_PRAGMA_OPTIONS:
       // Later tables overwrite earlier ones.
       // Later tables overwrite earlier ones.
@@ -3284,6 +3337,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
             ReadSourceLocation(F, Record, I).getRawEncoding());
             ReadSourceLocation(F, Record, I).getRawEncoding());
       }
       }
       break;
       break;
+
     case DELETE_EXPRS_TO_ANALYZE:
     case DELETE_EXPRS_TO_ANALYZE:
       for (unsigned I = 0, N = Record.size(); I != N;) {
       for (unsigned I = 0, N = Record.size(); I != N;) {
         DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
         DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
@@ -3297,7 +3351,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
       }
       }
       break;
       break;
 
 
-    case IMPORTED_MODULES: {
+    case IMPORTED_MODULES:
       if (!F.isModule()) {
       if (!F.isModule()) {
         // If we aren't loading a module (which has its own exports), make
         // If we aren't loading a module (which has its own exports), make
         // all of the imported modules visible.
         // all of the imported modules visible.
@@ -3313,7 +3367,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
         }
         }
       }
       }
       break;
       break;
-    }
 
 
     case MACRO_OFFSET: {
     case MACRO_OFFSET: {
       if (F.LocalNumMacros != 0) {
       if (F.LocalNumMacros != 0) {
@@ -3339,10 +3392,9 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
       break;
       break;
     }
     }
 
 
-    case LATE_PARSED_TEMPLATE: {
+    case LATE_PARSED_TEMPLATE:
       LateParsedTemplates.append(Record.begin(), Record.end());
       LateParsedTemplates.append(Record.begin(), Record.end());
       break;
       break;
-    }
 
 
     case OPTIMIZE_PRAGMA_OPTIONS:
     case OPTIMIZE_PRAGMA_OPTIONS:
       if (Record.size() != 1) {
       if (Record.size() != 1) {
@@ -3424,8 +3476,7 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
   }
   }
 
 
   // Continuous range maps we may be updating in our module.
   // Continuous range maps we may be updating in our module.
-  typedef ContinuousRangeMap<uint32_t, int, 2>::Builder
-      RemapBuilder;
+  using RemapBuilder = ContinuousRangeMap<uint32_t, int, 2>::Builder;
   RemapBuilder SLocRemap(F.SLocRemap);
   RemapBuilder SLocRemap(F.SLocRemap);
   RemapBuilder IdentifierRemap(F.IdentifierRemap);
   RemapBuilder IdentifierRemap(F.IdentifierRemap);
   RemapBuilder MacroRemap(F.MacroRemap);
   RemapBuilder MacroRemap(F.MacroRemap);
@@ -3589,7 +3640,6 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
   return Success;
   return Success;
 }
 }
 
 
-
 /// \brief Move the given method to the back of the global list of methods.
 /// \brief Move the given method to the back of the global list of methods.
 static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) {
 static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) {
   // Find the entry for this selector in the method pool.
   // Find the entry for this selector in the method pool.
@@ -4242,7 +4292,7 @@ ASTReader::ASTReadResult ASTReader::readUnhashedControlBlockImpl(
   // Read all of the records in the options block.
   // Read all of the records in the options block.
   RecordData Record;
   RecordData Record;
   ASTReadResult Result = Success;
   ASTReadResult Result = Success;
-  while (1) {
+  while (true) {
     llvm::BitstreamEntry Entry = Stream.advance();
     llvm::BitstreamEntry Entry = Stream.advance();
 
 
     switch (Entry.Kind) {
     switch (Entry.Kind) {
@@ -4262,11 +4312,10 @@ ASTReader::ASTReadResult ASTReader::readUnhashedControlBlockImpl(
     Record.clear();
     Record.clear();
     switch (
     switch (
         (UnhashedControlBlockRecordTypes)Stream.readRecord(Entry.ID, Record)) {
         (UnhashedControlBlockRecordTypes)Stream.readRecord(Entry.ID, Record)) {
-    case SIGNATURE: {
+    case SIGNATURE:
       if (F)
       if (F)
         std::copy(Record.begin(), Record.end(), F->Signature.data());
         std::copy(Record.begin(), Record.end(), F->Signature.data());
       break;
       break;
-    }
     case DIAGNOSTIC_OPTIONS: {
     case DIAGNOSTIC_OPTIONS: {
       bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
       bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
       if (Listener && ValidateDiagnosticOptions &&
       if (Listener && ValidateDiagnosticOptions &&
@@ -4595,9 +4644,7 @@ namespace {
         ExistingTargetOpts(ExistingTargetOpts),
         ExistingTargetOpts(ExistingTargetOpts),
         ExistingPPOpts(ExistingPPOpts),
         ExistingPPOpts(ExistingPPOpts),
         ExistingModuleCachePath(ExistingModuleCachePath),
         ExistingModuleCachePath(ExistingModuleCachePath),
-        FileMgr(FileMgr)
-    {
-    }
+        FileMgr(FileMgr) {}
 
 
     bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
     bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
                              bool AllowCompatibleDifferences) override {
                              bool AllowCompatibleDifferences) override {
@@ -4627,7 +4674,7 @@ namespace {
     }
     }
   };
   };
 
 
-} // end anonymous namespace
+} // namespace
 
 
 bool ASTReader::readASTFileControlBlock(
 bool ASTReader::readASTFileControlBlock(
     StringRef Filename, FileManager &FileMgr,
     StringRef Filename, FileManager &FileMgr,
@@ -4711,15 +4758,12 @@ bool ASTReader::readASTFileControlBlock(
     StringRef Blob;
     StringRef Blob;
     unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
     unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
     switch ((ControlRecordTypes)RecCode) {
     switch ((ControlRecordTypes)RecCode) {
-    case METADATA: {
+    case METADATA:
       if (Record[0] != VERSION_MAJOR)
       if (Record[0] != VERSION_MAJOR)
         return true;
         return true;
-
       if (Listener.ReadFullVersionInformation(Blob))
       if (Listener.ReadFullVersionInformation(Blob))
         return true;
         return true;
-
       break;
       break;
-    }
     case MODULE_NAME:
     case MODULE_NAME:
       Listener.ReadModuleName(Blob);
       Listener.ReadModuleName(Blob);
       break;
       break;
@@ -5027,10 +5071,9 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
       // them here.
       // them here.
       break;
       break;
 
 
-    case SUBMODULE_TOPHEADER: {
+    case SUBMODULE_TOPHEADER:
       CurrentModule->addTopHeaderFilename(Blob);
       CurrentModule->addTopHeaderFilename(Blob);
       break;
       break;
-    }
 
 
     case SUBMODULE_UMBRELLA_DIR: {
     case SUBMODULE_UMBRELLA_DIR: {
       std::string Dirname = Blob;
       std::string Dirname = Blob;
@@ -5067,7 +5110,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
       break;
       break;
     }
     }
 
 
-    case SUBMODULE_IMPORTS: {
+    case SUBMODULE_IMPORTS:
       for (unsigned Idx = 0; Idx != Record.size(); ++Idx) {
       for (unsigned Idx = 0; Idx != Record.size(); ++Idx) {
         UnresolvedModuleRef Unresolved;
         UnresolvedModuleRef Unresolved;
         Unresolved.File = &F;
         Unresolved.File = &F;
@@ -5078,9 +5121,8 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
         UnresolvedModuleRefs.push_back(Unresolved);
         UnresolvedModuleRefs.push_back(Unresolved);
       }
       }
       break;
       break;
-    }
 
 
-    case SUBMODULE_EXPORTS: {
+    case SUBMODULE_EXPORTS:
       for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
       for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
         UnresolvedModuleRef Unresolved;
         UnresolvedModuleRef Unresolved;
         Unresolved.File = &F;
         Unresolved.File = &F;
@@ -5095,12 +5137,11 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
       // the parsed, unresolved exports around.
       // the parsed, unresolved exports around.
       CurrentModule->UnresolvedExports.clear();
       CurrentModule->UnresolvedExports.clear();
       break;
       break;
-    }
-    case SUBMODULE_REQUIRES: {
+
+    case SUBMODULE_REQUIRES:
       CurrentModule->addRequirement(Blob, Record[0], PP.getLangOpts(),
       CurrentModule->addRequirement(Blob, Record[0], PP.getLangOpts(),
                                     PP.getTargetInfo());
                                     PP.getTargetInfo());
       break;
       break;
-    }
 
 
     case SUBMODULE_LINK_LIBRARY:
     case SUBMODULE_LINK_LIBRARY:
       CurrentModule->LinkLibraries.push_back(
       CurrentModule->LinkLibraries.push_back(
@@ -5450,7 +5491,7 @@ struct PPEntityComp {
   const ASTReader &Reader;
   const ASTReader &Reader;
   ModuleFile &M;
   ModuleFile &M;
 
 
-  PPEntityComp(const ASTReader &Reader, ModuleFile &M) : Reader(Reader), M(M) { }
+  PPEntityComp(const ASTReader &Reader, ModuleFile &M) : Reader(Reader), M(M) {}
 
 
   bool operator()(const PPEntityOffset &L, const PPEntityOffset &R) const {
   bool operator()(const PPEntityOffset &L, const PPEntityOffset &R) const {
     SourceLocation LHS = getLoc(L);
     SourceLocation LHS = getLoc(L);
@@ -5473,7 +5514,7 @@ struct PPEntityComp {
   }
   }
 };
 };
 
 
-} // end anonymous namespace
+} // namespace
 
 
 PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
 PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
                                                        bool EndsAfter) const {
                                                        bool EndsAfter) const {
@@ -5489,7 +5530,9 @@ PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
     return findNextPreprocessedEntity(SLocMapI);
     return findNextPreprocessedEntity(SLocMapI);
 
 
   ModuleFile &M = *SLocMapI->second;
   ModuleFile &M = *SLocMapI->second;
-  typedef const PPEntityOffset *pp_iterator;
+
+  using pp_iterator = const PPEntityOffset *;
+
   pp_iterator pp_begin = M.PreprocessedEntityOffsets;
   pp_iterator pp_begin = M.PreprocessedEntityOffsets;
   pp_iterator pp_end = pp_begin + M.NumPreprocessedEntities;
   pp_iterator pp_end = pp_begin + M.NumPreprocessedEntities;
 
 
@@ -5567,12 +5610,10 @@ namespace {
   /// \brief Visitor used to search for information about a header file.
   /// \brief Visitor used to search for information about a header file.
   class HeaderFileInfoVisitor {
   class HeaderFileInfoVisitor {
     const FileEntry *FE;
     const FileEntry *FE;
-
     Optional<HeaderFileInfo> HFI;
     Optional<HeaderFileInfo> HFI;
 
 
   public:
   public:
-    explicit HeaderFileInfoVisitor(const FileEntry *FE)
-      : FE(FE) { }
+    explicit HeaderFileInfoVisitor(const FileEntry *FE) : FE(FE) {}
 
 
     bool operator()(ModuleFile &M) {
     bool operator()(ModuleFile &M) {
       HeaderFileInfoLookupTable *Table
       HeaderFileInfoLookupTable *Table
@@ -5592,7 +5633,7 @@ namespace {
     Optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
     Optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
   };
   };
 
 
-} // end anonymous namespace
+} // namespace
 
 
 HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) {
 HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) {
   HeaderFileInfoVisitor Visitor(FE);
   HeaderFileInfoVisitor Visitor(FE);
@@ -6113,6 +6154,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
       Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
       Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
     return Context.getObjCTypeParamType(Decl, Protos);
     return Context.getObjCTypeParamType(Decl, Protos);
   }
   }
+
   case TYPE_OBJC_OBJECT: {
   case TYPE_OBJC_OBJECT: {
     unsigned Idx = 0;
     unsigned Idx = 0;
     QualType Base = readType(*Loc.F, Record, Idx);
     QualType Base = readType(*Loc.F, Record, Idx);
@@ -6309,7 +6351,9 @@ void ASTReader::readExceptionSpec(ModuleFile &ModuleFile,
   }
   }
 }
 }
 
 
-class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
+namespace clang {
+
+class TypeLocReader : public TypeLocVisitor<TypeLocReader> {
   ModuleFile *F;
   ModuleFile *F;
   ASTReader *Reader;
   ASTReader *Reader;
   const ASTReader::RecordData &Record;
   const ASTReader::RecordData &Record;
@@ -6344,6 +6388,8 @@ public:
   void VisitArrayTypeLoc(ArrayTypeLoc);
   void VisitArrayTypeLoc(ArrayTypeLoc);
 };
 };
 
 
+} // namespace clang
+
 void TypeLocReader::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
 void TypeLocReader::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
   // nothing to do
   // nothing to do
 }
 }
@@ -6460,23 +6506,28 @@ void TypeLocReader::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
 void TypeLocReader::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
 void TypeLocReader::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
   VisitFunctionTypeLoc(TL);
   VisitFunctionTypeLoc(TL);
 }
 }
+
 void TypeLocReader::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
 void TypeLocReader::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
   TL.setNameLoc(ReadSourceLocation());
 }
 }
+
 void TypeLocReader::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
 void TypeLocReader::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
   TL.setNameLoc(ReadSourceLocation());
 }
 }
+
 void TypeLocReader::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
 void TypeLocReader::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
   TL.setTypeofLoc(ReadSourceLocation());
   TL.setTypeofLoc(ReadSourceLocation());
   TL.setLParenLoc(ReadSourceLocation());
   TL.setLParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
 }
 }
+
 void TypeLocReader::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
 void TypeLocReader::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
   TL.setTypeofLoc(ReadSourceLocation());
   TL.setTypeofLoc(ReadSourceLocation());
   TL.setLParenLoc(ReadSourceLocation());
   TL.setLParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
   TL.setUnderlyingTInfo(GetTypeSourceInfo());
   TL.setUnderlyingTInfo(GetTypeSourceInfo());
 }
 }
+
 void TypeLocReader::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
 void TypeLocReader::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
   TL.setNameLoc(ReadSourceLocation());
 }
 }
@@ -6530,10 +6581,12 @@ void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
                                             SubstTemplateTypeParmTypeLoc TL) {
                                             SubstTemplateTypeParmTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
   TL.setNameLoc(ReadSourceLocation());
 }
 }
+
 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
                                           SubstTemplateTypeParmPackTypeLoc TL) {
                                           SubstTemplateTypeParmPackTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation());
   TL.setNameLoc(ReadSourceLocation());
 }
 }
+
 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
                                            TemplateSpecializationTypeLoc TL) {
                                            TemplateSpecializationTypeLoc TL) {
   TL.setTemplateKeywordLoc(ReadSourceLocation());
   TL.setTemplateKeywordLoc(ReadSourceLocation());
@@ -6546,6 +6599,7 @@ void TypeLocReader::VisitTemplateSpecializationTypeLoc(
         Reader->GetTemplateArgumentLocInfo(
         Reader->GetTemplateArgumentLocInfo(
             *F, TL.getTypePtr()->getArg(i).getKind(), Record, Idx));
             *F, TL.getTypePtr()->getArg(i).getKind(), Record, Idx));
 }
 }
+
 void TypeLocReader::VisitParenTypeLoc(ParenTypeLoc TL) {
 void TypeLocReader::VisitParenTypeLoc(ParenTypeLoc TL) {
   TL.setLParenLoc(ReadSourceLocation());
   TL.setLParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
@@ -6656,13 +6710,11 @@ QualType ASTReader::GetType(TypeID ID) {
     case PREDEF_TYPE_BOOL_ID:
     case PREDEF_TYPE_BOOL_ID:
       T = Context.BoolTy;
       T = Context.BoolTy;
       break;
       break;
-
     case PREDEF_TYPE_CHAR_U_ID:
     case PREDEF_TYPE_CHAR_U_ID:
     case PREDEF_TYPE_CHAR_S_ID:
     case PREDEF_TYPE_CHAR_S_ID:
       // FIXME: Check that the signedness of CharTy is correct!
       // FIXME: Check that the signedness of CharTy is correct!
       T = Context.CharTy;
       T = Context.CharTy;
       break;
       break;
-
     case PREDEF_TYPE_UCHAR_ID:
     case PREDEF_TYPE_UCHAR_ID:
       T = Context.UnsignedCharTy;
       T = Context.UnsignedCharTy;
       break;
       break;
@@ -6776,19 +6828,15 @@ QualType ASTReader::GetType(TypeID ID) {
     case PREDEF_TYPE_AUTO_DEDUCT:
     case PREDEF_TYPE_AUTO_DEDUCT:
       T = Context.getAutoDeductType();
       T = Context.getAutoDeductType();
       break;
       break;
-
     case PREDEF_TYPE_AUTO_RREF_DEDUCT:
     case PREDEF_TYPE_AUTO_RREF_DEDUCT:
       T = Context.getAutoRRefDeductType();
       T = Context.getAutoRRefDeductType();
       break;
       break;
-
     case PREDEF_TYPE_ARC_UNBRIDGED_CAST:
     case PREDEF_TYPE_ARC_UNBRIDGED_CAST:
       T = Context.ARCUnbridgedCastTy;
       T = Context.ARCUnbridgedCastTy;
       break;
       break;
-
     case PREDEF_TYPE_BUILTIN_FN:
     case PREDEF_TYPE_BUILTIN_FN:
       T = Context.BuiltinFnTy;
       T = Context.BuiltinFnTy;
       break;
       break;
-
     case PREDEF_TYPE_OMP_ARRAY_SECTION:
     case PREDEF_TYPE_OMP_ARRAY_SECTION:
       T = Context.OMPArraySectionTy;
       T = Context.OMPArraySectionTy;
       break;
       break;
@@ -7275,7 +7323,7 @@ public:
   }
   }
 };
 };
 
 
-} // end anonymous namespace
+} // namespace
 
 
 void ASTReader::FindFileRegionDecls(FileID File,
 void ASTReader::FindFileRegionDecls(FileID File,
                                     unsigned Offset, unsigned Length,
                                     unsigned Offset, unsigned Length,
@@ -7471,30 +7519,25 @@ void ASTReader::PrintStats() {
                  NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
                  NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
                  ((float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
                  ((float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
                   * 100));
                   * 100));
-  if (TotalNumMethodPoolEntries) {
+  if (TotalNumMethodPoolEntries)
     std::fprintf(stderr, "  %u/%u method pool entries read (%f%%)\n",
     std::fprintf(stderr, "  %u/%u method pool entries read (%f%%)\n",
                  NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
                  NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
                  ((float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
                  ((float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
                   * 100));
                   * 100));
-  }
-  if (NumMethodPoolLookups) {
+  if (NumMethodPoolLookups)
     std::fprintf(stderr, "  %u/%u method pool lookups succeeded (%f%%)\n",
     std::fprintf(stderr, "  %u/%u method pool lookups succeeded (%f%%)\n",
                  NumMethodPoolHits, NumMethodPoolLookups,
                  NumMethodPoolHits, NumMethodPoolLookups,
                  ((float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
                  ((float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
-  }
-  if (NumMethodPoolTableLookups) {
+  if (NumMethodPoolTableLookups)
     std::fprintf(stderr, "  %u/%u method pool table lookups succeeded (%f%%)\n",
     std::fprintf(stderr, "  %u/%u method pool table lookups succeeded (%f%%)\n",
                  NumMethodPoolTableHits, NumMethodPoolTableLookups,
                  NumMethodPoolTableHits, NumMethodPoolTableLookups,
                  ((float)NumMethodPoolTableHits/NumMethodPoolTableLookups
                  ((float)NumMethodPoolTableHits/NumMethodPoolTableLookups
                   * 100.0));
                   * 100.0));
-  }
-
-  if (NumIdentifierLookupHits) {
+  if (NumIdentifierLookupHits)
     std::fprintf(stderr,
     std::fprintf(stderr,
                  "  %u / %u identifier table lookups succeeded (%f%%)\n",
                  "  %u / %u identifier table lookups succeeded (%f%%)\n",
                  NumIdentifierLookupHits, NumIdentifierLookups,
                  NumIdentifierLookupHits, NumIdentifierLookups,
                  (double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
                  (double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
-  }
 
 
   if (GlobalIndex) {
   if (GlobalIndex) {
     std::fprintf(stderr, "\n");
     std::fprintf(stderr, "\n");
@@ -7514,7 +7557,8 @@ dumpModuleIDMap(StringRef Name,
   if (Map.begin() == Map.end())
   if (Map.begin() == Map.end())
     return;
     return;
 
 
-  typedef ContinuousRangeMap<Key, ModuleFile *, InitialCapacity> MapType;
+  using MapType = ContinuousRangeMap<Key, ModuleFile *, InitialCapacity>;
+
   llvm::errs() << Name << ":\n";
   llvm::errs() << Name << ":\n";
   for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
   for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
        I != IEnd; ++I) {
        I != IEnd; ++I) {
@@ -7711,7 +7755,7 @@ namespace clang {
     StringRef Next() override;
     StringRef Next() override;
   };
   };
 
 
-} // end namespace clang
+} // namespace clang
 
 
 ASTIdentifierIterator::ASTIdentifierIterator(const ASTReader &Reader,
 ASTIdentifierIterator::ASTIdentifierIterator(const ASTReader &Reader,
                                              bool SkipModules)
                                              bool SkipModules)
@@ -7769,7 +7813,7 @@ public:
   }
   }
 };
 };
 
 
-} // end anonymous namespace.
+} // namespace
 
 
 IdentifierIterator *ASTReader::getIdentifiers() {
 IdentifierIterator *ASTReader::getIdentifiers() {
   if (!loadGlobalIndex()) {
   if (!loadGlobalIndex()) {
@@ -7791,19 +7835,17 @@ namespace serialization {
     ASTReader &Reader;
     ASTReader &Reader;
     Selector Sel;
     Selector Sel;
     unsigned PriorGeneration;
     unsigned PriorGeneration;
-    unsigned InstanceBits;
-    unsigned FactoryBits;
-    bool InstanceHasMoreThanOneDecl;
-    bool FactoryHasMoreThanOneDecl;
+    unsigned InstanceBits = 0;
+    unsigned FactoryBits = 0;
+    bool InstanceHasMoreThanOneDecl = false;
+    bool FactoryHasMoreThanOneDecl = false;
     SmallVector<ObjCMethodDecl *, 4> InstanceMethods;
     SmallVector<ObjCMethodDecl *, 4> InstanceMethods;
     SmallVector<ObjCMethodDecl *, 4> FactoryMethods;
     SmallVector<ObjCMethodDecl *, 4> FactoryMethods;
 
 
   public:
   public:
     ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel,
     ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel,
                           unsigned PriorGeneration)
                           unsigned PriorGeneration)
-        : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration),
-          InstanceBits(0), FactoryBits(0), InstanceHasMoreThanOneDecl(false),
-          FactoryHasMoreThanOneDecl(false) {}
+        : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
 
 
     bool operator()(ModuleFile &M) {
     bool operator()(ModuleFile &M) {
       if (!M.SelectorLookupTable)
       if (!M.SelectorLookupTable)
@@ -7851,14 +7893,16 @@ namespace serialization {
 
 
     unsigned getInstanceBits() const { return InstanceBits; }
     unsigned getInstanceBits() const { return InstanceBits; }
     unsigned getFactoryBits() const { return FactoryBits; }
     unsigned getFactoryBits() const { return FactoryBits; }
+
     bool instanceHasMoreThanOneDecl() const {
     bool instanceHasMoreThanOneDecl() const {
       return InstanceHasMoreThanOneDecl;
       return InstanceHasMoreThanOneDecl;
     }
     }
+
     bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; }
     bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; }
   };
   };
 
 
-} // end namespace serialization
-} // end namespace clang
+} // namespace serialization
+} // namespace clang
 
 
 /// \brief Add the given set of methods to the method list.
 /// \brief Add the given set of methods to the method list.
 static void addMethodsToPool(Sema &S, ArrayRef<ObjCMethodDecl *> Methods,
 static void addMethodsToPool(Sema &S, ArrayRef<ObjCMethodDecl *> Methods,
@@ -8001,7 +8045,7 @@ void ASTReader::ReadUnusedLocalTypedefNameCandidates(
 }
 }
 
 
 void ASTReader::ReadReferencedSelectors(
 void ASTReader::ReadReferencedSelectors(
-       SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {
+       SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) {
   if (ReferencedSelectorsData.empty())
   if (ReferencedSelectorsData.empty())
     return;
     return;
 
 
@@ -8019,7 +8063,7 @@ void ASTReader::ReadReferencedSelectors(
 }
 }
 
 
 void ASTReader::ReadWeakUndeclaredIdentifiers(
 void ASTReader::ReadWeakUndeclaredIdentifiers(
-       SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WeakIDs) {
+       SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WeakIDs) {
   if (WeakUndeclaredIdentifiers.empty())
   if (WeakUndeclaredIdentifiers.empty())
     return;
     return;
 
 
@@ -8051,7 +8095,7 @@ void ASTReader::ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {
 }
 }
 
 
 void ASTReader::ReadPendingInstantiations(
 void ASTReader::ReadPendingInstantiations(
-       SmallVectorImpl<std::pair<ValueDecl *, SourceLocation> > &Pending) {
+       SmallVectorImpl<std::pair<ValueDecl *, SourceLocation>> &Pending) {
   for (unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
   for (unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
     ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
     ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
     SourceLocation Loc
     SourceLocation Loc
@@ -8763,11 +8807,10 @@ ASTReader::ReadNestedNameSpecifier(ModuleFile &F,
       break;
       break;
     }
     }
 
 
-    case NestedNameSpecifier::Global: {
+    case NestedNameSpecifier::Global:
       NNS = NestedNameSpecifier::GlobalSpecifier(Context);
       NNS = NestedNameSpecifier::GlobalSpecifier(Context);
       // No associated value, and there can't be a prefix.
       // No associated value, and there can't be a prefix.
       break;
       break;
-    }
 
 
     case NestedNameSpecifier::Super: {
     case NestedNameSpecifier::Super: {
       CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
       CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(F, Record, Idx);
@@ -8944,7 +8987,7 @@ void ASTReader::ReadComments() {
   ASTContext &Context = getContext();
   ASTContext &Context = getContext();
   std::vector<RawComment *> Comments;
   std::vector<RawComment *> Comments;
   for (SmallVectorImpl<std::pair<BitstreamCursor,
   for (SmallVectorImpl<std::pair<BitstreamCursor,
-                                 serialization::ModuleFile *> >::iterator
+                                 serialization::ModuleFile *>>::iterator
        I = CommentsCursors.begin(),
        I = CommentsCursors.begin(),
        E = CommentsCursors.end();
        E = CommentsCursors.end();
        I != E; ++I) {
        I != E; ++I) {
@@ -9034,7 +9077,7 @@ std::string ASTReader::getOwningModuleNameForDiagnostic(const Decl *D) {
     return M->ModuleName;
     return M->ModuleName;
 
 
   // Not from a module.
   // Not from a module.
-  return "";
+  return {};
 }
 }
 
 
 void ASTReader::finishPendingActions() {
 void ASTReader::finishPendingActions() {
@@ -9044,8 +9087,8 @@ void ASTReader::finishPendingActions() {
          !PendingUpdateRecords.empty()) {
          !PendingUpdateRecords.empty()) {
     // If any identifiers with corresponding top-level declarations have
     // If any identifiers with corresponding top-level declarations have
     // been loaded, load those declarations now.
     // been loaded, load those declarations now.
-    typedef llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2> >
-      TopLevelDeclsMap;
+    using TopLevelDeclsMap =
+        llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
     TopLevelDeclsMap TopLevelDecls;
     TopLevelDeclsMap TopLevelDecls;
 
 
     while (!PendingIdentifierInfos.empty()) {
     while (!PendingIdentifierInfos.empty()) {
@@ -10412,7 +10455,7 @@ void ASTReader::diagnoseOdrViolations() {
       }
       }
       }
       }
 
 
-      if (Diagnosed == true)
+      if (Diagnosed)
         continue;
         continue;
 
 
       Diag(FirstDecl->getLocation(),
       Diag(FirstDecl->getLocation(),

+ 11 - 0
lib/Serialization/ASTWriter.cpp

@@ -2407,6 +2407,17 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
 
 
   if (PP.isRecordingPreamble() && PP.hasRecordedPreamble()) {
   if (PP.isRecordingPreamble() && PP.hasRecordedPreamble()) {
     assert(!IsModule);
     assert(!IsModule);
+    auto SkipInfo = PP.getPreambleSkipInfo();
+    if (SkipInfo.hasValue()) {
+      Record.push_back(true);
+      AddSourceLocation(SkipInfo->HashTokenLoc, Record);
+      AddSourceLocation(SkipInfo->IfTokenLoc, Record);
+      Record.push_back(SkipInfo->FoundNonSkipPortion);
+      Record.push_back(SkipInfo->FoundElse);
+      AddSourceLocation(SkipInfo->ElseLoc, Record);
+    } else {
+      Record.push_back(false);
+    }
     for (const auto &Cond : PP.getPreambleConditionalStack()) {
     for (const auto &Cond : PP.getPreambleConditionalStack()) {
       AddSourceLocation(Cond.IfLoc, Record);
       AddSourceLocation(Cond.IfLoc, Record);
       Record.push_back(Cond.WasSkipping);
       Record.push_back(Cond.WasSkipping);

+ 18 - 9
lib/Serialization/ASTWriterDecl.cpp

@@ -2258,15 +2258,24 @@ void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) {
   assert(FD->doesThisDeclarationHaveABody());
   assert(FD->doesThisDeclarationHaveABody());
   bool ModulesCodegen = false;
   bool ModulesCodegen = false;
   if (Writer->WritingModule && !FD->isDependentContext()) {
   if (Writer->WritingModule && !FD->isDependentContext()) {
-    // Under -fmodules-codegen, codegen is performed for all defined functions.
-    // When building a C++ Modules TS module interface unit, a strong definition
-    // in the module interface is provided by the compilation of that module
-    // interface unit, not by its users. (Inline functions are still emitted
-    // in module users.)
-    ModulesCodegen =
-        Writer->Context->getLangOpts().ModulesCodegen ||
-        (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit &&
-         Writer->Context->GetGVALinkageForFunction(FD) == GVA_StrongExternal);
+    Optional<GVALinkage> Linkage;
+    if (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
+      // When building a C++ Modules TS module interface unit, a strong
+      // definition in the module interface is provided by the compilation of
+      // that module interface unit, not by its users. (Inline functions are
+      // still emitted in module users.)
+      Linkage = Writer->Context->GetGVALinkageForFunction(FD);
+      ModulesCodegen = *Linkage == GVA_StrongExternal;
+    }
+    if (Writer->Context->getLangOpts().ModulesCodegen) {
+      // Under -fmodules-codegen, codegen is performed for all non-internal,
+      // non-always_inline functions.
+      if (!FD->hasAttr<AlwaysInlineAttr>()) {
+        if (!Linkage)
+          Linkage = Writer->Context->GetGVALinkageForFunction(FD);
+        ModulesCodegen = *Linkage != GVA_Internal;
+      }
+    }
   }
   }
   Record->push_back(ModulesCodegen);
   Record->push_back(ModulesCodegen);
   if (ModulesCodegen)
   if (ModulesCodegen)

+ 41 - 28
lib/Serialization/MultiOnDiskHashTable.h

@@ -1,4 +1,4 @@
-//===--- MultiOnDiskHashTable.h - Merged set of hash tables -----*- C++ -*-===//
+//===- MultiOnDiskHashTable.h - Merged set of hash tables -------*- C++ -*-===//
 //
 //
 //                     The LLVM Compiler Infrastructure
 //                     The LLVM Compiler Infrastructure
 //
 //
@@ -15,6 +15,7 @@
 //  files.
 //  files.
 //
 //
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CLANG_LIB_SERIALIZATION_MULTIONDISKHASHTABLE_H
 #ifndef LLVM_CLANG_LIB_SERIALIZATION_MULTIONDISKHASHTABLE_H
 #define LLVM_CLANG_LIB_SERIALIZATION_MULTIONDISKHASHTABLE_H
 #define LLVM_CLANG_LIB_SERIALIZATION_MULTIONDISKHASHTABLE_H
 
 
@@ -22,33 +23,43 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/ADT/TinyPtrVector.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Endian.h"
 #include "llvm/Support/EndianStream.h"
 #include "llvm/Support/EndianStream.h"
 #include "llvm/Support/OnDiskHashTable.h"
 #include "llvm/Support/OnDiskHashTable.h"
+#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cstdint>
+#include <vector>
 
 
 namespace clang {
 namespace clang {
 namespace serialization {
 namespace serialization {
 
 
-class ModuleFile;
-
 /// \brief A collection of on-disk hash tables, merged when relevant for performance.
 /// \brief A collection of on-disk hash tables, merged when relevant for performance.
 template<typename Info> class MultiOnDiskHashTable {
 template<typename Info> class MultiOnDiskHashTable {
 public:
 public:
   /// A handle to a file, used when overriding tables.
   /// A handle to a file, used when overriding tables.
-  typedef typename Info::file_type file_type;
+  using file_type = typename Info::file_type;
+
   /// A pointer to an on-disk representation of the hash table.
   /// A pointer to an on-disk representation of the hash table.
-  typedef const unsigned char *storage_type;
+  using storage_type = const unsigned char *;
 
 
-  typedef typename Info::external_key_type external_key_type;
-  typedef typename Info::internal_key_type internal_key_type;
-  typedef typename Info::data_type data_type;
-  typedef typename Info::data_type_builder data_type_builder;
-  typedef unsigned hash_value_type;
+  using external_key_type = typename Info::external_key_type;
+  using internal_key_type = typename Info::internal_key_type;
+  using data_type = typename Info::data_type;
+  using data_type_builder = typename Info::data_type_builder;
+  using hash_value_type = unsigned;
 
 
 private:
 private:
+  /// The generator is permitted to read our merged table.
+  template<typename ReaderInfo, typename WriterInfo>
+  friend class MultiOnDiskHashTableGenerator;
+
   /// \brief A hash table stored on disk.
   /// \brief A hash table stored on disk.
   struct OnDiskTable {
   struct OnDiskTable {
-    typedef llvm::OnDiskIterableChainedHashTable<Info> HashTable;
+    using HashTable = llvm::OnDiskIterableChainedHashTable<Info>;
 
 
     file_type File;
     file_type File;
     HashTable Table;
     HashTable Table;
@@ -65,8 +76,8 @@ private:
     llvm::DenseMap<internal_key_type, data_type> Data;
     llvm::DenseMap<internal_key_type, data_type> Data;
   };
   };
 
 
-  typedef llvm::PointerUnion<OnDiskTable*, MergedTable*> Table;
-  typedef llvm::TinyPtrVector<void*> TableVector;
+  using Table = llvm::PointerUnion<OnDiskTable *, MergedTable *>;
+  using TableVector = llvm::TinyPtrVector<void *>;
 
 
   /// \brief The current set of on-disk and merged tables.
   /// \brief The current set of on-disk and merged tables.
   /// We manually store the opaque value of the Table because TinyPtrVector
   /// We manually store the opaque value of the Table because TinyPtrVector
@@ -80,14 +91,16 @@ private:
   llvm::TinyPtrVector<file_type> PendingOverrides;
   llvm::TinyPtrVector<file_type> PendingOverrides;
 
 
   struct AsOnDiskTable {
   struct AsOnDiskTable {
-    typedef OnDiskTable *result_type;
+    using result_type = OnDiskTable *;
+
     result_type operator()(void *P) const {
     result_type operator()(void *P) const {
       return Table::getFromOpaqueValue(P).template get<OnDiskTable *>();
       return Table::getFromOpaqueValue(P).template get<OnDiskTable *>();
     }
     }
   };
   };
-  typedef llvm::mapped_iterator<TableVector::iterator, AsOnDiskTable>
-      table_iterator;
-  typedef llvm::iterator_range<table_iterator> table_range;
+
+  using table_iterator =
+      llvm::mapped_iterator<TableVector::iterator, AsOnDiskTable>;
+  using table_range = llvm::iterator_range<table_iterator>;
 
 
   /// \brief The current set of on-disk tables.
   /// \brief The current set of on-disk tables.
   table_range tables() {
   table_range tables() {
@@ -160,17 +173,15 @@ private:
     Tables.push_back(Table(Merged).getOpaqueValue());
     Tables.push_back(Table(Merged).getOpaqueValue());
   }
   }
 
 
-  /// The generator is permitted to read our merged table.
-  template<typename ReaderInfo, typename WriterInfo>
-  friend class MultiOnDiskHashTableGenerator;
-
 public:
 public:
-  MultiOnDiskHashTable() {}
+  MultiOnDiskHashTable() = default;
+
   MultiOnDiskHashTable(MultiOnDiskHashTable &&O)
   MultiOnDiskHashTable(MultiOnDiskHashTable &&O)
       : Tables(std::move(O.Tables)),
       : Tables(std::move(O.Tables)),
         PendingOverrides(std::move(O.PendingOverrides)) {
         PendingOverrides(std::move(O.PendingOverrides)) {
     O.Tables.clear();
     O.Tables.clear();
   }
   }
+
   MultiOnDiskHashTable &operator=(MultiOnDiskHashTable &&O) {
   MultiOnDiskHashTable &operator=(MultiOnDiskHashTable &&O) {
     if (&O == this)
     if (&O == this)
       return *this;
       return *this;
@@ -180,11 +191,13 @@ public:
     PendingOverrides = std::move(O.PendingOverrides);
     PendingOverrides = std::move(O.PendingOverrides);
     return *this;
     return *this;
   }
   }
+
   ~MultiOnDiskHashTable() { clear(); }
   ~MultiOnDiskHashTable() { clear(); }
 
 
   /// \brief Add the table \p Data loaded from file \p File.
   /// \brief Add the table \p Data loaded from file \p File.
   void add(file_type File, storage_type Data, Info InfoObj = Info()) {
   void add(file_type File, storage_type Data, Info InfoObj = Info()) {
     using namespace llvm::support;
     using namespace llvm::support;
+
     storage_type Ptr = Data;
     storage_type Ptr = Data;
 
 
     uint32_t BucketOffset = endian::readNext<uint32_t, little, unaligned>(Ptr);
     uint32_t BucketOffset = endian::readNext<uint32_t, little, unaligned>(Ptr);
@@ -278,8 +291,8 @@ public:
 /// \brief Writer for the on-disk hash table.
 /// \brief Writer for the on-disk hash table.
 template<typename ReaderInfo, typename WriterInfo>
 template<typename ReaderInfo, typename WriterInfo>
 class MultiOnDiskHashTableGenerator {
 class MultiOnDiskHashTableGenerator {
-  typedef MultiOnDiskHashTable<ReaderInfo> BaseTable;
-  typedef llvm::OnDiskChainedHashTableGenerator<WriterInfo> Generator;
+  using BaseTable = MultiOnDiskHashTable<ReaderInfo>;
+  using Generator = llvm::OnDiskChainedHashTableGenerator<WriterInfo>;
 
 
   Generator Gen;
   Generator Gen;
 
 
@@ -294,6 +307,7 @@ public:
   void emit(llvm::SmallVectorImpl<char> &Out, WriterInfo &Info,
   void emit(llvm::SmallVectorImpl<char> &Out, WriterInfo &Info,
             const BaseTable *Base) {
             const BaseTable *Base) {
     using namespace llvm::support;
     using namespace llvm::support;
+
     llvm::raw_svector_ostream OutStream(Out);
     llvm::raw_svector_ostream OutStream(Out);
 
 
     // Write our header information.
     // Write our header information.
@@ -327,8 +341,7 @@ public:
   }
   }
 };
 };
 
 
-} // end namespace clang::serialization
-} // end namespace clang
-
+} // namespace serialization
+} // namespace clang
 
 
-#endif
+#endif // LLVM_CLANG_LIB_SERIALIZATION_MULTIONDISKHASHTABLE_H

+ 4 - 2
lib/StaticAnalyzer/Checkers/CStringChecker.cpp

@@ -289,8 +289,8 @@ ProgramStateRef CStringChecker::CheckLocation(CheckerContext &C,
   if (!ER)
   if (!ER)
     return state;
     return state;
 
 
-  assert(ER->getValueType() == C.getASTContext().CharTy &&
-    "CheckLocation should only be called with char* ElementRegions");
+  if (ER->getValueType() != C.getASTContext().CharTy)
+    return state;
 
 
   // Get the size of the array.
   // Get the size of the array.
   const SubRegion *superReg = cast<SubRegion>(ER->getSuperRegion());
   const SubRegion *superReg = cast<SubRegion>(ER->getSuperRegion());
@@ -874,6 +874,8 @@ bool CStringChecker::IsFirstBufInBound(CheckerContext &C,
   if (!ER)
   if (!ER)
     return true; // cf top comment.
     return true; // cf top comment.
 
 
+  // FIXME: Does this crash when a non-standard definition
+  // of a library function is encountered?
   assert(ER->getValueType() == C.getASTContext().CharTy &&
   assert(ER->getValueType() == C.getASTContext().CharTy &&
          "IsFirstBufInBound should only be called with char* ElementRegions");
          "IsFirstBufInBound should only be called with char* ElementRegions");
 
 

+ 12 - 4
lib/StaticAnalyzer/Core/ExprEngineC.cpp

@@ -92,12 +92,10 @@ void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
       // Process non-assignments except commas or short-circuited
       // Process non-assignments except commas or short-circuited
       // logical expressions (LAnd and LOr).
       // logical expressions (LAnd and LOr).
       SVal Result = evalBinOp(state, Op, LeftV, RightV, B->getType());
       SVal Result = evalBinOp(state, Op, LeftV, RightV, B->getType());
-      if (Result.isUnknown()) {
-        Bldr.generateNode(B, *it, state);
-        continue;
+      if (!Result.isUnknown()) {
+        state = state->BindExpr(B, LCtx, Result);
       }
       }
 
 
-      state = state->BindExpr(B, LCtx, Result);
       Bldr.generateNode(B, *it, state);
       Bldr.generateNode(B, *it, state);
       continue;
       continue;
     }
     }
@@ -628,6 +626,16 @@ void ExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred,
   StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
   StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
   ProgramStateRef state = Pred->getState();
   ProgramStateRef state = Pred->getState();
 
 
+  if (B->getType()->isVectorType()) {
+    // FIXME: We do not model vector arithmetic yet. When adding support for
+    // that, note that the CFG-based reasoning below does not apply, because
+    // logical operators on vectors are not short-circuit. Currently they are
+    // modeled as short-circuit in Clang CFG but this is incorrect.
+    // Do not set the value for the expression. It'd be UnknownVal by default.
+    Bldr.generateNode(B, Pred, state);
+    return;
+  }
+
   ExplodedNode *N = Pred;
   ExplodedNode *N = Pred;
   while (!N->getLocation().getAs<BlockEntrance>()) {
   while (!N->getLocation().getAs<BlockEntrance>()) {
     ProgramPoint P = N->getLocation();
     ProgramPoint P = N->getLocation();

+ 0 - 1
lib/Tooling/Core/CMakeLists.txt

@@ -3,7 +3,6 @@ set(LLVM_LINK_COMPONENTS support)
 add_clang_library(clangToolingCore
 add_clang_library(clangToolingCore
   Lookup.cpp
   Lookup.cpp
   Replacement.cpp
   Replacement.cpp
-  QualTypeNames.cpp
   Diagnostic.cpp
   Diagnostic.cpp
 
 
   LINK_LIBS
   LINK_LIBS

+ 20 - 4
lib/Tooling/Execution.cpp

@@ -54,13 +54,14 @@ llvm::Error ToolExecutor::execute(std::unique_ptr<FrontendActionFactory> Action,
   return execute(Actions);
   return execute(Actions);
 }
 }
 
 
+namespace internal {
 llvm::Expected<std::unique_ptr<ToolExecutor>>
 llvm::Expected<std::unique_ptr<ToolExecutor>>
-createExecutorFromCommandLineArgs(int &argc, const char **argv,
-                                  llvm::cl::OptionCategory &Category,
-                                  const char *Overview) {
+createExecutorFromCommandLineArgsImpl(int &argc, const char **argv,
+                                      llvm::cl::OptionCategory &Category,
+                                      const char *Overview) {
   auto OptionsParser =
   auto OptionsParser =
       CommonOptionsParser::create(argc, argv, Category, llvm::cl::ZeroOrMore,
       CommonOptionsParser::create(argc, argv, Category, llvm::cl::ZeroOrMore,
-                                  /*Overview=*/nullptr);
+                                  /*Overview=*/Overview);
   if (!OptionsParser)
   if (!OptionsParser)
     return OptionsParser.takeError();
     return OptionsParser.takeError();
   for (auto I = ToolExecutorPluginRegistry::begin(),
   for (auto I = ToolExecutorPluginRegistry::begin(),
@@ -84,6 +85,21 @@ createExecutorFromCommandLineArgs(int &argc, const char **argv,
       llvm::Twine("Executor \"") + ExecutorName + "\" is not registered.",
       llvm::Twine("Executor \"") + ExecutorName + "\" is not registered.",
       llvm::inconvertibleErrorCode());
       llvm::inconvertibleErrorCode());
 }
 }
+} // end namespace internal
+
+llvm::Expected<std::unique_ptr<ToolExecutor>>
+createExecutorFromCommandLineArgs(int &argc, const char **argv,
+                                  llvm::cl::OptionCategory &Category,
+                                  const char *Overview) {
+  return internal::createExecutorFromCommandLineArgsImpl(argc, argv, Category,
+                                                         Overview);
+}
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the StandaloneToolExecutorPlugin.
+extern volatile int StandaloneToolExecutorAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED StandaloneToolExecutorAnchorDest =
+    StandaloneToolExecutorAnchorSource;
 
 
 } // end namespace tooling
 } // end namespace tooling
 } // end namespace clang
 } // end namespace clang

+ 22 - 1
lib/Tooling/Refactoring/ASTSelection.cpp

@@ -249,9 +249,30 @@ struct SelectedNodeWithParents {
   SelectedNodeWithParents &operator=(SelectedNodeWithParents &&) = default;
   SelectedNodeWithParents &operator=(SelectedNodeWithParents &&) = default;
   SelectedASTNode::ReferenceType Node;
   SelectedASTNode::ReferenceType Node;
   llvm::SmallVector<SelectedASTNode::ReferenceType, 8> Parents;
   llvm::SmallVector<SelectedASTNode::ReferenceType, 8> Parents;
+
+  /// Canonicalizes the given selection by selecting different related AST nodes
+  /// when it makes sense to do so.
+  void canonicalize();
 };
 };
 } // end anonymous namespace
 } // end anonymous namespace
 
 
+void SelectedNodeWithParents::canonicalize() {
+  const Stmt *S = Node.get().Node.get<Stmt>();
+  assert(S && "non statement selection!");
+  const Stmt *Parent = Parents[Parents.size() - 1].get().Node.get<Stmt>();
+  if (!Parent)
+    return;
+  // Select the parent expression when:
+  // - The string literal in ObjC string literal is selected, e.g.:
+  //     @"test"   becomes   @"test"
+  //      ~~~~~~             ~~~~~~~
+  if (isa<StringLiteral>(S) && isa<ObjCStringLiteral>(Parent))
+    Node = Parents.pop_back_val();
+  // FIXME: Syntactic form -> Entire pseudo-object expr.
+  // FIXME: Callee -> Call.
+  // FIXME: Callee member expr -> Call.
+}
+
 /// Finds the set of bottom-most selected AST nodes that are in the selection
 /// Finds the set of bottom-most selected AST nodes that are in the selection
 /// tree with the specified selection kind.
 /// tree with the specified selection kind.
 ///
 ///
@@ -330,7 +351,7 @@ CodeRangeASTSelection::create(SourceRange SelectionRange,
     return None;
     return None;
   const Stmt *CodeRangeStmt = Selected.Node.get().Node.get<Stmt>();
   const Stmt *CodeRangeStmt = Selected.Node.get().Node.get<Stmt>();
   if (!isa<CompoundStmt>(CodeRangeStmt)) {
   if (!isa<CompoundStmt>(CodeRangeStmt)) {
-    // FIXME (Alex L): Canonicalize.
+    Selected.canonicalize();
     return CodeRangeASTSelection(Selected.Node, Selected.Parents,
     return CodeRangeASTSelection(Selected.Node, Selected.Parents,
                                  /*AreChildrenSelected=*/false);
                                  /*AreChildrenSelected=*/false);
   }
   }

+ 2 - 1
lib/Tooling/Refactoring/CMakeLists.txt

@@ -4,7 +4,8 @@ add_clang_library(clangToolingRefactor
   ASTSelection.cpp
   ASTSelection.cpp
   ASTSelectionRequirements.cpp
   ASTSelectionRequirements.cpp
   AtomicChange.cpp
   AtomicChange.cpp
-  Extract.cpp
+  Extract/Extract.cpp
+  Extract/SourceExtraction.cpp
   RefactoringActions.cpp
   RefactoringActions.cpp
   Rename/RenamingAction.cpp
   Rename/RenamingAction.cpp
   Rename/SymbolOccurrences.cpp
   Rename/SymbolOccurrences.cpp

+ 7 - 3
lib/Tooling/Refactoring/Extract.cpp → lib/Tooling/Refactoring/Extract/Extract.cpp

@@ -14,6 +14,7 @@
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
 #include "clang/Tooling/Refactoring/Extract/Extract.h"
 #include "clang/Tooling/Refactoring/Extract/Extract.h"
+#include "SourceExtraction.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Expr.h"
@@ -145,6 +146,8 @@ ExtractFunction::createSourceReplacements(RefactoringRuleContext &Context) {
   PP.SuppressLifetimeQualifiers = true;
   PP.SuppressLifetimeQualifiers = true;
   PP.SuppressUnwrittenScope = true;
   PP.SuppressUnwrittenScope = true;
 
 
+  ExtractionSemicolonPolicy Semicolons = ExtractionSemicolonPolicy::compute(
+      Code[Code.size() - 1], ExtractedRange, SM, LangOpts);
   AtomicChange Change(SM, ExtractedDeclLocation);
   AtomicChange Change(SM, ExtractedDeclLocation);
   // Create the replacement for the extracted declaration.
   // Create the replacement for the extracted declaration.
   {
   {
@@ -162,8 +165,8 @@ ExtractFunction::createSourceReplacements(RefactoringRuleContext &Context) {
     if (IsExpr && !ReturnType->isVoidType())
     if (IsExpr && !ReturnType->isVoidType())
       OS << "return ";
       OS << "return ";
     OS << ExtractedCodeRewriter.getRewrittenText(ExtractedRange);
     OS << ExtractedCodeRewriter.getRewrittenText(ExtractedRange);
-    // FIXME: Compute the correct semicolon policy.
-    OS << ';';
+    if (Semicolons.isNeededInExtractedFunction())
+      OS << ';';
     OS << "\n}\n\n";
     OS << "\n}\n\n";
     auto Err = Change.insert(SM, ExtractedDeclLocation, OS.str());
     auto Err = Change.insert(SM, ExtractedDeclLocation, OS.str());
     if (Err)
     if (Err)
@@ -178,7 +181,8 @@ ExtractFunction::createSourceReplacements(RefactoringRuleContext &Context) {
     OS << DeclName << '(';
     OS << DeclName << '(';
     // FIXME: Forward arguments.
     // FIXME: Forward arguments.
     OS << ')';
     OS << ')';
-    // FIXME: Add semicolon if needed.
+    if (Semicolons.isNeededInOriginalFunction())
+      OS << ';';
 
 
     auto Err = Change.replace(
     auto Err = Change.replace(
         SM, CharSourceRange::getTokenRange(ExtractedRange), OS.str());
         SM, CharSourceRange::getTokenRange(ExtractedRange), OS.str());

+ 112 - 0
lib/Tooling/Refactoring/Extract/SourceExtraction.cpp

@@ -0,0 +1,112 @@
+//===--- SourceExtraction.cpp - Clang refactoring library -----------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "SourceExtraction.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/StmtCXX.h"
+#include "clang/AST/StmtObjC.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang;
+
+namespace {
+
+/// Returns true if the token at the given location is a semicolon.
+bool isSemicolonAtLocation(SourceLocation TokenLoc, const SourceManager &SM,
+                           const LangOptions &LangOpts) {
+  return Lexer::getSourceText(
+             CharSourceRange::getTokenRange(TokenLoc, TokenLoc), SM,
+             LangOpts) == ";";
+}
+
+/// Returns true if there should be a semicolon after the given statement.
+bool isSemicolonRequiredAfter(const Stmt *S) {
+  if (isa<CompoundStmt>(S))
+    return false;
+  if (const auto *If = dyn_cast<IfStmt>(S))
+    return isSemicolonRequiredAfter(If->getElse() ? If->getElse()
+                                                  : If->getThen());
+  if (const auto *While = dyn_cast<WhileStmt>(S))
+    return isSemicolonRequiredAfter(While->getBody());
+  if (const auto *For = dyn_cast<ForStmt>(S))
+    return isSemicolonRequiredAfter(For->getBody());
+  if (const auto *CXXFor = dyn_cast<CXXForRangeStmt>(S))
+    return isSemicolonRequiredAfter(CXXFor->getBody());
+  if (const auto *ObjCFor = dyn_cast<ObjCForCollectionStmt>(S))
+    return isSemicolonRequiredAfter(ObjCFor->getBody());
+  switch (S->getStmtClass()) {
+  case Stmt::SwitchStmtClass:
+  case Stmt::CXXTryStmtClass:
+  case Stmt::ObjCAtSynchronizedStmtClass:
+  case Stmt::ObjCAutoreleasePoolStmtClass:
+  case Stmt::ObjCAtTryStmtClass:
+    return false;
+  default:
+    return true;
+  }
+}
+
+/// Returns true if the two source locations are on the same line.
+bool areOnSameLine(SourceLocation Loc1, SourceLocation Loc2,
+                   const SourceManager &SM) {
+  return !Loc1.isMacroID() && !Loc2.isMacroID() &&
+         SM.getSpellingLineNumber(Loc1) == SM.getSpellingLineNumber(Loc2);
+}
+
+} // end anonymous namespace
+
+namespace clang {
+namespace tooling {
+
+ExtractionSemicolonPolicy
+ExtractionSemicolonPolicy::compute(const Stmt *S, SourceRange &ExtractedRange,
+                                   const SourceManager &SM,
+                                   const LangOptions &LangOpts) {
+  auto neededInExtractedFunction = []() {
+    return ExtractionSemicolonPolicy(true, false);
+  };
+  auto neededInOriginalFunction = []() {
+    return ExtractionSemicolonPolicy(false, true);
+  };
+
+  /// The extracted expression should be terminated with a ';'. The call to
+  /// the extracted function will replace this expression, so it won't need
+  /// a terminating ';'.
+  if (isa<Expr>(S))
+    return neededInExtractedFunction();
+
+  /// Some statements don't need to be terminated with ';'. The call to the
+  /// extracted function will be a standalone statement, so it should be
+  /// terminated with a ';'.
+  bool NeedsSemi = isSemicolonRequiredAfter(S);
+  if (!NeedsSemi)
+    return neededInOriginalFunction();
+
+  /// Some statements might end at ';'. The extraction will move that ';', so
+  /// the call to the extracted function should be terminated with a ';'.
+  SourceLocation End = ExtractedRange.getEnd();
+  if (isSemicolonAtLocation(End, SM, LangOpts))
+    return neededInOriginalFunction();
+
+  /// Other statements should generally have a trailing ';'. We can try to find
+  /// it and move it together it with the extracted code.
+  Optional<Token> NextToken = Lexer::findNextToken(End, SM, LangOpts);
+  if (NextToken && NextToken->is(tok::semi) &&
+      areOnSameLine(NextToken->getLocation(), End, SM)) {
+    ExtractedRange.setEnd(NextToken->getLocation());
+    return neededInOriginalFunction();
+  }
+
+  /// Otherwise insert semicolons in both places.
+  return ExtractionSemicolonPolicy(true, true);
+}
+
+} // end namespace tooling
+} // end namespace clang

+ 52 - 0
lib/Tooling/Refactoring/Extract/SourceExtraction.h

@@ -0,0 +1,52 @@
+//===--- SourceExtraction.cpp - Clang refactoring library -----------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_TOOLING_REFACTORING_EXTRACT_SOURCE_EXTRACTION_H
+#define LLVM_CLANG_LIB_TOOLING_REFACTORING_EXTRACT_SOURCE_EXTRACTION_H
+
+#include "clang/Basic/LLVM.h"
+
+namespace clang {
+
+class LangOptions;
+class SourceManager;
+class SourceRange;
+class Stmt;
+
+namespace tooling {
+
+/// Determines which semicolons should be inserted during extraction.
+class ExtractionSemicolonPolicy {
+public:
+  bool isNeededInExtractedFunction() const {
+    return IsNeededInExtractedFunction;
+  }
+
+  bool isNeededInOriginalFunction() const { return IsNeededInOriginalFunction; }
+
+  /// Returns the semicolon insertion policy that is needed for extraction of
+  /// the given statement from the given source range.
+  static ExtractionSemicolonPolicy compute(const Stmt *S,
+                                           SourceRange &ExtractedRange,
+                                           const SourceManager &SM,
+                                           const LangOptions &LangOpts);
+
+private:
+  ExtractionSemicolonPolicy(bool IsNeededInExtractedFunction,
+                            bool IsNeededInOriginalFunction)
+      : IsNeededInExtractedFunction(IsNeededInExtractedFunction),
+        IsNeededInOriginalFunction(IsNeededInOriginalFunction) {}
+  bool IsNeededInExtractedFunction;
+  bool IsNeededInOriginalFunction;
+};
+
+} // end namespace tooling
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_TOOLING_REFACTORING_EXTRACT_SOURCE_EXTRACTION_H

+ 20 - 0
lib/Tooling/Refactoring/RefactoringActions.cpp

@@ -46,6 +46,22 @@ public:
   }
   }
 };
 };
 
 
+class OldQualifiedNameOption : public RequiredRefactoringOption<std::string> {
+public:
+  StringRef getName() const override { return "old-qualified-name"; }
+  StringRef getDescription() const override {
+    return "The old qualified name to be renamed";
+  }
+};
+
+class NewQualifiedNameOption : public RequiredRefactoringOption<std::string> {
+public:
+  StringRef getName() const override { return "new-qualified-name"; }
+  StringRef getDescription() const override {
+    return "The new qualified name to change the symbol to";
+  }
+};
+
 class NewNameOption : public RequiredRefactoringOption<std::string> {
 class NewNameOption : public RequiredRefactoringOption<std::string> {
 public:
 public:
   StringRef getName() const override { return "new-name"; }
   StringRef getName() const override { return "new-name"; }
@@ -70,6 +86,10 @@ public:
     RefactoringActionRules Rules;
     RefactoringActionRules Rules;
     Rules.push_back(createRefactoringActionRule<RenameOccurrences>(
     Rules.push_back(createRefactoringActionRule<RenameOccurrences>(
         SourceRangeSelectionRequirement(), OptionRequirement<NewNameOption>()));
         SourceRangeSelectionRequirement(), OptionRequirement<NewNameOption>()));
+    // FIXME: Use NewNameOption.
+    Rules.push_back(createRefactoringActionRule<QualifiedRenameRule>(
+        OptionRequirement<OldQualifiedNameOption>(),
+        OptionRequirement<NewQualifiedNameOption>()));
     return Rules;
     return Rules;
   }
   }
 };
 };

+ 65 - 18
lib/Tooling/Refactoring/Rename/RenamingAction.cpp

@@ -31,6 +31,8 @@
 #include "clang/Tooling/Refactoring/Rename/USRLocFinder.h"
 #include "clang/Tooling/Refactoring/Rename/USRLocFinder.h"
 #include "clang/Tooling/Tooling.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 
 
@@ -41,22 +43,14 @@ namespace tooling {
 
 
 namespace {
 namespace {
 
 
-class OccurrenceFinder final : public FindSymbolOccurrencesRefactoringRule {
-public:
-  OccurrenceFinder(const NamedDecl *ND) : ND(ND) {}
-
-  Expected<SymbolOccurrences>
-  findSymbolOccurrences(RefactoringRuleContext &Context) override {
-    std::vector<std::string> USRs =
-        getUSRsForDeclaration(ND, Context.getASTContext());
-    std::string PrevName = ND->getNameAsString();
-    return getOccurrencesOfUSRs(
-        USRs, PrevName, Context.getASTContext().getTranslationUnitDecl());
-  }
-
-private:
-  const NamedDecl *ND;
-};
+Expected<SymbolOccurrences>
+findSymbolOccurrences(const NamedDecl *ND, RefactoringRuleContext &Context) {
+  std::vector<std::string> USRs =
+      getUSRsForDeclaration(ND, Context.getASTContext());
+  std::string PrevName = ND->getNameAsString();
+  return getOccurrencesOfUSRs(USRs, PrevName,
+                              Context.getASTContext().getTranslationUnitDecl());
+}
 
 
 } // end anonymous namespace
 } // end anonymous namespace
 
 
@@ -83,8 +77,7 @@ RenameOccurrences::initiate(RefactoringRuleContext &Context,
 
 
 Expected<AtomicChanges>
 Expected<AtomicChanges>
 RenameOccurrences::createSourceReplacements(RefactoringRuleContext &Context) {
 RenameOccurrences::createSourceReplacements(RefactoringRuleContext &Context) {
-  Expected<SymbolOccurrences> Occurrences =
-      OccurrenceFinder(ND).findSymbolOccurrences(Context);
+  Expected<SymbolOccurrences> Occurrences = findSymbolOccurrences(ND, Context);
   if (!Occurrences)
   if (!Occurrences)
     return Occurrences.takeError();
     return Occurrences.takeError();
   // FIXME: Verify that the new name is valid.
   // FIXME: Verify that the new name is valid.
@@ -93,6 +86,60 @@ RenameOccurrences::createSourceReplacements(RefactoringRuleContext &Context) {
       *Occurrences, Context.getASTContext().getSourceManager(), Name);
       *Occurrences, Context.getASTContext().getSourceManager(), Name);
 }
 }
 
 
+Expected<QualifiedRenameRule>
+QualifiedRenameRule::initiate(RefactoringRuleContext &Context,
+                              std::string OldQualifiedName,
+                              std::string NewQualifiedName) {
+  const NamedDecl *ND =
+      getNamedDeclFor(Context.getASTContext(), OldQualifiedName);
+  if (!ND)
+    return llvm::make_error<llvm::StringError>("Could not find symbol " +
+                                                   OldQualifiedName,
+                                               llvm::errc::invalid_argument);
+  return QualifiedRenameRule(ND, std::move(NewQualifiedName));
+}
+
+const RefactoringDescriptor &QualifiedRenameRule::describe() {
+  static const RefactoringDescriptor Descriptor = {
+      /*Name=*/"local-qualified-rename",
+      /*Title=*/"Qualified Rename",
+      /*Description=*/
+      R"(Finds and renames qualified symbols in code within a translation unit.
+It is used to move/rename a symbol to a new namespace/name:
+  * Supported symbols: classes, class members, functions, enums, and type alias.
+  * Renames all symbol occurrences from the old qualified name to the new
+    qualified name. All symbol references will be correctly qualified; For
+    symbol definitions, only name will be changed.
+For example, rename "A::Foo" to "B::Bar":
+  Old code:
+    namespace foo {
+    class A {};
+    }
+
+    namespace bar {
+    void f(foo::A a) {}
+    }
+
+  New code after rename:
+    namespace foo {
+    class B {};
+    }
+
+    namespace bar {
+    void f(B b) {}
+    })"
+  };
+  return Descriptor;
+}
+
+Expected<AtomicChanges>
+QualifiedRenameRule::createSourceReplacements(RefactoringRuleContext &Context) {
+  auto USRs = getUSRsForDeclaration(ND, Context.getASTContext());
+  assert(!USRs.empty());
+  return tooling::createRenameAtomicChanges(
+      USRs, NewQualifiedName, Context.getASTContext().getTranslationUnitDecl());
+}
+
 Expected<std::vector<AtomicChange>>
 Expected<std::vector<AtomicChange>>
 createRenameReplacements(const SymbolOccurrences &Occurrences,
 createRenameReplacements(const SymbolOccurrences &Occurrences,
                          const SourceManager &SM, const SymbolName &NewName) {
                          const SourceManager &SM, const SymbolName &NewName) {

+ 4 - 4
lib/Tooling/StandaloneExecution.cpp

@@ -79,13 +79,13 @@ public:
   }
   }
 };
 };
 
 
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the plugin.
-volatile int ToolExecutorPluginAnchorSource = 0;
-
 static ToolExecutorPluginRegistry::Add<StandaloneToolExecutorPlugin>
 static ToolExecutorPluginRegistry::Add<StandaloneToolExecutorPlugin>
     X("standalone", "Runs FrontendActions on a set of files provided "
     X("standalone", "Runs FrontendActions on a set of files provided "
                     "via positional arguments.");
                     "via positional arguments.");
 
 
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the plugin.
+volatile int StandaloneToolExecutorAnchorSource = 0;
+
 } // end namespace tooling
 } // end namespace tooling
 } // end namespace clang
 } // end namespace clang

+ 56 - 0
test/Analysis/call_once.cpp

@@ -1,6 +1,11 @@
 // RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -verify %s
 // RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -verify %s
 // RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBSTDCPP -verify %s
 // RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBSTDCPP -verify %s
 
 
+// We do NOT model libcxx03 implementation, but the analyzer should still
+// not crash.
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBCXX03 -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -analyzer-checker=core,debug.ExprInspection -DEMULATE_LIBCXX03 -DEMULATE_LIBSTDCPP -verify %s
+
 void clang_analyzer_eval(bool);
 void clang_analyzer_eval(bool);
 
 
 // Faking std::std::call_once implementation.
 // Faking std::std::call_once implementation.
@@ -16,8 +21,13 @@ typedef struct once_flag_s {
 } once_flag;
 } once_flag;
 #endif
 #endif
 
 
+#ifndef EMULATE_LIBCXX03
 template <class Callable, class... Args>
 template <class Callable, class... Args>
 void call_once(once_flag &o, Callable&& func, Args&&... args) {};
 void call_once(once_flag &o, Callable&& func, Args&&... args) {};
+#else
+template <class Callable, class... Args> // libcxx03 call_once
+void call_once(once_flag &o, Callable func, Args&&... args) {};
+#endif
 
 
 } // namespace std
 } // namespace std
 
 
@@ -28,7 +38,9 @@ void test_called_warning() {
 
 
   std::call_once(g_initialize, [&] {
   std::call_once(g_initialize, [&] {
     int *x = nullptr;
     int *x = nullptr;
+#ifndef EMULATE_LIBCXX03
     int y = *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
     int y = *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+#endif
     z = 200;
     z = 200;
   });
   });
 }
 }
@@ -45,8 +57,10 @@ void test_called_on_path_inside_no_warning() {
     x = &z;
     x = &z;
   });
   });
 
 
+#ifndef EMULATE_LIBCXX03
   *x = 100; // no-warning
   *x = 100; // no-warning
   clang_analyzer_eval(z == 100); // expected-warning{{TRUE}}
   clang_analyzer_eval(z == 100); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 void test_called_on_path_no_warning() {
 void test_called_on_path_no_warning() {
@@ -59,7 +73,11 @@ void test_called_on_path_no_warning() {
     x = &y;
     x = &y;
   });
   });
 
 
+#ifndef EMULATE_LIBCXX03
   *x = 100; // no-warning
   *x = 100; // no-warning
+#else
+  *x = 100; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+#endif
 }
 }
 
 
 void test_called_on_path_warning() {
 void test_called_on_path_warning() {
@@ -72,7 +90,9 @@ void test_called_on_path_warning() {
     x = nullptr;
     x = nullptr;
   });
   });
 
 
+#ifndef EMULATE_LIBCXX03
   *x = 100; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
   *x = 100; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+#endif
 }
 }
 
 
 void test_called_once_warning() {
 void test_called_once_warning() {
@@ -89,7 +109,9 @@ void test_called_once_warning() {
     x = &y;
     x = &y;
   });
   });
 
 
+#ifndef EMULATE_LIBCXX03
   *x = 100; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
   *x = 100; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+#endif
 }
 }
 
 
 void test_called_once_no_warning() {
 void test_called_once_no_warning() {
@@ -106,7 +128,9 @@ void test_called_once_no_warning() {
     x = nullptr;
     x = nullptr;
   });
   });
 
 
+#ifndef EMULATE_LIBCXX03
   *x = 100; // no-warning
   *x = 100; // no-warning
+#endif
 }
 }
 
 
 static int global = 0;
 static int global = 0;
@@ -117,7 +141,9 @@ void funcPointer() {
 void test_func_pointers() {
 void test_func_pointers() {
   static std::once_flag flag;
   static std::once_flag flag;
   std::call_once(flag, &funcPointer);
   std::call_once(flag, &funcPointer);
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(global == 1); // expected-warning{{TRUE}}
   clang_analyzer_eval(global == 1); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 template <class _Fp>
 template <class _Fp>
@@ -157,7 +183,9 @@ void test_param_passing_lambda() {
   },
   },
                  x);
                  x);
 
 
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(y == 120); // expected-warning{{TRUE}}
   clang_analyzer_eval(y == 120); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 void test_param_passing_lambda_false() {
 void test_param_passing_lambda_false() {
@@ -169,7 +197,9 @@ void test_param_passing_lambda_false() {
   },
   },
                  x);
                  x);
 
 
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(x == 120); // expected-warning{{FALSE}}
   clang_analyzer_eval(x == 120); // expected-warning{{FALSE}}
+#endif
 }
 }
 
 
 void test_param_passing_stored_lambda() {
 void test_param_passing_stored_lambda() {
@@ -182,7 +212,9 @@ void test_param_passing_stored_lambda() {
   };
   };
 
 
   std::call_once(flag, lambda, x);
   std::call_once(flag, lambda, x);
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(y == 120); // expected-warning{{TRUE}}
   clang_analyzer_eval(y == 120); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 void test_multiparam_passing_lambda() {
 void test_multiparam_passing_lambda() {
@@ -194,8 +226,10 @@ void test_multiparam_passing_lambda() {
   },
   },
                  1, 2, 3);
                  1, 2, 3);
 
 
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(x == 120); // expected-warning{{FALSE}}
   clang_analyzer_eval(x == 120); // expected-warning{{FALSE}}
   clang_analyzer_eval(x == 6); // expected-warning{{TRUE}}
   clang_analyzer_eval(x == 6); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 static int global2 = 0;
 static int global2 = 0;
@@ -206,7 +240,9 @@ void test_param_passing_lambda_global() {
     global2 = a + b + c;
     global2 = a + b + c;
   },
   },
                  1, 2, 3);
                  1, 2, 3);
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(global2 == 6); // expected-warning{{TRUE}}
   clang_analyzer_eval(global2 == 6); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 static int global3 = 0;
 static int global3 = 0;
@@ -220,7 +256,9 @@ void test_param_passing_funcptr() {
 
 
   std::call_once(flag, &funcptr, 1, 2, 3);
   std::call_once(flag, &funcptr, 1, 2, 3);
 
 
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(global3 == 6); // expected-warning{{TRUE}}
   clang_analyzer_eval(global3 == 6); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 void test_blocks() {
 void test_blocks() {
@@ -229,7 +267,9 @@ void test_blocks() {
   std::call_once(flag, ^{
   std::call_once(flag, ^{
     global3 = 120;
     global3 = 120;
   });
   });
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(global3 == 120); // expected-warning{{TRUE}}
   clang_analyzer_eval(global3 == 120); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 int call_once() {
 int call_once() {
@@ -238,7 +278,9 @@ int call_once() {
 
 
 void test_non_std_call_once() {
 void test_non_std_call_once() {
   int x = call_once();
   int x = call_once();
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 namespace std {
 namespace std {
@@ -247,28 +289,36 @@ void call_once(d, e);
 }
 }
 void g();
 void g();
 void test_no_segfault_on_different_impl() {
 void test_no_segfault_on_different_impl() {
+#ifndef EMULATE_LIBCXX03
   std::call_once(g, false); // no-warning
   std::call_once(g, false); // no-warning
+#endif
 }
 }
 
 
 void test_lambda_refcapture() {
 void test_lambda_refcapture() {
   static std::once_flag flag;
   static std::once_flag flag;
   int a = 6;
   int a = 6;
   std::call_once(flag, [&](int &a) { a = 42; }, a);
   std::call_once(flag, [&](int &a) { a = 42; }, a);
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(a == 42); // expected-warning{{TRUE}}
   clang_analyzer_eval(a == 42); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 void test_lambda_refcapture2() {
 void test_lambda_refcapture2() {
   static std::once_flag flag;
   static std::once_flag flag;
   int a = 6;
   int a = 6;
   std::call_once(flag, [=](int &a) { a = 42; }, a);
   std::call_once(flag, [=](int &a) { a = 42; }, a);
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(a == 42); // expected-warning{{TRUE}}
   clang_analyzer_eval(a == 42); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 void test_lambda_fail_refcapture() {
 void test_lambda_fail_refcapture() {
   static std::once_flag flag;
   static std::once_flag flag;
   int a = 6;
   int a = 6;
   std::call_once(flag, [=](int a) { a = 42; }, a);
   std::call_once(flag, [=](int a) { a = 42; }, a);
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(a == 42); // expected-warning{{FALSE}}
   clang_analyzer_eval(a == 42); // expected-warning{{FALSE}}
+#endif
 }
 }
 
 
 void mutator(int &param) {
 void mutator(int &param) {
@@ -278,7 +328,9 @@ void test_reftypes_funcptr() {
   static std::once_flag flag;
   static std::once_flag flag;
   int a = 6;
   int a = 6;
   std::call_once(flag, &mutator, a);
   std::call_once(flag, &mutator, a);
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(a == 42); // expected-warning{{TRUE}}
   clang_analyzer_eval(a == 42); // expected-warning{{TRUE}}
+#endif
 }
 }
 
 
 void fail_mutator(int param) {
 void fail_mutator(int param) {
@@ -288,7 +340,9 @@ void test_mutator_noref() {
   static std::once_flag flag;
   static std::once_flag flag;
   int a = 6;
   int a = 6;
   std::call_once(flag, &fail_mutator, a);
   std::call_once(flag, &fail_mutator, a);
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(a == 42); // expected-warning{{FALSE}}
   clang_analyzer_eval(a == 42); // expected-warning{{FALSE}}
+#endif
 }
 }
 
 
 // Function is implicitly treated as a function pointer
 // Function is implicitly treated as a function pointer
@@ -301,5 +355,7 @@ void test_implicit_funcptr() {
   static std::once_flag flagn;
   static std::once_flag flagn;
 
 
   std::call_once(flagn, callbackn, x);
   std::call_once(flagn, callbackn, x);
+#ifndef EMULATE_LIBCXX03
   clang_analyzer_eval(x == 42); // expected-warning{{TRUE}}
   clang_analyzer_eval(x == 42); // expected-warning{{TRUE}}
+#endif
 }
 }

+ 10 - 0
test/Analysis/string-with-signedness.c

@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -Wno-incompatible-library-redeclaration -analyzer-checker=core,unix.cstring,alpha.unix.cstring -verify %s
+
+// expected-no-diagnostics
+
+void *strcpy(unsigned char *, unsigned char *);
+
+unsigned char a, b;
+void testUnsignedStrcpy() {
+  strcpy(&a, &b);
+}

File diff suppressed because it is too large
+ 161 - 131
test/Analysis/unix-fns.c


+ 28 - 0
test/Analysis/vector.c

@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+typedef int __attribute__((ext_vector_type(2))) V;
+
+void clang_analyzer_numTimesReached();
+void clang_analyzer_eval(int);
+
+int flag;
+
+V pass_through_and_set_flag(V v) {
+  flag = 1;
+  return v;
+}
+
+V dont_crash_and_dont_split_state(V x, V y) {
+  flag = 0;
+  V z = x && pass_through_and_set_flag(y);
+  clang_analyzer_eval(flag); // expected-warning{{TRUE}}
+  // FIXME: For now we treat vector operator && as short-circuit,
+  // but in fact it is not. It should always evaluate
+  // pass_through_and_set_flag(). It should not split state.
+  // Now we also get FALSE on the other path.
+  // expected-warning@-5{{FALSE}}
+
+  // FIXME: Should be 1 since we should not split state.
+  clang_analyzer_numTimesReached(); // expected-warning{{2}}
+  return z;
+}

+ 2 - 2
test/CodeCompletion/call.cpp

@@ -19,10 +19,10 @@ void test() {
   f(Y(), 0, 0);
   f(Y(), 0, 0);
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
   // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
-  // CHECK-CC1: f(N::Y y, <#int ZZ#>)
+  // CHECK-CC1: f(Y y, <#int ZZ#>)
   // CHECK-CC1-NEXT: f(int i, <#int j#>, int k)
   // CHECK-CC1-NEXT: f(int i, <#int j#>, int k)
   // CHECK-CC1-NEXT: f(float x, <#float y#>)
   // CHECK-CC1-NEXT: f(float x, <#float y#>)
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-  // CHECK-CC2-NOT: f(N::Y y, int ZZ)
+  // CHECK-CC2-NOT: f(Y y, int ZZ)
   // CHECK-CC2: f(int i, int j, <#int k#>)
   // CHECK-CC2: f(int i, int j, <#int k#>)
 }
 }

+ 31 - 0
test/CodeCompletion/qualifiers-as-written.cpp

@@ -0,0 +1,31 @@
+struct foo {
+  typedef int type;
+
+  type method(type, foo::type, ::foo::type, ::foo::foo::type);
+};
+
+namespace ns {
+  struct bar {
+  };
+
+  struct baz {
+  };
+
+  int func(foo::type a, bar b, baz c);
+}
+
+typedef ns::bar bar;
+
+int func(foo a, bar b, ns::bar c, ns::baz d);
+using ns::func;
+
+void test() {
+  foo().method(0, 0, 0, 0);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:9 %s -o - | FileCheck %s --check-prefix=CHECK-1
+  // CHECK-1: COMPLETION: method : [#type#]method(<#type#>, <#foo::type#>, <#::foo::type#>, <#::foo::foo::type#>)
+  f
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:26:3 %s -o - | FileCheck %s --check-prefix=CHECK-2
+  // FIXME(ibiryukov): We should get rid of CHECK-DAGs here when completion output is made deterministic (see PR35244).
+  // CHECK-2-DAG: COMPLETION: func : [#int#]func(<#foo a#>, <#bar b#>, <#ns::bar c#>, <#ns::baz d#>
+  // CHECK-2-DAG: COMPLETION: func : [#int#]func(<#foo::type a#>, <#bar b#>, <#baz c#>
+}

Some files were not shown because too many files changed in this diff