diff options
| author | 2019-06-23 21:36:31 +0000 | |
|---|---|---|
| committer | 2019-06-23 21:36:31 +0000 | |
| commit | 23f101f37937a1bd4a29726cab2f76e0fb038b35 (patch) | |
| tree | f7da7d6b32c2e07114da399150bfa88d72187012 /gnu/llvm/tools/clang/lib/Format/WhitespaceManager.cpp | |
| parent | sort previous; ok deraadt (diff) | |
| download | wireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.tar.xz wireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.zip | |
Import LLVM 8.0.0 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/tools/clang/lib/Format/WhitespaceManager.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/Format/WhitespaceManager.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gnu/llvm/tools/clang/lib/Format/WhitespaceManager.cpp b/gnu/llvm/tools/clang/lib/Format/WhitespaceManager.cpp index 7070ce03c86..032b1333322 100644 --- a/gnu/llvm/tools/clang/lib/Format/WhitespaceManager.cpp +++ b/gnu/llvm/tools/clang/lib/Format/WhitespaceManager.cpp @@ -90,7 +90,7 @@ const tooling::Replacements &WhitespaceManager::generateReplacements() { if (Changes.empty()) return Replaces; - llvm::sort(Changes.begin(), Changes.end(), Change::IsBeforeInFile(SourceMgr)); + llvm::sort(Changes, Change::IsBeforeInFile(SourceMgr)); calculateLineBreakInformation(); alignConsecutiveDeclarations(); alignConsecutiveAssignments(); @@ -255,8 +255,14 @@ AlignTokenSequence(unsigned Start, unsigned End, unsigned Column, F &&Matches, Changes[ScopeStack.back()].indentAndNestingLevel()) ScopeStack.pop_back(); + // Compare current token to previous non-comment token to ensure whether + // it is in a deeper scope or not. + unsigned PreviousNonComment = i - 1; + while (PreviousNonComment > Start && + Changes[PreviousNonComment].Tok->is(tok::comment)) + PreviousNonComment--; if (i != Start && Changes[i].indentAndNestingLevel() > - Changes[i - 1].indentAndNestingLevel()) + Changes[PreviousNonComment].indentAndNestingLevel()) ScopeStack.push_back(i); bool InsideNestedScope = ScopeStack.size() != 0; |
