Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
289 commits
Select commit Hold shift + click to select a range
ccddca3
Merging r367062:
zmodem Jul 29, 2019
a99af82
UsersManual.rst: Update clang-cl command reference
zmodem Jul 29, 2019
6aa75a2
Merging r367215:
zmodem Jul 29, 2019
f574442
Merging r367008:
zmodem Jul 30, 2019
900b7dd
Merging r367314:
zmodem Jul 30, 2019
6e08fdb
Merging r366487:
zmodem Jul 30, 2019
372334b
Merging r367340 and r367341:
zmodem Jul 31, 2019
5f32370
Merging r366878 and r367301:
zmodem Jul 31, 2019
77e8f41
Merging r367124, r367292, r367394, r367396, and r367398.
zmodem Jul 31, 2019
4f1869c
Merging r367414:
zmodem Aug 1, 2019
b980ebe
Merging r367442:
zmodem Aug 1, 2019
9a3e9c7
Merging r367323:
zmodem Aug 1, 2019
ecb5f95
Merging r367304:
zmodem Aug 1, 2019
e3cbac7
Merging r367305:
zmodem Aug 1, 2019
ddea81c
Merging r367387:
zmodem Aug 1, 2019
f08bb47
Merging r367417:
zmodem Aug 1, 2019
c023a03
Merging r367308:
zmodem Aug 1, 2019
f94a258
Merging r366545:
zmodem Aug 1, 2019
64dfe88
Update release notes for things I've done since the last release
mstorsjo Aug 1, 2019
7f1bcc1
Update release notes for things I've done since the last release
mstorsjo Aug 1, 2019
b359686
Update release notes for things I've done since the last release
mstorsjo Aug 1, 2019
18de8ea
Merging r367530:
zmodem Aug 2, 2019
7750339
Merging r367520:
zmodem Aug 5, 2019
8aaba9f
Merging r367661:
zmodem Aug 5, 2019
6c8e44e
Merge r367599 - [COFF] Fix wholearchive with thin archives (PR42388, …
zmodem Aug 5, 2019
1475909
Merging r367687:
zmodem Aug 5, 2019
4e21661
Merging r367753:
zmodem Aug 5, 2019
9d9021d
Merging r366868:
zmodem Aug 5, 2019
d4bdcb4
Merging r366868:
zmodem Aug 5, 2019
6fb930d
Merging r367662:
zmodem Aug 5, 2019
fa65831
Merging r367846 and r367847:
zmodem Aug 5, 2019
a4972dc
Merging r367836:
zmodem Aug 6, 2019
af8b074
Merging r367675 and r367823:
zmodem Aug 6, 2019
4445e5f
Merging r366660 and r367306:
zmodem Aug 6, 2019
7bfdcec
lit: Bump version to 0.9.0
zmodem Aug 6, 2019
df0dd03
Merge r367730 for PR42812
zmodem Aug 6, 2019
c3007c6
Merging r367906:
zmodem Aug 6, 2019
a935710
Merging r367929:
zmodem Aug 6, 2019
1b8baf2
Merging r367941:
zmodem Aug 6, 2019
a628617
Merging r368004:
zmodem Aug 6, 2019
13c4345
Merging r367898:
zmodem Aug 6, 2019
8df6d06
Merging r368019:
zmodem Aug 7, 2019
0d584ef
Merging r367837:
zmodem Aug 7, 2019
1cda5ae
Merging r368078:
zmodem Aug 7, 2019
79d4fef
Merging r366513:
zmodem Aug 8, 2019
343874d
ReleaseNotes: LLVM_ENABLE_Z3_SOLVER (PR42921)
zmodem Aug 8, 2019
94e7307
Merging r368041:
zmodem Aug 8, 2019
280dccc
Merging r368058:
zmodem Aug 9, 2019
4ed16ed
[docs][mips] 9.0 Release notes
zmodem Aug 9, 2019
97fe26c
[docs][mips] 9.0 Release notes
zmodem Aug 9, 2019
817e3ea
Merging r368315:
zmodem Aug 9, 2019
702cccb
Merging r367403:
zmodem Aug 9, 2019
172e222
Merging r367403:
zmodem Aug 9, 2019
ffea3e3
Merging r367750:
zmodem Aug 9, 2019
87e914c
Merging r368104 and r368202:
zmodem Aug 9, 2019
ffa29fd
Merging r368324:
zmodem Aug 9, 2019
542fb41
Merge r368103 '[TSAN] Fix tsan on FreeBSD after D54889'
zmodem Aug 9, 2019
a23c907
Merging r367802:
zmodem Aug 9, 2019
47a5583
Merging r368498:
zmodem Aug 12, 2019
4b59015
Merging r368230:
zmodem Aug 12, 2019
b13c264
Merging r366541:
zmodem Aug 13, 2019
2c69b13
Merging r368581:
zmodem Aug 13, 2019
97e6d08
Merging r368517, r368518, r368519, and r368554:
zmodem Aug 13, 2019
3f91051
Merging r368572:
zmodem Aug 13, 2019
8bb0d04
Merging r368477:
zmodem Aug 13, 2019
a705aad
Merging r368478:
zmodem Aug 13, 2019
ff20769
Merging r368516:
zmodem Aug 13, 2019
fcfd891
Merging r367303:
zmodem Aug 13, 2019
f44fc88
Merging r368549:
zmodem Aug 13, 2019
9bea39d
Merging r368561:
zmodem Aug 14, 2019
69e3c1a
Merging r368552:
zmodem Aug 14, 2019
82330f1
Merging r368300:
zmodem Aug 14, 2019
2a39809
Merging r367084:
zmodem Aug 14, 2019
201b879
Merging release note update in r368874
llvm-beanz Aug 14, 2019
450f5f3
Correcting clang-cpp release not to spcify supported targets.
llvm-beanz Aug 15, 2019
8cb652b
Merging r368873:
zmodem Aug 16, 2019
b77d471
Merging r367019:
zmodem Aug 16, 2019
150ad31
Merging r368940:
zmodem Aug 16, 2019
739ab8a
Revert r365860 for PR42966 (with a tweak to the test case for r365862)
zmodem Aug 20, 2019
0a24543
Merging r369011:
zmodem Aug 20, 2019
25ca9e1
Merging r369097:
zmodem Aug 20, 2019
9381f6a
Merge r368247 (requested in PR42988)
zmodem Aug 20, 2019
f3feb0f
Merge r368246 for PR42988
zmodem Aug 20, 2019
0c67478
Merge r368219 (PR42988)
zmodem Aug 20, 2019
10f293f
Merging r369026:
zmodem Aug 20, 2019
0482ca8
Merging r369168:
zmodem Aug 20, 2019
356a2b3
Merging r369084:
zmodem Aug 20, 2019
589f1c4
Merging r369199:
zmodem Aug 20, 2019
90dc09f
Merging r369043:
zmodem Aug 20, 2019
d9e9479
Merging r367412 and r367429:
zmodem Aug 20, 2019
67a4a12
Merging r368867 and r368916:
zmodem Aug 20, 2019
7dc092d
Merging r369399:
zmodem Aug 21, 2019
5c10d73
Merging r369251:
zmodem Aug 21, 2019
f3a5f23
Merging r369537:
zmodem Aug 22, 2019
74ed1f2
Merging r369093:
zmodem Aug 22, 2019
79c1eb9
Merging r369095:
zmodem Aug 22, 2019
ee7601a
Merging r369426 and r369443:
zmodem Aug 22, 2019
07507c2
Merging r367580:
zmodem Aug 22, 2019
6e6e769
Merging r369641:
zmodem Aug 23, 2019
ab6d19b
Merging r368145:
zmodem Aug 23, 2019
884e989
Add Mull project to the release notes
AlexDenisov Aug 23, 2019
2ae73f1
Merging r369445:
zmodem Aug 23, 2019
9f06b98
Mention r363078 in the lld release notes.
nico Aug 23, 2019
d0b88fc
[Docs][OpenCL] Release 9.0 notes for OpenCL
Aug 23, 2019
c95063d
Merging r369349:
zmodem Aug 26, 2019
565fc9f
Merging r366573:
zmodem Aug 26, 2019
c343ded
Merging r366836:
zmodem Aug 26, 2019
71d5152
Merging r369694:
zmodem Aug 26, 2019
82fecfd
Release notes: -ftime-trace
zmodem Aug 26, 2019
9d3cb76
ReleaseNotes: __declspec(allocator)
zmodem Aug 26, 2019
a3a8bf9
Merge r369708 - [Sanitizer] checks ASLR on FreeBSD
zmodem Aug 26, 2019
35c6deb
Merging r369364:
zmodem Aug 26, 2019
5883514
Merging r366447:
zmodem Aug 26, 2019
cfcc2fe
Merging r366447:
zmodem Aug 26, 2019
6d070f2
Merging r366447:
zmodem Aug 26, 2019
23c8505
Merging r366447:
zmodem Aug 26, 2019
094e9b4
Merging r367115, r367125, r367127, and r367153.
zmodem Aug 26, 2019
eb67eea
ReleaseNotes: ARM and AArch64
zmodem Aug 26, 2019
af1c50d
Merge 'r369779 - [OpenCL] Renamed value of std flag in C++ mode'
zmodem Aug 26, 2019
b2b72ec
Merging r369829:
zmodem Aug 26, 2019
5600387
[clangd] Release notes for 9.x
sam-mccall Aug 27, 2019
263e040
Merging r369749:
zmodem Aug 27, 2019
d2fb9bb
Merging r369834:
zmodem Aug 27, 2019
244e6c1
Merging r370036:
zmodem Aug 27, 2019
7527c11
ReleaseNotes: PowerPC
zmodem Aug 27, 2019
79bfd16
ReleaseNotes: RISCV
zmodem Aug 27, 2019
8fee65e
ReleaseNotes: Zig
zmodem Aug 27, 2019
caa3819
[analyzer] Add 9.0.0. release notes.
zmodem Aug 28, 2019
4a24003
ReleaseNotes: ORC note, by Lang
zmodem Aug 28, 2019
845db80
Merging r370176:
zmodem Aug 28, 2019
67afb7c
Merging r370073:
zmodem Aug 28, 2019
e82a536
Merging r369886:
zmodem Aug 28, 2019
f7a1e48
Merging r370204:
zmodem Aug 28, 2019
e7a52d7
Merging r370035:
zmodem Aug 28, 2019
44b3f67
Merging r370271:
zmodem Aug 29, 2019
9c8b896
Merging r368964:
zmodem Aug 29, 2019
a384ddb
Merging r369184:
zmodem Aug 29, 2019
f8ed27f
ReleaseNotes from Sam Parker
zmodem Aug 29, 2019
9adebd4
ReleaseNotes: omitting range checks for switches with unreachable def…
zmodem Aug 29, 2019
9f45ba8
ReleaseNotes: sinking of instructions without uses
zmodem Aug 29, 2019
7552a39
ReleaseNotes: reduce the indent
zmodem Aug 29, 2019
2f35f00
ReleaseNotes: matching wide stores (r362472)
zmodem Aug 29, 2019
5297063
ReleaseNotes: remove in-progress warning and empty sections
zmodem Aug 29, 2019
e7ecc55
ReleaseNotes: cleanups
zmodem Aug 29, 2019
78ecdd5
ReleaseNotes: drop in-progress warning and empty sections
zmodem Aug 29, 2019
d6c7f87
ReleaseNotes: fixes
zmodem Aug 29, 2019
6f2f929
ReleaseNotes: remove in-progress warnings and empty sections
zmodem Aug 29, 2019
2857b97
ReleaseNotes: remove in-progress warning, remove empty sections
zmodem Aug 29, 2019
a400f31
ReleaseNotes: remove in-progress warning and empty sections
zmodem Aug 29, 2019
16d2d31
Merging r370367:
zmodem Aug 29, 2019
3c8c557
Merging r368164:
zmodem Aug 30, 2019
92734ca
ReleaseNotes: pocl and TCE; by Pekka Jääskeläinen
zmodem Aug 30, 2019
25f22e7
Merging r370404:
zmodem Aug 30, 2019
892dfd7
Merging r370355:
zmodem Aug 30, 2019
bb081fe
Re-generate {Attribute,ClangCommandLine,Diagnostics}Reference.rst
zmodem Aug 30, 2019
1cf7a88
index.rst: Remove non-release warning
zmodem Aug 30, 2019
fa0bc00
Update libc++ release notes
zoecarver Aug 30, 2019
4bc0d50
Update ReleaseNotes for lld 9.0.
rui314 Sep 5, 2019
9831a1c
ReleaseNotes tweaks
zmodem Sep 5, 2019
8b1a3a3
Merging r370850:
zmodem Sep 5, 2019
1b8425c
Merging r369310:
zmodem Sep 5, 2019
5a661d6
Merging r370753:
zmodem Sep 5, 2019
f8b1c25
Merging r370720 and r370721:
zmodem Sep 5, 2019
d8975f4
Merging r370430:
zmodem Sep 5, 2019
ab62fa5
Merging r371048:
zmodem Sep 5, 2019
8d4ccfe
Merging r369760:
zmodem Sep 5, 2019
ff382fe
Merging r370426:
zmodem Sep 5, 2019
c255101
Merging r371027:
zmodem Sep 5, 2019
5fc0367
Merging r371088 and r371095:
zmodem Sep 6, 2019
501ad1d
Merging r369828:
zmodem Sep 6, 2019
de934bf
Merging r371013:
zmodem Sep 6, 2019
c168b4b
Fix release notes for the MinGW frontend
mstorsjo Sep 7, 2019
7b927f7
Merging r369705 and r369713 for PR43243:
zmodem Sep 9, 2019
9523a1c
Merging r371262:
zmodem Sep 9, 2019
8cdf289
Merging r371111:
zmodem Sep 9, 2019
1c21c19
Merging r371305 and r371307:
zmodem Sep 9, 2019
b508b4b
Merging r371221 and r371224:
zmodem Sep 9, 2019
5cbaa56
Merging r370592:
zmodem Sep 9, 2019
127240a
Merging r371434:
zmodem Sep 10, 2019
02a0ef0
Merging r371766:
zmodem Sep 13, 2019
8972a47
ReleaseNotes: known issue: PR40547
zmodem Sep 16, 2019
12f174e
Merging r371969:
zmodem Sep 17, 2019
0399d5a
Add external project LDC to release notes.
redstar Sep 17, 2019
d0b8dd1
[CAHP] Add skeleton backend for CAHP
ushitora-anqou Oct 12, 2019
2c31c0a
[CAHP] Add simple assembler
ushitora-anqou Oct 12, 2019
aa66568
[CAHP] Add InstPrinter to enable -show-encoding option
ushitora-anqou Oct 12, 2019
c8bbf89
[CAHP] Add tests for assembler
ushitora-anqou Oct 12, 2019
43145f8
[CAHP] Add lw/lb/lbu/sw/sb/lwsp/swsp
ushitora-anqou Oct 13, 2019
1963e02
[CAHP] Add records to instruction
ushitora-anqou Oct 13, 2019
01fdfc0
[CAHP] Add disassembler
ushitora-anqou Oct 14, 2019
a03e70e
[CAHP] Add support for fixups for jump/branch
ushitora-anqou Oct 16, 2019
41a7092
[CAHP] Follow changes in ISA
ushitora-anqou Oct 16, 2019
7199c15
[CAHP] Add support for %hi/%lo
ushitora-anqou Oct 20, 2019
a7d2649
[CAHP] Follow changes in ISA
ushitora-anqou Oct 20, 2019
b653548
[CAHP] Add support for update_llc_test_checks.py
ushitora-anqou Oct 21, 2019
93131c5
[CAHP] Add skeleton for codegen
ushitora-anqou Oct 21, 2019
4cc3095
[CAHP] Add codegen patterns for instrs using alu
ushitora-anqou Oct 21, 2019
01169e8
[CAHP] Codegen support for materializing constants
ushitora-anqou Oct 22, 2019
4ba83f5
[CAHP] Codegen support for memory operations
ushitora-anqou Oct 23, 2019
ebd2dbc
[CAHP] Codegen support for memory operations on global addresses
ushitora-anqou Oct 23, 2019
392f40d
[CAHP] Add support for relocations
ushitora-anqou Oct 23, 2019
4b6d690
[CAHP] Codegen for conditional branches
ushitora-anqou Oct 24, 2019
4202dc9
[CAHP] Add support for storing/loading register to stack
ushitora-anqou Oct 27, 2019
4f800ab
[CAHP] Add support for function calls
ushitora-anqou Oct 27, 2019
f5bc466
[CAHP] Add CAHP-specific getFrameIndexReference
ushitora-anqou Oct 27, 2019
36fef74
[CAHP] Add prologue/epilogue insertion
ushitora-anqou Oct 27, 2019
1f08594
[CAHP] Add support for frame pointer elimination
ushitora-anqou Oct 28, 2019
9a6e8ae
[CAHP] Add support for SELECT/SELECT_CC
ushitora-anqou Oct 28, 2019
7f4c27b
[CAHP] Add support for lowering FrameIndex
ushitora-anqou Oct 28, 2019
8715fe9
[CAHP] Add support for large stack frame
ushitora-anqou Oct 28, 2019
67405d9
[CAHP] Use BR_CC instead of BRCOND
ushitora-anqou Oct 28, 2019
29d8664
[CAHP] Expand SETCC into SELECT
ushitora-anqou Oct 28, 2019
918a6a1
[CAHP] Add support for ExternalSymbol
ushitora-anqou Oct 28, 2019
994bb52
[CAHP] s/lowerSymbolOperand/LowerSymbolOperand/ NFC.
ushitora-anqou Oct 28, 2019
70fa0c1
[CAHP] s/normaliseSetCC/normalizeSetCC/ NFC.
ushitora-anqou Oct 28, 2019
e9c75fb
[CAHP] s/lowerGlobalAddress/LowerGlobalAddress/ NFC.
ushitora-anqou Oct 28, 2019
a54da6e
[CAHP] Disable JumpTable and expand BR_JT
ushitora-anqou Oct 30, 2019
f7c5aaa
[CAHP] Add CAHP target to LLD
ushitora-anqou Oct 30, 2019
848b297
[CAHP] Add CAHPAsmWriter
ushitora-anqou Nov 3, 2019
189d406
[CAHP] Use 16-bit instructions aggressively
ushitora-anqou Nov 3, 2019
c6d49a7
[CAHP] Add CAHP target to Clang
ushitora-anqou Nov 3, 2019
43f204d
[CAHP] Add Clang driver
ushitora-anqou Nov 3, 2019
3ffccb9
[CAHP] Enable frame pointer elimination when optmization is enabled
ushitora-anqou Nov 3, 2019
eebc587
[CAHP] Add support for branch analysis
ushitora-anqou Nov 6, 2019
24bcafc
[CAHP] Add support for inline assembly
ushitora-anqou Nov 6, 2019
f940fa9
[CAHP] Add support for branch relaxation
ushitora-anqou Nov 6, 2019
f57ab62
[CAHP] Add support for sext/zext/trunc
ushitora-anqou Nov 6, 2019
332084c
[CAHP] Add support for fastcc; currently same as ccc
ushitora-anqou Nov 6, 2019
42dda4b
[CAHP] Use jsal rather than jalr with lui and addi
ushitora-anqou Nov 9, 2019
4c5dd31
[CAHP] Expand mul into __mulhi3/__mulsi3
ushitora-anqou Nov 9, 2019
1b4a776
[CAHP] Expand div/rem into __udivhi3/__udivsi3/__divhi3/__divsi3/__um…
ushitora-anqou Nov 9, 2019
7bf51dd
[CAHP] Add hlt pseudo instruction
ushitora-anqou Nov 9, 2019
b76b67f
[CAHP] Link crt0.s unless -nostdlib or -nostartfiles specified
ushitora-anqou Nov 10, 2019
4cda22e
[CAHP] Use linker script chap.lds as default
ushitora-anqou Nov 10, 2019
7bab48a
[CAHP] Set LLD's --nmagic option to make output smaller
ushitora-anqou Nov 10, 2019
7e63f88
[CAHP] Enable linking of libc unless -nostdlib or -nodefaultlibs spec…
ushitora-anqou Nov 10, 2019
04c5758
[CAHP] Reject bare symbols for simm10 operands of arithmetic instruct…
ushitora-anqou Nov 20, 2019
b67a802
[CAHP] Reject bare symbols for simm6 operands
ushitora-anqou Nov 22, 2019
02670cc
[CAHP] uimm4 is 4-bit unsigned immediate
ushitora-anqou Nov 22, 2019
67cea36
[CAHP] Handle invalid byte sequence correctly
ushitora-anqou Dec 8, 2019
bd25923
[CAHP] Pass arguments via stack when necessary
ushitora-anqou Dec 8, 2019
9db6cd3
[CAHP] Add support for byval arguments
ushitora-anqou Dec 8, 2019
6b44042
[CAHP] Allow to pass -mcpu option to clang
ushitora-anqou Dec 27, 2019
d20c8f1
[CAHP] Add WriteALU and WriteLDST to schedule intructions
ushitora-anqou Dec 27, 2019
06555ba
[CAHP] Enable MIScheduler
ushitora-anqou Dec 30, 2019
cfb5c54
[CAHP] Add scheduling for processor emerald
ushitora-anqou Dec 30, 2019
ab23571
[CAHP] Add support for dynamic stack allocation
ushitora-anqou Dec 30, 2019
5287519
[CAHP] Add support for frameaddr and returnaddr
ushitora-anqou Dec 30, 2019
680e50e
[CAHP] Add support for emergency spill
ushitora-anqou Dec 30, 2019
9b9f061
Bump minimatch and mocha
dependabot[bot] Nov 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ add_clang_library(clangDaemon
XRefs.cpp

index/Background.cpp
index/BackgroundIndexLoader.cpp
index/BackgroundIndexStorage.cpp
index/BackgroundQueue.cpp
index/BackgroundRebuild.cpp
Expand Down
9 changes: 6 additions & 3 deletions clang-tools-extra/clangd/ClangdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <future>
#include <memory>
#include <mutex>
#include <type_traits>

namespace clang {
namespace clangd {
Expand Down Expand Up @@ -101,8 +103,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
: nullptr),
GetClangTidyOptions(Opts.GetClangTidyOptions),
SuggestMissingIncludes(Opts.SuggestMissingIncludes),
TweakFilter(Opts.TweakFilter),
WorkspaceRoot(Opts.WorkspaceRoot),
TweakFilter(Opts.TweakFilter), WorkspaceRoot(Opts.WorkspaceRoot),
// Pass a callback into `WorkScheduler` to extract symbols from a newly
// parsed file and rebuild the file index synchronously each time an AST
// is parsed.
Expand All @@ -127,7 +128,9 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
if (Opts.BackgroundIndex) {
BackgroundIdx = llvm::make_unique<BackgroundIndex>(
Context::current().clone(), FSProvider, CDB,
BackgroundIndexStorage::createDiskBackedStorageFactory());
BackgroundIndexStorage::createDiskBackedStorageFactory(
[&CDB](llvm::StringRef File) { return CDB.getProjectInfo(File); }),
std::max(Opts.AsyncThreadsCount, 1u));
AddIndex(BackgroundIdx.get());
}
if (DynamicIdx)
Expand Down
5 changes: 2 additions & 3 deletions clang-tools-extra/clangd/ClangdUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class DeclTrackingASTConsumer : public ASTConsumer {
bool HandleTopLevelDecl(DeclGroupRef DG) override {
for (Decl *D : DG) {
auto &SM = D->getASTContext().getSourceManager();
if (!SM.isWrittenInMainFile(SM.getExpansionLoc(D->getLocation())))
if (!isInsideMainFile(D->getLocation(), SM))
continue;

// ObjCMethodDecl are not actually top-level decls.
Expand Down Expand Up @@ -355,8 +355,7 @@ ParsedAST::build(std::unique_ptr<CompilerInvocation> CI,
// those might take us into a preamble file as well.
bool IsInsideMainFile =
Info.hasSourceManager() &&
Info.getSourceManager().isWrittenInMainFile(
Info.getSourceManager().getFileLoc(Info.getLocation()));
isInsideMainFile(Info.getLocation(), Info.getSourceManager());
if (IsInsideMainFile && tidy::ShouldSuppressDiagnostic(
DiagLevel, Info, *CTContext,
/* CheckMacroExpansion = */ false)) {
Expand Down
50 changes: 29 additions & 21 deletions clang-tools-extra/clangd/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "clang/Lex/Lexer.h"
#include "clang/Lex/Token.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Capacity.h"
Expand Down Expand Up @@ -107,25 +108,35 @@ Range diagnosticRange(const clang::Diagnostic &D, const LangOptions &L) {
return halfOpenToRange(M, R);
}

void adjustDiagFromHeader(Diag &D, const clang::Diagnostic &Info,
// Returns whether the \p D is modified.
bool adjustDiagFromHeader(Diag &D, const clang::Diagnostic &Info,
const LangOptions &LangOpts) {
// We only report diagnostics with at least error severity from headers.
if (D.Severity < DiagnosticsEngine::Level::Error)
return false;

const SourceLocation &DiagLoc = Info.getLocation();
const SourceManager &SM = Info.getSourceManager();
SourceLocation IncludeInMainFile;
auto GetIncludeLoc = [&SM](SourceLocation SLoc) {
return SM.getIncludeLoc(SM.getFileID(SLoc));
};
for (auto IncludeLocation = GetIncludeLoc(DiagLoc); IncludeLocation.isValid();
IncludeLocation = GetIncludeLoc(IncludeLocation))
IncludeInMainFile = IncludeLocation;
IncludeLocation = GetIncludeLoc(IncludeLocation)) {
if (clangd::isInsideMainFile(IncludeLocation, SM)) {
IncludeInMainFile = IncludeLocation;
break;
}
}
if (IncludeInMainFile.isInvalid())
return;
return false;

// Update diag to point at include inside main file.
D.File = SM.getFileEntryForID(SM.getMainFileID())->getName().str();
D.Range.start = sourceLocToPosition(SM, IncludeInMainFile);
D.Range.end = sourceLocToPosition(
SM, Lexer::getLocForEndOfToken(IncludeInMainFile, 0, SM, LangOpts));
D.InsideMainFile = true;

// Add a note that will point to real diagnostic.
const auto *FE = SM.getFileEntryForID(SM.getFileID(DiagLoc));
Expand All @@ -138,17 +149,14 @@ void adjustDiagFromHeader(Diag &D, const clang::Diagnostic &Info,

// Update message to mention original file.
D.Message = llvm::Twine("in included file: ", D.Message).str();
}

bool isInsideMainFile(const SourceLocation Loc, const SourceManager &M) {
return Loc.isValid() && M.isWrittenInMainFile(M.getFileLoc(Loc));
return true;
}

bool isInsideMainFile(const clang::Diagnostic &D) {
if (!D.hasSourceManager())
return false;

return isInsideMainFile(D.getLocation(), D.getSourceManager());
return clangd::isInsideMainFile(D.getLocation(), D.getSourceManager());
}

bool isNote(DiagnosticsEngine::Level L) {
Expand Down Expand Up @@ -469,15 +477,15 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
}

bool InsideMainFile = isInsideMainFile(Info);
SourceManager &SM = Info.getSourceManager();

auto FillDiagBase = [&](DiagBase &D) {
D.Range = diagnosticRange(Info, *LangOpts);
llvm::SmallString<64> Message;
Info.FormatDiagnostic(Message);
D.Message = Message.str();
D.InsideMainFile = InsideMainFile;
D.File = Info.getSourceManager().getFilename(Info.getLocation());
auto &SM = Info.getSourceManager();
D.File = SM.getFilename(Info.getLocation());
D.AbsFile = getCanonicalPath(
SM.getFileEntryForID(SM.getFileID(Info.getLocation())), SM);
D.Severity = DiagLevel;
Expand All @@ -500,19 +508,18 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
if (FixIt.RemoveRange.getBegin().isMacroID() ||
FixIt.RemoveRange.getEnd().isMacroID())
return false;
if (!isInsideMainFile(FixIt.RemoveRange.getBegin(),
Info.getSourceManager()))
if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
return false;
Edits.push_back(toTextEdit(FixIt, Info.getSourceManager(), *LangOpts));
Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
}

llvm::SmallString<64> Message;
// If requested and possible, create a message like "change 'foo' to 'bar'".
if (SyntheticMessage && Info.getNumFixItHints() == 1) {
const auto &FixIt = Info.getFixItHint(0);
bool Invalid = false;
llvm::StringRef Remove = Lexer::getSourceText(
FixIt.RemoveRange, Info.getSourceManager(), *LangOpts, &Invalid);
llvm::StringRef Remove =
Lexer::getSourceText(FixIt.RemoveRange, SM, *LangOpts, &Invalid);
llvm::StringRef Insert = FixIt.CodeToInsert;
if (!Invalid) {
llvm::raw_svector_ostream M(Message);
Expand Down Expand Up @@ -557,7 +564,9 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
LastDiag = Diag();
LastDiag->ID = Info.getID();
FillDiagBase(*LastDiag);
adjustDiagFromHeader(*LastDiag, Info, *LangOpts);
LastDiagWasAdjusted = false;
if (!InsideMainFile)
LastDiagWasAdjusted = adjustDiagFromHeader(*LastDiag, Info, *LangOpts);

if (!Info.getFixItHints().empty())
AddFix(true /* try to invent a message instead of repeating the diag */);
Expand Down Expand Up @@ -599,10 +608,9 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
void StoreDiags::flushLastDiag() {
if (!LastDiag)
return;
// Only keeps diagnostics inside main file or the first one coming from a
// header.
if (mentionsMainFile(*LastDiag) ||
(LastDiag->Severity >= DiagnosticsEngine::Level::Error &&
if (mentionsMainFile(*LastDiag) &&
(!LastDiagWasAdjusted ||
// Only report the first diagnostic coming from each particular header.
IncludeLinesWithErrors.insert(LastDiag->Range.start.line).second)) {
Output.push_back(std::move(*LastDiag));
} else {
Expand Down
2 changes: 2 additions & 0 deletions clang-tools-extra/clangd/Diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class StoreDiags : public DiagnosticConsumer {
std::vector<Diag> Output;
llvm::Optional<LangOptions> LangOpts;
llvm::Optional<Diag> LastDiag;
/// Set iff adjustDiagFromHeader resulted in changes to LastDiag.
bool LastDiagWasAdjusted = false;
llvm::DenseSet<int> IncludeLinesWithErrors;
bool LastPrimaryDiagnosticWasSuppressed = false;
};
Expand Down
6 changes: 6 additions & 0 deletions clang-tools-extra/clangd/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,11 @@ PreambleFileStatusCache::getConsumingFS(
return llvm::IntrusiveRefCntPtr<CacheVFS>(new CacheVFS(std::move(FS), *this));
}

Path removeDots(PathRef File) {
llvm::SmallString<128> CanonPath(File);
llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true);
return CanonPath.str().str();
}

} // namespace clangd
} // namespace clang
8 changes: 8 additions & 0 deletions clang-tools-extra/clangd/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H

#include "Path.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/VirtualFileSystem.h"
Expand Down Expand Up @@ -65,6 +66,13 @@ class PreambleFileStatusCache {
llvm::StringMap<llvm::vfs::Status> StatCache;
};

/// Returns a version of \p File that doesn't contain dots and dot dots.
/// e.g /a/b/../c -> /a/c
/// /a/b/./c -> /a/b/c
/// FIXME: We should avoid encountering such paths in clangd internals by
/// filtering everything we get over LSP, CDB, etc.
Path removeDots(PathRef File);

} // namespace clangd
} // namespace clang

Expand Down
11 changes: 8 additions & 3 deletions clang-tools-extra/clangd/FormattedString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,20 @@ void FormattedString::appendInlineCode(std::string Code) {

std::string FormattedString::renderAsMarkdown() const {
std::string R;
auto EnsureWhitespace = [&R]() {
// Adds a space for nicer rendering.
if (!R.empty() && !isWhitespace(R.back()))
R += " ";
};
for (const auto &C : Chunks) {
switch (C.Kind) {
case ChunkKind::PlainText:
if (!C.Contents.empty() && !isWhitespace(C.Contents.front()))
EnsureWhitespace();
R += renderText(C.Contents);
continue;
case ChunkKind::InlineCodeBlock:
// Make sure we don't glue two backticks together.
if (llvm::StringRef(R).endswith("`"))
R += " ";
EnsureWhitespace();
R += renderInlineBlock(C.Contents);
continue;
case ChunkKind::CodeBlock:
Expand Down
Loading