Re: r339163 - [WebAssembly] Remove use of lld -flavor flag
$ bin/clang -target wasm32-unknown-unknown -fuse-ld=wasm-ld -o test.wasm test.cc clang: error: invalid linker name in argument '-fuse-ld=wasm-ld' This here http://llvm-cs.pcc.me.uk/tools/clang/lib/Driver/ToolChain.cpp#453 makes clang look for "ld.wasm-ld", but the wasm lld symlink is called "wasm-ld". Does the driver need updating? Is the symlink name wrong? Am I doing something wrong? On Tue, Aug 7, 2018 at 2:56 PM Sam Clegg via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: sbc > Date: Tue Aug 7 11:55:41 2018 > New Revision: 339163 > > URL: http://llvm.org/viewvc/llvm-project?rev=339163&view=rev > Log: > [WebAssembly] Remove use of lld -flavor flag > > This flag is deprecated. The preferred way to select the lld > flavor is by calling it by one of its aliases. > > Differential Revision: https://reviews.llvm.org/D50395 > > Modified: > cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp > cfe/trunk/lib/Driver/ToolChains/WebAssembly.h > cfe/trunk/test/Driver/wasm-toolchain.c > cfe/trunk/test/Driver/wasm-toolchain.cpp > > Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=339163&r1=339162&r2=339163&view=diff > > == > --- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original) > +++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Tue Aug 7 11:55:41 > 2018 > @@ -41,8 +41,6 @@ void wasm::Linker::ConstructJob(Compilat >const ToolChain &ToolChain = getToolChain(); >const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath()); >ArgStringList CmdArgs; > - CmdArgs.push_back("-flavor"); > - CmdArgs.push_back("wasm"); > >if (Args.hasArg(options::OPT_s)) > CmdArgs.push_back("--strip-all"); > > Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=339163&r1=339162&r2=339163&view=diff > > == > --- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original) > +++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Tue Aug 7 11:55:41 2018 > @@ -66,9 +66,7 @@ private: > llvm::opt::ArgStringList &CmdArgs) const > override; >std::string getThreadModel() const override; > > - const char *getDefaultLinker() const override { > -return "lld"; > - } > + const char *getDefaultLinker() const override { return "wasm-ld"; } > >Tool *buildLinker() const override; > }; > > Modified: cfe/trunk/test/Driver/wasm-toolchain.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=339163&r1=339162&r2=339163&view=diff > > == > --- cfe/trunk/test/Driver/wasm-toolchain.c (original) > +++ cfe/trunk/test/Driver/wasm-toolchain.c Tue Aug 7 11:55:41 2018 > @@ -12,12 +12,12 @@ > > // A basic C link command-line. > > -// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown > --sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s > +// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown > --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s > // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" > -// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" > "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" > +// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" > "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" > > // A basic C link command-line with optimization. > > -// RUN: %clang -### -O2 -no-canonical-prefixes -target > wasm32-unknown-unknown --sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck > -check-prefix=LINK_OPT %s > +// RUN: %clang -### -O2 -no-canonical-prefixes -target > wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck > -check-prefix=LINK_OPT %s > // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" > -// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" > "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" > +// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" > "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out" > > Modified: cfe/trunk/test/Driver/wasm-toolchain.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.cpp?rev=339163&r1=339162&r2=339163&view=diff > > == > --- cfe/trunk/test/Driver/wasm-toolchain.cpp (original) > +++ cfe/trunk/test/Driver/wasm-toolchain.cpp Tue Aug 7 11:55:41 2018 > @@ -12,12 +12,12 @@ > > // A basic C++ link command-line. > > -// RUN: %clangxx -### -no-canonical-prefixes -target > wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ -fuse-ld=lld %s 2>&1
[PATCH] D53308: [Fixed Point Arithmetic] Fixed Point to Boolean Cast
ebevhan added inline comments. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1032 + // them. + return Builder.CreateIsNotNull(Src); +} Is this comment true? I don't think EmitFixedPointConversion does this. Maybe I'm misinterpreting what it means. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2023 +// We do not check the padding bit on unsigned types since they are zero'd +// out on operations that can cause overflow into the bit. +assert(E->getType()->isFixedPointType() && This comment is a duplicate of the one in EmitScalarConversion. Comment at: clang/lib/Sema/Sema.cpp:537 case Type::STK_FixedPoint: -llvm_unreachable("Unknown cast from FixedPoint to boolean"); +return CK_FixedPointToBoolean; } Put this on the line above directly after the case like the others. Repository: rC Clang https://reviews.llvm.org/D53308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53312: [clangd] Support limiting down traversals from sources in FileDistance.
ioeric created this revision. ioeric added a reviewer: sammccall. Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov. This is useful for symbo scope proximity, where down traversals from the global scope if not desired. The limitation in the current implementation is that we may lose coverage of paths that when are otherwise reachable from a more expensive node with larger down traversal limit, as the greedy algorithm favors nodes with cheapest costs. Another option is to simply special-case the root path in FileDistance. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53312 Files: clangd/FileDistance.cpp clangd/FileDistance.h unittests/clangd/FileDistanceTests.cpp Index: unittests/clangd/FileDistanceTests.cpp === --- unittests/clangd/FileDistanceTests.cpp +++ unittests/clangd/FileDistanceTests.cpp @@ -95,6 +95,37 @@ EXPECT_EQ(D.distance("/a/b/z"), 2u); } +TEST(FileDistance, LimitDownTraversals) { + FileDistanceOptions Opts; + Opts.UpCost = 1; + Opts.DownCost = 1; + SourceParams CheapButLimited, CostLots; + CheapButLimited.MaxDownTraversals = 1; + CostLots.Cost = 100; + + FileDistance D({{"/", CheapButLimited}, {"/a/b", CostLots}}, Opts); + EXPECT_EQ(D.distance("/a"), 1u); + EXPECT_EQ(D.distance("/a/b"), 100u); + EXPECT_EQ(D.distance("/a/b/c"), 101u); +} + +TEST(FileDistance, LimitDownTraversalsCorner) { + FileDistanceOptions Opts; + Opts.UpCost = 1; + Opts.DownCost = 1; + SourceParams CheapButLimited, CostLots; + CheapButLimited.MaxDownTraversals = 1; + CostLots.Cost = 100; + + FileDistance D({{"/", CheapButLimited}, {"/a", CostLots}}, Opts); + EXPECT_EQ(D.distance("/x"), 1u); + EXPECT_EQ(D.distance("/a"), 1u); + // These are actually reacahble from "/a" with high cost. But we don't support + // such case. + EXPECT_EQ(D.distance("/a/b"), FileDistance::Unreachable); + EXPECT_EQ(D.distance("/a/b/c"), FileDistance::Unreachable); +} + } // namespace } // namespace clangd } // namespace clang Index: clangd/FileDistance.h === --- clangd/FileDistance.h +++ clangd/FileDistance.h @@ -61,8 +61,11 @@ struct SourceParams { // Base cost for paths starting at this source. unsigned Cost = 0; - // Limits the number of upwards traversals allowed from this source. - unsigned MaxUpTraversals = std::numeric_limits::max(); + // Limits the number of upwards/downwards traversals allowed from this source. + static constexpr unsigned MaxTraversals = + std::numeric_limits::max(); + unsigned MaxUpTraversals = MaxTraversals; + unsigned MaxDownTraversals = MaxTraversals; }; // Supports lookups to find the minimum distance to a file from any source. @@ -80,7 +83,11 @@ private: // Costs computed so far. Always contains sources and their ancestors. // We store hash codes only. Collisions are rare and consequences aren't dire. - llvm::DenseMap Cache; + struct CacheNode { +unsigned Cost = Unreachable; +unsigned MaxDownTraversals = std::numeric_limits::max(); + }; + llvm::DenseMap Cache; FileDistanceOptions Opts; }; Index: clangd/FileDistance.cpp === --- clangd/FileDistance.cpp +++ clangd/FileDistance.cpp @@ -63,8 +63,8 @@ // Keep track of down edges, in case we can use them to improve on this. for (const auto &S : Sources) { auto Canonical = canonicalize(S.getKey()); -dlog("Source {0} = {1}, MaxUp = {2}", Canonical, S.second.Cost, - S.second.MaxUpTraversals); +dlog("Source {0} = {1}, MaxUp = {2}, MaxDown = {3}", Canonical, + S.second.Cost, S.second.MaxUpTraversals, S.second.MaxDownTraversals); // Walk up to ancestors of this source, assigning cost. StringRef Rest = Canonical; llvm::hash_code Hash = hash_value(Rest); @@ -79,11 +79,16 @@ if (Cache.find(Hash) != Cache.end()) break; } else { -unsigned Cost = S.getValue().Cost + I * Opts.UpCost; -auto R = Cache.try_emplace(Hash, Cost); +CacheNode Node; +Node.Cost = S.getValue().Cost + I * Opts.UpCost; +if (SourceParams::MaxTraversals - S.getValue().MaxDownTraversals >= I) + Node.MaxDownTraversals = S.getValue().MaxDownTraversals + I; +auto R = Cache.try_emplace(Hash, Node); if (!R.second) { - if (Cost < R.first->second) { -R.first->second = Cost; + // Note that we might lose coverage of some paths that are otherwise + // reachable with a higher cost but large down traversal limit. + if (Node.Cost < R.first->second.Cost) { +R.first->second = std::move(Node); } else { // If we're not the best way to get to this path, stop assigning. break; @@ -99,42 +104,52 @@ for (auto Child : DownEdges.lookup(hash_value(llvm::StringRef("
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
takuto.ikuta updated this revision to Diff 169791. takuto.ikuta added a comment. Fix linkage for inline function of explicit template instantiation declaration https://reviews.llvm.org/D51340 Files: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/LangOptions.h clang/include/clang/Driver/CC1Options.td clang/include/clang/Driver/CLCompatOptions.td clang/lib/AST/ASTContext.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp Index: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp === --- /dev/null +++ clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp @@ -0,0 +1,174 @@ +// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \ +// RUN: -fno-dllexport-inlines -emit-llvm -O0 -o - |\ +// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=NOINLINE %s + +// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \ +// RUN: -emit-llvm -O0 -o - | \ +// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=INLINE %s + +// Function + +// DEFAULT-DAG: define dso_local dllexport void @"?NormalFunction@@YAXXZ"() +void __declspec(dllexport) NormalFunction() {} + + +// DEFAULT-DAG: define weak_odr dso_local dllexport void @"?AlwaysInlineFunction@@YAXXZ" +__forceinline void __declspec(dllexport) AlwaysInlineFunction() {} + +// DEFAULT-DAG: @"?static_variable@?1??AlwaysInlineWithStaticVariableExported@@YAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 +__forceinline int __declspec(dllexport) AlwaysInlineWithStaticVariableExported() { + static int static_variable = 0; + ++static_variable; + return static_variable; +} + +// DEFAULT-DAG: @"?static_variable@?1??AlwaysInlineWithStaticVariableImported@@YAHXZ@4HA" = available_externally dllimport global i32 0, align 4 +__forceinline int __declspec(dllimport) AlwaysInlineWithStaticVariableImported() { + static int static_variable = 0; + ++static_variable; + return static_variable; +} + +int ImportedFunctionUser() { + return AlwaysInlineWithStaticVariableImported(); +} + +// Class member function + +// check for local static variables +// NOINLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 + +// INLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 + +// NOINLINE-DAG: @"?static_variable@?1??InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ@4HA" = available_externally dllimport global i32 0, align 4 + +class __declspec(dllexport) NoTemplateExportedClass { + public: + // DEFAULT-NOT: NoTemplateExportedClass@NoTemplateExportedClass@@ + NoTemplateExportedClass() = default; + + // NOINLINE-NOT: InclassDefFunc@NoTemplateExportedClass + // INLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@NoTemplateExportedClass@@ + void InclassDefFunc() {} + + int f(); + + // DEFAULT-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ" + int InclassDefFuncWithStaticVariable() { +static int static_variable = 0; +++static_variable; +return static_variable; + } + + // DEFAULT-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@NoTemplateExportedClass@@QEAAHXZ" + int InclassDefFunctWithLambdaStaticVariable() { +return ([]() { static int static_x; return ++static_x; })(); + } + + // DEFAULT-NOT: InlineOutclassDefFuncWihtoutDefinition + __forceinline void InlineOutclassDefFuncWihtoutDefinition(); + + // DEFAULT-NOT: InlineOutclassDefFunc@NoTemplateExportedClass@@ + __forceinline void InlineOutclassDefFunc(); + + // DEFAULT-NOT: InlineOutclassDefFuncWithStaticVariable@NoTemplateExportedClass@@ + __forceinline int InlineOutclassDefFuncWithStaticVariable(); + + // DEFAULT-DAG: define dso_local dllexport void @"?OutclassDefFunc@NoTemplateExportedClass@@QEAAXXZ" + void OutclassDefFunc(); +}; + +void NoTemplateExportedClass::OutclassDefFunc() {} + +__forceinline void NoTemplateExportedClass::InlineOutclassDefFunc() {} + +__forceinline int NoTemplateExportedClass::InlineOutclassDefFuncWithStaticVariable() { + static int static_variable = 0; + return ++static_variable; +} + +void __declspec(dllexport) NoTemplateExportedClassUser() { + NoTemplateExportedClass a; + a.InlineOutclassDefFunc(); +} + +template +class __declspec(dllexport) TemplateExportedClass { + void InclassDefFunc() {} + void OutclassDefFunc(); + + T templateValue; +}; + +// DEFAULT-NOT: define dso_local dllexport void @"?OutclassDefFunc@NoTempl
[PATCH] D53272: Add target requirement to profile remap test.
peter.smith accepted this revision. peter.smith added a comment. This revision is now accepted and ready to land. Looks good to me. REQUIRES: x86-registered-target is used in the same directory for tests that depend on specific targets. Repository: rC Clang https://reviews.llvm.org/D53272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
takuto.ikuta updated this revision to Diff 169792. takuto.ikuta added a comment. remove comment out code https://reviews.llvm.org/D51340 Files: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/LangOptions.h clang/include/clang/Driver/CC1Options.td clang/include/clang/Driver/CLCompatOptions.td clang/lib/AST/ASTContext.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp Index: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp === --- /dev/null +++ clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp @@ -0,0 +1,174 @@ +// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \ +// RUN: -fno-dllexport-inlines -emit-llvm -O0 -o - |\ +// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=NOINLINE %s + +// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \ +// RUN: -emit-llvm -O0 -o - | \ +// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=INLINE %s + +// Function + +// DEFAULT-DAG: define dso_local dllexport void @"?NormalFunction@@YAXXZ"() +void __declspec(dllexport) NormalFunction() {} + + +// DEFAULT-DAG: define weak_odr dso_local dllexport void @"?AlwaysInlineFunction@@YAXXZ" +__forceinline void __declspec(dllexport) AlwaysInlineFunction() {} + +// DEFAULT-DAG: @"?static_variable@?1??AlwaysInlineWithStaticVariableExported@@YAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 +__forceinline int __declspec(dllexport) AlwaysInlineWithStaticVariableExported() { + static int static_variable = 0; + ++static_variable; + return static_variable; +} + +// DEFAULT-DAG: @"?static_variable@?1??AlwaysInlineWithStaticVariableImported@@YAHXZ@4HA" = available_externally dllimport global i32 0, align 4 +__forceinline int __declspec(dllimport) AlwaysInlineWithStaticVariableImported() { + static int static_variable = 0; + ++static_variable; + return static_variable; +} + +int ImportedFunctionUser() { + return AlwaysInlineWithStaticVariableImported(); +} + +// Class member function + +// check for local static variables +// NOINLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 + +// INLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 + +// NOINLINE-DAG: @"?static_variable@?1??InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ@4HA" = available_externally dllimport global i32 0, align 4 + +class __declspec(dllexport) NoTemplateExportedClass { + public: + // DEFAULT-NOT: NoTemplateExportedClass@NoTemplateExportedClass@@ + NoTemplateExportedClass() = default; + + // NOINLINE-NOT: InclassDefFunc@NoTemplateExportedClass + // INLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@NoTemplateExportedClass@@ + void InclassDefFunc() {} + + int f(); + + // DEFAULT-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ" + int InclassDefFuncWithStaticVariable() { +static int static_variable = 0; +++static_variable; +return static_variable; + } + + // DEFAULT-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@NoTemplateExportedClass@@QEAAHXZ" + int InclassDefFunctWithLambdaStaticVariable() { +return ([]() { static int static_x; return ++static_x; })(); + } + + // DEFAULT-NOT: InlineOutclassDefFuncWihtoutDefinition + __forceinline void InlineOutclassDefFuncWihtoutDefinition(); + + // DEFAULT-NOT: InlineOutclassDefFunc@NoTemplateExportedClass@@ + __forceinline void InlineOutclassDefFunc(); + + // DEFAULT-NOT: InlineOutclassDefFuncWithStaticVariable@NoTemplateExportedClass@@ + __forceinline int InlineOutclassDefFuncWithStaticVariable(); + + // DEFAULT-DAG: define dso_local dllexport void @"?OutclassDefFunc@NoTemplateExportedClass@@QEAAXXZ" + void OutclassDefFunc(); +}; + +void NoTemplateExportedClass::OutclassDefFunc() {} + +__forceinline void NoTemplateExportedClass::InlineOutclassDefFunc() {} + +__forceinline int NoTemplateExportedClass::InlineOutclassDefFuncWithStaticVariable() { + static int static_variable = 0; + return ++static_variable; +} + +void __declspec(dllexport) NoTemplateExportedClassUser() { + NoTemplateExportedClass a; + a.InlineOutclassDefFunc(); +} + +template +class __declspec(dllexport) TemplateExportedClass { + void InclassDefFunc() {} + void OutclassDefFunc(); + + T templateValue; +}; + +// DEFAULT-NOT: define dso_local dllexport void @"?OutclassDefFunc@NoTemplateExportedClass@@ +template void TemplateExportedClass
[PATCH] D53312: [clangd] Support limiting down traversals from sources in FileDistance.
sammccall added a comment. The slightly weird down-traversals semantics are indeed slightly weird. I'm happy to move forward with this approach though if we document it. I did think of one alternative: - instead of `unsigned Source::MaxDownTraversals`, have `bool Source::AllowDownTraversals` (obviously less flexible) - instead of `(min-cost, max-down-traversals)` in the cache, store `(first=min-cost, second=min-cost-allowing-downtraversals)`. When populating tree based on sources, set both cache values if down-traversals are allowed, otherwise just the first. When propagating scores from parent to child, only read from the second cache value, and write to both. When looking up a result from the cache, use the first cached value. I don't think there's a lot of practical difference for our use case, the advantage would be the semantics are easier to reason about. WDYT? Comment at: clangd/FileDistance.cpp:84 +Node.Cost = S.getValue().Cost + I * Opts.UpCost; +if (SourceParams::MaxTraversals - S.getValue().MaxDownTraversals >= I) + Node.MaxDownTraversals = S.getValue().MaxDownTraversals + I; I don't understand this if condition Comment at: clangd/FileDistance.cpp:90 + // reachable with a higher cost but large down traversal limit. + if (Node.Cost < R.first->second.Cost) { +R.first->second = std::move(Node); For consistency, tiebreak with down traversals: `|| Node.Cost == R.first->second.Cost && Node.MaxDownTraversals > R.first->second.MaxDownTraversals` (note the opposite sign) But probably clearer to write this by defining `CacheNode::operator<` Comment at: clangd/FileDistance.cpp:107 while (!Next.empty()) { -auto ParentCost = Cache.lookup(Next.front()); -for (auto Child : DownEdges.lookup(Next.front())) { - auto &ChildCost = - Cache.try_emplace(Child, Unreachable).first->getSecond(); - if (ParentCost + Opts.DownCost < ChildCost) -ChildCost = ParentCost + Opts.DownCost; - Next.push(Child); +const auto &Parent = Cache[Next.front()]; +if (Parent.MaxDownTraversals > 0) { This fills in the cache if it wasn't set - it's probably harmless but not quite as clear. Does lookup not work here? Comment at: clangd/FileDistance.h:65 + // Limits the number of upwards/downwards traversals allowed from this source. + static constexpr unsigned MaxTraversals = + std::numeric_limits::max(); nit: "unlimited" might be a clearer name here. Comment at: clangd/FileDistance.h:68 + unsigned MaxUpTraversals = MaxTraversals; + unsigned MaxDownTraversals = MaxTraversals; }; We should document the slightly weird semantics. Comment at: unittests/clangd/FileDistanceTests.cpp:124 + // These are actually reacahble from "/a" with high cost. But we don't support + // such case. + EXPECT_EQ(D.distance("/a/b"), FileDistance::Unreachable); , because /a itself is reached more cheaply via the root. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53312 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344593 - Add target requirement to profile remap test.
Author: yroux Date: Tue Oct 16 01:47:36 2018 New Revision: 344593 URL: http://llvm.org/viewvc/llvm-project?rev=344593&view=rev Log: Add target requirement to profile remap test. Fix bots which don't have x86_64 target built (ARM/AArch64). Differential Revision: https://reviews.llvm.org/D53272 Modified: cfe/trunk/test/CodeGenCXX/profile-remap.cpp Modified: cfe/trunk/test/CodeGenCXX/profile-remap.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/profile-remap.cpp?rev=344593&r1=344592&r2=344593&view=diff == --- cfe/trunk/test/CodeGenCXX/profile-remap.cpp (original) +++ cfe/trunk/test/CodeGenCXX/profile-remap.cpp Tue Oct 16 01:47:36 2018 @@ -1,3 +1,5 @@ +// REQUIRES: x86-registered-target +// // RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-sample-use=%S/Inputs/profile-remap.samples -fprofile-remapping-file=%S/Inputs/profile-remap.map -fexperimental-new-pass-manager -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SAMPLES // RUN: llvm-profdata merge -output %T.profdata %S/Inputs/profile-remap.proftext // RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-instrument-use-path=%T.profdata -fprofile-remapping-file=%S/Inputs/profile-remap.map -fexperimental-new-pass-manager -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53313: [clangd] Fix threading bugs in (not-yet-used) BackgroundIndex, re-enable test.
sammccall created this revision. sammccall added a reviewer: ioeric. Herald added subscribers: cfe-commits, jfb, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov. One relatively boring bug: forgot to notify the CV after enqueue. One much more fun bug: the thread member could access instance variables before they were initialized. Although the thread was last in the init list, QueueCV etc were listed after Thread in the class, so their default constructors raced with the thread itself. We have to get very unlucky to lose this race, I saw it 0.02% of the time. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53313 Files: clangd/index/Background.cpp clangd/index/Background.h unittests/clangd/BackgroundIndexTests.cpp Index: unittests/clangd/BackgroundIndexTests.cpp === --- unittests/clangd/BackgroundIndexTests.cpp +++ unittests/clangd/BackgroundIndexTests.cpp @@ -11,8 +11,6 @@ MATCHER_P(Named, N, "") { return arg.Name == N; } -// Temporarily disabled: test timing out on buildbots. -#if 0 TEST(BackgroundIndexTest, IndexTwoFiles) { MockFSProvider FS; // a.h yields different symbols when included by A.cc vs B.cc. @@ -34,7 +32,6 @@ EXPECT_THAT(runFuzzyFind(Idx, ""), UnorderedElementsAre(Named("a_h"), Named("foo"), Named("bar"))); } -#endif } // namespace clangd } // namespace clang Index: clangd/index/Background.h === --- clangd/index/Background.h +++ clangd/index/Background.h @@ -65,12 +65,12 @@ using Task = std::function; // FIXME: use multiple worker threads. void run(); // Main loop executed by Thread. Runs tasks from Queue. void enqueueLocked(tooling::CompileCommand Cmd); - std::thread Thread; std::mutex QueueMu; unsigned NumActiveTasks = 0; // Only idle when queue is empty *and* no tasks. std::condition_variable QueueCV; bool ShouldStop = false; std::deque Queue; + std::thread Thread; // Must be last, spawned thread reads instance vars. }; } // namespace clangd Index: clangd/index/Background.cpp === --- clangd/index/Background.cpp +++ clangd/index/Background.cpp @@ -75,8 +75,11 @@ void BackgroundIndex::enqueue(StringRef Directory, tooling::CompileCommand Cmd) { - std::lock_guard Lock(QueueMu); - enqueueLocked(std::move(Cmd)); + { +std::lock_guard Lock(QueueMu); +enqueueLocked(std::move(Cmd)); + } + QueueCV.notify_all(); } void BackgroundIndex::enqueueAll(StringRef Directory, Index: unittests/clangd/BackgroundIndexTests.cpp === --- unittests/clangd/BackgroundIndexTests.cpp +++ unittests/clangd/BackgroundIndexTests.cpp @@ -11,8 +11,6 @@ MATCHER_P(Named, N, "") { return arg.Name == N; } -// Temporarily disabled: test timing out on buildbots. -#if 0 TEST(BackgroundIndexTest, IndexTwoFiles) { MockFSProvider FS; // a.h yields different symbols when included by A.cc vs B.cc. @@ -34,7 +32,6 @@ EXPECT_THAT(runFuzzyFind(Idx, ""), UnorderedElementsAre(Named("a_h"), Named("foo"), Named("bar"))); } -#endif } // namespace clangd } // namespace clang Index: clangd/index/Background.h === --- clangd/index/Background.h +++ clangd/index/Background.h @@ -65,12 +65,12 @@ using Task = std::function; // FIXME: use multiple worker threads. void run(); // Main loop executed by Thread. Runs tasks from Queue. void enqueueLocked(tooling::CompileCommand Cmd); - std::thread Thread; std::mutex QueueMu; unsigned NumActiveTasks = 0; // Only idle when queue is empty *and* no tasks. std::condition_variable QueueCV; bool ShouldStop = false; std::deque Queue; + std::thread Thread; // Must be last, spawned thread reads instance vars. }; } // namespace clangd Index: clangd/index/Background.cpp === --- clangd/index/Background.cpp +++ clangd/index/Background.cpp @@ -75,8 +75,11 @@ void BackgroundIndex::enqueue(StringRef Directory, tooling::CompileCommand Cmd) { - std::lock_guard Lock(QueueMu); - enqueueLocked(std::move(Cmd)); + { +std::lock_guard Lock(QueueMu); +enqueueLocked(std::move(Cmd)); + } + QueueCV.notify_all(); } void BackgroundIndex::enqueueAll(StringRef Directory, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r344594 - [clangd] Optionally use dex for the preamble parts of the dynamic index.
Author: sammccall Date: Tue Oct 16 01:53:52 2018 New Revision: 344594 URL: http://llvm.org/viewvc/llvm-project?rev=344594&view=rev Log: [clangd] Optionally use dex for the preamble parts of the dynamic index. Summary: Reuse the old -use-dex-index experiment flag for this. To avoid breaking the tests, make Dex deduplicate symbols, addressing an old FIXME. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53288 Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/ClangdServer.h clang-tools-extra/trunk/clangd/index/Background.cpp clang-tools-extra/trunk/clangd/index/FileIndex.cpp clang-tools-extra/trunk/clangd/index/FileIndex.h clang-tools-extra/trunk/clangd/index/dex/Dex.h clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp clang-tools-extra/trunk/unittests/clangd/DexTests.cpp clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp clang-tools-extra/trunk/unittests/clangd/TestTU.cpp Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=344594&r1=344593&r2=344594&view=diff == --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Oct 16 01:53:52 2018 @@ -105,8 +105,10 @@ ClangdServer::ClangdServer(const GlobalC : CDB(CDB), DiagConsumer(DiagConsumer), FSProvider(FSProvider), ResourceDir(Opts.ResourceDir ? Opts.ResourceDir->str() : getStandardResourceDir()), - DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex(Opts.URISchemes) - : nullptr), + DynamicIdx(Opts.BuildDynamicSymbolIndex + ? new FileIndex(Opts.URISchemes, + Opts.HeavyweightDynamicSymbolIndex) + : nullptr), PCHs(std::make_shared()), // Pass a callback into `WorkScheduler` to extract symbols from a newly // parsed file and rebuild the file index synchronously each time an AST Modified: clang-tools-extra/trunk/clangd/ClangdServer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=344594&r1=344593&r2=344594&view=diff == --- clang-tools-extra/trunk/clangd/ClangdServer.h (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.h Tue Oct 16 01:53:52 2018 @@ -75,6 +75,9 @@ public: /// If true, ClangdServer builds a dynamic in-memory index for symbols in /// opened files and uses the index to augment code completion results. bool BuildDynamicSymbolIndex = false; +/// Use a heavier and faster in-memory index implementation. +/// FIXME: we should make this true if it isn't too slow to build!. +bool HeavyweightDynamicSymbolIndex = false; /// URI schemes to use when building the dynamic index. /// If empty, the default schemes in SymbolCollector will be used. Modified: clang-tools-extra/trunk/clangd/index/Background.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=344594&r1=344593&r2=344594&view=diff == --- clang-tools-extra/trunk/clangd/index/Background.cpp (original) +++ clang-tools-extra/trunk/clangd/index/Background.cpp Tue Oct 16 01:53:52 2018 @@ -183,7 +183,7 @@ llvm::Error BackgroundIndex::index(tooli // FIXME: this should rebuild once-in-a-while, not after every file. // At that point we should use Dex, too. vlog("Rebuilding automatic index"); - reset(IndexedSymbols.buildMemIndex()); + reset(IndexedSymbols.buildIndex(IndexType::Light)); return Error::success(); } Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=344594&r1=344593&r2=344594&view=diff == --- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original) +++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Tue Oct 16 01:53:52 2018 @@ -13,6 +13,7 @@ #include "SymbolCollector.h" #include "index/Index.h" #include "index/Merge.h" +#include "index/dex/Dex.h" #include "clang/Index/IndexingAction.h" #include "clang/Lex/MacroInfo.h" #include "clang/Lex/Preprocessor.h" @@ -98,7 +99,8 @@ void FileSymbols::update(PathRef Path, s FileToRefs[Path] = std::move(Refs); } -std::unique_ptr FileSymbols::buildMemIndex() { +std::unique_ptr +FileSymbols::buildIndex(IndexType Type, ArrayRef URISchemes) { std::vector> SymbolSlabs; std::vector> RefSlabs; { @@ -144,18 +146,27 @@ std
[PATCH] D53288: [clangd] Optionally use dex for the preamble parts of the dynamic index.
This revision was automatically updated to reflect the committed changes. sammccall marked an inline comment as done. Closed by commit rL344594: [clangd] Optionally use dex for the preamble parts of the dynamic index. (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53288?vs=169702&id=169795#toc Repository: rL LLVM https://reviews.llvm.org/D53288 Files: clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/ClangdServer.h clang-tools-extra/trunk/clangd/index/Background.cpp clang-tools-extra/trunk/clangd/index/FileIndex.cpp clang-tools-extra/trunk/clangd/index/FileIndex.h clang-tools-extra/trunk/clangd/index/dex/Dex.h clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp clang-tools-extra/trunk/unittests/clangd/DexTests.cpp clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp clang-tools-extra/trunk/unittests/clangd/TestTU.cpp Index: clang-tools-extra/trunk/unittests/clangd/DexTests.cpp === --- clang-tools-extra/trunk/unittests/clangd/DexTests.cpp +++ clang-tools-extra/trunk/unittests/clangd/DexTests.cpp @@ -492,19 +492,13 @@ "other::A")); } -// FIXME(kbobyrev): This test is different for Dex and MemIndex: while -// MemIndex manages response deduplication, Dex simply returns all matched -// symbols which means there might be equivalent symbols in the response. -// Before drop-in replacement of MemIndex with Dex happens, FileIndex -// should handle deduplication instead. TEST(DexTest, DexDeduplicate) { std::vector Symbols = {symbol("1"), symbol("2"), symbol("3"), symbol("2") /* duplicate */}; FuzzyFindRequest Req; Req.Query = "2"; Dex I(Symbols, RefSlab(), URISchemes); - EXPECT_FALSE(Req.Limit); - EXPECT_THAT(match(I, Req), ElementsAre("2", "2")); + EXPECT_THAT(match(I, Req), ElementsAre("2")); } TEST(DexTest, DexLimitedNumMatches) { Index: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp === --- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp +++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp @@ -82,37 +82,38 @@ TEST(FileSymbolsTest, UpdateAndGet) { FileSymbols FS; - EXPECT_THAT(runFuzzyFind(*FS.buildMemIndex(), ""), IsEmpty()); + EXPECT_THAT(runFuzzyFind(*FS.buildIndex(IndexType::Light), ""), IsEmpty()); FS.update("f1", numSlab(1, 3), refSlab(SymbolID("1"), "f1.cc")); - EXPECT_THAT(runFuzzyFind(*FS.buildMemIndex(), ""), + EXPECT_THAT(runFuzzyFind(*FS.buildIndex(IndexType::Light), ""), UnorderedElementsAre(QName("1"), QName("2"), QName("3"))); - EXPECT_THAT(getRefs(*FS.buildMemIndex(), SymbolID("1")), + EXPECT_THAT(getRefs(*FS.buildIndex(IndexType::Light), SymbolID("1")), RefsAre({FileURI("f1.cc")})); } TEST(FileSymbolsTest, Overlap) { FileSymbols FS; FS.update("f1", numSlab(1, 3), nullptr); FS.update("f2", numSlab(3, 5), nullptr); - EXPECT_THAT(runFuzzyFind(*FS.buildMemIndex(), ""), - UnorderedElementsAre(QName("1"), QName("2"), QName("3"), - QName("4"), QName("5"))); + for (auto Type : {IndexType::Light, IndexType::Heavy}) +EXPECT_THAT(runFuzzyFind(*FS.buildIndex(Type), ""), +UnorderedElementsAre(QName("1"), QName("2"), QName("3"), + QName("4"), QName("5"))); } TEST(FileSymbolsTest, SnapshotAliveAfterRemove) { FileSymbols FS; SymbolID ID("1"); FS.update("f1", numSlab(1, 3), refSlab(ID, "f1.cc")); - auto Symbols = FS.buildMemIndex(); + auto Symbols = FS.buildIndex(IndexType::Light); EXPECT_THAT(runFuzzyFind(*Symbols, ""), UnorderedElementsAre(QName("1"), QName("2"), QName("3"))); EXPECT_THAT(getRefs(*Symbols, ID), RefsAre({FileURI("f1.cc")})); FS.update("f1", nullptr, nullptr); - auto Empty = FS.buildMemIndex(); + auto Empty = FS.buildIndex(IndexType::Light); EXPECT_THAT(runFuzzyFind(*Empty, ""), IsEmpty()); EXPECT_THAT(getRefs(*Empty, ID), ElementsAre()); Index: clang-tools-extra/trunk/unittests/clangd/TestTU.cpp === --- clang-tools-extra/trunk/unittests/clangd/TestTU.cpp +++ clang-tools-extra/trunk/unittests/clangd/TestTU.cpp @@ -50,7 +50,8 @@ std::unique_ptr TestTU::index() const { auto AST = build(); - auto Idx = llvm::make_unique(); + auto Idx = llvm::make_unique( + /*URISchemes=*/std::vector{}, /*UseDex=*/true); Idx->updatePreamble(Filename, AST.getASTContext(), AST.getPreprocessorPtr()); Idx->updateMain(Filename, AST); return std::move(Idx); Index: clang-tools-extra/trunk/clangd/index/Background.cpp === --- clang-tools-extra/trunk/clangd/index/Ba
[clang-tools-extra] r344595 - [clangd] Fix threading bugs in (not-yet-used) BackgroundIndex, re-enable test.
Author: sammccall Date: Tue Oct 16 02:05:13 2018 New Revision: 344595 URL: http://llvm.org/viewvc/llvm-project?rev=344595&view=rev Log: [clangd] Fix threading bugs in (not-yet-used) BackgroundIndex, re-enable test. Summary: One relatively boring bug: forgot to notify the CV after enqueue. One much more fun bug: the thread member could access instance variables before they were initialized. Although the thread was last in the init list, QueueCV etc were listed after Thread in the class, so their default constructors raced with the thread itself. We have to get very unlucky to lose this race, I saw it 0.02% of the time. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D53313 Modified: clang-tools-extra/trunk/clangd/index/Background.cpp clang-tools-extra/trunk/clangd/index/Background.h clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp Modified: clang-tools-extra/trunk/clangd/index/Background.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=344595&r1=344594&r2=344595&view=diff == --- clang-tools-extra/trunk/clangd/index/Background.cpp (original) +++ clang-tools-extra/trunk/clangd/index/Background.cpp Tue Oct 16 02:05:13 2018 @@ -75,8 +75,11 @@ void BackgroundIndex::blockUntilIdleForT void BackgroundIndex::enqueue(StringRef Directory, tooling::CompileCommand Cmd) { - std::lock_guard Lock(QueueMu); - enqueueLocked(std::move(Cmd)); + { +std::lock_guard Lock(QueueMu); +enqueueLocked(std::move(Cmd)); + } + QueueCV.notify_all(); } void BackgroundIndex::enqueueAll(StringRef Directory, Modified: clang-tools-extra/trunk/clangd/index/Background.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.h?rev=344595&r1=344594&r2=344595&view=diff == --- clang-tools-extra/trunk/clangd/index/Background.h (original) +++ clang-tools-extra/trunk/clangd/index/Background.h Tue Oct 16 02:05:13 2018 @@ -65,12 +65,12 @@ private: using Task = std::function; // FIXME: use multiple worker threads. void run(); // Main loop executed by Thread. Runs tasks from Queue. void enqueueLocked(tooling::CompileCommand Cmd); - std::thread Thread; std::mutex QueueMu; unsigned NumActiveTasks = 0; // Only idle when queue is empty *and* no tasks. std::condition_variable QueueCV; bool ShouldStop = false; std::deque Queue; + std::thread Thread; // Must be last, spawned thread reads instance vars. }; } // namespace clangd Modified: clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp?rev=344595&r1=344594&r2=344595&view=diff == --- clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp Tue Oct 16 02:05:13 2018 @@ -11,8 +11,6 @@ namespace clangd { MATCHER_P(Named, N, "") { return arg.Name == N; } -// Temporarily disabled: test timing out on buildbots. -#if 0 TEST(BackgroundIndexTest, IndexTwoFiles) { MockFSProvider FS; // a.h yields different symbols when included by A.cc vs B.cc. @@ -34,7 +32,6 @@ TEST(BackgroundIndexTest, IndexTwoFiles) EXPECT_THAT(runFuzzyFind(Idx, ""), UnorderedElementsAre(Named("a_h"), Named("foo"), Named("bar"))); } -#endif } // namespace clangd } // namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r344513 - [clangd] Minimal implementation of automatic static index (not enabled).
Sorry Douglas. It was indeed a flaky test. Disabled in r344586 and then fixed in r344595. On Tue, Oct 16, 2018 at 3:57 AM wrote: > Hi Sam, > > The test you added in this commit is timing out when run on the PS4 > Windows bot: > > > http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20724/steps/test/logs/stdio > > command timed out: 1200 seconds without output running ['ninja', '-j', > '36', 'check-all'], attempting to kill > FAIL: Extra Tools Unit Tests :: > clangd/./ClangdTests.exe/BackgroundIndexTest.IndexTwoFiles (44401 of 44401) > TEST 'Extra Tools Unit Tests :: > clangd/./ClangdTests.exe/BackgroundIndexTest.IndexTwoFiles' FAILED > > Note: Google Test filter = BackgroundIndexTest.IndexTwoFiles > > [==] Running 1 test from 1 test case. > > [--] Global test environment set-up. > > [--] 1 test from BackgroundIndexTest > > [ RUN ] BackgroundIndexTest.IndexTwoFiles > > > > program finished with exit code 1 > elapsedTime=1446.10 > > Can you take a look? > > Douglas Yung > > > -Original Message- > > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf > > Of Sam McCall via cfe-commits > > Sent: Monday, October 15, 2018 6:34 > > To: cfe-commits@lists.llvm.org > > Subject: [clang-tools-extra] r344513 - [clangd] Minimal implementation > > of automatic static index (not enabled). > > > > Author: sammccall > > Date: Mon Oct 15 06:34:10 2018 > > New Revision: 344513 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=344513&view=rev > > Log: > > [clangd] Minimal implementation of automatic static index (not > > enabled). > > > > Summary: > > See tinyurl.com/clangd-automatic-index for design and goals. > > > > Lots of limitations to keep this patch smallish, TODOs everywhere: > > - no serialization to disk > > - no changes to dynamic index, which now has a much simpler job > > - no partitioning of symbols by file to avoid duplication of header > > symbols > > - no reindexing of edited files > > - only a single worker thread > > - compilation database is slurped synchronously (doesn't scale) > > - uses memindex, rebuilds after every file (should be dex, > > periodically) > > > > It's not hooked up to ClangdServer/ClangdLSPServer yet: the layering > > isn't clear (it should really be in ClangdServer, but ClangdLSPServer > > has all the CDB interactions). > > > > Reviewers: ioeric > > > > Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, > > kadircet, jfb, cfe-commits > > > > Differential Revision: https://reviews.llvm.org/D53032 > > > > Added: > > clang-tools-extra/trunk/clangd/index/Background.cpp > > clang-tools-extra/trunk/clangd/index/Background.h > > clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp > > Modified: > > clang-tools-extra/trunk/clangd/CMakeLists.txt > > clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt > > clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp > > clang-tools-extra/trunk/unittests/clangd/SyncAPI.h > > > > Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt > > URL: http://llvm.org/viewvc/llvm-project/clang-tools- > > extra/trunk/clangd/CMakeLists.txt?rev=344513&r1=344512&r2=344513&view=d > > iff > > === > > === > > --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original) > > +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Mon Oct 15 06:34:10 > > 2018 > > @@ -38,6 +38,7 @@ add_clang_library(clangDaemon > >URI.cpp > >XRefs.cpp > > > > + index/Background.cpp > >index/CanonicalIncludes.cpp > >index/FileIndex.cpp > >index/Index.cpp > > > > Added: clang-tools-extra/trunk/clangd/index/Background.cpp > > URL: http://llvm.org/viewvc/llvm-project/clang-tools- > > extra/trunk/clangd/index/Background.cpp?rev=344513&view=auto > > === > > === > > --- clang-tools-extra/trunk/clangd/index/Background.cpp (added) > > +++ clang-tools-extra/trunk/clangd/index/Background.cpp Mon Oct 15 > > 06:34:10 2018 > > @@ -0,0 +1,191 @@ > > +//===-- Background.cpp - Build an index in a background thread --- > > -===// > > +// > > +// The LLVM Compiler Infrastructure > > +// > > +// This file is distributed under the University of Illinois Open > > Source > > +// License. See LICENSE.TXT for details. > > +// > > +//===- > > -===// > > + > > +#include "index/Background.h" > > +#include "ClangdUnit.h" > > +#include "Compiler.h" > > +#include "Logger.h" > > +#include "Trace.h" > > +#include "index/IndexAction.h" > > +#include "index/MemIndex.h" > > +#include "index/Serialization.h" > > +#include "llvm/Support/SHA1.h" > > +#include > > + > > +using namespace llvm; > > +namespace clang { > > +namespace clangd { > > + > > +Ba
[PATCH] D53313: [clangd] Fix threading bugs in (not-yet-used) BackgroundIndex, re-enable test.
This revision was automatically updated to reflect the committed changes. Closed by commit rL344595: [clangd] Fix threading bugs in (not-yet-used) BackgroundIndex, re-enable test. (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D53313 Files: clang-tools-extra/trunk/clangd/index/Background.cpp clang-tools-extra/trunk/clangd/index/Background.h clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp Index: clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp === --- clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp +++ clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp @@ -11,8 +11,6 @@ MATCHER_P(Named, N, "") { return arg.Name == N; } -// Temporarily disabled: test timing out on buildbots. -#if 0 TEST(BackgroundIndexTest, IndexTwoFiles) { MockFSProvider FS; // a.h yields different symbols when included by A.cc vs B.cc. @@ -34,7 +32,6 @@ EXPECT_THAT(runFuzzyFind(Idx, ""), UnorderedElementsAre(Named("a_h"), Named("foo"), Named("bar"))); } -#endif } // namespace clangd } // namespace clang Index: clang-tools-extra/trunk/clangd/index/Background.h === --- clang-tools-extra/trunk/clangd/index/Background.h +++ clang-tools-extra/trunk/clangd/index/Background.h @@ -65,12 +65,12 @@ using Task = std::function; // FIXME: use multiple worker threads. void run(); // Main loop executed by Thread. Runs tasks from Queue. void enqueueLocked(tooling::CompileCommand Cmd); - std::thread Thread; std::mutex QueueMu; unsigned NumActiveTasks = 0; // Only idle when queue is empty *and* no tasks. std::condition_variable QueueCV; bool ShouldStop = false; std::deque Queue; + std::thread Thread; // Must be last, spawned thread reads instance vars. }; } // namespace clangd Index: clang-tools-extra/trunk/clangd/index/Background.cpp === --- clang-tools-extra/trunk/clangd/index/Background.cpp +++ clang-tools-extra/trunk/clangd/index/Background.cpp @@ -75,8 +75,11 @@ void BackgroundIndex::enqueue(StringRef Directory, tooling::CompileCommand Cmd) { - std::lock_guard Lock(QueueMu); - enqueueLocked(std::move(Cmd)); + { +std::lock_guard Lock(QueueMu); +enqueueLocked(std::move(Cmd)); + } + QueueCV.notify_all(); } void BackgroundIndex::enqueueAll(StringRef Directory, Index: clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp === --- clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp +++ clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp @@ -11,8 +11,6 @@ MATCHER_P(Named, N, "") { return arg.Name == N; } -// Temporarily disabled: test timing out on buildbots. -#if 0 TEST(BackgroundIndexTest, IndexTwoFiles) { MockFSProvider FS; // a.h yields different symbols when included by A.cc vs B.cc. @@ -34,7 +32,6 @@ EXPECT_THAT(runFuzzyFind(Idx, ""), UnorderedElementsAre(Named("a_h"), Named("foo"), Named("bar"))); } -#endif } // namespace clangd } // namespace clang Index: clang-tools-extra/trunk/clangd/index/Background.h === --- clang-tools-extra/trunk/clangd/index/Background.h +++ clang-tools-extra/trunk/clangd/index/Background.h @@ -65,12 +65,12 @@ using Task = std::function; // FIXME: use multiple worker threads. void run(); // Main loop executed by Thread. Runs tasks from Queue. void enqueueLocked(tooling::CompileCommand Cmd); - std::thread Thread; std::mutex QueueMu; unsigned NumActiveTasks = 0; // Only idle when queue is empty *and* no tasks. std::condition_variable QueueCV; bool ShouldStop = false; std::deque Queue; + std::thread Thread; // Must be last, spawned thread reads instance vars. }; } // namespace clangd Index: clang-tools-extra/trunk/clangd/index/Background.cpp === --- clang-tools-extra/trunk/clangd/index/Background.cpp +++ clang-tools-extra/trunk/clangd/index/Background.cpp @@ -75,8 +75,11 @@ void BackgroundIndex::enqueue(StringRef Directory, tooling::CompileCommand Cmd) { - std::lock_guard Lock(QueueMu); - enqueueLocked(std::move(Cmd)); + { +std::lock_guard Lock(QueueMu); +enqueueLocked(std::move(Cmd)); + } + QueueCV.notify_all(); } void BackgroundIndex::enqueueAll(StringRef Directory, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344597 - [ARM][AArch64] Pass through endian flags to assembler and linker.
Author: psmith Date: Tue Oct 16 02:21:17 2018 New Revision: 344597 URL: http://llvm.org/viewvc/llvm-project?rev=344597&view=rev Log: [ARM][AArch64] Pass through endian flags to assembler and linker. The big-endian arm32 Linux builds are currently failing when the -mbig-endian flag is used but the binutils default on the system is little endian. This also holds when -mlittle-endian is used and the binutils default is big endian. The patch always passes through -EL or -BE to the assembler and linker, taking into account the target and the -mbig-endian and -mlittle-endian flag. Fixes pr38770 Differential Revision: https://reviews.llvm.org/D52784 Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp cfe/trunk/test/Driver/linux-as.c cfe/trunk/test/Driver/linux-ld.c Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=344597&r1=344596&r2=344597&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Tue Oct 16 02:21:17 2018 @@ -643,7 +643,7 @@ StringRef arm::getLLVMArchSuffixForARM(S return llvm::ARM::getSubArch(ArchKind); } -void arm::appendEBLinkFlags(const ArgList &Args, ArgStringList &CmdArgs, +void arm::appendBE8LinkFlag(const ArgList &Args, ArgStringList &CmdArgs, const llvm::Triple &Triple) { if (Args.hasArg(options::OPT_r)) return; Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h?rev=344597&r1=344596&r2=344597&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h Tue Oct 16 02:21:17 2018 @@ -29,7 +29,7 @@ StringRef getARMCPUForMArch(llvm::String StringRef getLLVMArchSuffixForARM(llvm::StringRef CPU, llvm::StringRef Arch, const llvm::Triple &Triple); -void appendEBLinkFlags(const llvm::opt::ArgList &Args, +void appendBE8LinkFlag(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const llvm::Triple &Triple); enum class ReadTPMode { Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=344597&r1=344596&r2=344597&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Oct 16 02:21:17 2018 @@ -228,6 +228,29 @@ void tools::gcc::Linker::RenderExtraTool // The types are (hopefully) good enough. } +// On Arm the endianness of the output file is determined by the target and +// can be overridden by the pseudo-target flags '-mlittle-endian'/'-EL' and +// '-mbig-endian'/'-EB'. Unlike other targets the flag does not result in a +// normalized triple so we must handle the flag here. +static bool isArmBigEndian(const llvm::Triple &Triple, + const ArgList &Args) { + bool IsBigEndian = false; + switch (Triple.getArch()) { + case llvm::Triple::armeb: + case llvm::Triple::thumbeb: +IsBigEndian = true; + case llvm::Triple::arm: + case llvm::Triple::thumb: +if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, + options::OPT_mbig_endian)) + IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian); +break; + default: +break; + } + return IsBigEndian; +} + static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) { switch (T.getArch()) { case llvm::Triple::x86: @@ -240,10 +263,9 @@ static const char *getLDMOption(const ll return "aarch64linuxb"; case llvm::Triple::arm: case llvm::Triple::thumb: -return "armelf_linux_eabi"; case llvm::Triple::armeb: case llvm::Triple::thumbeb: -return "armelfb_linux_eabi"; +return isArmBigEndian(T, Args) ? "armelfb_linux_eabi" : "armelf_linux_eabi"; case llvm::Triple::ppc: return "elf32ppclinux"; case llvm::Triple::ppc64: @@ -337,8 +359,13 @@ void tools::gnutools::Linker::ConstructJ if (Args.hasArg(options::OPT_s)) CmdArgs.push_back("-s"); - if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb) -arm::appendEBLinkFlags(Args, CmdArgs, Triple); + if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) { +bool IsBigEndian = isArmBigEndian(Triple, Args); +if (IsBigEndian) + arm::appendBE8LinkFlag(Args, CmdArgs, Triple); +IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be; +CmdArgs.push_back(IsBig
[PATCH] D52784: [ARM][AArch64] Pass through endianness flags to the GNU assembler and linker
This revision was automatically updated to reflect the committed changes. Closed by commit rC344597: [ARM][AArch64] Pass through endian flags to assembler and linker. (authored by psmith, committed by ). Changed prior to commit: https://reviews.llvm.org/D52784?vs=169689&id=169799#toc Repository: rC Clang https://reviews.llvm.org/D52784 Files: lib/Driver/ToolChains/Arch/ARM.cpp lib/Driver/ToolChains/Arch/ARM.h lib/Driver/ToolChains/Gnu.cpp lib/Driver/ToolChains/NetBSD.cpp test/Driver/linux-as.c test/Driver/linux-ld.c Index: lib/Driver/ToolChains/Arch/ARM.h === --- lib/Driver/ToolChains/Arch/ARM.h +++ lib/Driver/ToolChains/Arch/ARM.h @@ -29,7 +29,7 @@ StringRef getLLVMArchSuffixForARM(llvm::StringRef CPU, llvm::StringRef Arch, const llvm::Triple &Triple); -void appendEBLinkFlags(const llvm::opt::ArgList &Args, +void appendBE8LinkFlag(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const llvm::Triple &Triple); enum class ReadTPMode { Index: lib/Driver/ToolChains/Arch/ARM.cpp === --- lib/Driver/ToolChains/Arch/ARM.cpp +++ lib/Driver/ToolChains/Arch/ARM.cpp @@ -643,7 +643,7 @@ return llvm::ARM::getSubArch(ArchKind); } -void arm::appendEBLinkFlags(const ArgList &Args, ArgStringList &CmdArgs, +void arm::appendBE8LinkFlag(const ArgList &Args, ArgStringList &CmdArgs, const llvm::Triple &Triple) { if (Args.hasArg(options::OPT_r)) return; Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -228,6 +228,29 @@ // The types are (hopefully) good enough. } +// On Arm the endianness of the output file is determined by the target and +// can be overridden by the pseudo-target flags '-mlittle-endian'/'-EL' and +// '-mbig-endian'/'-EB'. Unlike other targets the flag does not result in a +// normalized triple so we must handle the flag here. +static bool isArmBigEndian(const llvm::Triple &Triple, + const ArgList &Args) { + bool IsBigEndian = false; + switch (Triple.getArch()) { + case llvm::Triple::armeb: + case llvm::Triple::thumbeb: +IsBigEndian = true; + case llvm::Triple::arm: + case llvm::Triple::thumb: +if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, + options::OPT_mbig_endian)) + IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian); +break; + default: +break; + } + return IsBigEndian; +} + static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) { switch (T.getArch()) { case llvm::Triple::x86: @@ -240,10 +263,9 @@ return "aarch64linuxb"; case llvm::Triple::arm: case llvm::Triple::thumb: -return "armelf_linux_eabi"; case llvm::Triple::armeb: case llvm::Triple::thumbeb: -return "armelfb_linux_eabi"; +return isArmBigEndian(T, Args) ? "armelfb_linux_eabi" : "armelf_linux_eabi"; case llvm::Triple::ppc: return "elf32ppclinux"; case llvm::Triple::ppc64: @@ -337,8 +359,13 @@ if (Args.hasArg(options::OPT_s)) CmdArgs.push_back("-s"); - if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb) -arm::appendEBLinkFlags(Args, CmdArgs, Triple); + if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) { +bool IsBigEndian = isArmBigEndian(Triple, Args); +if (IsBigEndian) + arm::appendBE8LinkFlag(Args, CmdArgs, Triple); +IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be; +CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL"); + } // Most Android ARM64 targets should enable the linker fix for erratum // 843419. Only non-Cortex-A53 devices are allowed to skip this flag. @@ -640,6 +667,7 @@ case llvm::Triple::thumb: case llvm::Triple::thumbeb: { const llvm::Triple &Triple2 = getToolChain().getTriple(); +CmdArgs.push_back(isArmBigEndian(Triple2, Args) ? "-EB" : "-EL"); switch (Triple2.getSubArch()) { case llvm::Triple::ARMSubArch_v7: CmdArgs.push_back("-mfpu=neon"); @@ -672,6 +700,8 @@ } case llvm::Triple::aarch64: case llvm::Triple::aarch64_be: { +CmdArgs.push_back( +getToolChain().getArch() == llvm::Triple::aarch64_be ? "-EB" : "-EL"); Args.AddLastArg(CmdArgs, options::OPT_march_EQ); normalizeCPUNamesForAssembler(Args, CmdArgs); Index: lib/Driver/ToolChains/NetBSD.cpp === --- lib/Driver/ToolChains/NetBSD.cpp +++ lib/Driver/ToolChains/NetBSD.cpp @@ -164,7 +164,7 @@ break; case llvm::Triple::armeb: case llvm::Triple::thumbeb: -arm::appendEBLinkFlags(Args, CmdArgs, ToolChain.getEffectiveTriple()); +arm::appendBE8LinkFlag(Args, CmdArgs, Tool
r344598 - Fix buildbots - update clang-interpreter to use Legacy ORC classes introduced in rL344572.
Author: rksimon Date: Tue Oct 16 02:21:58 2018 New Revision: 344598 URL: http://llvm.org/viewvc/llvm-project?rev=344598&view=rev Log: Fix buildbots - update clang-interpreter to use Legacy ORC classes introduced in rL344572. Modified: cfe/trunk/examples/clang-interpreter/main.cpp Modified: cfe/trunk/examples/clang-interpreter/main.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?rev=344598&r1=344597&r2=344598&view=diff == --- cfe/trunk/examples/clang-interpreter/main.cpp (original) +++ cfe/trunk/examples/clang-interpreter/main.cpp Tue Oct 16 02:21:58 2018 @@ -54,8 +54,8 @@ private: std::shared_ptr Resolver; std::unique_ptr TM; const DataLayout DL; - RTDyldObjectLinkingLayer ObjectLayer; - IRCompileLayer CompileLayer; + LegacyRTDyldObjectLinkingLayer ObjectLayer; + LegacyIRCompileLayer CompileLayer; public: SimpleJIT() @@ -75,7 +75,7 @@ public: TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), ObjectLayer(ES, [this](VModuleKey) { - return RTDyldObjectLinkingLayer::Resources{ + return LegacyRTDyldObjectLinkingLayer::Resources{ std::make_shared(), Resolver}; }), CompileLayer(ObjectLayer, SimpleCompiler(*TM)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50850: clang: Add triples support for MIPS r6
wzssyqa added a comment. In https://reviews.llvm.org/D50850#1250313, @atanasyan wrote: > In https://reviews.llvm.org/D50850#1250285, @wzssyqa wrote: > > > This is really for Clang. I guess you mean that compiler-rt directory also > > need to be patched. > > > If you take a look at the previous version of this patch > https://reviews.llvm.org/D50850?id=167419, you see that it changed LLVM > files. Probably you attached another diff. You are right. I uploaded the patch for llvm here by mistake. And soon, I recognized, and then upload the right one. > As to `compiler-rt` - the Phabricator replace `R6` symbols by the > `https://reviews.llvm.org/source/compiler-rt/` links. So my statement was > "Could you attach an actual patch brings `R6` support to the Clang driver?". Comment at: lib/Driver/ToolChains/Linux.cpp:126 return "mips64-linux-gnu"; -if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnuabi64")) - return "mips64-linux-gnuabi64"; +MipsCpu = (TargetSubArch == llvm::Triple::MipsSubArch_r6) ? "mipsisa64" + : "mips64"; wzssyqa wrote: > atanasyan wrote: > > Suppose there are both "/lib/mips64-linux-gnu" and > > "/lib/mipsisa64-linux-gnuabi64" paths on a disk and provided target triple > > is mipsisa64-linux-gnuabi64. Is it good that we return "mips64-linux-gnu" > > from this function anyway? > No, return `mips64-linux-gnu' is not good, I keep it just for to making sure > I don't change the behavior of clang with my patch. > > In fact, mips64-linux-gnu in gcc is N32, and Debian never use this triple, we > use > mips*64*-linux-gnuabin32 > So, on Debian, mips64-linux-gnu should never appear. mips64-linux-gnu is removed and replaced by MipsCpu + "-linux-" + Mips64Abi https://reviews.llvm.org/D50850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53024: [analyzer][www] Add more open projects
Szelethus added a comment. Why d Comment at: clang/www/analyzer/open_projects.html:153 + problem still remains open. + + (Difficulty: Hard) Did you mean to have this newline here? Difficulty seems to have a weird placement when viewed in a browser. https://reviews.llvm.org/D53024 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53317: [clangd] Allow disble down traversals from root.
ioeric created this revision. ioeric added a reviewer: sammccall. Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov. This is useful for symbo scope proximity, where down traversals from the global scope if not desired. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53317 Files: clangd/FileDistance.cpp clangd/FileDistance.h unittests/clangd/FileDistanceTests.cpp Index: unittests/clangd/FileDistanceTests.cpp === --- unittests/clangd/FileDistanceTests.cpp +++ unittests/clangd/FileDistanceTests.cpp @@ -95,6 +95,20 @@ EXPECT_EQ(D.distance("/a/b/z"), 2u); } +TEST(FileDistance, DisallowDownTraversalsFromRoot) { + FileDistanceOptions Opts; + Opts.UpCost = Opts.DownCost = 1; + Opts.AllowDownTraversalFromRoot = false; + SourceParams CostLots; + CostLots.Cost = 100; + + FileDistance D({{"/", SourceParams()}, {"/a/b/c", CostLots}}, Opts); + EXPECT_EQ(D.distance("/"), 0u); + EXPECT_EQ(D.distance("/a"), 102u); + EXPECT_EQ(D.distance("/a/b"), 101u); + EXPECT_EQ(D.distance("/x"), FileDistance::Unreachable); +} + } // namespace } // namespace clangd } // namespace clang Index: clangd/FileDistance.h === --- clangd/FileDistance.h +++ clangd/FileDistance.h @@ -56,6 +56,7 @@ unsigned UpCost = 2; // |foo/bar.h -> foo| unsigned DownCost = 1;// |foo -> foo/bar.h| unsigned IncludeCost = 2; // |foo.cc -> included_header.h| + bool AllowDownTraversalFromRoot = true; // | / -> /a | }; struct SourceParams { @@ -70,6 +71,7 @@ class FileDistance { public: static constexpr unsigned Unreachable = std::numeric_limits::max(); + static const llvm::hash_code RootHash; FileDistance(llvm::StringMap Sources, const FileDistanceOptions &Opts = {}); Index: clangd/FileDistance.cpp === --- clangd/FileDistance.cpp +++ clangd/FileDistance.cpp @@ -54,6 +54,7 @@ } constexpr const unsigned FileDistance::Unreachable; +const llvm::hash_code FileDistance::RootHash = hash_value(StringRef("/")); FileDistance::FileDistance(StringMap Sources, const FileDistanceOptions &Opts) @@ -99,33 +100,40 @@ for (auto Child : DownEdges.lookup(hash_value(llvm::StringRef("" Next.push(Child); while (!Next.empty()) { -auto ParentCost = Cache.lookup(Next.front()); -for (auto Child : DownEdges.lookup(Next.front())) { - auto &ChildCost = - Cache.try_emplace(Child, Unreachable).first->getSecond(); - if (ParentCost + Opts.DownCost < ChildCost) -ChildCost = ParentCost + Opts.DownCost; +auto Parent = Next.front(); +Next.pop(); +auto ParentCost = Cache.lookup(Parent); +for (auto Child : DownEdges.lookup(Parent)) { + if (Parent != RootHash || Opts.AllowDownTraversalFromRoot) { +auto &ChildCost = +Cache.try_emplace(Child, Unreachable).first->getSecond(); +if (ParentCost + Opts.DownCost < ChildCost) + ChildCost = ParentCost + Opts.DownCost; + } Next.push(Child); } -Next.pop(); } } unsigned FileDistance::distance(StringRef Path) { auto Canonical = canonicalize(Path); unsigned Cost = Unreachable; SmallVector Ancestors; + hash_code KnownNode = hash_value(llvm::StringRef("")); // Walk up ancestors until we find a path we know the distance for. for (StringRef Rest = Canonical; !Rest.empty(); Rest = parent_path(Rest, sys::path::Style::posix)) { auto Hash = hash_value(Rest); auto It = Cache.find(Hash); if (It != Cache.end()) { + KnownNode = Hash; Cost = It->second; break; } Ancestors.push_back(Hash); } + if ((KnownNode == RootHash) && !Opts.AllowDownTraversalFromRoot) +return Ancestors.empty() ? Cost : Unreachable; // Now we know the costs for (known node, queried node]. // Fill these in, walking down the directory tree. for (hash_code Hash : reverse(Ancestors)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53312: [clangd] Support limiting down traversals from sources in FileDistance.
ioeric abandoned this revision. ioeric added a comment. As discussed offline, the semantics is getting a bit complicated. As what we really want for scope proximity is just disallow down traversals from root, we can go with special-casing the root path for now: https://reviews.llvm.org/D53317 Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53312 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344603 - [driver][mips] Adjust target triple's environment accordingly to provided ABI name
Author: atanasyan Date: Tue Oct 16 03:19:06 2018 New Revision: 344603 URL: http://llvm.org/viewvc/llvm-project?rev=344603&view=rev Log: [driver][mips] Adjust target triple's environment accordingly to provided ABI name For MIPS we need to adjust not only architecture name accordingly to ABI provided by the `-mabi` command line option, but also modify triple's environment. For example, for `mips-linux-gnu` triple and `-mabi=n32` option a correct final triple is `mips64-linux-gnuabin32`. Modified: cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/test/Driver/mips-abi.c Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=344603&r1=344602&r2=344603&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Oct 16 03:19:06 2018 @@ -486,12 +486,25 @@ static llvm::Triple computeTargetTriple( // If target is MIPS adjust the target triple // accordingly to provided ABI name. A = Args.getLastArg(options::OPT_mabi_EQ); - if (A && Target.isMIPS()) -Target = llvm::StringSwitch(A->getValue()) - .Case("32", Target.get32BitArchVariant()) - .Case("n32", Target.get64BitArchVariant()) - .Case("64", Target.get64BitArchVariant()) - .Default(Target); + if (A && Target.isMIPS()) { +StringRef ABIName = A->getValue(); +if (ABIName == "32") { + Target = Target.get32BitArchVariant(); + if (Target.getEnvironment() == llvm::Triple::GNUABI64 || + Target.getEnvironment() == llvm::Triple::GNUABIN32) +Target.setEnvironment(llvm::Triple::GNU); +} else if (ABIName == "n32") { + Target = Target.get64BitArchVariant(); + if (Target.getEnvironment() == llvm::Triple::GNU || + Target.getEnvironment() == llvm::Triple::GNUABI64) +Target.setEnvironment(llvm::Triple::GNUABIN32); +} else if (ABIName == "64") { + Target = Target.get64BitArchVariant(); + if (Target.getEnvironment() == llvm::Triple::GNU || + Target.getEnvironment() == llvm::Triple::GNUABIN32) +Target.setEnvironment(llvm::Triple::GNUABI64); +} + } return Target; } Modified: cfe/trunk/test/Driver/mips-abi.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abi.c?rev=344603&r1=344602&r2=344603&view=diff == --- cfe/trunk/test/Driver/mips-abi.c (original) +++ cfe/trunk/test/Driver/mips-abi.c Tue Oct 16 03:19:06 2018 @@ -164,7 +164,7 @@ // MIPS-ARCH-UNKNOWN: error: unknown target CPU 'unknown' // Check adjusting of target triple accordingly to `-mabi` option. -// RUN: %clang -target mips64-linux-gnu -mabi=32 -### %s 2>&1 \ +// RUN: %clang -target mips64-linux-gnuabi64 -mabi=32 -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=TARGET-O32 %s // TARGET-O32: "-triple" "mips-unknown-linux-gnu" // TARGET-O32: "-target-cpu" "mips32r2" @@ -174,7 +174,7 @@ // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=TARGET-N32 %s -// TARGET-N32: "-triple" "mips64-unknown-linux-gnu" +// TARGET-N32: "-triple" "mips64-unknown-linux-gnuabin32" // TARGET-N32: "-target-cpu" "mips64r2" // TARGET-N32: "-target-abi" "n32" // TARGET-N32: ld{{(.exe)?}}" @@ -182,7 +182,7 @@ // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=TARGET-N64 %s -// TARGET-N64: "-triple" "mips64-unknown-linux-gnu" +// TARGET-N64: "-triple" "mips64-unknown-linux-gnuabi64" // TARGET-N64: "-target-cpu" "mips64r2" // TARGET-N64: "-target-abi" "n64" // TARGET-N64: ld{{(.exe)?}}" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53317: [clangd] Allow disble down traversals from root.
sammccall accepted this revision. sammccall added a comment. This revision is now accepted and ready to land. Works for me! I think the code can be simplified slightly. Comment at: clangd/FileDistance.cpp:135 } + if ((KnownNode == RootHash) && !Opts.AllowDownTraversalFromRoot) +return Ancestors.empty() ? Cost : Unreachable; I think this is more power than it needs to be... and in fact messes up the caching. ``` if (KnownNode == RootHash && !Opts.AllowDownTraversalFromRoot && !Ancestors.empty()) Cost = Unreachable; ``` should be enough. Or maybe even clearer, after line 126: ``` if (Hash == RootHash && !Ancestors.empty() && !Opts.AllowDownTraversalFromRoot) { Cost = Unreachable; break; } ``` then you never have to store KnownNode. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52400: Improve -Wshadow warnings with enumerators
sberg added a comment. doesnt this make -Wshadow more aggressive for enumerators than for other entities? ~ cat test17.cc struct S1; struct S2; struct S3 { void S1(); enum { S2 }; }; ~ llvm/inst/bin/clang++ -fsyntax-only -Wshadow test17.cc test17.cc:5:10: warning: declaration shadows a variable in the global namespace [-Wshadow] enum { S2 }; ^ test17.cc:2:8: note: previous declaration is here struct S2; ^ 1 warning generated. warns about enumerator S2 but not about similar function S1 (ran into such a new -Wshadow while compiling LibreOffice) https://reviews.llvm.org/D52400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53317: [clangd] Allow disble down traversals from root.
ioeric updated this revision to Diff 169804. ioeric marked an inline comment as done. ioeric added a comment. - Simplify according to review suggestion. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53317 Files: clangd/FileDistance.cpp clangd/FileDistance.h unittests/clangd/FileDistanceTests.cpp Index: unittests/clangd/FileDistanceTests.cpp === --- unittests/clangd/FileDistanceTests.cpp +++ unittests/clangd/FileDistanceTests.cpp @@ -95,6 +95,20 @@ EXPECT_EQ(D.distance("/a/b/z"), 2u); } +TEST(FileDistance, DisallowDownTraversalsFromRoot) { + FileDistanceOptions Opts; + Opts.UpCost = Opts.DownCost = 1; + Opts.AllowDownTraversalFromRoot = false; + SourceParams CostLots; + CostLots.Cost = 100; + + FileDistance D({{"/", SourceParams()}, {"/a/b/c", CostLots}}, Opts); + EXPECT_EQ(D.distance("/"), 0u); + EXPECT_EQ(D.distance("/a"), 102u); + EXPECT_EQ(D.distance("/a/b"), 101u); + EXPECT_EQ(D.distance("/x"), FileDistance::Unreachable); +} + } // namespace } // namespace clangd } // namespace clang Index: clangd/FileDistance.h === --- clangd/FileDistance.h +++ clangd/FileDistance.h @@ -56,6 +56,7 @@ unsigned UpCost = 2; // |foo/bar.h -> foo| unsigned DownCost = 1;// |foo -> foo/bar.h| unsigned IncludeCost = 2; // |foo.cc -> included_header.h| + bool AllowDownTraversalFromRoot = true; // | / -> /a | }; struct SourceParams { @@ -70,6 +71,7 @@ class FileDistance { public: static constexpr unsigned Unreachable = std::numeric_limits::max(); + static const llvm::hash_code RootHash; FileDistance(llvm::StringMap Sources, const FileDistanceOptions &Opts = {}); Index: clangd/FileDistance.cpp === --- clangd/FileDistance.cpp +++ clangd/FileDistance.cpp @@ -54,6 +54,7 @@ } constexpr const unsigned FileDistance::Unreachable; +const llvm::hash_code FileDistance::RootHash = hash_value(StringRef("/")); FileDistance::FileDistance(StringMap Sources, const FileDistanceOptions &Opts) @@ -99,15 +100,18 @@ for (auto Child : DownEdges.lookup(hash_value(llvm::StringRef("" Next.push(Child); while (!Next.empty()) { -auto ParentCost = Cache.lookup(Next.front()); -for (auto Child : DownEdges.lookup(Next.front())) { - auto &ChildCost = - Cache.try_emplace(Child, Unreachable).first->getSecond(); - if (ParentCost + Opts.DownCost < ChildCost) -ChildCost = ParentCost + Opts.DownCost; +auto Parent = Next.front(); +Next.pop(); +auto ParentCost = Cache.lookup(Parent); +for (auto Child : DownEdges.lookup(Parent)) { + if (Parent != RootHash || Opts.AllowDownTraversalFromRoot) { +auto &ChildCost = +Cache.try_emplace(Child, Unreachable).first->getSecond(); +if (ParentCost + Opts.DownCost < ChildCost) + ChildCost = ParentCost + Opts.DownCost; + } Next.push(Child); } -Next.pop(); } } @@ -119,6 +123,11 @@ for (StringRef Rest = Canonical; !Rest.empty(); Rest = parent_path(Rest, sys::path::Style::posix)) { auto Hash = hash_value(Rest); +if (Hash == RootHash && !Ancestors.empty() && +!Opts.AllowDownTraversalFromRoot) { + Cost = Unreachable; + break; +} auto It = Cache.find(Hash); if (It != Cache.end()) { Cost = It->second; Index: unittests/clangd/FileDistanceTests.cpp === --- unittests/clangd/FileDistanceTests.cpp +++ unittests/clangd/FileDistanceTests.cpp @@ -95,6 +95,20 @@ EXPECT_EQ(D.distance("/a/b/z"), 2u); } +TEST(FileDistance, DisallowDownTraversalsFromRoot) { + FileDistanceOptions Opts; + Opts.UpCost = Opts.DownCost = 1; + Opts.AllowDownTraversalFromRoot = false; + SourceParams CostLots; + CostLots.Cost = 100; + + FileDistance D({{"/", SourceParams()}, {"/a/b/c", CostLots}}, Opts); + EXPECT_EQ(D.distance("/"), 0u); + EXPECT_EQ(D.distance("/a"), 102u); + EXPECT_EQ(D.distance("/a/b"), 101u); + EXPECT_EQ(D.distance("/x"), FileDistance::Unreachable); +} + } // namespace } // namespace clangd } // namespace clang Index: clangd/FileDistance.h === --- clangd/FileDistance.h +++ clangd/FileDistance.h @@ -56,6 +56,7 @@ unsigned UpCost = 2; // |foo/bar.h -> foo| unsigned DownCost = 1;// |foo -> foo/bar.h| unsigned IncludeCost = 2; // |foo.cc -> included_header.h| + bool AllowDownTraversalFromRoot = true; // | / -> /a | }; struct SourceParams { @@ -70,6 +71,7 @@ class FileDistance { public: static constexpr unsigned Unreachable = std::numeric_limits::max(); + static const llvm::hash_code RootHash; FileDistance(llvm::StringMap Sources, const FileDistanceOptions &O
[clang-tools-extra] r344604 - [clangd] Allow disble down traversals from root.
Author: ioeric Date: Tue Oct 16 03:41:17 2018 New Revision: 344604 URL: http://llvm.org/viewvc/llvm-project?rev=344604&view=rev Log: [clangd] Allow disble down traversals from root. Summary: This is useful for symbo scope proximity, where down traversals from the global scope if not desired. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53317 Modified: clang-tools-extra/trunk/clangd/FileDistance.cpp clang-tools-extra/trunk/clangd/FileDistance.h clang-tools-extra/trunk/unittests/clangd/FileDistanceTests.cpp Modified: clang-tools-extra/trunk/clangd/FileDistance.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FileDistance.cpp?rev=344604&r1=344603&r2=344604&view=diff == --- clang-tools-extra/trunk/clangd/FileDistance.cpp (original) +++ clang-tools-extra/trunk/clangd/FileDistance.cpp Tue Oct 16 03:41:17 2018 @@ -54,6 +54,7 @@ static SmallString<128> canonicalize(Str } constexpr const unsigned FileDistance::Unreachable; +const llvm::hash_code FileDistance::RootHash = hash_value(StringRef("/")); FileDistance::FileDistance(StringMap Sources, const FileDistanceOptions &Opts) @@ -99,15 +100,18 @@ FileDistance::FileDistance(StringMapgetSecond(); - if (ParentCost + Opts.DownCost < ChildCost) -ChildCost = ParentCost + Opts.DownCost; +auto Parent = Next.front(); +Next.pop(); +auto ParentCost = Cache.lookup(Parent); +for (auto Child : DownEdges.lookup(Parent)) { + if (Parent != RootHash || Opts.AllowDownTraversalFromRoot) { +auto &ChildCost = +Cache.try_emplace(Child, Unreachable).first->getSecond(); +if (ParentCost + Opts.DownCost < ChildCost) + ChildCost = ParentCost + Opts.DownCost; + } Next.push(Child); } -Next.pop(); } } @@ -119,6 +123,11 @@ unsigned FileDistance::distance(StringRe for (StringRef Rest = Canonical; !Rest.empty(); Rest = parent_path(Rest, sys::path::Style::posix)) { auto Hash = hash_value(Rest); +if (Hash == RootHash && !Ancestors.empty() && +!Opts.AllowDownTraversalFromRoot) { + Cost = Unreachable; + break; +} auto It = Cache.find(Hash); if (It != Cache.end()) { Cost = It->second; Modified: clang-tools-extra/trunk/clangd/FileDistance.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FileDistance.h?rev=344604&r1=344603&r2=344604&view=diff == --- clang-tools-extra/trunk/clangd/FileDistance.h (original) +++ clang-tools-extra/trunk/clangd/FileDistance.h Tue Oct 16 03:41:17 2018 @@ -56,6 +56,7 @@ struct FileDistanceOptions { unsigned UpCost = 2; // |foo/bar.h -> foo| unsigned DownCost = 1;// |foo -> foo/bar.h| unsigned IncludeCost = 2; // |foo.cc -> included_header.h| + bool AllowDownTraversalFromRoot = true; // | / -> /a | }; struct SourceParams { @@ -70,6 +71,7 @@ struct SourceParams { class FileDistance { public: static constexpr unsigned Unreachable = std::numeric_limits::max(); + static const llvm::hash_code RootHash; FileDistance(llvm::StringMap Sources, const FileDistanceOptions &Opts = {}); Modified: clang-tools-extra/trunk/unittests/clangd/FileDistanceTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FileDistanceTests.cpp?rev=344604&r1=344603&r2=344604&view=diff == --- clang-tools-extra/trunk/unittests/clangd/FileDistanceTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/FileDistanceTests.cpp Tue Oct 16 03:41:17 2018 @@ -95,6 +95,20 @@ TEST(FileDistance, LimitUpTraversals) { EXPECT_EQ(D.distance("/a/b/z"), 2u); } +TEST(FileDistance, DisallowDownTraversalsFromRoot) { + FileDistanceOptions Opts; + Opts.UpCost = Opts.DownCost = 1; + Opts.AllowDownTraversalFromRoot = false; + SourceParams CostLots; + CostLots.Cost = 100; + + FileDistance D({{"/", SourceParams()}, {"/a/b/c", CostLots}}, Opts); + EXPECT_EQ(D.distance("/"), 0u); + EXPECT_EQ(D.distance("/a"), 102u); + EXPECT_EQ(D.distance("/a/b"), 101u); + EXPECT_EQ(D.distance("/x"), FileDistance::Unreachable); +} + } // namespace } // namespace clangd } // namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
takuto.ikuta added a comment. Herald added a subscriber: nhaehnle. Hans, I addressed all your comments. How do you think about current implementation? Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5719 + TSK != TSK_ExplicitInstantiationDeclaration && + TSK != TSK_ExplicitInstantiationDefinition) { +if (ClassExported) { takuto.ikuta wrote: > hans wrote: > > takuto.ikuta wrote: > > > hans wrote: > > > > I still don't understand why we need these checks for template > > > > instantiations. Why does it matter whether the functions get inlined or > > > > not? > > > When function of dllimported class is not inlined, such funtion needs to > > > be dllexported from implementation library. > > > > > > c.h > > > ``` > > > template > > > class EXPORT C { > > > public: > > > void f() {} > > > }; > > > ``` > > > > > > cuser.cc > > > ``` > > > #include "c.h" > > > > > > void cuser() { > > > C c; > > > c.f(); // This function may not be inlined when EXPORT is > > > __declspec(dllimport), so link may fail. > > > } > > > ``` > > > > > > When cuser.cc and c.h are built to different library, cuser.cc needs to > > > be able to see dllexported C::f() when C::f() is not inlined. > > > This is my understanding. > > Your example doesn't use explicit instantiation definition or declaration, > > so doesn't apply here I think. > > > > As long as the dllexport and dllimport attributes matches it's fine. It > > doesn't matter whether the function gets inlined or not, the only thing > > that matters is that if it's marked dllimport on the "consumer side", it > > must be dllexport when building the dll. > Hmm, I changed the linkage for functions having DLLExport/ImportStaticLocal > Attr. > I changed linkage in ASTContext so that inline function is emitted when it is necessary when we use fno-dllexport-inlines. https://reviews.llvm.org/D51340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53317: [clangd] Allow disble down traversals from root.
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE344604: [clangd] Allow disble down traversals from root. (authored by ioeric, committed by ). Changed prior to commit: https://reviews.llvm.org/D53317?vs=169804&id=169805#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53317 Files: clangd/FileDistance.cpp clangd/FileDistance.h unittests/clangd/FileDistanceTests.cpp Index: clangd/FileDistance.h === --- clangd/FileDistance.h +++ clangd/FileDistance.h @@ -56,6 +56,7 @@ unsigned UpCost = 2; // |foo/bar.h -> foo| unsigned DownCost = 1;// |foo -> foo/bar.h| unsigned IncludeCost = 2; // |foo.cc -> included_header.h| + bool AllowDownTraversalFromRoot = true; // | / -> /a | }; struct SourceParams { @@ -70,6 +71,7 @@ class FileDistance { public: static constexpr unsigned Unreachable = std::numeric_limits::max(); + static const llvm::hash_code RootHash; FileDistance(llvm::StringMap Sources, const FileDistanceOptions &Opts = {}); Index: clangd/FileDistance.cpp === --- clangd/FileDistance.cpp +++ clangd/FileDistance.cpp @@ -54,6 +54,7 @@ } constexpr const unsigned FileDistance::Unreachable; +const llvm::hash_code FileDistance::RootHash = hash_value(StringRef("/")); FileDistance::FileDistance(StringMap Sources, const FileDistanceOptions &Opts) @@ -99,15 +100,18 @@ for (auto Child : DownEdges.lookup(hash_value(llvm::StringRef("" Next.push(Child); while (!Next.empty()) { -auto ParentCost = Cache.lookup(Next.front()); -for (auto Child : DownEdges.lookup(Next.front())) { - auto &ChildCost = - Cache.try_emplace(Child, Unreachable).first->getSecond(); - if (ParentCost + Opts.DownCost < ChildCost) -ChildCost = ParentCost + Opts.DownCost; +auto Parent = Next.front(); +Next.pop(); +auto ParentCost = Cache.lookup(Parent); +for (auto Child : DownEdges.lookup(Parent)) { + if (Parent != RootHash || Opts.AllowDownTraversalFromRoot) { +auto &ChildCost = +Cache.try_emplace(Child, Unreachable).first->getSecond(); +if (ParentCost + Opts.DownCost < ChildCost) + ChildCost = ParentCost + Opts.DownCost; + } Next.push(Child); } -Next.pop(); } } @@ -119,6 +123,11 @@ for (StringRef Rest = Canonical; !Rest.empty(); Rest = parent_path(Rest, sys::path::Style::posix)) { auto Hash = hash_value(Rest); +if (Hash == RootHash && !Ancestors.empty() && +!Opts.AllowDownTraversalFromRoot) { + Cost = Unreachable; + break; +} auto It = Cache.find(Hash); if (It != Cache.end()) { Cost = It->second; Index: unittests/clangd/FileDistanceTests.cpp === --- unittests/clangd/FileDistanceTests.cpp +++ unittests/clangd/FileDistanceTests.cpp @@ -95,6 +95,20 @@ EXPECT_EQ(D.distance("/a/b/z"), 2u); } +TEST(FileDistance, DisallowDownTraversalsFromRoot) { + FileDistanceOptions Opts; + Opts.UpCost = Opts.DownCost = 1; + Opts.AllowDownTraversalFromRoot = false; + SourceParams CostLots; + CostLots.Cost = 100; + + FileDistance D({{"/", SourceParams()}, {"/a/b/c", CostLots}}, Opts); + EXPECT_EQ(D.distance("/"), 0u); + EXPECT_EQ(D.distance("/a"), 102u); + EXPECT_EQ(D.distance("/a/b"), 101u); + EXPECT_EQ(D.distance("/x"), FileDistance::Unreachable); +} + } // namespace } // namespace clangd } // namespace clang Index: clangd/FileDistance.h === --- clangd/FileDistance.h +++ clangd/FileDistance.h @@ -56,6 +56,7 @@ unsigned UpCost = 2; // |foo/bar.h -> foo| unsigned DownCost = 1;// |foo -> foo/bar.h| unsigned IncludeCost = 2; // |foo.cc -> included_header.h| + bool AllowDownTraversalFromRoot = true; // | / -> /a | }; struct SourceParams { @@ -70,6 +71,7 @@ class FileDistance { public: static constexpr unsigned Unreachable = std::numeric_limits::max(); + static const llvm::hash_code RootHash; FileDistance(llvm::StringMap Sources, const FileDistanceOptions &Opts = {}); Index: clangd/FileDistance.cpp === --- clangd/FileDistance.cpp +++ clangd/FileDistance.cpp @@ -54,6 +54,7 @@ } constexpr const unsigned FileDistance::Unreachable; +const llvm::hash_code FileDistance::RootHash = hash_value(StringRef("/")); FileDistance::FileDistance(StringMap Sources, const FileDistanceOptions &Opts) @@ -99,15 +100,18 @@ for (auto Child : DownEdges.lookup(hash_value(llvm::StringRef("" Next.push(Child); while (!Next.empty()) { -auto ParentCost = Cache.lookup(Next.front()); -for (auto Child : DownEdges.lookup(Next.fro
[PATCH] D52615: Handle -fsanitize-address-poison-class-member-array-new-cookie in the driver and propagate it to cc1
filcab added a comment. In https://reviews.llvm.org/D52615#1254567, @rsmith wrote: > This seems like an unreasonably long flag name. Can you try to find a shorter > name for it? `-fsanitize-poison-extra-operator-new`? Not as explicit, but maybe ok if documented? Thank you, Filipe Repository: rC Clang https://reviews.llvm.org/D52615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53295: [OpenCL] Mark load of block invoke function as invariant
yaxunl added inline comments. Comment at: lib/CodeGen/CGBlocks.cpp:1318 +CGM.getModule().getMDKindID("invariant.load"), +llvm::MDNode::get(getLLVMContext(), None)); + rjmccall wrote: > OpenCL blocks are still potentially function-local, right? I don't think > you're allowed to put `invariant.load` on something that's visibly > initialized, even if it's visibly initialized to the same thing every time. > The problem is that `invariant.load` could allow the load to be hoisted above > the initialization. > > If you can solve that problem, you can make this non-OpenCL-specific. It seems that invariant.load implies the pointer is invariant in the whole module, disregarding the store to it, which is not suitable for this case. In this case what I need is that after the first store to the pointer, every load does not change. It seems invariant.group can be used for this. https://reviews.llvm.org/D53295 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53286: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
sammccall updated this revision to Diff 169807. sammccall added a comment. Add unit test for JSON transport. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53286 Files: clangd/CMakeLists.txt clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/JSONRPCDispatcher.cpp clangd/JSONRPCDispatcher.h clangd/JSONTransport.cpp clangd/Protocol.cpp clangd/Protocol.h clangd/ProtocolHandlers.cpp clangd/Transport.h clangd/tool/ClangdMain.cpp test/clangd/compile-commands-path-in-initialize.test test/clangd/compile-commands-path.test test/clangd/completion-snippets.test test/clangd/completion.test test/clangd/crash-non-added-files.test test/clangd/execute-command.test test/clangd/input-mirror.test test/clangd/signature-help.test test/clangd/textdocument-didchange-fail.test test/clangd/trace.test test/clangd/xrefs.test unittests/clangd/CMakeLists.txt unittests/clangd/JSONTransportTests.cpp Index: unittests/clangd/JSONTransportTests.cpp === --- /dev/null +++ unittests/clangd/JSONTransportTests.cpp @@ -0,0 +1,199 @@ +//===-- JSONTransportTests.cpp ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +#include "Protocol.h" +#include "Transport.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +using namespace llvm; +namespace clang { +namespace clangd { +namespace { + +// No fmemopen on windows, so we can't easily run this test. +#ifndef WIN32 + +// Fixture takes care of managing the input/output buffers for the transport. +class JSONTransportTest : public ::testing::Test { + std::string InBuf, OutBuf, MirrorBuf; + llvm::raw_string_ostream Out, Mirror; + std::unique_ptr In; + +protected: + JSONTransportTest() : Out(OutBuf), Mirror(MirrorBuf), In(nullptr, nullptr) {} + + template + std::unique_ptr transport(std::string InData, bool Pretty, + JSONStreamStyle Style) { +InBuf = std::move(InData); +In = {fmemopen(&InBuf[0], InBuf.size(), "r"), &fclose}; +return newJSONTransport(In.get(), Out, &Mirror, Pretty, Style); + } + + std::string input() const { return InBuf; } + std::string output() { return Out.str(); } + std::string input_mirror() { return Mirror.str(); } +}; + +// Echo is a simple server running on a transport: +// - logs each message it gets. +// - when it gets a call, replies to it +// - when it gets a notification for method "call", makes a call on Target +// Hangs up when it gets an exit notification. +class Echo : public Transport::MessageHandler { + Transport &Target; + std::string LogBuf; + raw_string_ostream Log; + +public: + Echo(Transport &Target) : Target(Target), Log(LogBuf) {} + + std::string log() { return Log.str(); } + + bool notify(StringRef Method, json::Value Params) override { +Log << "Notification " << Method << ": " << Params << "\n"; +if (Method == "call") + Target.call("echo call", std::move(Params), 42); +return Method == "exit"; + } + + bool call(StringRef Method, json::Value Params, json::Value ID) override { +Log << "Call " << Method << "(" << ID << "): " << Params << "\n"; +if (Method == "err") + Target.reply(ID, make_error("trouble at mill", ErrorCode(88))); +else + Target.reply(ID, std::move(Params)); +return false; + } + + bool reply(json::Value ID, Expected Params) override { +if (Params) + Log << "Reply(" << ID << "): " << *Params << "\n"; +else + Log << "Reply(" << ID + << "): error = " << llvm::toString(Params.takeError()) << "\n"; +return false; + } +}; + +std::string trim(StringRef S) { return S.trim().str(); } + +// Runs an Echo session using the standard JSON-RPC format we use in production. +TEST_F(JSONTransportTest, StandardDense) { + auto T = transport( + "Content-Length: 52\r\n\r\n" + R"({"jsonrpc": "2.0", "method": "call", "params": 1234})" + "Content-Length: 46\r\n\r\n" + R"({"jsonrpc": "2.0", "id": 1234, "result": 5678})" + "Content-Length: 67\r\n\r\n" + R"({"jsonrpc": "2.0", "method": "foo", "id": "abcd", "params": "efgh"})" + "Content-Length: 73\r\n\r\n" + R"({"jsonrpc": "2.0", "id": "xyz", "error": {"code": 99, "message": "bad!"}})" + "Content-Length: 68\r\n\r\n" + R"({"jsonrpc": "2.0", "method": "err", "id": "wxyz", "params": "boom!"})" + "Content-Length: 36\r\n\r\n" + R"({"jsonrpc": "2.0", "method": "exit"})", + /*Pretty=*/false, JSONStreamStyle::Standard); + Echo E(*T); + auto Err = T->loop(E); + EXPECT_FALSE(bool(Err)) << llvm::toString(std::move(Err)); + + EXPECT_EQ(trim(E.log()), trim(R"( +Notification call: 1234 +Reply(1234): 5678 +Ca
[PATCH] D52400: Improve -Wshadow warnings with enumerators
aaron.ballman added a comment. In https://reviews.llvm.org/D52400#1266307, @sberg wrote: > doesnt this make -Wshadow more aggressive for enumerators than for other > entities? It does, but whether that's an issue with the enumerator shadow diagnosing or with the other entities not diagnosing, I'm less clear. Consider this slight modification to your code: struct S1; struct S2; struct S3 { void S1(); enum { S2 }; void f(S2 s); }; On the one hand, the warning is telling you about a problem before you hit it. However, this code will err on the declaration of `S::f()` anyway because `S2` is not a type, so the warning doesn't get us all *that* much benefit. Then again, this is a case where you don't get any error but you do get a silent behavioral ambiguity without the current enumerator shadow diagnostic: struct S1; struct S2; struct S3 { void S1(); enum { S2 }; void f(decltype(S2) s); }; So there are cases where this behavior can be somewhat useful. > (ran into such a new -Wshadow while compiling LibreOffice) Was it a frequent/annoying occurrence? https://reviews.llvm.org/D52400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50850: clang: Add triples support for MIPS r6
wzssyqa updated this revision to Diff 169810. https://reviews.llvm.org/D50850 Files: lib/Driver/ToolChains/Arch/Mips.cpp lib/Driver/ToolChains/Gnu.cpp lib/Driver/ToolChains/Linux.cpp test/CodeGen/atomics-inlining.c test/CodeGen/mips-zero-sized-struct.c test/CodeGen/target-data.c test/CodeGen/xray-attributes-supported.cpp test/Driver/clang-translation.c Index: test/Driver/clang-translation.c === --- test/Driver/clang-translation.c +++ test/Driver/clang-translation.c @@ -291,13 +291,27 @@ // MIPS: "-target-cpu" "mips32r2" // MIPS: "-mfloat-abi" "hard" +// RUN: %clang -target mipsisa32r6-linux-gnu -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPSR6 %s +// MIPSR6: clang +// MIPSR6: "-cc1" +// MIPSR6: "-target-cpu" "mips32r6" +// MIPSR6: "-mfloat-abi" "hard" + // RUN: %clang -target mipsel-linux-gnu -### -S %s 2>&1 | \ // RUN: FileCheck -check-prefix=MIPSEL %s // MIPSEL: clang // MIPSEL: "-cc1" // MIPSEL: "-target-cpu" "mips32r2" // MIPSEL: "-mfloat-abi" "hard" +// RUN: %clang -target mipsisa32r6el-linux-gnu -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPSR6EL %s +// MIPSR6EL: clang +// MIPSR6EL: "-cc1" +// MIPSR6EL: "-target-cpu" "mips32r6" +// MIPSR6EL: "-mfloat-abi" "hard" + // RUN: %clang -target mipsel-linux-android -### -S %s 2>&1 | \ // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s // MIPSEL-ANDROID: clang @@ -323,45 +337,91 @@ // MIPS64: "-target-cpu" "mips64r2" // MIPS64: "-mfloat-abi" "hard" +// RUN: %clang -target mipsisa64r6-linux-gnu -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPS64R6 %s +// MIPS64R6: clang +// MIPS64R6: "-cc1" +// MIPS64R6: "-target-cpu" "mips64r6" +// MIPS64R6: "-mfloat-abi" "hard" + // RUN: %clang -target mips64el-linux-gnu -### -S %s 2>&1 | \ // RUN: FileCheck -check-prefix=MIPS64EL %s // MIPS64EL: clang // MIPS64EL: "-cc1" // MIPS64EL: "-target-cpu" "mips64r2" // MIPS64EL: "-mfloat-abi" "hard" +// RUN: %clang -target mipsisa64r6el-linux-gnu -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPS64R6EL %s +// MIPS64R6EL: clang +// MIPS64R6EL: "-cc1" +// MIPS64R6EL: "-target-cpu" "mips64r6" +// MIPS64R6EL: "-mfloat-abi" "hard" + // RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \ // RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s // MIPS64-GNUABI64: clang // MIPS64-GNUABI64: "-cc1" // MIPS64-GNUABI64: "-target-cpu" "mips64r2" // MIPS64-GNUABI64: "-target-abi" "n64" // MIPS64-GNUABI64: "-mfloat-abi" "hard" +// RUN: %clang -target mipsisa64r6-linux-gnuabi64 -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPS64R6-GNUABI64 %s +// MIPS64R6-GNUABI64: clang +// MIPS64R6-GNUABI64: "-cc1" +// MIPS64R6-GNUABI64: "-target-cpu" "mips64r6" +// MIPS64R6-GNUABI64: "-target-abi" "n64" +// MIPS64R6-GNUABI64: "-mfloat-abi" "hard" + // RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \ // RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s // MIPS64EL-GNUABI64: clang // MIPS64EL-GNUABI64: "-cc1" // MIPS64EL-GNUABI64: "-target-cpu" "mips64r2" // MIPS64EL-GNUABI64: "-target-abi" "n64" // MIPS64EL-GNUABI64: "-mfloat-abi" "hard" +// RUN: %clang -target mipsisa64r6el-linux-gnuabi64 -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPS64R6EL-GNUABI64 %s +// MIPS64R6EL-GNUABI64: clang +// MIPS64R6EL-GNUABI64: "-cc1" +// MIPS64R6EL-GNUABI64: "-target-cpu" "mips64r6" +// MIPS64R6EL-GNUABI64: "-target-abi" "n64" +// MIPS64R6EL-GNUABI64: "-mfloat-abi" "hard" + // RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \ // RUN: FileCheck -check-prefix=MIPSN32 %s // MIPSN32: clang // MIPSN32: "-cc1" // MIPSN32: "-target-cpu" "mips64r2" // MIPSN32: "-target-abi" "n32" // MIPSN32: "-mfloat-abi" "hard" +// RUN: %clang -target mipsisa64r6-linux-gnuabin32 -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPSN32R6 %s +// MIPSN32R6: clang +// MIPSN32R6: "-cc1" +// MIPSN32R6: "-target-cpu" "mips64r6" +// MIPSN32R6: "-target-abi" "n32" +// MIPSN32R6: "-mfloat-abi" "hard" + // RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \ // RUN: FileCheck -check-prefix=MIPSN32EL %s // MIPSN32EL: clang // MIPSN32EL: "-cc1" // MIPSN32EL: "-target-cpu" "mips64r2" // MIPSN32EL: "-target-abi" "n32" // MIPSN32EL: "-mfloat-abi" "hard" +// RUN: %clang -target mipsisa64r6el-linux-gnuabin32 -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPSN32R6EL %s +// MIPSN32R6EL: clang +// MIPSN32R6EL: "-cc1" +// MIPSN32R6EL: "-target-cpu" "mips64r6" +// MIPSN32R6EL: "-target-abi" "n32" +// MIPSN32R6EL: "-mfloat-abi" "hard" + // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \ // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s // MIPS64EL-ANDROID: clang Index: test/CodeGen/xray-attributes-supported.cpp === --- test/CodeGen/xray-attributes-supported.cpp +++ test/CodeGen/xray-attributes-supported.cpp @@ -5,20 +5,36 @@ // RUN: %clang_cc1
[PATCH] D53131: [clangd] Support scope proximity in code completion.
ioeric updated this revision to Diff 169814. ioeric marked 3 inline comments as done. ioeric added a comment. - refactor to use FileDistance and address review comments. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53131 Files: clangd/AST.cpp clangd/AST.h clangd/CodeComplete.cpp clangd/Quality.cpp clangd/Quality.h unittests/clangd/CodeCompleteTests.cpp unittests/clangd/QualityTests.cpp Index: unittests/clangd/QualityTests.cpp === --- unittests/clangd/QualityTests.cpp +++ unittests/clangd/QualityTests.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/Casting.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include namespace clang { namespace clangd { @@ -117,13 +118,14 @@ Relevance = {}; Relevance.merge(CodeCompletionResult(&findDecl(AST, "main"), 42)); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) << "Decl in current file"; + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) + << "Decl in current file"; Relevance = {}; Relevance.merge(CodeCompletionResult(&findDecl(AST, "header"), 42)); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 0.6f) << "Decl from header"; + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 0.6f) << "Decl from header"; Relevance = {}; Relevance.merge(CodeCompletionResult(&findDecl(AST, "header_main"), 42)); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) << "Current file and header"; auto constructShadowDeclCompletionResult = [&](const std::string DeclName) { @@ -146,10 +148,10 @@ Relevance = {}; Relevance.merge(constructShadowDeclCompletionResult("Bar")); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) << "Using declaration in main file"; Relevance.merge(constructShadowDeclCompletionResult("FLAGS_FOO")); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) << "Using declaration in main file"; Relevance = {}; @@ -210,9 +212,21 @@ PoorNameMatch.NameMatch = 0.2f; EXPECT_LT(PoorNameMatch.evaluate(), Default.evaluate()); - SymbolRelevanceSignals WithSemaProximity; - WithSemaProximity.SemaProximityScore = 0.2f; - EXPECT_GT(WithSemaProximity.evaluate(), Default.evaluate()); + SymbolRelevanceSignals WithSemaFileProximity; + WithSemaFileProximity.SemaFileProximityScore = 0.2f; + EXPECT_GT(WithSemaFileProximity.evaluate(), Default.evaluate()); + + QueryScopeProximity ScopeProximity({"x::y::"}); + + SymbolRelevanceSignals WithSemaScopeProximity; + WithSemaScopeProximity.ScopeProximityMatch = &ScopeProximity; + WithSemaScopeProximity.SemaSaysInScope = true; + EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate()); + + SymbolRelevanceSignals WithIndexScopeProximity; + WithIndexScopeProximity.ScopeProximityMatch = &ScopeProximity; + WithIndexScopeProximity.SymbolScope = "x::"; + EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate()); SymbolRelevanceSignals IndexProximate; IndexProximate.SymbolURI = "unittest:/foo/bar.h"; @@ -242,6 +256,35 @@ EXPECT_EQ(Instance.evaluate(), Default.evaluate()); } +TEST(QualityTests, ScopeProximity) { + SymbolRelevanceSignals Default; + + SymbolRelevanceSignals Relevance; + QueryScopeProximity ScopeProximity({"x::y::", "x::", "std::", ""}); + Relevance.ScopeProximityMatch = &ScopeProximity; + + Relevance.SymbolScope = "other::"; + float NotMatched = Relevance.evaluate(); + log(" --- not matched: ", NotMatched); + EXPECT_LT(NotMatched, Default.evaluate()); + + Relevance.SymbolScope = ""; + float Global = Relevance.evaluate(); + EXPECT_GT(Global, Default.evaluate()); + + Relevance.SymbolScope = "std::"; + float NonParent = Relevance.evaluate(); + EXPECT_GT(NonParent, Global); + + Relevance.SymbolScope = "x::"; + float Parent = Relevance.evaluate(); + EXPECT_GT(Parent, NonParent); + + Relevance.SymbolScope = "x::y::"; + float Enclosing = Relevance.evaluate(); + EXPECT_GT(Enclosing, Parent); +} + TEST(QualityTests, SortText) { EXPECT_LT(sortText(std::numeric_limits::infinity()), sortText(1000.2f)); Index: unittests/clangd/CodeCompleteTests.cpp === --- unittests/clangd/CodeCompleteTests.cpp +++ unittests/clangd/CodeCompleteTests.cpp @@ -1040,6 +1040,29 @@ UnorderedElementsAre("", "ns::", "std::"; } +TEST(CompletionTest, EnclosingScopeComesFirst) { + auto Requests = captureIndexRequests(R"cpp( + namespace std {} + using namespace std; + namespace nx { + namespace ns { + namespace { + void f() { +vec^ + } + } + } + } + )cpp"); + + EXPECT_THAT(Requests, + ElementsAre(Field( + &FuzzyFindRequest::Scopes, +
[PATCH] D53322: [clangd] Collect refs from headers.
hokein created this revision. hokein added a reviewer: sammccall. Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric, ilya-biryukov. Add a flag to SymbolCollector to collect refs fdrom headers. Note that we collect refs from headers in static index, and we don't do it for dynamic index because of the preamble (we skip function body in preamble, collecting it will result incomplete results). Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53322 Files: clangd/index/IndexAction.cpp clangd/index/IndexAction.h clangd/index/SymbolCollector.cpp clangd/index/SymbolCollector.h unittests/clangd/SymbolCollectorTests.cpp Index: unittests/clangd/SymbolCollectorTests.cpp === --- unittests/clangd/SymbolCollectorTests.cpp +++ unittests/clangd/SymbolCollectorTests.cpp @@ -479,6 +479,17 @@ EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "c").ID, _; } +TEST_F(SymbolCollectorTest, RefsInHeaders) { + CollectorOpts.RefFilter = RefKind::All; + CollectorOpts.RefMainFileOnly = false; + Annotations Header(R"( + class [[Foo]] {}; + )"); + runSymbolCollector(Header.code(), ""); + EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Foo").ID, + HaveRanges(Header.ranges(); +} + TEST_F(SymbolCollectorTest, References) { const std::string Header = R"( class W; Index: clangd/index/SymbolCollector.h === --- clangd/index/SymbolCollector.h +++ clangd/index/SymbolCollector.h @@ -57,6 +57,10 @@ /// The symbol ref kinds that will be collected. /// If not set, SymbolCollector will not collect refs. RefKind RefFilter = RefKind::Unknown; +/// If set to true, SymbolCollector will collect refs from main file only; +/// otherwise, refs from headers included by main file will be collected. +/// This flag is only available when RefFilter is set. +bool RefMainFileOnly = true; // Every symbol collected will be stamped with this origin. SymbolOrigin Origin = SymbolOrigin::Unknown; /// Collect macros. Index: clangd/index/SymbolCollector.cpp === --- clangd/index/SymbolCollector.cpp +++ clangd/index/SymbolCollector.cpp @@ -354,7 +354,8 @@ return true; if (!shouldCollectSymbol(*ND, *ASTCtx, Opts)) return true; - if (CollectRef && SM.getFileID(SpellingLoc) == SM.getMainFileID()) + if (CollectRef && + (!Opts.RefMainFileOnly || SM.getFileID(SpellingLoc) == SM.getMainFileID())) DeclRefs[ND].emplace_back(SpellingLoc, Roles); // Don't continue indexing if this is a mere reference. if (IsOnlyRef) @@ -476,17 +477,35 @@ const auto &SM = ASTCtx->getSourceManager(); auto* MainFileEntry = SM.getFileEntryForID(SM.getMainFileID()); + llvm::DenseMap URICache; if (auto MainFileURI = toURI(SM, MainFileEntry->getName(), Opts)) { -std::string MainURI = *MainFileURI; +URICache.insert({SM.getMainFileID(), *MainFileURI}); for (const auto &It : DeclRefs) { if (auto ID = getSymbolID(It.first)) { for (const auto &LocAndRole : It.second) { - Ref R; + auto FileID = SM.getFileID(LocAndRole.first); + auto Found = URICache.find(FileID); + if (Found == URICache.end()) { +if (auto* FileEntry = SM.getFileEntryForID(FileID)) { + auto FileURI = toURI(SM, FileEntry->getName(), Opts); + if (!FileURI) { +log("Failed to create URI for file: {0}\n", FileEntry); +continue; + } + Found = URICache.insert({FileID, *FileURI}).first; +} else { + // Ignore cases where we can not find a corresponding file entry + // for the loc, thoses are not interesting, e.g. symbols formed + // via macro concatenation. + continue; +} + } auto Range = getTokenRange(LocAndRole.first, SM, ASTCtx->getLangOpts()); + Ref R; R.Location.Start = Range.first; R.Location.End = Range.second; - R.Location.FileURI = MainURI; + R.Location.FileURI = Found->second; R.Kind = toRefKind(LocAndRole.second); Refs.insert(*ID, R); } Index: clangd/index/IndexAction.h === --- clangd/index/IndexAction.h +++ clangd/index/IndexAction.h @@ -21,9 +21,9 @@ // Only a subset of SymbolCollector::Options are respected: // - include paths are always collected, and canonicalized appropriately // - references are always counted -// - main-file refs are collected (if RefsCallback is non-null) +// - refs in main file and #included headers are collected (if RefsCallback +// is non-null) // - the symbol origin is always Static -// FIXM
[PATCH] D53322: [clangd] Collect refs from headers.
hokein added a comment. For references, the binary-format index file (for whole llvm project) size: | Before | WithRef | | 50MB | 91MB| Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53322 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D52840: Include Python binding tests in CMake rules
Hi Michal, AArch64 bots are broken as well, logs are available at: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/15717/steps/ninja%20check%201/logs/stdio Cheers, Yvan On Mon, 15 Oct 2018 at 20:39, Ulrich Weigand via Phabricator via cfe-commits wrote: > > uweigand added a comment. > > In https://reviews.llvm.org/D52840#1265615, @mgorny wrote: > > > The first one seems to indicate that your `libclang.so` is broken in > > release mode (optimization error?). The second one is correct (some of the > > tests test for errors, and apparently don't silence the messages). > > > Ok, thanks for the clarification on the second point. > > As to the first issue, it turned out to be more complicated. The wrong value > results from this call in CursorVisitor::Visit > > switch (Visitor(Cursor, Parent, ClientData)) { > > This is a callback routine passed in from the caller, which in the case of > the Python bindings means that an FFI closure is being called. > > Now, due to a historical quirk in the FFI ABI, return values of integral type > smaller than the register word size must be passed as the special "ffi_arg" > type when using FFI (either for calls or for closures). It seems the Python > 2.7 code that interfaces with FFI does not correctly respect this. As a > result, it seems that when the closure returns a 32-bit value, it is not > properly extended and the high bits of the return register contain garbage. > > But that violates our ABI, which requires extension to full register size. > And it seems the clang code, when built with optimization, does indeed rely > on that ABI guarantee. > > So there's a bug in Python (or depending on how you want to look at it, in > libffi -- that part of the interface has also long been under-documented > unfortunately), which hits on our platform. I'll see if I can do anything > about that, but for now we'll probably want to disable those tests on SystemZ. > > > Repository: > rC Clang > > https://reviews.llvm.org/D52840 > > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52840: Include Python binding tests in CMake rules
kparzysz added a comment. Hexagon clang builder has been failing since around the time of this commit as well: http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/20617/steps/ninja%20check%201/logs/stdio Repository: rC Clang https://reviews.llvm.org/D52840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53131: [clangd] Support scope proximity in code completion.
sammccall added inline comments. Comment at: clangd/AST.cpp:77 + for (const auto *Ctx = &DC; Ctx != nullptr; Ctx = Ctx->getParent()) +if (const auto *NS = dyn_cast(Ctx)) + if (!NS->isAnonymousNamespace() && !NS->isInlineNamespace()) It would be nice to have the invariant `splitQualifiedName(printQualifiedName(D)) == printScope(D.getContext())` for Decl D. That's why I was suggesting splitting `NamedDecl::printQualifiedName`. Given the limited functionality here it should probably be called printNamespaceScope, lest someone try to reuse it to get a symbol's scope. Comment at: clangd/AST.h:51 +/// Returns the first enclosing namespace scope starting from \p DC. +std::string printScope(const DeclContext &DC); next to printQualifiedName? Comment at: clangd/CodeComplete.cpp:562 SpecifiedScope Info; for (auto *Context : CCContext.getVisitedContexts()) { if (isa(Context)) do you also want to use printScope here? Comment at: clangd/Quality.cpp:250 + SmallVector Split; + Scope.split(Split, "::", /*MaxSplit=*/-1, /*KeppEmpty=*/false); + return {llvm::join(Split, "/"), Split.size()}; kepp -> keep Comment at: clangd/Quality.cpp:251 + Scope.split(Split, "::", /*MaxSplit=*/-1, /*KeppEmpty=*/false); + return {llvm::join(Split, "/"), Split.size()}; +} might be clearer to explicitly prepend "/" rather than relying on normalization to do it? Comment at: clangd/Quality.cpp:261 + StringMap Sources; + Opts.UpCost = 1; + Opts.DownCost = 1; My intuition is that mostly the ranking should look like: 1. results from queried namespaces 2. results from nearby namespaces 3. results from unrelated namespaces That would require Source.Cost < (UpCost, DownCost), which isn't possible when they're 1. WDYT? Comment at: clangd/Quality.cpp:262 + Opts.UpCost = 1; + Opts.DownCost = 1; + Opts.AllowDownTraversalFromRoot = false; I thought we concluded down cost was likely to be significantly higher than up cost? Comment at: clangd/Quality.cpp:267 +SourceParams Param; +// Make sure cost of "" is not from traversals from other query scopes. +Param.MaxUpTraversals = std::max(Path.second - 1, 0); This seems a little focused on the implementation rather than the intent... maybe "The global namespace is not 'near' its children"? Comment at: clangd/Quality.cpp:272 +else if (!S.empty() && Preferred.startswith(S)) + Param.Cost = Opts.UpCost; +else This seems like an odd rule, what's the intuition? - if the preferred scope is a::b::c:: then we're considering a::b:: and a:: to be equal, rather than preferring the former - you're defining the cost in terms of UpCost, but it's not clear why - is this just being used as a scale? - for the direct parent of the preferred scope, this is a no-op. So this only does anything when the preferred scope is at least 3 deep As a first approximation, `; // just rely on up-traversals` might be OK, otherwise, I guess you're trying to boost these compared to just relying on up-traversals, so I'd expect this to look something like `Cost = UpCost * (len(preferred) - len(S)) / 2` Comment at: clangd/Quality.cpp:274 +else + Param.Cost = 2 * Opts.UpCost; +if (S == "") Again, if this just means "parents of preferred are 1, others are 2", I'm not sure that sounds right. A using-directive is explicit in the user's code, I'm not sure it should rank lower? Happy enough to try this out as it is though, maybe just drop the references to UpCost. Comment at: clangd/Quality.cpp:276 +if (S == "") + Param.Cost += Opts.UpCost; +Sources[Path.first] = std::move(Param); Why is this +=? Seems like there's three cases here: - global is the preferred scope: I think the cost has to be 0 in this case, no? - global is another acceptable scope: some large fixed cost seems appropriate - global is not listed: no source to worry about Comment at: clangd/Quality.cpp:287 + auto D = Distance->distance(scopeToPath(Scope).first); + return std::max(0.6, MaxBoost - D * 0.25); +} 0.6 seems too high for AnyScope matches, to me. And you're not distinguishing anyScope matches from bad path matches. I think the linear scale is too flat: if you're in clang::clangd::, then clangd symbols will only get a 13% boost over clang ones. Given the current UpCost == DownCost == 1, I'd consider something like ``` if (D == FileDistance::Unreachable) return 0.1; return max(0.5, MaxBoost * pow(0.6, D)) ``` Comment at: clangd/Quality.cpp:382 +// always in the accessible scope. +Score *= SemaSaysInScope ? Quer
r344608 - [driver][mips] Support MIPS R6 target triples
Author: atanasyan Date: Tue Oct 16 07:29:27 2018 New Revision: 344608 URL: http://llvm.org/viewvc/llvm-project?rev=344608&view=rev Log: [driver][mips] Support MIPS R6 target triples This change adds support for the following MIPS target triples: mipsisa32r6-linux-gnu mipsisa32r6el-linux-gnu mipsisa64r6-linux-gnuabi64 mipsisa64r6el-linux-gnuabi64 mipsisa64r6-linux-gnuabin32 mipsisa64r6el-linux-gnuabin32 Patch by Yun Qiang Su. Differential revision: https://reviews.llvm.org/D50850 Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/lib/Driver/ToolChains/Linux.cpp cfe/trunk/test/CodeGen/atomics-inlining.c cfe/trunk/test/CodeGen/mips-zero-sized-struct.c cfe/trunk/test/CodeGen/target-data.c cfe/trunk/test/CodeGen/xray-attributes-supported.cpp cfe/trunk/test/Driver/clang-translation.c Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=344608&r1=344607&r2=344608&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Tue Oct 16 07:29:27 2018 @@ -35,6 +35,11 @@ void mips::getMipsCPUAndABI(const ArgLis DefMips64CPU = "mips64r6"; } + if (Triple.getSubArch() == llvm::Triple::MipsSubArch_r6) { +DefMips32CPU = "mips32r6"; +DefMips64CPU = "mips64r6"; + } + // MIPS64r6 is the default for Android MIPS64 (mips64el-linux-android). if (Triple.isAndroid()) { DefMips32CPU = "mips32"; Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=344608&r1=344607&r2=344608&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Oct 16 07:29:27 2018 @@ -1871,26 +1871,30 @@ void Generic_GCC::GCCInstallationDetecto "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu"}; static const char *const MIPSLibDirs[] = {"/lib"}; - static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux", -"mips-mti-linux-gnu", -"mips-img-linux-gnu"}; + static const char *const MIPSTriples[] = { + "mips-linux-gnu", "mips-mti-linux", "mips-mti-linux-gnu", + "mips-img-linux-gnu", "mipsisa32r6-linux-gnu"}; static const char *const MIPSELLibDirs[] = {"/lib"}; - static const char *const MIPSELTriples[] = {"mipsel-linux-gnu", - "mips-img-linux-gnu"}; + static const char *const MIPSELTriples[] = { + "mipsel-linux-gnu", "mips-img-linux-gnu", "mipsisa32r6el-linux-gnu"}; static const char *const MIPS64LibDirs[] = {"/lib64", "/lib"}; static const char *const MIPS64Triples[] = { - "mips64-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu", - "mips64-linux-gnuabi64"}; + "mips64-linux-gnu", "mips-mti-linux-gnu", + "mips-img-linux-gnu","mips64-linux-gnuabi64", + "mipsisa64r6-linux-gnu", "mipsisa64r6-linux-gnuabi64"}; static const char *const MIPS64ELLibDirs[] = {"/lib64", "/lib"}; static const char *const MIPS64ELTriples[] = { - "mips64el-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu", - "mips64el-linux-gnuabi64"}; + "mips64el-linux-gnu", "mips-mti-linux-gnu", + "mips-img-linux-gnu", "mips64el-linux-gnuabi64", + "mipsisa64r6el-linux-gnu", "mipsisa64r6el-linux-gnuabi64"}; static const char *const MIPSN32LibDirs[] = {"/lib32"}; - static const char *const MIPSN32Triples[] = {"mips64-linux-gnuabin32"}; + static const char *const MIPSN32Triples[] = {"mips64-linux-gnuabin32", + "mipsisa64r6-linux-gnuabin32"}; static const char *const MIPSN32ELLibDirs[] = {"/lib32"}; - static const char *const MIPSN32ELTriples[] = {"mips64el-linux-gnuabin32"}; + static const char *const MIPSN32ELTriples[] = { + "mips64el-linux-gnuabin32", "mipsisa64r6el-linux-gnuabin32"}; static const char *const PPCLibDirs[] = {"/lib32", "/lib"}; static const char *const PPCTriples[] = { Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=344608&r1=344607&r2=344608&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Tue Oct 16 07:29:27 2018 @@ -44,9 +44,7 @@ static std::string getMultiarchTriple(co llvm::Triple::EnvironmentType TargetEnvironment = TargetTriple.getEnvironment(); bool IsAndroid = TargetTriple.isAndroid(); - std::string Mips64
[PATCH] D50850: clang: Add triples support for MIPS r6
atanasyan accepted this revision. atanasyan added a comment. This revision is now accepted and ready to land. LGTM. Thanks for the patch. https://reviews.llvm.org/D50850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50850: clang: Add triples support for MIPS r6
This revision was automatically updated to reflect the committed changes. Closed by commit rL344608: [driver][mips] Support MIPS R6 target triples (authored by atanasyan, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50850?vs=169810&id=169824#toc Repository: rL LLVM https://reviews.llvm.org/D50850 Files: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/lib/Driver/ToolChains/Linux.cpp cfe/trunk/test/CodeGen/atomics-inlining.c cfe/trunk/test/CodeGen/mips-zero-sized-struct.c cfe/trunk/test/CodeGen/target-data.c cfe/trunk/test/CodeGen/xray-attributes-supported.cpp cfe/trunk/test/Driver/clang-translation.c Index: cfe/trunk/test/CodeGen/xray-attributes-supported.cpp === --- cfe/trunk/test/CodeGen/xray-attributes-supported.cpp +++ cfe/trunk/test/CodeGen/xray-attributes-supported.cpp @@ -5,20 +5,36 @@ // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ // RUN: -triple mips-unknown-linux-gnu | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ +// RUN: -triple mipsisa32r6-unknown-linux-gnu | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ // RUN: -triple mipsel-unknown-linux-gnu | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ +// RUN: -triple mipsisa32r6el-unknown-linux-gnu | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ // RUN: -triple mips64-unknown-linux-gnu | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ +// RUN: -triple mipsisa64r6-unknown-linux-gnu | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ // RUN: -triple mips64el-unknown-linux-gnu | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ +// RUN: -triple mipsisa64r6el-unknown-linux-gnu | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ // RUN: -triple mips64-unknown-linux-gnuabi64 | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ +// RUN: -triple mipsisa64r6-unknown-linux-gnuabi64 | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ // RUN: -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ +// RUN: -triple mipsisa64r6el-unknown-linux-gnuabi64 | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ // RUN: -triple mips64-unknown-linux-gnuabin32 | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ +// RUN: -triple mipsisa64r6-unknown-linux-gnuabin32 | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ // RUN: -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ +// RUN: -triple mipsisa64r6el-unknown-linux-gnuabin32 | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \ // RUN: -triple powerpc64le-unknown-linux-gnu | FileCheck %s // Make sure that the LLVM attribute for XRay-annotated functions do show up. Index: cfe/trunk/test/CodeGen/atomics-inlining.c === --- cfe/trunk/test/CodeGen/atomics-inlining.c +++ cfe/trunk/test/CodeGen/atomics-inlining.c @@ -2,8 +2,10 @@ // RUN: %clang_cc1 -triple powerpc-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=PPC32 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=PPC64 // RUN: %clang_cc1 -triple mipsel-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS32 +// RUN: %clang_cc1 -triple mipsisa32r6el-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS32 // RUN: %clang_cc1 -triple mips64el-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64 // RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64 +// RUN: %clang_cc1 -triple mipsisa64r6el-linux-gnuabi64 -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64 // RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV8 -check-prefix=SPARC // RUN: %clang_cc1 -triple sparcv9-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV9 -check-prefix=SPARC Index: cfe/trunk/test/CodeGen/mips-zero-sized-struct.c === --- cfe/trunk/test/CodeGen/mips-zero-sized-struct.c +++ cfe/trunk/test/CodeGen/mips-zero-sized-struct.c @@ -1,13 +1,23 @@ // RUN: %clang_
[PATCH] D53322: [clangd] Collect refs from headers.
sammccall added a comment. This looks reasonable. +80% to index size is a shame, but not disastrous, and we have ways to shave it. Can you check: - how much we're increasing the in-memory size (Dex) - that we're not outputting duplicate refs when preambles overlap between TUs Comment at: clangd/index/IndexAction.h:24 // - references are always counted -// - main-file refs are collected (if RefsCallback is non-null) +// - refs in main file and #included headers are collected (if RefsCallback +// is non-null) just "all references are collected"? Comment at: clangd/index/SymbolCollector.cpp:480 + llvm::DenseMap URICache; if (auto MainFileURI = toURI(SM, MainFileEntry->getName(), Opts)) { maybe pull out ```auto GetURI = [&](clang::FileID FID) -> Optional { ... look up or populate cache entry ... }``` then both the outer if and inner lookups can be written as: `if (auto MainFileURI = GetURI(SM.getMainFileID())) {` etc Comment at: clangd/index/SymbolCollector.cpp:491 + auto FileURI = toURI(SM, FileEntry->getName(), Opts); + if (!FileURI) { +log("Failed to create URI for file: {0}\n", FileEntry); I think you probably also want to cache this case - using an empty string is fine Comment at: clangd/index/SymbolCollector.h:62 +/// otherwise, refs from headers included by main file will be collected. +/// This flag is only available when RefFilter is set. +bool RefMainFileOnly = true; available -> meaningful Comment at: clangd/index/SymbolCollector.h:63 +/// This flag is only available when RefFilter is set. +bool RefMainFileOnly = true; // Every symbol collected will be stamped with this origin. having "true" mean **don't** do something is a bit confusing. What about `bool RefsInHeaders = false`? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53322 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344611 - [SystemZ] Actually enable -mzvector keywords
Author: uweigand Date: Tue Oct 16 07:57:20 2018 New Revision: 344611 URL: http://llvm.org/viewvc/llvm-project?rev=344611&view=rev Log: [SystemZ] Actually enable -mzvector keywords It appears when initially committing the support for the IBM Z vector extension language, one critical line was lost, causing the specific keywords __vector, __bool, and vec_step to not actually be enabled. (Note that this does not affect "vector" and "bool"!) Unfortunately, this was not caught by any tests either. (All existing Z vector tests just use the regular "vector" and "bool" keywords ...) Fixed by adding the missing line and updating the tests. Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp cfe/trunk/test/Sema/zvector.c cfe/trunk/test/Sema/zvector2.c Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=344611&r1=344610&r2=344611&view=diff == --- cfe/trunk/lib/Basic/IdentifierTable.cpp (original) +++ cfe/trunk/lib/Basic/IdentifierTable.cpp Tue Oct 16 07:57:20 2018 @@ -155,6 +155,7 @@ static KeywordStatus getKeywordStatus(co if (LangOpts.WChar && (Flags & WCHARSUPPORT)) return KS_Enabled; if (LangOpts.Char8 && (Flags & CHAR8SUPPORT)) return KS_Enabled; if (LangOpts.AltiVec && (Flags & KEYALTIVEC)) return KS_Enabled; + if (LangOpts.ZVector && (Flags & KEYZVECTOR)) return KS_Enabled; if (LangOpts.OpenCL && !LangOpts.OpenCLCPlusPlus && (Flags & KEYOPENCLC)) return KS_Enabled; if (LangOpts.OpenCLCPlusPlus && (Flags & KEYOPENCLCXX)) return KS_Enabled; Modified: cfe/trunk/test/Sema/zvector.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/zvector.c?rev=344611&r1=344610&r2=344611&view=diff == --- cfe/trunk/test/Sema/zvector.c (original) +++ cfe/trunk/test/Sema/zvector.c Tue Oct 16 07:57:20 2018 @@ -37,6 +37,49 @@ unsigned long ul_scalar; double fd_scalar; +// Verify that __vector is also recognized +__vector signed char sc3; +__vector unsigned char uc3; +__vector bool char bc3; +__vector signed short ss3; +__vector unsigned short us3; +__vector bool short bs3; +__vector signed int si3; +__vector unsigned int ui3; +__vector bool int bi3; +__vector signed long long sl3; +__vector unsigned long long ul3; +__vector bool long long bl3; +__vector double fd3; +__vector long ll3; // expected-error {{cannot use 'long' with '__vector'}} +__vector float ff3; // expected-error {{cannot use 'float' with '__vector'}} + +// Likewise for __bool +vector __bool char bc4; +vector __bool short bs4; +vector __bool int bi4; +vector __bool long long bl4; +__vector __bool char bc5; +__vector __bool short bs5; +__vector __bool int bi5; +__vector __bool long long bl5; + +// Verify operation of vec_step +int res_sc[vec_step(sc) == 16 ? 1 : -1]; +int res_uc[vec_step(uc) == 16 ? 1 : -1]; +int res_bc[vec_step(bc) == 16 ? 1 : -1]; +int res_ss[vec_step(ss) == 8 ? 1 : -1]; +int res_us[vec_step(us) == 8 ? 1 : -1]; +int res_bs[vec_step(bs) == 8 ? 1 : -1]; +int res_si[vec_step(si) == 4 ? 1 : -1]; +int res_ui[vec_step(ui) == 4 ? 1 : -1]; +int res_bi[vec_step(bi) == 4 ? 1 : -1]; +int res_sl[vec_step(sl) == 2 ? 1 : -1]; +int res_ul[vec_step(ul) == 2 ? 1 : -1]; +int res_bl[vec_step(bl) == 2 ? 1 : -1]; +int res_fd[vec_step(fd) == 2 ? 1 : -1]; + + void foo(void) { // - Modified: cfe/trunk/test/Sema/zvector2.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/zvector2.c?rev=344611&r1=344610&r2=344611&view=diff == --- cfe/trunk/test/Sema/zvector2.c (original) +++ cfe/trunk/test/Sema/zvector2.c Tue Oct 16 07:57:20 2018 @@ -22,6 +22,13 @@ vector double fd, fd2; vector float ff, ff2; +// Verify that __vector is also recognized +__vector float ff3; + +// Verify operation of vec_step +int res_ff[vec_step(ff) == 4 ? 1 : -1]; + + void foo(void) { // - ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53220: Remove possibility to change compile database path at runtime
simark marked 7 inline comments as done. simark added inline comments. Comment at: clangd/ClangdLSPServer.cpp:433 reparseOpenedFiles(); } sammccall wrote: > sammccall wrote: > > This isn't needed, the compilation database can only be set during > > initialization. > It's still here... maybe forgot to upload a new diff? > (Just to be clear: I meant `reparseOpenFiles` doesn't need to be called, as > there are none.) Oh I have only done the change locally, I have not uploaded a new diff yet. Comment at: clangd/ClangdLSPServer.h:90 void reparseOpenedFiles(); + void applyConfiguration(const ClangdInitializationOptions &Settings); void applyConfiguration(const ClangdConfigurationParamsChange &Settings); sammccall wrote: > simark wrote: > > sammccall wrote: > > > Prefer a different name for this function - an overload set should have > > > similar semantics and these are quite different (pseudo-constructor vs > > > mutation allowed at any time). > > Ok, I'll think about a better name. > (In fact, this could also live directly in `onInitialize`, I think?) Indeed, since it's things that can only be set during initialization. Comment at: clangd/Protocol.h:422 +struct ClangdInitializationOptions : public ClangdConfigurationParamsChange { + llvm::Optional compilationDatabasePath; +}; sammccall wrote: > simark wrote: > > sammccall wrote: > > > Can we just move this to InitializeParams as a clangd extension? > > > Doing tricks with inheritance here makes the protocol harder to > > > understand. > > > Can we just move this to InitializeParams as a clangd extension? > > > > Do you mean move it in the JSON, so it looks like this on the wire? > > > > ``` > > { > > "method": "initialize", > > "params": { > > "compilationDatabasePath": "", > > ... > > } > > } > > ``` > > > > instead of > > > > ``` > > { > > "method": "initialize", > > "params": { > > "initializationOptions": { > > "compilationDatabasePath": "" > > }, > > ... > > } > > } > > ``` > > > > ? > > > > I think `initializationOptions` is a good place for this to be, I wouldn't > > change that.. If you don't like the inheritance, we can just get rid of it > > in our code and have two separate versions of the deserializing code. We > > designed it so `didChangeConfiguration` and the initialization options > > would share the same structure, but it doesn't have to stay that way. > > Do you mean move it in the JSON, so it looks like this on the wire? > > Well, since you asked... :-) I'm not going to push hard for it (this patch is > certainly a win already), but I do think that would be much clearer. > > The current protocol has `InitializeParams` and > `ClangdInitializationOptions`, and it's not clear semantically what the > distinction between them is. > > With hindsight, I think something like this would be easier to follow: > ``` > // Clangd options that may be set at startup. > struct InitializeParams { > // Clangd extension: override the path used to load the CDB. > Optional compilationDatabasePath; > // Provides initial configuration as if by workspace/updateConfiguration. > Optional initialConfiguration; > } > // Clangd options that may be set dynamically at runtime. > struct ClangdConfigurationParamsChange { ... } > ``` > though even here, the benefit from being able to inline the initial > configuration into the initalize message is unclear to me. The implementation > has to support dynamic updates in any case, so why not make use of that? > > > We designed it so didChangeConfiguration and the initialization options > > would share the same structure > > This makes sense, but if they're diverging, I'm not sure that keeping them > *mostly* the same brings more benefits than confusion. > > -- > > That said, if you prefer to keep the JSON as it is, that's fine. (If we grow > more extensions, we may want to reorganize in future though?) > My main concern is the use of inheritance here, and how it provides a default > (configuration-change options can be provided at startup) that doesn't seem > obviously correct and is hard to opt out of. > The current protocol has InitializeParams and ClangdInitializationOptions, > and it's not clear semantically what the distinction between them is. `InitializeParams` is the type for the parameters of the `initialize` request. In it, there is this field: ``` /** * User provided initialization options. */ initializationOptions?: any; ``` which is made to pass such language-server-specific options. Since it's of the `any` type, we gave it a name, `ClangdInitializationOptions`. > With hindsight, I think something like this would be easier to follow: > > [snippet] I don't really understand why putting fields as extra fields in `InitializeParams` would be any easier than putting t
[PATCH] D53220: Remove possibility to change compile database path at runtime
simark updated this revision to Diff 169828. simark marked 3 inline comments as done. simark added a comment. Address comments Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53220 Files: clangd/ClangdLSPServer.cpp clangd/Protocol.cpp clangd/Protocol.h test/clangd/compile-commands-path-in-initialize.test test/clangd/compile-commands-path.test Index: test/clangd/compile-commands-path.test === --- test/clangd/compile-commands-path.test +++ /dev/null @@ -1,42 +0,0 @@ -# Test that we can switch between configuration/build using the -# workspace/didChangeConfiguration notification. - -# RUN: rm -rf %t.dir/* && mkdir -p %t.dir -# RUN: mkdir %t.dir/build-1 -# RUN: mkdir %t.dir/build-2 -# RUN: echo '[{"directory": "%/t.dir", "command": "c++ the-file.cpp", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json -# RUN: echo '[{"directory": "%/t.dir/build-1", "command": "c++ -DMACRO=1 the-file.cpp", "file": "../the-file.cpp"}]' > %t.dir/build-1/compile_commands.json -# RUN: echo '[{"directory": "%/t.dir/build-2", "command": "c++ -DMACRO=2 the-file.cpp", "file": "../the-file.cpp"}]' > %t.dir/build-2/compile_commands.json - -# RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1 - -# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..." -# (with the extra slash in the front), so we add it here. -# RUN: sed -e "s|file://\([A-Z]\):/|file:///\1:/|g" %t.test.1 > %t.test - -# RUN: clangd -lit-test < %t.test | FileCheck -strict-whitespace %t.test - -{"jsonrpc":"2.0","id":0,"method":"initialize","params":{}} -{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file://INPUT_DIR/the-file.cpp","languageId":"cpp","version":1,"text":"#if !defined(MACRO)\n#pragma message (\"MACRO is not defined\")\n#elif MACRO == 1\n#pragma message (\"MACRO is one\")\n#elif MACRO == 2\n#pragma message (\"MACRO is two\")\n#else\n#pragma message (\"woops\")\n#endif\nint main() {}\n"}}} -# CHECK: "method": "textDocument/publishDiagnostics", -# CHECK-NEXT: "params": { -# CHECK-NEXT: "diagnostics": [ -# CHECK-NEXT: { -# CHECK-NEXT: "message": "MACRO is not defined", -{"jsonrpc":"2.0","id":0,"method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":"INPUT_DIR/build-1"}}} -# CHECK: "method": "textDocument/publishDiagnostics", -# CHECK-NEXT: "params": { -# CHECK-NEXT: "diagnostics": [ -# CHECK-NEXT: { -# CHECK-NEXT: "message": "MACRO is one", -{"jsonrpc":"2.0","id":0,"method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":"INPUT_DIR/build-2"}}} -# CHECK: "method": "textDocument/publishDiagnostics", -# CHECK-NEXT: "params": { -# CHECK-NEXT: "diagnostics": [ -# CHECK-NEXT: { -# CHECK-NEXT: "message": "MACRO is two", -{"jsonrpc":"2.0","id":1,"method":"shutdown"} Index: test/clangd/compile-commands-path-in-initialize.test === --- test/clangd/compile-commands-path-in-initialize.test +++ test/clangd/compile-commands-path-in-initialize.test @@ -3,10 +3,8 @@ # RUN: rm -rf %t.dir/* && mkdir -p %t.dir # RUN: mkdir %t.dir/build-1 -# RUN: mkdir %t.dir/build-2 # RUN: echo '[{"directory": "%/t.dir", "command": "c++ the-file.cpp", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json # RUN: echo '[{"directory": "%/t.dir/build-1", "command": "c++ -DMACRO=1 the-file.cpp", "file": "../the-file.cpp"}]' > %t.dir/build-1/compile_commands.json -# RUN: echo '[{"directory": "%/t.dir/build-2", "command": "c++ -DMACRO=2 the-file.cpp", "file": "../the-file.cpp"}]' > %t.dir/build-2/compile_commands.json # RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1 @@ -18,18 +16,11 @@ {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"initializationOptions":{"compilationDatabasePath":"INPUT_DIR/build-1"}}} --- -{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file://INPUT_DIR/the-file.cpp","languageId":"cpp","version":1,"text":"#if !defined(MACRO)\n#pragma message (\"MACRO is not defined\")\n#elif MACRO == 1\n#pragma message (\"MACRO is one\")\n#elif MACRO == 2\n#pragma message (\"MACRO is two\")\n#else\n#pragma message (\"woops\")\n#endif\nint main() {}\n"}}} +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file://INPUT_DIR/the-file.cpp","languageId":"cpp","version":1,"text":"#if !defined(MACRO)\n#pragma message (\"MACRO is not defined\")\n#elif MACRO == 1\n#pragma message (\"MACRO is one\")\n#else\n#pragma message (\"woops\")\n#endif\nint main() {}\n"}}} # CHECK: "method": "textDocument/publishDiagnostics", # CHECK-NEXT: "params": { # CHECK-NEXT: "diagnostics": [ # CHECK-NEXT: { # CHECK-NEXT: "message": "MACRO is one", --- -{"jsonrpc":"2.0","id":0,"method":"workspace/didChangeConfiguration","params":{"settings":
[PATCH] D53286: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
ioeric added a comment. Nice! The code looks much clearer. Just some nits Comment at: clangd/ClangdLSPServer.cpp:156 +void ClangdLSPServer::onExit(ExitParams &Params) { + // XXX handler should return true. +} ? Comment at: clangd/ClangdLSPServer.h:45 /// Run LSP server loop, receiving input for it from \p In. \p In must be /// opened in binary mode. Output will be written using Out variable passed to doc is outdated now Comment at: clangd/JSONRPCDispatcher.cpp:218 -// Tries to read a line up to and including \n. -// If failing, feof() or ferror() will be set. -static bool readLine(std::FILE *In, std::string &Out) { - static constexpr int BufSize = 1024; - size_t Size = 0; - Out.clear(); - for (;;) { -Out.resize(Size + BufSize); -// Handle EINTR which is sent when a debugger attaches on some platforms. -if (!llvm::sys::RetryAfterSignal(nullptr, ::fgets, &Out[Size], BufSize, In)) - return false; -clearerr(In); -// If the line contained null bytes, anything after it (including \n) will -// be ignored. Fortunately this is not a legal header or JSON. -size_t Read = std::strlen(&Out[Size]); -if (Read > 0 && Out[Size + Read - 1] == '\n') { - Out.resize(Size + Read); - return true; -} -Size += Read; - } -} - -// Returns None when: -// - ferror() or feof() are set. -// - Content-Length is missing or empty (protocol error) -static llvm::Optional readStandardMessage(std::FILE *In, - JSONOutput &Out) { - // A Language Server Protocol message starts with a set of HTTP headers, - // delimited by \r\n, and terminated by an empty line (\r\n). - unsigned long long ContentLength = 0; - std::string Line; - while (true) { -if (feof(In) || ferror(In) || !readLine(In, Line)) - return llvm::None; - -Out.mirrorInput(Line); -llvm::StringRef LineRef(Line); - -// We allow comments in headers. Technically this isn't part -// of the LSP specification, but makes writing tests easier. -if (LineRef.startswith("#")) - continue; - -// Content-Length is a mandatory header, and the only one we handle. -if (LineRef.consume_front("Content-Length: ")) { - if (ContentLength != 0) { -elog("Warning: Duplicate Content-Length header received. " - "The previous value for this message ({0}) was ignored.", - ContentLength); - } - llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength); - continue; -} else if (!LineRef.trim().empty()) { - // It's another header, ignore it. - continue; -} else { - // An empty line indicates the end of headers. - // Go ahead and read the JSON. - break; -} - } - - // The fuzzer likes crashing us by sending "Content-Length: " - if (ContentLength > 1 << 30) { // 1024M -elog("Refusing to read message with long Content-Length: {0}. " - "Expect protocol errors", - ContentLength); -return llvm::None; - } - if (ContentLength == 0) { -log("Warning: Missing Content-Length header, or zero-length message."); -return llvm::None; - } - - std::string JSON(ContentLength, '\0'); - for (size_t Pos = 0, Read; Pos < ContentLength; Pos += Read) { -// Handle EINTR which is sent when a debugger attaches on some platforms. -Read = llvm::sys::RetryAfterSignal(0u, ::fread, &JSON[Pos], 1, - ContentLength - Pos, In); -Out.mirrorInput(StringRef(&JSON[Pos], Read)); -if (Read == 0) { - elog("Input was aborted. Read only {0} bytes of expected {1}.", Pos, - ContentLength); - return llvm::None; -} -clearerr(In); // If we're done, the error was transient. If we're not done, - // either it was transient or we'll see it again on retry. -Pos += Read; - } - return std::move(JSON); -} - -// For lit tests we support a simplified syntax: -// - messages are delimited by '---' on a line by itself -// - lines starting with # are ignored. -// This is a testing path, so favor simplicity over performance here. -// When returning None, feof() or ferror() will be set. -static llvm::Optional readDelimitedMessage(std::FILE *In, -JSONOutput &Out) { - std::string JSON; - std::string Line; - while (readLine(In, Line)) { -auto LineRef = llvm::StringRef(Line).trim(); -if (LineRef.startswith("#")) // comment - continue; - -// found a delimiter -if (LineRef.rtrim() == "---") - break; - -JSON += Line; - } - - if (ferror(In)) { -elog("Input error while reading message!"); -return llvm::None; - } else { // Including EOF -Out.mirrorInput( -llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON)); -return std::move(JSON); - } -} - // The use o
[PATCH] D53322: [clangd] Collect refs from headers.
sammccall accepted this revision. sammccall added a comment. This revision is now accepted and ready to land. (please do check there are no duplicates in the output) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53322 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53220: Remove possibility to change compile database path at runtime
sammccall accepted this revision. sammccall added a comment. Still LG! Comment at: clangd/Protocol.h:422 +struct ClangdInitializationOptions : public ClangdConfigurationParamsChange { + llvm::Optional compilationDatabasePath; +}; simark wrote: > sammccall wrote: > > simark wrote: > > > sammccall wrote: > > > > Can we just move this to InitializeParams as a clangd extension? > > > > Doing tricks with inheritance here makes the protocol harder to > > > > understand. > > > > Can we just move this to InitializeParams as a clangd extension? > > > > > > Do you mean move it in the JSON, so it looks like this on the wire? > > > > > > ``` > > > { > > > "method": "initialize", > > > "params": { > > > "compilationDatabasePath": "", > > > ... > > > } > > > } > > > ``` > > > > > > instead of > > > > > > ``` > > > { > > > "method": "initialize", > > > "params": { > > > "initializationOptions": { > > > "compilationDatabasePath": "" > > > }, > > > ... > > > } > > > } > > > ``` > > > > > > ? > > > > > > I think `initializationOptions` is a good place for this to be, I > > > wouldn't change that.. If you don't like the inheritance, we can just > > > get rid of it in our code and have two separate versions of the > > > deserializing code. We designed it so `didChangeConfiguration` and the > > > initialization options would share the same structure, but it doesn't > > > have to stay that way. > > > Do you mean move it in the JSON, so it looks like this on the wire? > > > > Well, since you asked... :-) I'm not going to push hard for it (this patch > > is certainly a win already), but I do think that would be much clearer. > > > > The current protocol has `InitializeParams` and > > `ClangdInitializationOptions`, and it's not clear semantically what the > > distinction between them is. > > > > With hindsight, I think something like this would be easier to follow: > > ``` > > // Clangd options that may be set at startup. > > struct InitializeParams { > > // Clangd extension: override the path used to load the CDB. > > Optional compilationDatabasePath; > > // Provides initial configuration as if by workspace/updateConfiguration. > > Optional initialConfiguration; > > } > > // Clangd options that may be set dynamically at runtime. > > struct ClangdConfigurationParamsChange { ... } > > ``` > > though even here, the benefit from being able to inline the initial > > configuration into the initalize message is unclear to me. The > > implementation has to support dynamic updates in any case, so why not make > > use of that? > > > > > We designed it so didChangeConfiguration and the initialization options > > > would share the same structure > > > > This makes sense, but if they're diverging, I'm not sure that keeping them > > *mostly* the same brings more benefits than confusion. > > > > -- > > > > That said, if you prefer to keep the JSON as it is, that's fine. (If we > > grow more extensions, we may want to reorganize in future though?) > > My main concern is the use of inheritance here, and how it provides a > > default (configuration-change options can be provided at startup) that > > doesn't seem obviously correct and is hard to opt out of. > > The current protocol has InitializeParams and ClangdInitializationOptions, > > and it's not clear semantically what the distinction between them is. > > `InitializeParams` is the type for the parameters of the `initialize` > request. In it, there is this field: > > ``` > /** >* User provided initialization options. >*/ > initializationOptions?: any; > ``` > > which is made to pass such language-server-specific options. Since it's of > the `any` type, we gave it a name, `ClangdInitializationOptions`. > > > With hindsight, I think something like this would be easier to follow: > > > > [snippet] > > I don't really understand why putting fields as extra fields in > `InitializeParams` would be any easier than putting them in the object that > exists specifically for that purpose. > > > though even here, the benefit from being able to inline the initial > > configuration into the initalize message is unclear to me. The > > implementation has to support dynamic updates in any case, so why not make > > use of that? > > I'd say, to avoid having the server start some work (like indexing some files > using a certain set of flags) that will be invalidated when it receives some > config changes moments later. > > > This makes sense, but if they're diverging, I'm not sure that keeping them > > *mostly* the same brings more benefits than confusion. > > I think you are exaggerating the confusion. It is pretty straightforward: > everything you can change during execution, you can also specify at > initialize time. > which is made to pass such language-server-specific options. Since it's of > the any type, we gave it a name, `Clangd
[PATCH] D53213: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)
kadircet accepted this revision. kadircet added a comment. This revision is now accepted and ready to land. LGTM, thanks! Comment at: clangd/ClangdLSPServer.cpp:338 + Command Cmd; + if (Action.command && Action.edit) +return llvm::None; sammccall wrote: > kadircet wrote: > > What would you think about emitting two commands in this case? First the > > edit and then the command. I believe LSP doesn't specify any ordering on > > how the commands returned should be executed by the client, so I am OK with > > current state as well. Just wanted to know if there were any other concerns. > That doesn't have the right semantics. Multiple commands returned from > `textDocument/codeAction` are alternatives that the user should select > between, whereas having both an edit and a command means they should be > performed atomically as one action. > > (This never actually happens as we don't emit such actions, added a comment) Oh I see, nvm then. Comment at: clangd/ClangdLSPServer.cpp:350 + if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND) +Cmd.title = "Apply fix: " + Cmd.title; + return Cmd; sammccall wrote: > kadircet wrote: > > It seems we only prepend title with Apply fix when we fallback, I believe > > it would be better to add them in CodeAction instead? > The `CodeAction` has a slot to describe the type of action: if the client > wants to prepend "Quick Fix: " or so it can. > (Personally this just seems like noise to me, so I'd rather the client omit > it, but...) OK, that makes sense. Comment at: clangd/Protocol.h:390 + /// Flattened from codeAction.codeActionLiteralSupport. + // FIXME: flatten other properties in this way. + bool codeActionLiteralSupport = false; sammccall wrote: > kadircet wrote: > > What is the reason behind this one? Is it because clients must handle > > unknown items on their own and fallback to a default one? > > > > Since that default is client specific, behavior might change from client to > > client. I agree that clients should be up-to-date with the specs and handle > > all kinds of items but these might still create confusions during the > > transition period. > > > > For example, ycmd decided to fallback to None instead of Text when they > > don't know about a symbolkind of a completion item, so users will get to > > see "File" for the include insertions on both folders and files but when > > they update to a newer clangd, they will start to see "File" for files and > > "None" for directory elements. Which I believe might create confusion, but > > we could still fallback to File for those elements(if we handled them > > within clangd) and user experience would neither worsen or improve. > > > > (Currently ycmd's symbolkindcapabilities are actually up-to-date with > > specs, so this issue wouldn't happen. Just wanted to make my point > > clearer). > Sorry, I don't really understand the question. > > Are you talking about the default for `codeActionLiteralSupport`? The > protocol says servers must send `Command`s unless the client indicates > support for `CodeAction`s. There's no room for a different default here. > > Or flattening of other properties? That will have no effect on logic, it just > simplifies the code (see D53266). > Ok, I thought we were also going to throw away the "valueset"s and just keep whether the client has the capability(and therefore graceful handling) or not. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53325: Disable code object version 3 for HIP toolchain
yaxunl created this revision. yaxunl added a reviewer: kzhuravl. Herald added a subscriber: tpr. AMDGPU backend will switch to code object version 3 by default. Since HIP runtime is not ready, disable it until the runtime is ready. https://reviews.llvm.org/D53325 Files: lib/Driver/ToolChains/HIP.cpp test/Driver/hip-toolchain-no-rdc.hip test/Driver/hip-toolchain-rdc.hip Index: test/Driver/hip-toolchain-rdc.hip === --- test/Driver/hip-toolchain-rdc.hip +++ test/Driver/hip-toolchain-rdc.hip @@ -35,7 +35,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV1:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV1]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[OBJ_DEV1]] @@ -61,7 +63,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV2:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC]] [[OPT_BC_DEV2]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV2:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV2:".*-gfx900-.*o"]] // CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[OBJ_DEV2]] Index: test/Driver/hip-toolchain-no-rdc.hip === --- test/Driver/hip-toolchain-no-rdc.hip +++ test/Driver/hip-toolchain-no-rdc.hip @@ -32,7 +32,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]] @@ -57,7 +59,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]] @@ -97,7 +101,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_803:.*out]]" [[OBJ_DEV_B_803]] @@ -122,7 +128,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_900:.*out]]" [[OBJ_DEV_B_900]] Index: lib/Driver/ToolChains/HIP.cpp === --- lib/Driver/ToolChains/HIP.cpp +++ lib/Driver/ToolChains/HIP.cpp @@ -154,7 +154,7 @@ llvm::StringRef OutputFilePrefix, const char *InputFileName) const { // Construct llc command. ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa", -"-filetype=obj", +"-filetype=obj", "-mattr=-code-object-v3", Args.MakeArgString("-mcpu=" + SubArchName), "-o"}; std::string LlcOutputFileName = C.getDriver().GetTemporaryPath(OutputFilePrefix, "o"); Index: test/Driver/hip-toolchain-rdc.hip === --- test/Driver/hip-toolchain-rdc.hip +++ test/Driver/hip-toolchain-rdc.hip @@ -35,7 +35,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV1:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV1]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +//
[PATCH] D53326: [python] [tests] Disable on known-broken arches
mgorny created this revision. mgorny added reviewers: uweigand, yroux, kparzysz, steveire, aaron.ballman. Herald added a reviewer: javed.absar. Herald added a subscriber: kristof.beyls. Disable the Python binding tests on AArch64, Hexagon and SystemZ following reports on test failures. The first two yield different results, possibly indicating test case problems. The last one seems to have broken FFI in Python. While at it, refactor the code to make adding future test restrictions easier. Repository: rC Clang https://reviews.llvm.org/D53326 Files: bindings/python/tests/CMakeLists.txt Index: bindings/python/tests/CMakeLists.txt === --- bindings/python/tests/CMakeLists.txt +++ bindings/python/tests/CMakeLists.txt @@ -7,24 +7,34 @@ DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) -# Check if we are building with ASan -list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) -if (LLVM_USE_ASAN_INDEX EQUAL -1) - set(LLVM_USE_ASAN FALSE) -else() - set(LLVM_USE_ASAN TRUE) -endif() +set(RUN_PYTHON_TESTS TRUE) -# Tests fail on Windows, and need someone knowledgeable to fix. -# It's not clear whether it's a test or a valid binding problem. -# # Do not try to run if libclang was built with ASan because # the sanitizer library will likely be loaded too late to perform # interception and will then fail. # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't # portable so its easier just to not run the tests when building # with ASan. -if((NOT WIN32) AND (NOT LLVM_USE_ASAN)) +list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) +if(NOT LLVM_USE_ASAN_INDEX EQUAL -1) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# Tests fail on Windows, and need someone knowledgeable to fix. +# It's not clear whether it's a test or a valid binding problem. +if(WIN32) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# AArch64 and Hexagon have known test failures that need to be +# addressed. +# SystemZ has broken Python/FFI interface: +# https://reviews.llvm.org/D52840#1265716 +if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$") + set(RUN_PYTHON_TESTS FALSE) +endif() + +if(RUN_PYTHON_TESTS) set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) endif() Index: bindings/python/tests/CMakeLists.txt === --- bindings/python/tests/CMakeLists.txt +++ bindings/python/tests/CMakeLists.txt @@ -7,24 +7,34 @@ DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) -# Check if we are building with ASan -list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) -if (LLVM_USE_ASAN_INDEX EQUAL -1) - set(LLVM_USE_ASAN FALSE) -else() - set(LLVM_USE_ASAN TRUE) -endif() +set(RUN_PYTHON_TESTS TRUE) -# Tests fail on Windows, and need someone knowledgeable to fix. -# It's not clear whether it's a test or a valid binding problem. -# # Do not try to run if libclang was built with ASan because # the sanitizer library will likely be loaded too late to perform # interception and will then fail. # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't # portable so its easier just to not run the tests when building # with ASan. -if((NOT WIN32) AND (NOT LLVM_USE_ASAN)) +list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) +if(NOT LLVM_USE_ASAN_INDEX EQUAL -1) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# Tests fail on Windows, and need someone knowledgeable to fix. +# It's not clear whether it's a test or a valid binding problem. +if(WIN32) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# AArch64 and Hexagon have known test failures that need to be +# addressed. +# SystemZ has broken Python/FFI interface: +# https://reviews.llvm.org/D52840#1265716 +if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$") + set(RUN_PYTHON_TESTS FALSE) +endif() + +if(RUN_PYTHON_TESTS) set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52840: Include Python binding tests in CMake rules
mgorny added a comment. Thanks for all your reports. I have filed https://reviews.llvm.org/D53326 to disable the tests on all three known-broken arches. Repository: rC Clang https://reviews.llvm.org/D52840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r344614 - Remove possibility to change compile database path at runtime
Author: simark Date: Tue Oct 16 08:55:03 2018 New Revision: 344614 URL: http://llvm.org/viewvc/llvm-project?rev=344614&view=rev Log: Remove possibility to change compile database path at runtime Summary: This patch removes the possibility to change the compilation database path at runtime using the didChangeConfiguration request. Instead, it is suggested to use the setting on the initialize request, and clangd whenever the user wants to use a different build configuration. Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53220 Removed: clang-tools-extra/trunk/test/clangd/compile-commands-path.test Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=344614&r1=344613&r2=344614&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Oct 16 08:55:03 2018 @@ -81,8 +81,16 @@ CompletionItemKindBitset defaultCompleti } // namespace void ClangdLSPServer::onInitialize(InitializeParams &Params) { - if (Params.initializationOptions) -applyConfiguration(*Params.initializationOptions); + if (Params.initializationOptions) { +const ClangdInitializationOptions &Opts = *Params.initializationOptions; + +// Explicit compilation database path. +if (Opts.compilationDatabasePath.hasValue()) { + CDB.setCompileCommandsDir(Opts.compilationDatabasePath.getValue()); +} + +applyConfiguration(Opts.ParamsChange); + } if (Params.rootUri && *Params.rootUri) Server->setRootPath(Params.rootUri->file()); @@ -425,17 +433,10 @@ void ClangdLSPServer::onHover(TextDocume } void ClangdLSPServer::applyConfiguration( -const ClangdConfigurationParamsChange &Settings) { - // Compilation database change. - if (Settings.compilationDatabasePath.hasValue()) { -CDB.setCompileCommandsDir(Settings.compilationDatabasePath.getValue()); - -reparseOpenedFiles(); - } - - // Update to the compilation database. - if (Settings.compilationDatabaseChanges) { -const auto &CompileCommandUpdates = *Settings.compilationDatabaseChanges; +const ClangdConfigurationParamsChange &Params) { + // Per-file update to the compilation database. + if (Params.compilationDatabaseChanges) { +const auto &CompileCommandUpdates = *Params.compilationDatabaseChanges; bool ShouldReparseOpenFiles = false; for (auto &Entry : CompileCommandUpdates) { /// The opened files need to be reparsed only when some existing Modified: clang-tools-extra/trunk/clangd/Protocol.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=344614&r1=344613&r2=344614&view=diff == --- clang-tools-extra/trunk/clangd/Protocol.cpp (original) +++ clang-tools-extra/trunk/clangd/Protocol.cpp Tue Oct 16 08:55:03 2018 @@ -665,10 +665,19 @@ bool fromJSON(const llvm::json::Value &P bool fromJSON(const json::Value &Params, ClangdConfigurationParamsChange &CCPC) { json::ObjectMapper O(Params); - return O && O.map("compilationDatabasePath", CCPC.compilationDatabasePath) && + return O && O.map("compilationDatabaseChanges", CCPC.compilationDatabaseChanges); } +bool fromJSON(const json::Value &Params, ClangdInitializationOptions &Opts) { + if (!fromJSON(Params, Opts.ParamsChange)) { +return false; + } + + json::ObjectMapper O(Params); + return O && O.map("compilationDatabasePath", Opts.compilationDatabasePath); +} + bool fromJSON(const json::Value &Params, ReferenceParams &R) { TextDocumentPositionParams &Base = R; return fromJSON(Params, Base); Modified: clang-tools-extra/trunk/clangd/Protocol.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=344614&r1=344613&r2=344614&view=diff == --- clang-tools-extra/trunk/clangd/Protocol.h (original) +++ clang-tools-extra/trunk/clangd/Protocol.h Tue Oct 16 08:55:03 2018 @@ -411,8 +411,6 @@ bool fromJSON(const llvm::json::Value &, /// "initialize" request and for the "workspace/didChangeConfiguration" /// notification since the data received is described as 'any' type in LSP. struct ClangdConfigurationParamsChange { - llvm::Optional compilationDatabasePath; - // The changes that happened to the compilation database. // The key of the map is a file name. llvm::Optional> @@ -420,7 +418,14 @@ struct ClangdConfigurationParamsChange { }
[PATCH] D53220: Remove possibility to change compile database path at runtime
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE344614: Remove possibility to change compile database path at runtime (authored by simark, committed by ). Changed prior to commit: https://reviews.llvm.org/D53220?vs=169828&id=169833#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53220 Files: clangd/ClangdLSPServer.cpp clangd/Protocol.cpp clangd/Protocol.h test/clangd/compile-commands-path-in-initialize.test test/clangd/compile-commands-path.test Index: clangd/Protocol.cpp === --- clangd/Protocol.cpp +++ clangd/Protocol.cpp @@ -665,10 +665,19 @@ bool fromJSON(const json::Value &Params, ClangdConfigurationParamsChange &CCPC) { json::ObjectMapper O(Params); - return O && O.map("compilationDatabasePath", CCPC.compilationDatabasePath) && + return O && O.map("compilationDatabaseChanges", CCPC.compilationDatabaseChanges); } +bool fromJSON(const json::Value &Params, ClangdInitializationOptions &Opts) { + if (!fromJSON(Params, Opts.ParamsChange)) { +return false; + } + + json::ObjectMapper O(Params); + return O && O.map("compilationDatabasePath", Opts.compilationDatabasePath); +} + bool fromJSON(const json::Value &Params, ReferenceParams &R) { TextDocumentPositionParams &Base = R; return fromJSON(Params, Base); Index: clangd/ClangdLSPServer.cpp === --- clangd/ClangdLSPServer.cpp +++ clangd/ClangdLSPServer.cpp @@ -81,8 +81,16 @@ } // namespace void ClangdLSPServer::onInitialize(InitializeParams &Params) { - if (Params.initializationOptions) -applyConfiguration(*Params.initializationOptions); + if (Params.initializationOptions) { +const ClangdInitializationOptions &Opts = *Params.initializationOptions; + +// Explicit compilation database path. +if (Opts.compilationDatabasePath.hasValue()) { + CDB.setCompileCommandsDir(Opts.compilationDatabasePath.getValue()); +} + +applyConfiguration(Opts.ParamsChange); + } if (Params.rootUri && *Params.rootUri) Server->setRootPath(Params.rootUri->file()); @@ -425,17 +433,10 @@ } void ClangdLSPServer::applyConfiguration( -const ClangdConfigurationParamsChange &Settings) { - // Compilation database change. - if (Settings.compilationDatabasePath.hasValue()) { -CDB.setCompileCommandsDir(Settings.compilationDatabasePath.getValue()); - -reparseOpenedFiles(); - } - - // Update to the compilation database. - if (Settings.compilationDatabaseChanges) { -const auto &CompileCommandUpdates = *Settings.compilationDatabaseChanges; +const ClangdConfigurationParamsChange &Params) { + // Per-file update to the compilation database. + if (Params.compilationDatabaseChanges) { +const auto &CompileCommandUpdates = *Params.compilationDatabaseChanges; bool ShouldReparseOpenFiles = false; for (auto &Entry : CompileCommandUpdates) { /// The opened files need to be reparsed only when some existing Index: clangd/Protocol.h === --- clangd/Protocol.h +++ clangd/Protocol.h @@ -411,16 +411,21 @@ /// "initialize" request and for the "workspace/didChangeConfiguration" /// notification since the data received is described as 'any' type in LSP. struct ClangdConfigurationParamsChange { - llvm::Optional compilationDatabasePath; - // The changes that happened to the compilation database. // The key of the map is a file name. llvm::Optional> compilationDatabaseChanges; }; bool fromJSON(const llvm::json::Value &, ClangdConfigurationParamsChange &); -struct ClangdInitializationOptions : public ClangdConfigurationParamsChange {}; +struct ClangdInitializationOptions { + // What we can change throught the didChangeConfiguration request, we can + // also set through the initialize request (initializationOptions field). + ClangdConfigurationParamsChange ParamsChange; + + llvm::Optional compilationDatabasePath; +}; +bool fromJSON(const llvm::json::Value &, ClangdInitializationOptions &); struct InitializeParams { /// The process Id of the parent process that started Index: test/clangd/compile-commands-path-in-initialize.test === --- test/clangd/compile-commands-path-in-initialize.test +++ test/clangd/compile-commands-path-in-initialize.test @@ -3,10 +3,8 @@ # RUN: rm -rf %t.dir/* && mkdir -p %t.dir # RUN: mkdir %t.dir/build-1 -# RUN: mkdir %t.dir/build-2 # RUN: echo '[{"directory": "%/t.dir", "command": "c++ the-file.cpp", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json # RUN: echo '[{"directory": "%/t.dir/build-1", "command": "c++ -DMACRO=1 the-file.cpp", "file": "../the-file.cpp"}]' > %t.dir/build-1/compile_commands.json -# RUN: echo '[{"directory": "%/t.dir/build-2", "command": "c++ -DMACRO=2 the-file
[PATCH] D53327: [Hexagon] Use -fuse-ld update checks.
sidneym created this revision. sidneym added reviewers: phosek, rsmith, kparzysz, bcain. Herald added a subscriber: cfe-commits. Use -fuse-ld to explicitly name the linker. Replace checks for hexagon-link | ld to just "hexagon-link", the name of the explicitly chosen linker. Repository: rC Clang https://reviews.llvm.org/D53327 Files: test/Driver/hexagon-toolchain-elf.c test/Driver/linux-ld.c Index: test/Driver/linux-ld.c === --- test/Driver/linux-ld.c +++ test/Driver/linux-ld.c @@ -876,10 +876,10 @@ // // Check that we do not pass --hash-style=gnu or --hash-style=both to // hexagon linux linker -// RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: %clang %s -### -o %t.o -fuse-ld=hexagon-link 2>&1 \ // RUN: --target=hexagon-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s -// CHECK-HEXAGON: "{{.*}}{{hexagon-link|ld}}{{(.exe)?}}" +// CHECK-HEXAGON: "{{.*}}hexagon-link{{(.exe)?}}" // CHECK-HEXAGON-NOT: "--hash-style={{gnu|both}}" // // Check that we do not pass --hash-style=gnu and --hash-style=both to linker Index: test/Driver/hexagon-toolchain-elf.c === --- test/Driver/hexagon-toolchain-elf.c +++ test/Driver/hexagon-toolchain-elf.c @@ -57,69 +57,69 @@ // - // Test -mcpu= -mv // - -// RUN: %clang -### -target hexagon-unknown-elf \ +// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=hexagon-link \ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ // RUN: -mcpu=hexagonv4 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK020 %s // CHECK020: "-cc1" {{.*}} "-target-cpu" "hexagonv4" -// CHECK020: {{hexagon-link|ld}}{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v4/crt0 +// CHECK020: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v4/crt0 -// RUN: %clang -### -target hexagon-unknown-elf \ +// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=hexagon-link \ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ // RUN: -mcpu=hexagonv5 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK021 %s // CHECK021: "-cc1" {{.*}} "-target-cpu" "hexagonv5" -// CHECK021: {{hexagon-link|ld}}{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v5/crt0 +// CHECK021: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v5/crt0 -// RUN: %clang -### -target hexagon-unknown-elf \ +// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=hexagon-link \ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ // RUN: -mcpu=hexagonv55 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK022 %s // CHECK022: "-cc1" {{.*}} "-target-cpu" "hexagonv55" -// CHECK022: {{hexagon-link|ld}}{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v55/crt0 +// CHECK022: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v55/crt0 -// RUN: %clang -### -target hexagon-unknown-elf \ +// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=hexagon-link \ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ // RUN: -mcpu=hexagonv60 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK023 %s // CHECK023: "-cc1" {{.*}} "-target-cpu" "hexagonv60" -// CHECK023: {{hexagon-link|ld}}{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v60/crt0 +// CHECK023: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v60/crt0 -// RUN: %clang -### -target hexagon-unknown-elf \ +// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=hexagon-link \ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ // RUN: -mcpu=hexagonv62 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK024 %s // CHECK024: "-cc1" {{.*}} "-target-cpu" "hexagonv62" -// CHECK024: {{hexagon-link|ld}}{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v62/crt0 +// CHECK024: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v62/crt0 -// RUN: %clang -### -target hexagon-unknown-elf \ +// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=hexagon-link \ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ // RUN: -mcpu=hexagonv65 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK025 %s // CHECK025: "-cc1" {{.*}} "-target-cpu" "hexagonv65" -// CHECK025: {{hexagon-link|ld}}{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v65/crt0 +// CHECK025: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v65/crt0 -// RUN: %clang -### -target hexagon-unknown-elf \ +// RUN: %clang -### -target hexagon-unknown-elf -fuse-ld=hexagon-link \ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ // RUN: -O3 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-
[PATCH] D53286: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
sammccall marked 9 inline comments as done. sammccall added inline comments. Comment at: clangd/ClangdLSPServer.cpp:156 +void ClangdLSPServer::onExit(ExitParams &Params) { + // XXX handler should return true. +} ioeric wrote: > ? Fixed this comment. I'm not totally happy with the shutdown mechanism, it's noisier and more magic than I'd like. May find something nicer to replace it with. Comment at: clangd/JSONTransport.cpp:23 +Code = L.Code; +return make_error(L.Message, inconvertibleErrorCode()); + })); ioeric wrote: > Is `E` guaranteed to be an `LSPError`? Do we need a handler for other errors? This actually handles generic errors as well, Error just has a really confusing API. Rewrote this to be more direct. Comment at: clangd/Transport.h:50 +virtual ~MessageHandler() = default; +virtual bool notify(llvm::StringRef Method, llvm::json::Value) = 0; +virtual bool call(llvm::StringRef Method, llvm::json::Value Params, ioeric wrote: > nit: maybe `handleNotify` to make the two directions more distinguishable? > This can get a bit counter-intuitive in the call sites. `onNotify` etc Comment at: unittests/clangd/JSONTransportTests.cpp:106 + auto Err = T->loop(E); + EXPECT_FALSE(bool(Err)) << llvm::toString(std::move(Err)); + ioeric wrote: > Would `operator<<` be used when the error is real (i.e. check passes)? No, EXPECT_* are magic macros that only evaluate the right hand side of << if they fire. `EXPECT_FALSE(expr)` expands to something like `if (expr) CreateErrorStream("expr")`, so the `<< blah` becomes part of the if statement. (And the temporary stream returned from CreateErrorStream does the actual logging/mark-the-test-as-failed in its destructor). Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53286 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53286: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
sammccall updated this revision to Diff 169835. sammccall marked 9 inline comments as done. sammccall added a comment. Addressed review comments. Also inverted the sense of the boolean return from `onNotify` etc, was "should exit" and is now "should continue", which I think is slightly clearer. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53286 Files: clangd/CMakeLists.txt clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/JSONRPCDispatcher.cpp clangd/JSONRPCDispatcher.h clangd/JSONTransport.cpp clangd/Protocol.cpp clangd/Protocol.h clangd/ProtocolHandlers.cpp clangd/Transport.h clangd/tool/ClangdMain.cpp test/clangd/compile-commands-path-in-initialize.test test/clangd/compile-commands-path.test test/clangd/completion-snippets.test test/clangd/completion.test test/clangd/crash-non-added-files.test test/clangd/execute-command.test test/clangd/input-mirror.test test/clangd/signature-help.test test/clangd/textdocument-didchange-fail.test test/clangd/trace.test test/clangd/xrefs.test unittests/clangd/CMakeLists.txt unittests/clangd/JSONTransportTests.cpp Index: unittests/clangd/JSONTransportTests.cpp === --- /dev/null +++ unittests/clangd/JSONTransportTests.cpp @@ -0,0 +1,199 @@ +//===-- JSONTransportTests.cpp ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +#include "Protocol.h" +#include "Transport.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include + +using namespace llvm; +namespace clang { +namespace clangd { +namespace { + +// No fmemopen on windows, so we can't easily run this test. +#ifndef WIN32 + +// Fixture takes care of managing the input/output buffers for the transport. +class JSONTransportTest : public ::testing::Test { + std::string InBuf, OutBuf, MirrorBuf; + llvm::raw_string_ostream Out, Mirror; + std::unique_ptr In; + +protected: + JSONTransportTest() : Out(OutBuf), Mirror(MirrorBuf), In(nullptr, nullptr) {} + + template + std::unique_ptr transport(std::string InData, bool Pretty, + JSONStreamStyle Style) { +InBuf = std::move(InData); +In = {fmemopen(&InBuf[0], InBuf.size(), "r"), &fclose}; +return newJSONTransport(In.get(), Out, &Mirror, Pretty, Style); + } + + std::string input() const { return InBuf; } + std::string output() { return Out.str(); } + std::string input_mirror() { return Mirror.str(); } +}; + +// Echo is a simple server running on a transport: +// - logs each message it gets. +// - when it gets a call, replies to it +// - when it gets a notification for method "call", makes a call on Target +// Hangs up when it gets an exit notification. +class Echo : public Transport::MessageHandler { + Transport &Target; + std::string LogBuf; + raw_string_ostream Log; + +public: + Echo(Transport &Target) : Target(Target), Log(LogBuf) {} + + std::string log() { return Log.str(); } + + bool onNotify(StringRef Method, json::Value Params) override { +Log << "Notification " << Method << ": " << Params << "\n"; +if (Method == "call") + Target.call("echo call", std::move(Params), 42); +return Method != "exit"; + } + + bool onCall(StringRef Method, json::Value Params, json::Value ID) override { +Log << "Call " << Method << "(" << ID << "): " << Params << "\n"; +if (Method == "err") + Target.reply(ID, make_error("trouble at mill", ErrorCode(88))); +else + Target.reply(ID, std::move(Params)); +return true; + } + + bool onReply(json::Value ID, Expected Params) override { +if (Params) + Log << "Reply(" << ID << "): " << *Params << "\n"; +else + Log << "Reply(" << ID + << "): error = " << llvm::toString(Params.takeError()) << "\n"; +return true; + } +}; + +std::string trim(StringRef S) { return S.trim().str(); } + +// Runs an Echo session using the standard JSON-RPC format we use in production. +TEST_F(JSONTransportTest, StandardDense) { + auto T = transport( + "Content-Length: 52\r\n\r\n" + R"({"jsonrpc": "2.0", "method": "call", "params": 1234})" + "Content-Length: 46\r\n\r\n" + R"({"jsonrpc": "2.0", "id": 1234, "result": 5678})" + "Content-Length: 67\r\n\r\n" + R"({"jsonrpc": "2.0", "method": "foo", "id": "abcd", "params": "efgh"})" + "Content-Length: 73\r\n\r\n" + R"({"jsonrpc": "2.0", "id": "xyz", "error": {"code": 99, "message": "bad!"}})" + "Content-Length: 68\r\n\r\n" + R"({"jsonrpc": "2.0", "method": "err", "id": "wxyz", "params": "boom!"})" + "Content-Length: 36\r\n\r\n" + R"({"jsonrpc": "2.0", "method": "exit"})", + /*Pretty=*/false, JSONStreamStyle::Standard)
[PATCH] D53213: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)
sammccall updated this revision to Diff 169837. sammccall added a comment. rebase only Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53213 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/Protocol.cpp clangd/Protocol.h test/clangd/fixits-codeaction.test test/clangd/fixits-command.test test/clangd/fixits.test Index: test/clangd/fixits.test === --- /dev/null +++ test/clangd/fixits.test @@ -1,210 +0,0 @@ -# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s -{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} -{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"int main(int i, char **a) { if (i = 2) {}}"}}} -# CHECK:"method": "textDocument/publishDiagnostics", -# CHECK-NEXT: "params": { -# CHECK-NEXT:"diagnostics": [ -# CHECK-NEXT: { -# CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses", -# CHECK-NEXT:"range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT:"character": 37, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT:"character": 32, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: } -# CHECK-NEXT:}, -# CHECK-NEXT:"severity": 2 -# CHECK-NEXT: } -# CHECK-NEXT:], -# CHECK-NEXT:"uri": "file://{{.*}}/foo.c" -# CHECK-NEXT: } -{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses"}]}}} -# CHECK: "id": 2, -# CHECK-NEXT: "jsonrpc": "2.0", -# CHECK-NEXT: "result": [ -# CHECK-NEXT:{ -# CHECK-NEXT: "arguments": [ -# CHECK-NEXT:{ -# CHECK-NEXT: "changes": { -# CHECK-NEXT:"file://{{.*}}/foo.c": [ -# CHECK-NEXT: { -# CHECK-NEXT:"newText": "(", -# CHECK-NEXT:"range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT:"character": 32, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT:"character": 32, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: }, -# CHECK-NEXT: { -# CHECK-NEXT:"newText": ")", -# CHECK-NEXT:"range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT:"character": 37, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT:"character": 37, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: } -# CHECK-NEXT:] -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: ], -# CHECK-NEXT: "command": "clangd.applyFix", -# CHECK-NEXT: "title": "Apply fix: place parentheses around the assignment to silence this warning" -# CHECK-NEXT:}, -# CHECK-NEXT:{ -# CHECK-NEXT: "arguments": [ -# CHECK-NEXT:{ -# CHECK-NEXT: "changes": { -# CHECK-NEXT:"file://{{.*}}/foo.c": [ -# CHECK-NEXT: { -# CHECK-NEXT:"newText": "==", -# CHECK-NEXT:"range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT:"character": 35, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT:"character": 34, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: } -# CHECK-NEXT:] -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: ], -# CHECK-NEXT: "command": "clangd.applyFix", -# CHECK-NEXT: "title": "Apply fix: use '==' to turn this assignment into an equality comparison" -# CHECK-NEXT:} -# CHECK-NEXT: ] -{"jsonrpc":"2.0","id":3,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses"}]}}}
[clang-tools-extra] r344617 - [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)
Author: sammccall Date: Tue Oct 16 09:29:41 2018 New Revision: 344617 URL: http://llvm.org/viewvc/llvm-project?rev=344617&view=rev Log: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8) Summary: I don't bother mirroring the full capabilities struct, just parse the bits we care about. I'll send a new patch to use this approach elsewhere too. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53213 Added: clang-tools-extra/trunk/test/clangd/fixits-codeaction.test clang-tools-extra/trunk/test/clangd/fixits-command.test - copied, changed from r344614, clang-tools-extra/trunk/test/clangd/fixits.test Removed: clang-tools-extra/trunk/test/clangd/fixits.test Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=344617&r1=344616&r2=344617&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Oct 16 09:29:41 2018 @@ -103,6 +103,8 @@ void ClangdLSPServer::onInitialize(Initi Params.capabilities.textDocument.publishDiagnostics.clangdFixSupport; DiagOpts.SendDiagnosticCategory = Params.capabilities.textDocument.publishDiagnostics.categorySupport; + SupportsCodeAction = + Params.capabilities.textDocument.codeActionLiteralSupport; if (Params.capabilities.workspace && Params.capabilities.workspace->symbol && Params.capabilities.workspace->symbol->symbolKind && @@ -339,29 +341,53 @@ void ClangdLSPServer::onDocumentSymbol(D }); } +static Optional asCommand(const CodeAction &Action) { + Command Cmd; + if (Action.command && Action.edit) +return llvm::None; // Not representable. (We never emit these anyway). + if (Action.command) { +Cmd = *Action.command; + } else if (Action.edit) { +Cmd.command = Command::CLANGD_APPLY_FIX_COMMAND; +Cmd.workspaceEdit = *Action.edit; + } else { +return llvm::None; + } + Cmd.title = Action.title; + if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND) +Cmd.title = "Apply fix: " + Cmd.title; + return Cmd; +} + void ClangdLSPServer::onCodeAction(CodeActionParams &Params) { - // We provide a code action for each diagnostic at the requested location - // which has FixIts available. - auto Code = DraftMgr.getDraft(Params.textDocument.uri.file()); - if (!Code) + // We provide a code action for Fixes on the specified diagnostics. + if (!DraftMgr.getDraft(Params.textDocument.uri.file())) return replyError(ErrorCode::InvalidParams, "onCodeAction called for non-added file"); - std::vector Commands; + std::vector Actions; for (Diagnostic &D : Params.context.diagnostics) { for (auto &F : getFixes(Params.textDocument.uri.file(), D)) { - WorkspaceEdit WE; - std::vector Edits(F.Edits.begin(), F.Edits.end()); - Commands.emplace_back(); - Commands.back().title = llvm::formatv("Apply fix: {0}", F.Message); - Commands.back().command = ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND; - Commands.back().workspaceEdit.emplace(); - Commands.back().workspaceEdit->changes = { - {Params.textDocument.uri.uri(), std::move(Edits)}, - }; + Actions.emplace_back(); + Actions.back().title = F.Message; + Actions.back().kind = CodeAction::QUICKFIX_KIND; + Actions.back().diagnostics = {D}; + Actions.back().edit.emplace(); + Actions.back().edit->changes.emplace(); + (*Actions.back().edit->changes)[Params.textDocument.uri.uri()] = { + F.Edits.begin(), F.Edits.end()}; } } - reply(json::Array(Commands)); + + if (SupportsCodeAction) +reply(json::Array(Actions)); + else { +std::vector Commands; +for (const auto &Action : Actions) + if (auto Command = asCommand(Action)) +Commands.push_back(std::move(*Command)); +reply(json::Array(Commands)); + } } void ClangdLSPServer::onCompletion(TextDocumentPositionParams &Params) { Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=344617&r1=344616&r2=344617&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Tue Oct 16 09:29:41 2018 @@ -166,6 +166,8 @@ private: SymbolKindBitset SupportedSymbolKinds; /// The supported completion item kinds of the client. CompletionItemK
[PATCH] D53213: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)
sammccall added inline comments. Comment at: clangd/Protocol.h:390 + /// Flattened from codeAction.codeActionLiteralSupport. + // FIXME: flatten other properties in this way. + bool codeActionLiteralSupport = false; kadircet wrote: > sammccall wrote: > > kadircet wrote: > > > What is the reason behind this one? Is it because clients must handle > > > unknown items on their own and fallback to a default one? > > > > > > Since that default is client specific, behavior might change from client > > > to client. I agree that clients should be up-to-date with the specs and > > > handle all kinds of items but these might still create confusions during > > > the transition period. > > > > > > For example, ycmd decided to fallback to None instead of Text when they > > > don't know about a symbolkind of a completion item, so users will get to > > > see "File" for the include insertions on both folders and files but when > > > they update to a newer clangd, they will start to see "File" for files > > > and "None" for directory elements. Which I believe might create > > > confusion, but we could still fallback to File for those elements(if we > > > handled them within clangd) and user experience would neither worsen or > > > improve. > > > > > > (Currently ycmd's symbolkindcapabilities are actually up-to-date with > > > specs, so this issue wouldn't happen. Just wanted to make my point > > > clearer). > > Sorry, I don't really understand the question. > > > > Are you talking about the default for `codeActionLiteralSupport`? The > > protocol says servers must send `Command`s unless the client indicates > > support for `CodeAction`s. There's no room for a different default here. > > > > Or flattening of other properties? That will have no effect on logic, it > > just simplifies the code (see D53266). > > > Ok, I thought we were also going to throw away the "valueset"s and just keep > whether the client has the capability(and therefore graceful handling) or not. Ah, no. That might actually be a better complexity tradeoff, but I'm not proposing changing the existing behavior at the moment. On the other hand, for CodeActions themselves, this patch does rely on the client handling arbitrary `CodeActionKind`s, it doesn't look at exactly which ones the client understands. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53213: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)
This revision was automatically updated to reflect the committed changes. Closed by commit rL344617: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8) (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53213?vs=169837&id=169838#toc Repository: rL LLVM https://reviews.llvm.org/D53213 Files: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/test/clangd/fixits-codeaction.test clang-tools-extra/trunk/test/clangd/fixits-command.test clang-tools-extra/trunk/test/clangd/fixits.test Index: clang-tools-extra/trunk/test/clangd/fixits-command.test === --- clang-tools-extra/trunk/test/clangd/fixits-command.test +++ clang-tools-extra/trunk/test/clangd/fixits-command.test @@ -0,0 +1,210 @@ +# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"int main(int i, char **a) { if (i = 2) {}}"}}} +# CHECK:"method": "textDocument/publishDiagnostics", +# CHECK-NEXT: "params": { +# CHECK-NEXT:"diagnostics": [ +# CHECK-NEXT: { +# CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses", +# CHECK-NEXT:"range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT:"character": 37, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT:"character": 32, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: } +# CHECK-NEXT:}, +# CHECK-NEXT:"severity": 2 +# CHECK-NEXT: } +# CHECK-NEXT:], +# CHECK-NEXT:"uri": "file://{{.*}}/foo.c" +# CHECK-NEXT: } +--- +{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses"}]}}} +# CHECK: "id": 2, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": [ +# CHECK-NEXT:{ +# CHECK-NEXT: "arguments": [ +# CHECK-NEXT:{ +# CHECK-NEXT: "changes": { +# CHECK-NEXT:"file://{{.*}}/foo.c": [ +# CHECK-NEXT: { +# CHECK-NEXT:"newText": "(", +# CHECK-NEXT:"range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT:"character": 32, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT:"character": 32, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT:"newText": ")", +# CHECK-NEXT:"range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT:"character": 37, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT:"character": 37, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: } +# CHECK-NEXT:] +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: ], +# CHECK-NEXT: "command": "clangd.applyFix", +# CHECK-NEXT: "title": "Apply fix: place parentheses around the assignment to silence this warning" +# CHECK-NEXT:}, +# CHECK-NEXT:{ +# CHECK-NEXT: "arguments": [ +# CHECK-NEXT:{ +# CHECK-NEXT: "changes": { +# CHECK-NEXT:"file://{{.*}}/foo.c": [ +# CHECK-NEXT: { +# CHECK-NEXT:"newText": "==", +# CHECK-NEXT:"range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT:"character": 35, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT:"character": 34, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: } +# CHECK-NEXT:] +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: ], +# CHECK-NEXT: "command": "clangd.applyFix", +# CHECK-NEXT: "title": "
[PATCH] D53286: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
ioeric accepted this revision. ioeric added inline comments. This revision is now accepted and ready to land. Comment at: clangd/JSONRPCDispatcher.h:70 /// A handler responds to requests for a particular method name. + /// It returns true if the server should now shut down. /// s/true/false/ Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53286 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53325: Disable code object version 3 for HIP toolchain
kzhuravl accepted this revision. kzhuravl added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D53325 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53266: [clangd] Simplify client capabilities parsing.
sammccall updated this revision to Diff 169839. sammccall added a comment. Rebase to include CodeAction literal support Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53266 Files: clangd/ClangdLSPServer.cpp clangd/Protocol.cpp clangd/Protocol.h Index: clangd/Protocol.h === --- clangd/Protocol.h +++ clangd/Protocol.h @@ -221,18 +221,6 @@ Incremental = 2, }; -struct CompletionItemClientCapabilities { - /// Client supports snippets as insert text. - bool snippetSupport = false; - /// Client supports commit characters on a completion item. - bool commitCharacterSupport = false; - // Client supports the follow content formats for the documentation property. - // The order describes the preferred format of the client. - // NOTE: not used by clangd at the moment. - // std::vector documentationFormat; -}; -bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &); - /// The kind of a completion entry. enum class CompletionItemKind { Missing = 0, @@ -263,58 +251,16 @@ TypeParameter = 25, }; bool fromJSON(const llvm::json::Value &, CompletionItemKind &); - -struct CompletionItemKindCapabilities { - /// The CompletionItemKinds that the client supports. If not set, the client - /// only supports <= CompletionItemKind::Reference and will not fall back to a - /// valid default value. - llvm::Optional> valueSet; -}; -// Discards unknown CompletionItemKinds. -bool fromJSON(const llvm::json::Value &, std::vector &); -bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &); - constexpr auto CompletionItemKindMin = static_cast(CompletionItemKind::Text); constexpr auto CompletionItemKindMax = static_cast(CompletionItemKind::TypeParameter); using CompletionItemKindBitset = std::bitset; +bool fromJSON(const llvm::json::Value &, CompletionItemKindBitset &); CompletionItemKind adjustKindToCapability(CompletionItemKind Kind, CompletionItemKindBitset &supportedCompletionItemKinds); -struct CompletionClientCapabilities { - /// Whether completion supports dynamic registration. - bool dynamicRegistration = false; - /// The client supports the following `CompletionItem` specific capabilities. - CompletionItemClientCapabilities completionItem; - /// The CompletionItemKinds that the client supports. If not set, the client - /// only supports <= CompletionItemKind::Reference and will not fall back to a - /// valid default value. - llvm::Optional completionItemKind; - - /// The client supports to send additional context information for a - /// `textDocument/completion` request. - bool contextSupport = false; -}; -bool fromJSON(const llvm::json::Value &, CompletionClientCapabilities &); - -struct PublishDiagnosticsClientCapabilities { - // Whether the client accepts diagnostics with related information. - // NOTE: not used by clangd at the moment. - // bool relatedInformation; - - /// Whether the client accepts diagnostics with fixes attached using the - /// "clangd_fixes" extension. - bool clangdFixSupport = false; - - /// Whether the client accepts diagnostics with category attached to it - /// using the "category" extension. - bool categorySupport = false; -}; -bool fromJSON(const llvm::json::Value &, - PublishDiagnosticsClientCapabilities &); - /// A symbol kind. enum class SymbolKind { File = 1, @@ -344,62 +290,44 @@ Operator = 25, TypeParameter = 26 }; - +bool fromJSON(const llvm::json::Value &, SymbolKind &); constexpr auto SymbolKindMin = static_cast(SymbolKind::File); constexpr auto SymbolKindMax = static_cast(SymbolKind::TypeParameter); using SymbolKindBitset = std::bitset; - -bool fromJSON(const llvm::json::Value &, SymbolKind &); - -struct SymbolKindCapabilities { - /// The SymbolKinds that the client supports. If not set, the client only - /// supports <= SymbolKind::Array and will not fall back to a valid default - /// value. - llvm::Optional> valueSet; -}; -// Discards unknown SymbolKinds. -bool fromJSON(const llvm::json::Value &, std::vector &); -bool fromJSON(const llvm::json::Value &, SymbolKindCapabilities &); +bool fromJSON(const llvm::json::Value &, SymbolKindBitset &); SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset &supportedSymbolKinds); -struct WorkspaceSymbolCapabilities { - /// Capabilities SymbolKind. - llvm::Optional symbolKind; -}; -bool fromJSON(const llvm::json::Value &, WorkspaceSymbolCapabilities &); - -// FIXME: most of the capabilities are missing from this struct. Only the ones -// used by clangd are currently there. -struct WorkspaceClientCapabilities { - /// Capabilities specific to `workspace/symbol`. - llvm::Optional symbol; -}; -bool fromJSON(const llvm::json::Value &, WorkspaceClientCapabilities &); +// This struct doesn't mirror LSP! +// The protocol defines deeply nested structures for cli
[clang-tools-extra] r344620 - [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
Author: sammccall Date: Tue Oct 16 09:48:06 2018 New Revision: 344620 URL: http://llvm.org/viewvc/llvm-project?rev=344620&view=rev Log: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction. Summary: This paves the way for alternative transports (mac XPC, maybe messagepack?), and also generally improves layering: testing ClangdLSPServer becomes less of a pipe dream, we split up the JSONOutput monolith, etc. This isn't a final state, much of what remains in JSONRPCDispatcher can go away, handlers can call reply() on the transport directly, JSONOutput can be renamed to StreamLogger and removed, etc. But this patch is sprawling already. The main observable change (see tests) is that hitting EOF on input is now an error: the client should send the 'exit' notification. This is defensible: the protocol doesn't spell this case out. Reproducing the current behavior for all combinations of shutdown/exit/EOF clutters interfaces. We can iterate on this if desired. Reviewers: jkorous, ioeric, hokein Subscribers: mgorny, ilya-biryukov, MaskRay, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53286 Added: clang-tools-extra/trunk/clangd/JSONTransport.cpp clang-tools-extra/trunk/clangd/Transport.h clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test clang-tools-extra/trunk/test/clangd/completion-snippets.test clang-tools-extra/trunk/test/clangd/completion.test clang-tools-extra/trunk/test/clangd/crash-non-added-files.test clang-tools-extra/trunk/test/clangd/execute-command.test clang-tools-extra/trunk/test/clangd/input-mirror.test clang-tools-extra/trunk/test/clangd/signature-help.test clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test clang-tools-extra/trunk/test/clangd/trace.test clang-tools-extra/trunk/test/clangd/xrefs.test clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=344620&r1=344619&r2=344620&view=diff == --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Oct 16 09:48:06 2018 @@ -26,6 +26,7 @@ add_clang_library(clangDaemon GlobalCompilationDatabase.cpp Headers.cpp JSONRPCDispatcher.cpp + JSONTransport.cpp Logger.cpp Protocol.cpp ProtocolHandlers.cpp Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=344620&r1=344619&r2=344620&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Oct 16 09:48:06 2018 @@ -162,7 +162,10 @@ void ClangdLSPServer::onShutdown(Shutdow reply(nullptr); } -void ClangdLSPServer::onExit(ExitParams &Params) { IsDone = true; } +void ClangdLSPServer::onExit(ExitParams &Params) { + // No work to do. + // JSONRPCDispatcher shuts down the transport after this notification. +} void ClangdLSPServer::onDocumentDidOpen(DidOpenTextDocumentParams &Params) { PathRef File = Params.textDocument.uri.file(); @@ -497,39 +500,41 @@ void ClangdLSPServer::onReference(Refere }); } -ClangdLSPServer::ClangdLSPServer(JSONOutput &Out, +ClangdLSPServer::ClangdLSPServer(class Transport &Transport, const clangd::CodeCompleteOptions &CCOpts, llvm::Optional CompileCommandsDir, bool ShouldUseInMemoryCDB, const ClangdServer::Options &Opts) -: Out(Out), CDB(ShouldUseInMemoryCDB ? CompilationDB::makeInMemory() - : CompilationDB::makeDirectoryBased( - std::move(CompileCommandsDir))), +: Transport(Transport), + CDB(ShouldUseInMemoryCDB ? CompilationDB::makeInMemory() + : CompilationDB::makeDirectoryBased( + std::move(CompileCommandsDir))), CCOpts(CCOpts), SupportedSymbolKinds(defaultSymbolKinds()), SupportedComp
[PATCH] D53286: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
This revision was automatically updated to reflect the committed changes. sammccall marked 5 inline comments as done. Closed by commit rL344620: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction. (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53286?vs=169835&id=169841#toc Repository: rL LLVM https://reviews.llvm.org/D53286 Files: clang-tools-extra/trunk/clangd/CMakeLists.txt clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h clang-tools-extra/trunk/clangd/JSONTransport.cpp clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp clang-tools-extra/trunk/clangd/Transport.h clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test clang-tools-extra/trunk/test/clangd/completion-snippets.test clang-tools-extra/trunk/test/clangd/completion.test clang-tools-extra/trunk/test/clangd/crash-non-added-files.test clang-tools-extra/trunk/test/clangd/execute-command.test clang-tools-extra/trunk/test/clangd/input-mirror.test clang-tools-extra/trunk/test/clangd/signature-help.test clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test clang-tools-extra/trunk/test/clangd/trace.test clang-tools-extra/trunk/test/clangd/xrefs.test clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp Index: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h === --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h @@ -14,6 +14,7 @@ #include "Logger.h" #include "Protocol.h" #include "Trace.h" +#include "Transport.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" @@ -24,37 +25,19 @@ namespace clang { namespace clangd { -/// Encapsulates output and logs streams and provides thread-safe access to -/// them. +// Logs to an output stream, such as stderr. +// FIXME: Rename to StreamLogger or such, and move to Logger.h. class JSONOutput : public Logger { - // FIXME(ibiryukov): figure out if we can shrink the public interface of - // JSONOutput now that we pass Context everywhere. public: - JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs, - Logger::Level MinLevel, llvm::raw_ostream *InputMirror = nullptr, - bool Pretty = false) - : Pretty(Pretty), MinLevel(MinLevel), Outs(Outs), Logs(Logs), -InputMirror(InputMirror) {} - - /// Emit a JSONRPC message. - void writeMessage(const llvm::json::Value &Result); + JSONOutput(llvm::raw_ostream &Logs, Logger::Level MinLevel) + : MinLevel(MinLevel), Logs(Logs) {} /// Write a line to the logging stream. void log(Level, const llvm::formatv_object_base &Message) override; - /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror is - /// null. - /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe. - void mirrorInput(const Twine &Message); - - // Whether output should be pretty-printed. - const bool Pretty; - private: Logger::Level MinLevel; - llvm::raw_ostream &Outs; llvm::raw_ostream &Logs; - llvm::raw_ostream *InputMirror; std::mutex StreamMutex; }; @@ -81,26 +64,39 @@ /// /// The `$/cancelRequest` notification is handled by the dispatcher itself. /// It marks the matching request as cancelled, if it's still running. -class JSONRPCDispatcher { +class JSONRPCDispatcher : private Transport::MessageHandler { public: /// A handler responds to requests for a particular method name. + /// It returns false if the server should now shut down. /// /// JSONRPCDispatcher will mark the handler's context as cancelled if a /// matching cancellation request is received. Handlers are encouraged to /// check for cancellation and fail quickly in this case. - using Handler = std::function; + using Handler = std::function; /// Create a new JSONRPCDispatcher. UnknownHandler is called when an unknown /// method is received. JSONRPCDispatcher(Handler UnknownHandler); /// Registers a Handler for the specified Method. void registerHandler(StringRef Method, Handler H); - /// Parses a JSONRPC message and calls the Handler for it. - bool call(const llvm::json::Value &Message, JSONOutput &Out); + /// Parses input queries from LSP client (coming from \p In) and runs call + /// method for each query. + /// + /// Input stream(\p In) must be opened in binary mode to avoid + /// preliminary replacements of \r\n with \n. We use C-style FILE* for reading + //
[PATCH] D53329: Generate DIFile with main program if source is not available
yonghong-song created this revision. yonghong-song added reviewers: vsk, HsiangKai, ABataev. yonghong-song added a project: debug-info. Herald added subscribers: cfe-commits, JDevlieghere, aprantl. A llvm segfault happens when I tried to add "-g -gdwarf-5 -gembed-source" in bcc in order to get soruce code into IR and dwarf. A little bit background, bcc (https://github.com/iovisor/bcc) utilizes llvm MCJIT to generate BPF insns and load them to the kernel for execution. Several files passed to clang are memory mapped including the main program /virtual/main.c. I did some analysis on why segfault happens and whether we did get all file sources. And I found that we did not get source for one instance: !32 = !DIFile(filename: "/virtual/main.c", directory: "/usr/src/kernels/4.11.3-70_fbk18_4116_g1cf3f1a0ca4f") After some debugging, I found this patch can fix the problem. Basically, when the source is not available to generate DIFile use the main program. You can get more details of the bug, IR, cc1 flags, segfault stack and how to reproduce at this commit: https://github.com/yonghong-song/bcc/commit/7ac342e05468e60138d61e0e41691ed2f98bd929 Signed-off-by: Yonghong Song Repository: rC Clang https://reviews.llvm.org/D53329 Files: lib/CodeGen/CGDebugInfo.cpp Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -411,6 +411,10 @@ // If the location is not valid then use main input file. return getOrCreateMainFile(); + if (!getSource(SM, SM.getFileID(Loc))) +// If the source file is not valid then use main input file +return getOrCreateMainFile(); + // Cache the results. const char *fname = PLoc.getFilename(); auto It = DIFileCache.find(fname); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -411,6 +411,10 @@ // If the location is not valid then use main input file. return getOrCreateMainFile(); + if (!getSource(SM, SM.getFileID(Loc))) +// If the source file is not valid then use main input file +return getOrCreateMainFile(); + // Cache the results. const char *fname = PLoc.getFilename(); auto It = DIFileCache.find(fname); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53329: Generate DIFile with main program if source is not available
yonghong-song added a comment. Hi, @vsk @HsiangKai @ABataev I found a bug in clang when trying to use "-g -gdwarf-5 -gembed-source" for bcc MCJIT based clang/llvm compilation. This patch fixed the issue but I am not sure whether this is the correct fix or not. Please help take a look and advise if the fix is not correct and there is a better one. Thanks! Repository: rC Clang https://reviews.llvm.org/D53329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53329: Generate DIFile with main program if source is not available
aprantl added a comment. Couldn't you just pass `-main-file-name` to cc1 instead? Repository: rC Clang https://reviews.llvm.org/D53329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52320: AMDGPU: add __builtin_amdgcn_update_dpp
b-sumner added a comment. Ping. There's quite a bit of interest in getting this exposed by clang. https://reviews.llvm.org/D52320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53329: Generate DIFile with main program if source is not available
yonghong-song added a comment. We already have `-main-file-name` in cc1. `clang -cc1 -triple x86_64-unknown-linux-gnu ... -main-file-name main.c ... -o main.bc -x c /virtual/main.c -faddrsig` Is this expected? BTW, we just pass the normal C flags to the driver like vector flags_cstr({"-O0", "-O2", "-emit-llvm", "-I", dstack.cwd(), "-D", "__BPF_TRACING__", "-Wno-deprecated-declarations", "-Wno-gnu-variable-sized-type-not-at-end", "-Wno-pragma-once-outside-header", "-Wno-address-of-packed-member", "-Wno-unknown-warning-option", "-fno-color-diagnostics", "-fno-unwind-tables", "-fno-asynchronous-unwind-tables", "-x", "c", "-c", abs_file.c_str()}); flags_cstr.push_back("-g"); flags_cstr.push_back("-gdwarf-5"); flags_cstr.push_back("-gembed-source"); // A few other flags We call drv.BuildCompilation to get the cc1 flags. Repository: rC Clang https://reviews.llvm.org/D53329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53329: Generate DIFile with main program if source is not available
yonghong-song added a comment. In the above `/virtual/main.c` is a memory mapped file. The `invocation0.getPreprocessorOpts().addRemappedFile(...)` adds the mapping for the compilation. Repository: rC Clang https://reviews.llvm.org/D53329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50539: [VFS] Add property 'fallthrough' that controls fallback to real file system.
vsapsai updated this revision to Diff 169849. vsapsai added a comment. Herald added a subscriber: hiraditya. - Rebase on top of the latest changes in trunk. - Address review comments. I expect diff between diffs to be noisy due to rebase. https://reviews.llvm.org/D50539 Files: clang/lib/Frontend/CompilerInvocation.cpp clang/test/VFS/Inputs/Broken.framework/Headers/Error.h clang/test/VFS/Inputs/Broken.framework/Modules/module.modulemap clang/test/VFS/Inputs/Broken.framework/VFSHeaders/A.h clang/test/VFS/Inputs/vfsroot.yaml clang/test/VFS/vfsroot-include.c clang/test/VFS/vfsroot-module.m clang/test/VFS/vfsroot-with-overlay.c llvm/lib/Support/VirtualFileSystem.cpp llvm/unittests/Support/VirtualFileSystemTest.cpp Index: llvm/unittests/Support/VirtualFileSystemTest.cpp === --- llvm/unittests/Support/VirtualFileSystemTest.cpp +++ llvm/unittests/Support/VirtualFileSystemTest.cpp @@ -1599,3 +1599,89 @@ EXPECT_EQ(3, NumDiagnostics); } + +TEST_F(VFSFromYAMLTest, NonFallthroughDirectoryIteration) { + IntrusiveRefCntPtr Lower(new DummyFileSystem()); + Lower->addDirectory("//root/"); + Lower->addRegularFile("//root/a"); + Lower->addRegularFile("//root/b"); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'use-external-names': false,\n" + " 'fallthrough': false,\n" + " 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'c',\n" + " 'external-contents': '//root/a'\n" + "}\n" + " ]\n" + "}\n" + "]\n" + "}", + Lower); + ASSERT_TRUE(FS.get() != nullptr); + + std::error_code EC; + checkContents(FS->dir_begin("//root/", EC), +{"//root/c"}); +} + +TEST_F(VFSFromYAMLTest, DirectoryIterationWithDuplicates) { + IntrusiveRefCntPtr Lower(new DummyFileSystem()); + Lower->addDirectory("//root/"); + Lower->addRegularFile("//root/a"); + Lower->addRegularFile("//root/b"); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'use-external-names': false,\n" + " 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'a',\n" + " 'external-contents': '//root/a'\n" + "}\n" + " ]\n" + "}\n" + "]\n" + "}", + Lower); + ASSERT_TRUE(FS.get() != nullptr); + + std::error_code EC; + checkContents(FS->dir_begin("//root/", EC), +{"//root/a", "//root/b"}); +} + +TEST_F(VFSFromYAMLTest, DirectoryIterationErrorInVFSLayer) { + IntrusiveRefCntPtr Lower(new DummyFileSystem()); + Lower->addDirectory("//root/"); + Lower->addDirectory("//root/foo"); + Lower->addRegularFile("//root/foo/a"); + Lower->addRegularFile("//root/foo/b"); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'use-external-names': false,\n" + " 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'bar/a',\n" + " 'external-contents': '//root/foo/a'\n" + "}\n" + " ]\n" + "}\n" + "]\n" + "}", + Lower); + ASSERT_TRUE(FS.get() != nullptr); + + std::error_code EC; + checkContents(FS->dir_begin("//root/foo", EC), +{"//root/foo/a", "//root/foo/b"}); +} Index: llvm/lib/Support/VirtualFileSystem.cpp === --- llvm/lib/Support/VirtualFileSystem.cpp +++ llvm/lib/Support/VirtualFileSystem.cpp @@ -993,16 +993,40 @@ static bool classof(const Entry *E) { return E->getKind() == EK_File; } }; +// FIXME: reuse implementation common with OverlayFSDirIterImpl as these +// iterators are conceptually similar. class VFSFromYamlDirIterImpl : public llvm::vfs::detail::DirIterImpl { std::string Dir; RedirectingDirectoryEntry::iterator Current, End; - std::error_code incrementImpl(); + // To handle 'fallthrough' mode we need to iterate at first through + // RedirectingDirectoryEntry and then through ExternalFS. These operations are + // done sequentially, we just need to keep a track of what kind of iteration + // we are currently performing. + + // Flag telling if we should iterate through ExternalFS or stop at the last + // RedirectingDirectoryEntry::iterator. + bool IterateExternalFS; + // Flag telling if we have switched to iterating through ExternalFS. + bool IsExternalFSCurrent = false; + FileSystem &ExternalFS; + directory_iterator ExternalDirIter; + llvm::StringSet<> SeenNames; + + // To combine multiple iterations, different methods are responsible
[PATCH] D53200: [OpenCL] Fix serialization of OpenCLExtensionDecls
AlexeySachkov updated this revision to Diff 169851. AlexeySachkov added a comment. Added test https://reviews.llvm.org/D53200 Files: lib/Serialization/ASTWriter.cpp test/Headers/opencl-pragma-extension-begin.cl test/Headers/opencl-pragma-extension-begin.h Index: test/Headers/opencl-pragma-extension-begin.h === --- /dev/null +++ test/Headers/opencl-pragma-extension-begin.h @@ -0,0 +1,4 @@ + +#pragma OPENCL EXTENSION cl_my_ext : begin +void cl_my_ext_foo(); +#pragma OPENCL EXTENSION cl_my_ext : end Index: test/Headers/opencl-pragma-extension-begin.cl === --- /dev/null +++ test/Headers/opencl-pragma-extension-begin.cl @@ -0,0 +1,13 @@ +// RUN: rm -rf %t.ocl.pragma.ext.begin +// RUN: mkdir -p %t.ocl.pragma.ext.begin +// +// RUN: %clang_cc1 -cl-std=CL1.2 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1 +// +// RUN: rm -rf %t.ocl.pragma.ext.begin +// RUN: mkdir -p %t.ocl.pragma.ext.begin +// +// RUN: %clang_cc1 -cl-std=CL2.0 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1 + +void __kernel test(__global int *data) { + *data = 10; +} Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -5014,13 +5014,16 @@ WriteFPPragmaOptions(SemaRef.getFPOptions()); WriteOpenCLExtensions(SemaRef); WriteOpenCLExtensionTypes(SemaRef); - WriteOpenCLExtensionDecls(SemaRef); WriteCUDAPragmas(SemaRef); // If we're emitting a module, write out the submodule information. if (WritingModule) WriteSubmodules(WritingModule); + // We need to have information about submodules to correctly deserialize + // decls from OpenCLExtensionDecls block + WriteOpenCLExtensionDecls(SemaRef); + Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes); // Write the record containing external, unnamed definitions. Index: test/Headers/opencl-pragma-extension-begin.h === --- /dev/null +++ test/Headers/opencl-pragma-extension-begin.h @@ -0,0 +1,4 @@ + +#pragma OPENCL EXTENSION cl_my_ext : begin +void cl_my_ext_foo(); +#pragma OPENCL EXTENSION cl_my_ext : end Index: test/Headers/opencl-pragma-extension-begin.cl === --- /dev/null +++ test/Headers/opencl-pragma-extension-begin.cl @@ -0,0 +1,13 @@ +// RUN: rm -rf %t.ocl.pragma.ext.begin +// RUN: mkdir -p %t.ocl.pragma.ext.begin +// +// RUN: %clang_cc1 -cl-std=CL1.2 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1 +// +// RUN: rm -rf %t.ocl.pragma.ext.begin +// RUN: mkdir -p %t.ocl.pragma.ext.begin +// +// RUN: %clang_cc1 -cl-std=CL2.0 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1 + +void __kernel test(__global int *data) { + *data = 10; +} Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -5014,13 +5014,16 @@ WriteFPPragmaOptions(SemaRef.getFPOptions()); WriteOpenCLExtensions(SemaRef); WriteOpenCLExtensionTypes(SemaRef); - WriteOpenCLExtensionDecls(SemaRef); WriteCUDAPragmas(SemaRef); // If we're emitting a module, write out the submodule information. if (WritingModule) WriteSubmodules(WritingModule); + // We need to have information about submodules to correctly deserialize + // decls from OpenCLExtensionDecls block + WriteOpenCLExtensionDecls(SemaRef); + Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes); // Write the record containing external, unnamed definitions. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344630 - Disable code object version 3 for HIP toolchain
Author: yaxunl Date: Tue Oct 16 10:36:23 2018 New Revision: 344630 URL: http://llvm.org/viewvc/llvm-project?rev=344630&view=rev Log: Disable code object version 3 for HIP toolchain AMDGPU backend will switch to code object version 3 by default. Since HIP runtime is not ready, disable it until the runtime is ready. Differential Revision: https://reviews.llvm.org/D53325 Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip cfe/trunk/test/Driver/hip-toolchain-rdc.hip Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=344630&r1=344629&r2=344630&view=diff == --- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Tue Oct 16 10:36:23 2018 @@ -154,7 +154,7 @@ const char *AMDGCN::Linker::constructLlc llvm::StringRef OutputFilePrefix, const char *InputFileName) const { // Construct llc command. ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa", -"-filetype=obj", +"-filetype=obj", "-mattr=-code-object-v3", Args.MakeArgString("-mcpu=" + SubArchName), "-o"}; std::string LlcOutputFileName = C.getDriver().GetTemporaryPath(OutputFilePrefix, "o"); Modified: cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip?rev=344630&r1=344629&r2=344630&view=diff == --- cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip (original) +++ cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip Tue Oct 16 10:36:23 2018 @@ -32,7 +32,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]] @@ -57,7 +59,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]] @@ -97,7 +101,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_803:.*out]]" [[OBJ_DEV_B_803]] @@ -122,7 +128,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_900:.*out]]" [[OBJ_DEV_B_900]] Modified: cfe/trunk/test/Driver/hip-toolchain-rdc.hip URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-toolchain-rdc.hip?rev=344630&r1=344629&r2=344630&view=diff == --- cfe/trunk/test/Driver/hip-toolchain-rdc.hip (original) +++ cfe/trunk/test/Driver/hip-toolchain-rdc.hip Tue Oct 16 10:36:23 2018 @@ -35,7 +35,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV1:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV1]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[OBJ_DEV1]] @@ -61,7 +63,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV2:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC]] [[OPT_BC_DEV2]] "-mtriple=amdgcn-am
[PATCH] D53325: Disable code object version 3 for HIP toolchain
This revision was automatically updated to reflect the committed changes. Closed by commit rL344630: Disable code object version 3 for HIP toolchain (authored by yaxunl, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53325?vs=169831&id=169855#toc Repository: rL LLVM https://reviews.llvm.org/D53325 Files: cfe/trunk/lib/Driver/ToolChains/HIP.cpp cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip cfe/trunk/test/Driver/hip-toolchain-rdc.hip Index: cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip === --- cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip +++ cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip @@ -32,7 +32,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]] @@ -57,7 +59,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]] @@ -97,7 +101,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_803:.*out]]" [[OBJ_DEV_B_803]] @@ -122,7 +128,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_900:.*out]]" [[OBJ_DEV_B_900]] Index: cfe/trunk/test/Driver/hip-toolchain-rdc.hip === --- cfe/trunk/test/Driver/hip-toolchain-rdc.hip +++ cfe/trunk/test/Driver/hip-toolchain-rdc.hip @@ -35,7 +35,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV1:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV1]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[OBJ_DEV1]] @@ -61,7 +63,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV2:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC]] [[OPT_BC_DEV2]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV2:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV2:".*-gfx900-.*o"]] // CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[OBJ_DEV2]] Index: cfe/trunk/lib/Driver/ToolChains/HIP.cpp === --- cfe/trunk/lib/Driver/ToolChains/HIP.cpp +++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp @@ -154,7 +154,7 @@ llvm::StringRef OutputFilePrefix, const char *InputFileName) const { // Construct llc command. ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa", -"-filetype=obj", +"-filetype=obj", "-mattr=-code-object-v3", Args.MakeArgString("-mcpu=" + SubArchName), "-o"}; std::string LlcOutputFileName = C.getDriver().GetTemporaryPath(OutputFilePrefix, "o"); Index: cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip === --- cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip +++ cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip @@ -32,7 +32,
[PATCH] D52814: [PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address
leonardchan added a comment. @philip.pfaffe @fedor.sergeev Do you have any more comments on this patch? Repository: rC Clang https://reviews.llvm.org/D52814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50539: [VFS] Add property 'fallthrough' that controls fallback to real file system.
vsapsai marked 5 inline comments as done. vsapsai added inline comments. Comment at: clang/lib/Basic/VirtualFileSystem.cpp:934 RedirectingFileSystem &FS; RedirectingDirectoryEntry::iterator Current, End; + bool IsExternalFSCurrent; bruno wrote: > Can you add comments to these new members? Specifically, what's the purpose > of `IsExternalFSCurrent` and how it connects to `ExternalFS` Added comments. Comment at: clang/lib/Basic/VirtualFileSystem.cpp:940 - std::error_code incrementImpl(); + std::error_code incrementExternal(); + std::error_code incrementContent(bool IsFirstTime); bruno wrote: > Same for these methods Added comments. Not entirely happy with them, would like to hear opinion of others. Comment at: clang/lib/Basic/VirtualFileSystem.cpp:1738 +ErrorOr RedirectingFileSystem::status(const Twine &Path, + bool ShouldCheckExternalFS) { ErrorOr Result = lookupPath(Path); bruno wrote: > Is passing `ShouldCheckExternalFS ` really necessary? Why checking the status > of the member isn't enough? Not required anymore, simplified the code. https://reviews.llvm.org/D50539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50539: [VFS] Add property 'fallthrough' that controls fallback to real file system.
vsapsai marked 3 inline comments as done. vsapsai added a comment. In https://reviews.llvm.org/D50539#1241034, @bruno wrote: > > - Current way of working with modules in VFS "root" is clunky and > > error-prone. > > Why? Mostly because when you approach it in a straightforward way, you cannot read written modules because they aren't in VFS and "rootness" correctly prevents you from reading random files. You can add `-fdisable-module-hash` as I've done in the test but it has its own downsides when used not in a test but in a real project. >> Also I don't like that VFSFromYamlDirIterImpl is similar to overlay iterator >> but doesn't share code. At the moment I think it's not worth it to rework >> those abstractions to make more code reusable. If you've noticed problems >> with those iterators before, maybe it makes sense to try to find a better >> approach. > > Maybe add FIXMEs for it? Good idea, added. https://reviews.llvm.org/D50539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52742: [analyzer][PlistMacroExpansion] Part 1.: New expand-macros flag
Szelethus updated this revision to Diff 169858. Szelethus added a comment. Removed the version entry from the plist file. https://reviews.llvm.org/D52742 Files: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Core/BugReporter.cpp lib/StaticAnalyzer/Core/PlistDiagnostics.cpp test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist test/Analysis/plist-macros-with-expansion.cpp Index: test/Analysis/plist-macros-with-expansion.cpp === --- /dev/null +++ test/Analysis/plist-macros-with-expansion.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s +// +// RUN: %clang_analyze_cc1 -analyzer-checker=core %s \ +// RUN: -analyzer-output=plist -o %t.plist \ +// RUN: -analyzer-config expand-macros=true +// +// Check the actual plist output. +// RUN: cat %t.plist | %diff_plist \ +// RUN: %S/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist +// +// Check the macro expansions from the plist output here, to make the test more +// understandable. +// RUN: FileCheck --input-file=%t.plist %s + +void print(const void*); + +//===--===// +// Tests for non-function-like macro expansions. +//===--===// + +#define SET_PTR_VAR_TO_NULL \ + ptr = 0 + +void nonFunctionLikeMacroTest() { + int *ptr; + SET_PTR_VAR_TO_NULL; + *ptr = 5; // expected-warning{{Dereference of null pointer}} +} + +// CHECK: name +// CHECK: expansion + +#define NULL 0 +#define SET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO \ + ptr = NULL + +void nonFunctionLikeNestedMacroTest() { + int *ptr; + SET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO; + *ptr = 5; // expected-warning{{Dereference of null pointer}} +} + +// CHECK: name +// CHECK: expansion Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist === --- /dev/null +++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist @@ -0,0 +1,347 @@ + +http://www.apple.com/DTDs/PropertyList-1.0.dtd";> + + + diagnostics + + + path + + + kindcontrol + edges + + +start + + + line25 + col3 + file0 + + + line25 + col5 + file0 + + +end + + + line26 + col3 + file0 + + + line26 + col21 + file0 + + + + + + + kindmacro_expansion + location + + line26 + col3 + file0 + + name + expansion + + + kindevent + location + + line26 + col3 + file0 + + ranges + + + + line26 + col3 + file0 + + + line26 + col21 + file0 + + + + depth0 + extended_message + Null pointer value stored to 'ptr' + message + Null pointer value stored to 'ptr' + + + kindcontrol + edges + + +start + + + line27 + col3 + file0 + + + line27 + col3 + file0 + + +end + + + line27 + col8 + file0 + + + line27 + col8 + file0 + + + + + + + kindevent + location + + line27 + col8 + file0 + + ranges + + + + line27 + col4 + file0 + + + line27 + col6 + file0 + + + + depth0 + extended_message + Dereference of null pointer (loaded from variable 'ptr') + message + Dereference of null pointer (loaded from variable 'ptr') + + + descriptionDereference of null pointer (loaded from variable 'ptr') + categoryLogic error + typeDereference of null pointer + check_namecore.NullDereference + + issue_hash_content_of_line_in_contextf8fbc46cc5afbb056d92bd3d3d702781 + issue_context_kindfunction + issue_contextnonFunctionLikeMacroTest + issue_hash_function_offset3 + location + + line27 + col8 + file0 + + ExecutedLines + + 0 + +24 +25 +26 +27 + + + + + path + + + kindcontrol + edges + + +start + + + line38 + col3 + file0 + + + line38 + col5 + file0 + + +end + +
[PATCH] D52794: [analyzer][PlistMacroExpansion] Part 2.: Retrieving the macro name and primitive expansion
Szelethus updated this revision to Diff 169862. Szelethus added a comment. Herald added a subscriber: donat.nagy. - Removed the version entry from the plist file, - Now using `TokenConcatenation` to print spaces only when needed (this needed for https://reviews.llvm.org/D52988), - A bit more doc, - Reorganized ("refactored" would be too strong of a word) `getExpandedMacroImpl` to make it easier to read. https://reviews.llvm.org/D52794 Files: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist test/Analysis/plist-macros-with-expansion.cpp Index: test/Analysis/plist-macros-with-expansion.cpp === --- test/Analysis/plist-macros-with-expansion.cpp +++ test/Analysis/plist-macros-with-expansion.cpp @@ -27,8 +27,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: name -// CHECK: expansion +// CHECK: nameSET_PTR_VAR_TO_NULL +// CHECK: expansionptr = 0 #define NULL 0 #define SET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO \ @@ -40,5 +40,51 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: name -// CHECK: expansion +// CHECK: nameSET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO +// CHECK: expansionptr =0 + +//===--===// +// Tests for function-like macro expansions. +//===--===// + +void setToNull(int **vptr) { + *vptr = nullptr; +} + +#define TO_NULL(x) \ + setToNull(x) + +void functionLikeMacroTest() { + int *ptr; + TO_NULL(&ptr); + *ptr = 5; // expected-warning{{Dereference of null pointer}} +} + +// TODO: Expand argumnts. +// CHECK: nameTO_NULL +// CHECK: expansionsetToNull(x) + +#define DOES_NOTHING(x) \ + { \ +int b; \ +b = 5; \ + } \ + print(x) + +#define DEREF(x) \ + DOES_NOTHING(x); \ + *x + +void functionLikeNestedMacroTest() { + int *a; + TO_NULL(&a); + DEREF(a) = 5; // expected-warning{{Dereference of null pointer}} +} + +// TODO: Expand argumnts. +// CHECK: nameTO_NULL +// CHECK: expansionsetToNull(x) + +// TODO: Expand argumnts. +// CHECK: nameDEREF +// CHECK: expansion{ int b; b = 5; } print(x); *x Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist === --- test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist +++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist @@ -49,8 +49,8 @@ col3 file0 - name - expansion + nameSET_PTR_VAR_TO_NULL + expansion ptr = 0 kindevent @@ -216,8 +216,8 @@ col3 file0 - name - expansion + nameSET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO + expansion ptr =0 kindevent @@ -338,6 +338,533 @@ + + path + + + kindcontrol + edges + + +start + + + line58 + col3 + file0 + + + line58 + col5 + file0 + + +end + + + line59 + col3 + file0 + + + line59 + col9 + file0 + + + + + + + kindmacro_expansion + location + + line59 + col3 + file0 + + nameTO_NULL + expansion setToNull(x) + + + kindevent + location + + line59 + col3 + file0 + + ranges + + + + line59 + col3 + file0 + + + line59 + col15 + file0 + + + + depth0 + extended_message + Calling 'setToNull' + message + Calling 'setToNull' + + + kindevent + location + + line50 + col1 + file0 + + depth1 + extended_message + Entered call from 'functionLikeMacroTest' + message + Entered call from 'functionLikeMacroTest' + + + kindcontrol + edges + + +start + + + line50 + col1 + file0 + + + line50 + col4 + file0 + + +end + + + line51 + col3 + file0 + + + line51 + col3 + file0 + + + + + + + kindevent + location + + line51 + col3 + file0 + + ranges + + + + line51 + col3 + file0 + + + line51 + col17 + file0 +
[PATCH] D53334: [Frontend] Show diagnostics on prebuilt module configuration mismatch too
whisperity created this revision. whisperity added reviewers: rsmith, doug.gregor. whisperity added a project: clang. Herald added subscribers: Szelethus, dkrupp, rnkovacs. The current version only emits the below error for a module (attempted to be loaded) from the `prebuilt-module-path`: error: module file blabla.pcm cannot be loaded due to a configuration mismatch with the current compilation [-Wmodule-file-config-mismatch] With this change, if the prebuilt module is used, we allow the proper diagnostic behind the configuration mismatch to be shown. error: POSIX thread support was disabled in PCH file but is currently enabled error: module file blabla.pcm cannot be loaded due to a configuration mismatch with the current compilation [-Wmodule-file-config-mismatch] (A few lines later an error is emitted anyways, so there is no reason not to complain for configuration mismatches if a config mismatch is found and kills the build.) Repository: rC Clang https://reviews.llvm.org/D53334 Files: lib/Frontend/CompilerInstance.cpp Index: lib/Frontend/CompilerInstance.cpp === --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -1724,7 +1724,9 @@ // module cache, we don't know how to rebuild modules. unsigned ARRFlags = Source == ModuleCache ? ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing : -ASTReader::ARR_ConfigurationMismatch; +Source == PrebuiltModulePath ? +0 : +ASTReader::ARR_ConfigurationMismatch; switch (ModuleManager->ReadAST(ModuleFileName, Source == PrebuiltModulePath ? serialization::MK_PrebuiltModule Index: lib/Frontend/CompilerInstance.cpp === --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -1724,7 +1724,9 @@ // module cache, we don't know how to rebuild modules. unsigned ARRFlags = Source == ModuleCache ? ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing : -ASTReader::ARR_ConfigurationMismatch; +Source == PrebuiltModulePath ? +0 : +ASTReader::ARR_ConfigurationMismatch; switch (ModuleManager->ReadAST(ModuleFileName, Source == PrebuiltModulePath ? serialization::MK_PrebuiltModule ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53308: [Fixed Point Arithmetic] Fixed Point to Boolean Cast
leonardchan updated this revision to Diff 169863. leonardchan marked 3 inline comments as done. Repository: rC Clang https://reviews.llvm.org/D53308 Files: clang/include/clang/AST/OperationKinds.def clang/lib/AST/Expr.cpp clang/lib/AST/ExprConstant.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CGExprComplex.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/Edit/RewriteObjCFoundationAPI.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp clang/test/Frontend/fixed_point_to_bool.c clang/test/Frontend/fixed_point_unknown_conversions.c Index: clang/test/Frontend/fixed_point_unknown_conversions.c === --- clang/test/Frontend/fixed_point_unknown_conversions.c +++ clang/test/Frontend/fixed_point_unknown_conversions.c @@ -35,7 +35,6 @@ accum_ptr = ptr; // expected-warning{{incompatible pointer types assigning to '_Accum *' from 'int *'}} accum = i2; // expected-error{{conversion between fixed point and 'int_t' (aka 'int') is not yet supported}} - b = accum; // expected-error{{conversion between fixed point and '_Bool' is not yet supported}} c = accum; // expected-error{{conversion between fixed point and 'char' is not yet supported}} i = accum; // expected-error{{conversion between fixed point and 'int' is not yet supported}} f = accum; // expected-error{{conversion between fixed point and 'float' is not yet supported}} Index: clang/test/Frontend/fixed_point_to_bool.c === --- /dev/null +++ clang/test/Frontend/fixed_point_to_bool.c @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s + +_Bool global_b = 1.0k; // @global_b = {{*.}}global i8 1, align 1 +_Bool global_b2 = 0.0k; // @global_b2 = {{*.}}global i8 0, align 1 + +void func() { + _Accum a = 0.5k; + unsigned _Accum ua = 0.5uk; + _Bool b; + + // CHECK: store i8 1, i8* %b, align 1 + // CHECK-NEXT: store i8 0, i8* %b, align 1 + // CHECK: store i8 1, i8* %b, align 1 + // CHECK-NEXT: store i8 0, i8* %b, align 1 + b = 0.5k; + b = 0.0k; + b = 0.5uk; + b = 0.0uk; + + // CHECK-NEXT: store i8 1, i8* %b, align 1 + // CHECK-NEXT: store i8 0, i8* %b, align 1 + // CHECK-NEXT: store i8 1, i8* %b, align 1 + // CHECK-NEXT: store i8 0, i8* %b, align 1 + b = (_Bool)0.5r; + b = (_Bool)0.0r; + b = (_Bool)0.5ur; + b = (_Bool)0.0ur; + + // CHECK-NEXT: [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4 + // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0 + // CHECK-NEXT: %frombool = zext i1 [[NOTZERO]] to i8 + // CHECK-NEXT: store i8 %frombool, i8* %b, align 1 + b = a; + + // CHECK-NEXT: [[ACCUM:%[0-9]+]] = load i32, i32* %ua, align 4 + // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0 + // CHECK-NEXT: %frombool1 = zext i1 [[NOTZERO]] to i8 + // CHECK-NEXT: store i8 %frombool1, i8* %b, align 1 + b = ua; + + // CHECK-NEXT: [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4 + // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0 + // CHECK-NEXT: br i1 [[NOTZERO]], label %if.then, label %if.end + if (a) { + } + + // CHECK: [[ACCUM:%[0-9]+]] = load i32, i32* %ua, align 4 + // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0 + // CHECK-NEXT: br i1 [[NOTZERO]], label %if.then{{[0-9]+}}, label %if.end{{[0-9]+}} + if (ua) { + } +} Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp === --- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -416,7 +416,8 @@ case CK_ZeroToOCLQueue: case CK_IntToOCLSampler: case CK_LValueBitCast: - case CK_FixedPointCast: { + case CK_FixedPointCast: + case CK_FixedPointToBoolean: { state = handleLValueBitCast(state, Ex, LCtx, T, ExTy, CastE, Bldr, Pred); continue; Index: clang/lib/Sema/SemaExpr.cpp === --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -5894,10 +5894,7 @@ case Type::STK_FixedPoint: return CK_FixedPointCast; case Type::STK_Bool: - Diag(Src.get()->getExprLoc(), - diag::err_unimplemented_conversion_with_fixed_point_type) - << DestTy; - return CK_IntegralToBoolean; + return CK_FixedPointToBoolean; case Type::STK_Integral: case Type::STK_Floating: case Type::STK_IntegralComplex: @@ -12793,12 +12790,6 @@ if (Context.getLangOpts().CPlusPlus) { // C++03 [expr.unary.op]p8, C++0x [expr.unary.op]p9: // operand contextually converted to bool. -if (resultType->getScal
[PATCH] D53308: [Fixed Point Arithmetic] Fixed Point to Boolean Cast
leonardchan added inline comments. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1032 + // them. + return Builder.CreateIsNotNull(Src); +} ebevhan wrote: > Is this comment true? I don't think EmitFixedPointConversion does this. > > Maybe I'm misinterpreting what it means. Ah sorry, this was my bad. I briefly forgot that we intended for overflow into the bit to be undefined behavior. In that case, this comment doesn't make sense and should be removed, but we still shouldn't have to clear/check the padding bit in this case because we should assume it's zero'd. So this refers to handling when the padding bit needs to be cleared since if we ever have an operation that reads the whole int of an underlying unsigned type. I accidentally wrote this comment thinking that it would be cleared/zero'd at some point when we decided before that overflow into this padding was just undefined behavior. Updated the comment to reflect this. Repository: rC Clang https://reviews.llvm.org/D53308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53295: Mark store and load of block invoke function as invariant.group
yaxunl updated this revision to Diff 169864. yaxunl retitled this revision from "[OpenCL] Mark load of block invoke function as invariant" to "Mark store and load of block invoke function as invariant.group". yaxunl edited the summary of this revision. yaxunl added a comment. Herald added a subscriber: Prazek. mark store and load of block invoke function as invariant.group. https://reviews.llvm.org/D53295 Files: lib/CodeGen/CGBlocks.cpp test/CodeGenOpenCL/blocks-indirect-call.cl Index: test/CodeGenOpenCL/blocks-indirect-call.cl === --- /dev/null +++ test/CodeGenOpenCL/blocks-indirect-call.cl @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,NOOPT %s +// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,OPT %s + +// Check invariant.group MD are emitted at -O0 and indirect function calls +// are eliminated at default optimization level. + +// COMMON-LABEL: define {{.*}} @blockInLoopCondition +// NOOPT: store {{.*}}@__blockInLoopCondition_block_invoke{{.*}} !invariant.group +// NOOPT: %[[INV:.*]] = getelementptr {{.*}}%block.literal, i32 0, i32 2 +// NOOPT: load {{.*}}%[[INV]]{{.*}}, !invariant.group +// ToDo: Fix LLVM optimizations to lower indirect function call +// OPT: %[[INV:.*]] = phi {{.*}}[ @__blockInLoopCondition_block_invoke, %entry ] +// OPT: call i32 %[[INV]] + +// OPT-NOT: load {{.*}}!invariant.group +void blockInLoopCondition(int* res, int tid, int multiplier) { + int (^kernelBlock)(int) = ^(int num) { +return num * multiplier; + }; + res[tid] = 39; + for(int i=0; i Address { return Builder.CreateStructGEP(blockAddr, index, offset, name); }; - auto storeField = -[&](llvm::Value *value, unsigned index, CharUnits offset, -const Twine &name) { - Builder.CreateStore(value, projectField(index, offset, name)); -}; + auto storeField = [&](llvm::Value *value, unsigned index, CharUnits offset, +const Twine &name, bool IsInvariant) { +auto *ST = Builder.CreateStore(value, projectField(index, offset, name)); +if (IsInvariant) + ST->setMetadata(CGM.getModule().getMDKindID("invariant.group"), + llvm::MDNode::get(getLLVMContext(), None)); + }; // Initialize the block header. { // We assume all the header fields are densely packed. unsigned index = 0; CharUnits offset; -auto addHeaderField = - [&](llvm::Value *value, CharUnits size, const Twine &name) { -storeField(value, index, offset, name); -offset += size; -index++; - }; +auto addHeaderField = [&](llvm::Value *value, CharUnits size, + const Twine &name, bool IsInvariant = false) { + storeField(value, index, offset, name, IsInvariant); + offset += size; + index++; +}; if (!IsOpenCL) { addHeaderField(isa, getPointerSize(), "block.isa"); @@ -1008,7 +1010,8 @@ llvm::ConstantInt::get(IntTy, blockInfo.BlockAlign.getQuantity()), getIntSize(), "block.align"); } -addHeaderField(blockFn, GenVoidPtrSize, "block.invoke"); +addHeaderField(blockFn, GenVoidPtrSize, "block.invoke", + /*IsInvariant=*/true); if (!IsOpenCL) addHeaderField(descriptor, getPointerSize(), "block.descriptor"); else if (auto *Helper = @@ -1302,6 +1305,9 @@ // Load the function. llvm::Value *Func = Builder.CreateAlignedLoad(FuncPtr, getPointerAlign()); + cast(Func)->setMetadata( + CGM.getModule().getMDKindID("invariant.group"), + llvm::MDNode::get(getLLVMContext(), None)); const FunctionType *FuncTy = FnType->castAs(); const CGFunctionInfo &FnInfo = ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52790: [analyzer][PlistMacroExpansion] New flag to convert macro expansions to events
whisperity accepted this revision. whisperity added a comment. This revision is now accepted and ready to land. Herald added a subscriber: donat.nagy. Remove the custom file paths and URLs but other than that this is pretty trivial. https://reviews.llvm.org/D52790 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52986: [analyzer][PlistMacroExpansion] Part 4.: Support for __VA_ARGS__
Szelethus updated this revision to Diff 169869. Szelethus added a comment. Herald added a subscriber: dkrupp. Rebased to part 3. https://reviews.llvm.org/D52986 Files: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist test/Analysis/plist-macros-with-expansion.cpp Index: test/Analysis/plist-macros-with-expansion.cpp === --- test/Analysis/plist-macros-with-expansion.cpp +++ test/Analysis/plist-macros-with-expansion.cpp @@ -261,9 +261,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// TODO: Should correctly display the rest of the parameters. // CHECK: nameVARIADIC_SET_TO_NULL -// CHECK: expansionptr = nullptr; variadicFunc( 1) +// CHECK: expansionptr = nullptr; variadicFunc( 1, 5, "haha!") //===--===// // Tests for # and ##. Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist === --- test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist +++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist @@ -3588,7 +3588,7 @@ file0 nameVARIADIC_SET_TO_NULL - expansionptr = nullptr; variadicFunc( 1) + expansionptr = nullptr; variadicFunc( 1, 5, "haha!") kindevent @@ -3720,25 +3720,25 @@ start - line277 + line276 col3 file0 - line277 + line276 col5 file0 end - line278 + line277 col3 file0 - line278 + line277 col30 file0 @@ -3750,7 +3750,7 @@ kindmacro_expansion location - line278 + line277 col3 file0 @@ -3761,20 +3761,20 @@ kindevent location - line278 + line277 col3 file0 ranges - line278 + line277 col3 file0 - line278 + line277 col45 file0 @@ -3794,25 +3794,25 @@ start - line279 + line278 col3 file0 - line279 + line278 col3 file0 end - line279 + line278 col8 file0 - line279 + line278 col8 file0 @@ -3824,20 +3824,20 @@ kindevent location - line279 + line278 col8 file0 ranges - line279 + line278 col4 file0 - line279 + line278 col6 file0 @@ -3861,18 +3861,18 @@ issue_hash_function_offset3 location - line279 + line278 col8 file0 ExecutedLines 0 +275 276 277 278 -279 @@ -3887,25 +3887,25 @@ start - line291 + line290 col3 file0 - line291 + line290 col5 file0 end - line292 + line291 col3 file0 - line292 + line291 col11 file0 @@ -3917,7 +3917,7 @@ kindmacro_expansion location - line292 + line291 col3 file0 @@ -3928,20 +3928,20 @@ kindevent location - line292 + line291 col3 file0 ranges - line292 + line291 col3 file0 - line292 + line291 col23 file0 @@ -3961,25 +3961,25 @@ start - line293 + line292 col3 file0 - line293 + line292 col3 file0 end - line293 + line292 col8 file0 - line293 + line292 col8 file0 @@ -3991,20 +3991,20 @@ kindevent location - line293 + line292 col8 file0
[PATCH] D52795: [analyzer][PlistMacroExpansion] Part 3.: Macro arguments are expanded
george.karpenkov requested changes to this revision. george.karpenkov added inline comments. This revision now requires changes to proceed. Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:677 +/// need to expanded further when it is nested inside another macro. +class MacroArgMap : public std::map { +public: Please don't do this, inheritance from standard containers is a bad thing (tm) https://reviews.llvm.org/D52795 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52790: [analyzer][PlistMacroExpansion] New flag to convert macro expansions to events
george.karpenkov added inline comments. Comment at: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist:6 clang_version -clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 80e1678b9f598ca78bb3b71cf546a63414a37b11) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82) +clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang ec097c9a35733c2c703e8ff03ea9b6ae345bf3f3) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82) diagnostics Could we figure out how not to have hardcoded contributor-based strings there? Maybe have a python script generating those / doing a cleanup? https://reviews.llvm.org/D52790 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52988: [analyzer][PlistMacroExpansion] Part 5.: Support for # and ##
Szelethus updated this revision to Diff 169871. Szelethus added a comment. Herald added a subscriber: dkrupp. This patch didn't really work, sometimes it printed extra spaces, sometimes printed the hash tokens, and so on, so I refactored the whole project to deal with this issue almost out of the box. https://reviews.llvm.org/D52988 Files: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist test/Analysis/plist-macros-with-expansion.cpp Index: test/Analysis/plist-macros-with-expansion.cpp === --- test/Analysis/plist-macros-with-expansion.cpp +++ test/Analysis/plist-macros-with-expansion.cpp @@ -278,9 +278,17 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// TODO: Should expand correctly. // CHECK: nameDECLARE_FUNC_AND_SET_TO_NULL -// CHECK: expansionvoid generated_##whatever(); ptr = nullptr; +// CHECK: expansionvoid generated_whatever(); ptr = nullptr; + +void macroArgContainsHashHashInStringTest() { + int *a; + TO_NULL_AND_PRINT(a, "Will this ## cause a crash?"); + *a = 5; // expected-warning{{Dereference of null pointer}} +} + +// CHECK: nameTO_NULL_AND_PRINT +// CHECK: expansiona = 0; print( "Will this ## cause a crash?") #define PRINT_STR(str, ptr) \ print(#str); \ @@ -292,6 +300,14 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// TODO: Should expand correctly. // CHECK: namePRINT_STR -// CHECK: expansionprint(#Hello); ptr = nullptr +// CHECK: expansionprint("Hello"); ptr = nullptr + +void macroArgContainsHashInStringTest() { + int *a; + TO_NULL_AND_PRINT(a, "Will this # cause a crash?"); + *a = 5; // expected-warning{{Dereference of null pointer}} +} + +// CHECK: nameTO_NULL_AND_PRINT +// CHECK: expansiona = 0; print( "Will this # cause a crash?") Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist === --- test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist +++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist @@ -3755,7 +3755,7 @@ file0 nameDECLARE_FUNC_AND_SET_TO_NULL - expansionvoid generated_##whatever(); ptr = nullptr; + expansionvoid generated_whatever(); ptr = nullptr; kindevent @@ -3887,25 +3887,192 @@ start - line290 + line285 col3 file0 - line290 + line285 col5 file0 end - line291 + line286 col3 file0 - line291 + line286 + col19 + file0 + + + + + + + kindmacro_expansion + location + + line286 + col3 + file0 + + nameTO_NULL_AND_PRINT + expansiona = 0; print( "Will this ## cause a crash?") + + + kindevent + location + + line286 + col3 + file0 + + ranges + + + + line286 + col3 + file0 + + + line286 + col53 + file0 + + + + depth0 + extended_message + Null pointer value stored to 'a' + message + Null pointer value stored to 'a' + + + kindcontrol + edges + + +start + + + line287 + col3 + file0 + + + line287 + col3 + file0 + + +end + + + line287 + col6 + file0 + + + line287 + col6 + file0 + + + + + + + kindevent + location + + line287 + col6 + file0 + + ranges + + + + line287 + col4 + file0 + + + line287 + col4 + file0 + + + + depth0 + extended_message + Dereference of null pointer (loaded from variable 'a') + message + Dereference of null pointer (loaded from variable 'a') + + + descriptionDereference of null pointer (loaded from variable 'a') + categoryLogic error + typeDereference of null pointer + check_namecore.NullDereference + + issue_hash_content_of_line_in_context6817572ced27cb7d28fc87b2aba75fb4 + issue_context_kindfunction + issue_contextmacroArgContainsHashHashInStringTest + issue_hash_function_offset3 + location + + line287 + col6 + file0 + + ExecutedLines + + 0 + +284 +285 +286 +287 + + + + + path + + +
[PATCH] D52790: [analyzer][PlistMacroExpansion] New flag to convert macro expansions to events
Szelethus added inline comments. Comment at: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist:6 clang_version -clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 80e1678b9f598ca78bb3b71cf546a63414a37b11) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82) +clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang ec097c9a35733c2c703e8ff03ea9b6ae345bf3f3) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82) diagnostics george.karpenkov wrote: > Could we figure out how not to have hardcoded contributor-based strings > there? Maybe have a python script generating those / doing a cleanup? I'm just about to remove it, as I did for all the other [PlistMacroExpancion] patches. But yea, a tool wouldn't hurt. https://reviews.llvm.org/D52790 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52795: [analyzer][PlistMacroExpansion] Part 3.: Macro arguments are expanded
Szelethus added inline comments. Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:677 +/// need to expanded further when it is nested inside another macro. +class MacroArgMap : public std::map { +public: george.karpenkov wrote: > Please don't do this, inheritance from standard containers is a bad thing (tm) Actually, I disagree with you on this one. For ease of use, these constructs are used all over the place in the LLVM codebase, and since I never do anything inheritance related, this shouldn't hurt much. https://clang.llvm.org/doxygen/classclang_1_1ento_1_1PathPieces.html http://llvm.org/doxygen/classllvm_1_1PredicateBitsetImpl.html http://llvm.org/doxygen/classllvm_1_1HexagonBlockRanges_1_1RangeList.html These are just a few. Do you insist? https://reviews.llvm.org/D52795 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r344637 - Revert "[clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction."
Author: krasimir Date: Tue Oct 16 11:44:41 2018 New Revision: 344637 URL: http://llvm.org/viewvc/llvm-project?rev=344637&view=rev Log: Revert "[clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction." This reverts commit r344620. Breaks upstream bots. Removed: clang-tools-extra/trunk/clangd/JSONTransport.cpp clang-tools-extra/trunk/clangd/Transport.h clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test clang-tools-extra/trunk/test/clangd/completion-snippets.test clang-tools-extra/trunk/test/clangd/completion.test clang-tools-extra/trunk/test/clangd/crash-non-added-files.test clang-tools-extra/trunk/test/clangd/execute-command.test clang-tools-extra/trunk/test/clangd/input-mirror.test clang-tools-extra/trunk/test/clangd/signature-help.test clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test clang-tools-extra/trunk/test/clangd/trace.test clang-tools-extra/trunk/test/clangd/xrefs.test clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=344637&r1=344636&r2=344637&view=diff == --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Oct 16 11:44:41 2018 @@ -26,7 +26,6 @@ add_clang_library(clangDaemon GlobalCompilationDatabase.cpp Headers.cpp JSONRPCDispatcher.cpp - JSONTransport.cpp Logger.cpp Protocol.cpp ProtocolHandlers.cpp Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=344637&r1=344636&r2=344637&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Oct 16 11:44:41 2018 @@ -162,10 +162,7 @@ void ClangdLSPServer::onShutdown(Shutdow reply(nullptr); } -void ClangdLSPServer::onExit(ExitParams &Params) { - // No work to do. - // JSONRPCDispatcher shuts down the transport after this notification. -} +void ClangdLSPServer::onExit(ExitParams &Params) { IsDone = true; } void ClangdLSPServer::onDocumentDidOpen(DidOpenTextDocumentParams &Params) { PathRef File = Params.textDocument.uri.file(); @@ -500,41 +497,39 @@ void ClangdLSPServer::onReference(Refere }); } -ClangdLSPServer::ClangdLSPServer(class Transport &Transport, +ClangdLSPServer::ClangdLSPServer(JSONOutput &Out, const clangd::CodeCompleteOptions &CCOpts, llvm::Optional CompileCommandsDir, bool ShouldUseInMemoryCDB, const ClangdServer::Options &Opts) -: Transport(Transport), - CDB(ShouldUseInMemoryCDB ? CompilationDB::makeInMemory() - : CompilationDB::makeDirectoryBased( - std::move(CompileCommandsDir))), +: Out(Out), CDB(ShouldUseInMemoryCDB ? CompilationDB::makeInMemory() + : CompilationDB::makeDirectoryBased( + std::move(CompileCommandsDir))), CCOpts(CCOpts), SupportedSymbolKinds(defaultSymbolKinds()), SupportedCompletionItemKinds(defaultCompletionItemKinds()), Server(new ClangdServer(CDB.getCDB(), FSProvider, /*DiagConsumer=*/*this, Opts)) {} -bool ClangdLSPServer::run() { +bool ClangdLSPServer::run(std::FILE *In, JSONStreamStyle InputStyle) { + assert(!IsDone && "Run was called before"); assert(Server); // Set up JSONRPCDispatcher. JSONRPCDispatcher Dispatcher([](const json::Value &Params) { replyError(ErrorCode::MethodNotFound, "method not found"); -return true; }); registerCallbackHandlers(Dispatcher, /*Callbacks=*/*this); // Run the Language Server loop. - bool CleanExit = true; - if (auto Err = Dispatcher.runLanguageServerLoop(Transport)) { -elog("Transport error: {0}", std::move(Err)); -CleanExit = false; - } + runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone); + // Make sure IsDo
[PATCH] D52795: [analyzer][PlistMacroExpansion] Part 3.: Macro arguments are expanded
Szelethus added inline comments. Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:677 +/// need to expanded further when it is nested inside another macro. +class MacroArgMap : public std::map { +public: Szelethus wrote: > george.karpenkov wrote: > > Please don't do this, inheritance from standard containers is a bad thing > > (tm) > Actually, I disagree with you on this one. For ease of use, these constructs > are used all over the place in the LLVM codebase, and since I never do > anything inheritance related, this shouldn't hurt much. > > https://clang.llvm.org/doxygen/classclang_1_1ento_1_1PathPieces.html > http://llvm.org/doxygen/classllvm_1_1PredicateBitsetImpl.html > http://llvm.org/doxygen/classllvm_1_1HexagonBlockRanges_1_1RangeList.html > > These are just a few. > > Do you insist? I mean, polymorphism, not inheritance. https://reviews.llvm.org/D52795 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53266: [clangd] Simplify client capabilities parsing.
kadircet accepted this revision. kadircet added a comment. This revision is now accepted and ready to land. LGTM, thanks for the change! Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53266 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions
efriedma added a comment. Herald added a subscriber: nhaehnle. Looks like the latest update is missing a test file? https://reviews.llvm.org/D52835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47687: [Sema] Missing -Wlogical-op-parentheses warnings in macros (PR18971)
vsapsai added a comment. Sorry about the delay. The change seems to be correct but `ninja check-clang` reveals the test "Misc/caret-diags-macros.c" is failing. Can you please look into that? Appreciate your contribution, Xing, and thanks for verifying your change with tests. Comment at: lib/Sema/SemaExpr.cpp:7107-7108 + SourceManager &SM = Self.getSourceManager(); + SourceLocation spellLoc = SM.getSpellingLoc(ParenRange.getEnd()); + unsigned tokLen = Lexer::MeasureTokenLength(spellLoc, SM, Self.getLangOpts()); + SourceLocation EndLoc = spellLoc.getLocWithOffset(tokLen); Can you please start variables with an upper case letter? Like `SpellLoc`, `TokLen`. https://reviews.llvm.org/D47687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52390: [analyzer] Add StackSizeChecker to StaticAnalyzer
mate1214 abandoned this revision. mate1214 marked 24 inline comments as done. mate1214 added a comment. Herald added subscribers: dkrupp, nhaehnle, donat.nagy. Hi! Sorry for the delay. After considering the amount of requested tests and investigating the possibly reviewer friendly ways to split this up, I came to the conclusion that I can not go through with all this work for now. Thanks to everyone who took the time to comment. I'm abandoning this revision. Repository: rC Clang https://reviews.llvm.org/D52390 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52973: Add type_info predefined decl
mwasplund updated this revision to Diff 169879. mwasplund marked 2 inline comments as done. Repository: rC Clang https://reviews.llvm.org/D52973 Files: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/Sema/SemaDecl.cpp test/Modules/msvc-compat-implitic-types.cpp Index: test/Modules/msvc-compat-implitic-types.cpp === --- /dev/null +++ test/Modules/msvc-compat-implitic-types.cpp @@ -0,0 +1,14 @@ +// Verify there is not collision between the +// RUN: %clang -fms-compatibility -fmodules-ts -x c++-module --precompile -DEXPORT -o %t.pcm %s +// RUN: %clang -fms-compatibility -fmodules-ts -fmodule-file=%t.pcm -c -DMAIN %s + +// expected-no-diagnostics + +#if EXPORT +export module MyModule; +export class MyClass {}; +#elif MAIN +#include +#else +#error MISSING DEFINE +#endif \ No newline at end of file Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -1464,11 +1464,6 @@ if (NewM == OldM) return false; - // FIXME: The Modules TS does not specify how to handle inplicit types - // For now we will simply ignore the implicit global types - if (Old->isImplicit()) -return false; - // FIXME: Check proclaimed-ownership-declarations here too. bool NewIsModuleInterface = NewM && NewM->Kind == Module::ModuleInterfaceUnit; bool OldIsModuleInterface = OldM && OldM->Kind == Module::ModuleInterfaceUnit; Index: lib/AST/ASTContext.cpp === --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -1081,8 +1081,10 @@ } RecordDecl *ASTContext::getTypeInfoClassDecl() const { - if (!TypeInfoClassDecl) + if (!TypeInfoClassDecl) { TypeInfoClassDecl = buildImplicitRecord("type_info", TTK_Class); + TypeInfoClassDecl->setModuleOwnershipKind(Decl::ModuleOwnershipKind::Unowned); + } return TypeInfoClassDecl; } Index: include/clang/AST/ASTContext.h === --- include/clang/AST/ASTContext.h +++ include/clang/AST/ASTContext.h @@ -1126,7 +1126,7 @@ /// Retrieve the declaration for the 128-bit unsigned integer type. TypedefDecl *getUInt128Decl() const; - /// Retrieve the declaration for the type_info class type. + /// Retrieve the declaration for the MSVC ::type_info class type. RecordDecl *getTypeInfoClassDecl() const; //======// Index: test/Modules/msvc-compat-implitic-types.cpp === --- /dev/null +++ test/Modules/msvc-compat-implitic-types.cpp @@ -0,0 +1,14 @@ +// Verify there is not collision between the +// RUN: %clang -fms-compatibility -fmodules-ts -x c++-module --precompile -DEXPORT -o %t.pcm %s +// RUN: %clang -fms-compatibility -fmodules-ts -fmodule-file=%t.pcm -c -DMAIN %s + +// expected-no-diagnostics + +#if EXPORT +export module MyModule; +export class MyClass {}; +#elif MAIN +#include +#else +#error MISSING DEFINE +#endif \ No newline at end of file Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -1464,11 +1464,6 @@ if (NewM == OldM) return false; - // FIXME: The Modules TS does not specify how to handle inplicit types - // For now we will simply ignore the implicit global types - if (Old->isImplicit()) -return false; - // FIXME: Check proclaimed-ownership-declarations here too. bool NewIsModuleInterface = NewM && NewM->Kind == Module::ModuleInterfaceUnit; bool OldIsModuleInterface = OldM && OldM->Kind == Module::ModuleInterfaceUnit; Index: lib/AST/ASTContext.cpp === --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -1081,8 +1081,10 @@ } RecordDecl *ASTContext::getTypeInfoClassDecl() const { - if (!TypeInfoClassDecl) + if (!TypeInfoClassDecl) { TypeInfoClassDecl = buildImplicitRecord("type_info", TTK_Class); +TypeInfoClassDecl->setModuleOwnershipKind(Decl::ModuleOwnershipKind::Unowned); + } return TypeInfoClassDecl; } Index: include/clang/AST/ASTContext.h === --- include/clang/AST/ASTContext.h +++ include/clang/AST/ASTContext.h @@ -1126,7 +1126,7 @@ /// Retrieve the declaration for the 128-bit unsigned integer type. TypedefDecl *getUInt128Decl() const; - /// Retrieve the declaration for the type_info class type. + /// Retrieve the declaration for the MSVC ::type_info class type. RecordDecl *getTypeInfoClassDecl() const; //======// ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-