diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-04-11 23:47:25 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-04-11 23:47:25 +0000 |
commit | dee344cf85cec594994f5128e473421901ef7f3c (patch) | |
tree | 870c74dc3f70c0a13070b23410e7789338952663 | |
parent | 815f453f76f502ede5e722a74715d0ba90acdcc8 (diff) | |
download | bcm5719-llvm-dee344cf85cec594994f5128e473421901ef7f3c.tar.gz bcm5719-llvm-dee344cf85cec594994f5128e473421901ef7f3c.zip |
Lex: make `clang::Preprocessor::macros` work on MSVC
The order of argument construction is reversed on MS ABI on Windows.
When `macros` was invoked, the `end` call is made prior to `begin`. In
such a case, the DenseMap (`ModuleMap`) is populated after the `end`
iterator is constructed. This reversal results in the invalidation of
the end iterator, resulting in a failure at runtime (assertion failure
in `DenseMap<T>::operator!=` that "handles are not in sync!"). Ensure
that the end iterator is constructed after the begin iterator. This
fixes the use of `macros(bool)`, which symptomized as an assertion
failure in the swift compiler in the clang importer.
llvm-svn: 329866
-rw-r--r-- | clang/include/clang/Lex/Preprocessor.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 485600f1223..630b87ced35 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -1041,12 +1041,14 @@ public: macro_iterator macro_begin(bool IncludeExternalMacros = true) const; macro_iterator macro_end(bool IncludeExternalMacros = true) const; - llvm::iterator_range<macro_iterator> + llvm::iterator_range<macro_iterator> macros(bool IncludeExternalMacros = true) const { - return llvm::make_range(macro_begin(IncludeExternalMacros), - macro_end(IncludeExternalMacros)); + macro_iterator begin = macro_begin(IncludeExternalMacros); + macro_iterator end = macro_end(IncludeExternalMacros); + return llvm::make_range(begin, end); } + /// \} /// \brief Return the name of the macro defined before \p Loc that has |