[PATCH] D44616: Update existed CodeGen TBAA tests
This revision was automatically updated to reflect the committed changes. Closed by commit rL331292: Update existed CodeGen TBAA tests (authored by Danil, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D44616?vs=138874&id=144758#toc Repository: rL LLVM https://reviews.llvm.org/D44616 Files: cfe/trunk/test/CodeGen/tbaa-base.cpp cfe/trunk/test/CodeGen/tbaa-cast.cpp cfe/trunk/test/CodeGen/tbaa-class.cpp cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp cfe/trunk/test/CodeGen/tbaa-ms-abi.cpp cfe/trunk/test/CodeGen/tbaa-reference.cpp Index: cfe/trunk/test/CodeGen/tbaa-ms-abi.cpp === --- cfe/trunk/test/CodeGen/tbaa-ms-abi.cpp +++ cfe/trunk/test/CodeGen/tbaa-ms-abi.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple i686-pc-win32 -disable-llvm-passes -emit-llvm -o - -O1 %s | FileCheck %s +// RUN: %clang_cc1 -triple i686-pc-win32 -disable-llvm-passes -emit-llvm -o - -O1 %s | FileCheck %s -check-prefixes=CHECK,OLD-PATH +// RUN: %clang_cc1 -triple i686-pc-win32 -disable-llvm-passes -emit-llvm -new-struct-path-tbaa -o - -O1 %s | FileCheck %s -check-prefixes=CHECK,NEW-PATH // // Test that TBAA works in the Microsoft C++ ABI. We used to error out while // attempting to mangle RTTI. @@ -16,7 +17,11 @@ // CHECK: store i32 42, i32* {{.*}}, !tbaa [[TAG_A_i32:!.*]] } -// CHECK: [[TYPE_INT:!.*]] = !{!"int", [[TYPE_CHAR:!.*]], i64 0} -// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", ! -// CHECK: [[TAG_A_i32]] = !{[[TYPE_A:!.*]], [[TYPE_INT]], i64 0} -// CHECK: [[TYPE_A]] = !{!"?AUStructA@@", [[TYPE_INT]], i64 0} +// OLD-PATH: [[TYPE_INT:!.*]] = !{!"int", [[TYPE_CHAR:!.*]], i64 0} +// OLD-PATH: [[TYPE_CHAR]] = !{!"omnipotent char", ! +// OLD-PATH: [[TAG_A_i32]] = !{[[TYPE_A:!.*]], [[TYPE_INT]], i64 0} +// OLD-PATH: [[TYPE_A]] = !{!"?AUStructA@@", [[TYPE_INT]], i64 0} +// NEW-PATH: [[TYPE_INT:!.*]] = !{[[TYPE_CHAR:!.*]], i64 4, !"int"} +// NEW-PATH: [[TYPE_CHAR]] = !{{{.*}}, i64 1, !"omnipotent char"} +// NEW-PATH: [[TAG_A_i32]] = !{[[TYPE_A:!.*]], [[TYPE_INT]], i64 0, i64 4} +// NEW-PATH: [[TYPE_A]] = !{[[TYPE_CHAR]], i64 4, !"?AUStructA@@", [[TYPE_INT]], i64 0, i64 4} Index: cfe/trunk/test/CodeGen/tbaa-base.cpp === --- cfe/trunk/test/CodeGen/tbaa-base.cpp +++ cfe/trunk/test/CodeGen/tbaa-base.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,OLD-PATH +// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 %s -emit-llvm -new-struct-path-tbaa -o - | FileCheck %s -check-prefixes=CHECK,NEW-PATH // // Test generating of TBAA metadata for accesses to members of base classes. @@ -47,7 +48,11 @@ return (&(e->d))->y; } -// CHECK-DAG: [[TYPE_char:!.*]] = !{!"omnipotent char", {{.*}}, i64 0} -// CHECK-DAG: [[TYPE_int:!.*]] = !{!"int", [[TYPE_char]], i64 0} -// CHECK-DAG: [[TYPE_A:!.*]] = !{!"_ZTS1A", [[TYPE_int]], i64 0, [[TYPE_int]], i64 4, [[TYPE_int]], i64 8} -// CHECK-DAG: [[TAG_A_y]] = !{[[TYPE_A]], [[TYPE_int]], i64 4} +// OLD-PATH-DAG: [[TYPE_char:!.*]] = !{!"omnipotent char", {{.*}}, i64 0} +// OLD-PATH-DAG: [[TYPE_int:!.*]] = !{!"int", [[TYPE_char]], i64 0} +// OLD-PATH-DAG: [[TYPE_A:!.*]] = !{!"_ZTS1A", [[TYPE_int]], i64 0, [[TYPE_int]], i64 4, [[TYPE_int]], i64 8} +// OLD-PATH-DAG: [[TAG_A_y]] = !{[[TYPE_A]], [[TYPE_int]], i64 4} +// NEW-PATH-DAG: [[TYPE_char:!.*]] = !{{{.*}}, i64 1, !"omnipotent char"} +// NEW-PATH-DAG: [[TYPE_int:!.*]] = !{[[TYPE_char]], i64 4, !"int"} +// NEW-PATH-DAG: [[TYPE_A:!.*]] = !{[[TYPE_char]], i64 12, !"_ZTS1A", [[TYPE_int]], i64 0, i64 4, [[TYPE_int]], i64 4, i64 4, [[TYPE_int]], i64 8, i64 4} +// NEW-PATH-DAG: [[TAG_A_y]] = !{[[TYPE_A]], [[TYPE_int]], i64 4, i64 4} Index: cfe/trunk/test/CodeGen/tbaa-reference.cpp === --- cfe/trunk/test/CodeGen/tbaa-reference.cpp +++ cfe/trunk/test/CodeGen/tbaa-reference.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,OLD-PATH +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -new-struct-path-tbaa -o - | FileCheck %s -check-prefixes=CHECK,NEW-PATH // // Check that we generate correct TBAA information for reference accesses. @@ -29,9 +30,16 @@ return s; } -// CHECK-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 0} -// CHECK-DAG: [[TAG_B_s]] = !{[[TYPE_B:!.*]], [[TYPE_pointer]], i64 0} +// OLD-PATH-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 0} +// OLD-PATH-DAG: [[TAG_B_s]] = !{[[TYPE_B:!.*]], [[TYPE_pointer]], i64 0} // -// CHECK-DAG: [[TYPE_B]] = !{!"_ZTS1B", [[TYPE
[PATCH] D54077: [clangd] Implemented DraftFileSystem
LutsenkoDanil created this revision. LutsenkoDanil added reviewers: sammccall, ilya-biryukov. Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ioeric. Patch changes behavior of preamble building. If headers was changed in editor, preamble will be built with draft versions of them. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D54077 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/DraftStore.cpp clangd/DraftStore.h clangd/FS.h clangd/FSProvider.h unittests/clangd/DraftStoreTests.cpp Index: unittests/clangd/DraftStoreTests.cpp === --- unittests/clangd/DraftStoreTests.cpp +++ unittests/clangd/DraftStoreTests.cpp @@ -53,7 +53,7 @@ Expected Result = DS.updateDraft(Path, {Event}); ASSERT_TRUE(!!Result); EXPECT_EQ(*Result, SrcAfter.code()); -EXPECT_EQ(*DS.getDraft(Path), SrcAfter.code()); +EXPECT_EQ(DS.getDraft(Path)->Content, SrcAfter.code()); } } @@ -83,7 +83,7 @@ ASSERT_TRUE(!!Result) << toString(Result.takeError()); EXPECT_EQ(*Result, FinalSrc.code()); - EXPECT_EQ(*DS.getDraft(Path), FinalSrc.code()); + EXPECT_EQ(DS.getDraft(Path)->Content, FinalSrc.code()); } TEST(DraftStoreIncrementalUpdateTest, Simple) { @@ -339,9 +339,9 @@ EXPECT_EQ(toString(Result.takeError()), "UTF-16 offset 100 is invalid for line 0"); - Optional Contents = DS.getDraft(File); - EXPECT_TRUE(Contents); - EXPECT_EQ(*Contents, OriginalContents); + Optional NewDraft = DS.getDraft(File); + EXPECT_TRUE(NewDraft); + EXPECT_EQ(NewDraft->Content, OriginalContents); } } // namespace Index: clangd/FSProvider.h === --- clangd/FSProvider.h +++ clangd/FSProvider.h @@ -10,6 +10,7 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H +#include "FS.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/Support/VirtualFileSystem.h" @@ -38,6 +39,20 @@ } }; +class DraftFileSystemProvider : public FileSystemProvider { + DraftStore &DS; + +public: + DraftFileSystemProvider(DraftStore &DS) : DS(DS) {} + + llvm::IntrusiveRefCntPtr + getFileSystem() const override { +static llvm::IntrusiveRefCntPtr Result( +new DraftFileSystem(llvm::vfs::getRealFileSystem(), DS)); +return Result; + } +}; + } // namespace clangd } // namespace clang Index: clangd/FS.h === --- clangd/FS.h +++ clangd/FS.h @@ -10,13 +10,84 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H +#include "DraftStore.h" +#include "Logger.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/VirtualFileSystem.h" namespace clang { namespace clangd { +class DraftFile : public llvm::vfs::File { + std::unique_ptr F; + Draft DraftInfo; + +public: + DraftFile(std::unique_ptr F, Draft D) + : F(std::move(F)), DraftInfo(std::move(D)) {} + + llvm::ErrorOr getName() override { return F->getName(); } + + llvm::ErrorOr> + getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator, +bool IsVolatile) override { +(void)IsVolatile; +(void)RequiresNullTerminator; + +if (FileSize < 0) { + FileSize = DraftInfo.Content.size(); +} + +return llvm::MemoryBuffer::getMemBufferCopy( +llvm::StringRef(DraftInfo.Content).substr(0, FileSize), Name); + } + + llvm::ErrorOr status() override { +auto RealStatus = F->status(); + +if (!RealStatus) { + return RealStatus; +} + +llvm::vfs::Status Result( +RealStatus->getName(), RealStatus->getUniqueID(), DraftInfo.ModifyTime, +RealStatus->getUser(), RealStatus->getGroup(), DraftInfo.Content.size(), +RealStatus->getType(), RealStatus->getPermissions()); + +Result.IsVFSMapped = RealStatus->IsVFSMapped; +return Result; + } + + std::error_code close() override { return F->close(); } +}; + +/// Wrapper around real FS. If file was changed in the DraftStrore, returns +/// changed content, instead of real +class DraftFileSystem : public llvm::vfs::ProxyFileSystem { + DraftStore &DS; + +public: + DraftFileSystem(IntrusiveRefCntPtr FS, DraftStore &DS) + : llvm::vfs::ProxyFileSystem(FS), DS(DS) {} + + llvm::ErrorOr> + openFileForRead(const Twine &Path) override { +auto Result = getUnderlyingFS().openFileForRead(Path); + +if (!Result) { + return Result; +} + +if (auto D = DS.getDraft(Path.str())) { + return std::unique_ptr( + new DraftFile(std::move(*Result), std::move(*D))); +} + +return Result; + } +}; + /// Records status information for files open()ed or stat()ed during preamble /// build (except for the main file), so we can avoid stat()s on the underlying /// FS when reusing the preamble. For example, co
[PATCH] D54077: [clangd] Implemented DraftFileSystem
LutsenkoDanil planned changes to this revision. LutsenkoDanil added a comment. @ilya-biryukov, For example, VSCode saves all changed files by default when you press Ctrl+Shift+B (if build task configured for project). @klimek If behavior will be configurable, is it ok for you? @sammccall Current behavior may confuse new users, since, other IDEs mostly (all?) shows diagnostics for edited files instead of saved one. And it's unexpected that headers have 2 states - visible and saved (which cannot be viewed in IDE at all). Looks like performance will be same like usage of 'auto save after delay' feature in editor, if we make debounce delay configurable, what do you think? I suggest inroduce following changes to the patch: [ ] Changes proposed by @ilya-biryukov [ ] Configurable behavior [ ] Debounce timeout option Comment at: clangd/FS.h:82 + +if (auto D = DS.getDraft(Path.str())) { + return std::unique_ptr( ilya-biryukov wrote: > This assumes the `Path` is absolute and `vfs::FileSystem` can be called with > non-absolute paths too. > One way to make it work with relative paths is to create an > `InMemoryFileSystem` with the headers (it handles the absolute paths > conversions) and create an `OverlayFileSystem` on top of it and the > `RealFileSystem`. > > This would also make more complicated things work, e.g. getting the same > files when traversing parent directories, etc. > > Could we try this approach? WDYT? > Sounds good. Thank you for review! Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D54077 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54077: [clangd] Implemented DraftFileSystem
LutsenkoDanil added a comment. @sammccall Thank you for detailed explanation! In https://reviews.llvm.org/D54077#1288387, @sammccall wrote: > Someone mentioned to me that the interaction-between-features argument wasn't > clear here: > > - we **don't** currently update diagnostics for `A.cc` when `A.h` is edited > - we should, this seems more obvious & important than what we do with drafts > - this interacts badly with using draft state, as this patch proposes - there > are too many edits I already made a patch which introduces such behavior (not uploaded here yet), and looks like it works well with draft fs: diagnostics updates for depended files in 'real-time' on typing for opened files and no seen performance glitches, in multi-threaded mode at least. I suggest continue discussion when/if dependencies tracking will be implemented and real performance reduce introduced by this patch can be checked with real code. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D54077 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits