[PATCH] D37677: [libc++] implement future synchronization using atomic_flag
dennis.luxen planned changes to this revision. dennis.luxen added a comment. In https://reviews.llvm.org/D37677#868851, @EricWF wrote: > I agree with the general consensus that we should only make this change if > it's significantly faster, and only after we have a test that demonstrates > this. > > Unfortunately I don't recall exactly why I wrote that TODO in the first > place, but I'm sure I meant changing `__state_`, and not the lock. I suspect > it had to do with http://llvm.org/PR24692 . I talked to Marshall during CPPCon and he mentioned that the remark to use atomic was related to using `std::call_once`. I will rework this patch and use the defines from `__config` to mark it as an ABI breaking change. https://reviews.llvm.org/D37677 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38404: [CodeGen] Do not refer to complete TBAA info where we actually deal with just TBAA access types
This revision was automatically updated to reflect the committed changes. Closed by commit rL314657: [CodeGen] Do not refer to complete TBAA info where we actually deal with just… (authored by kosarev). Changed prior to commit: https://reviews.llvm.org/D38404?vs=117143&id=117315#toc Repository: rL LLVM https://reviews.llvm.org/D38404 Files: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -573,10 +573,10 @@ Types.RefreshTypeCacheForClass(RD); } -llvm::MDNode *CodeGenModule::getTBAAInfo(QualType QTy) { +llvm::MDNode *CodeGenModule::getTBAATypeInfo(QualType QTy) { if (!TBAA) return nullptr; - return TBAA->getTBAAInfo(QTy); + return TBAA->getTypeInfo(QTy); } llvm::MDNode *CodeGenModule::getTBAAInfoForVTablePtr() { Index: cfe/trunk/lib/CodeGen/CGExpr.cpp === --- cfe/trunk/lib/CodeGen/CGExpr.cpp +++ cfe/trunk/lib/CodeGen/CGExpr.cpp @@ -1165,7 +1165,7 @@ Scope.ForceCleanup({&V}); return LValue::MakeAddr(Address(V, LV.getAlignment()), LV.getType(), getContext(), LV.getBaseInfo(), - LV.getTBAAInfo()); + LV.getTBAAAccessType()); } // FIXME: Is it possible to create an ExprWithCleanups that produces a // bitfield lvalue or some other non-simple lvalue? @@ -1365,7 +1365,7 @@ SourceLocation Loc) { return EmitLoadOfScalar(lvalue.getAddress(), lvalue.isVolatile(), lvalue.getType(), Loc, lvalue.getBaseInfo(), - lvalue.getTBAAInfo(), + lvalue.getTBAAAccessType(), lvalue.getTBAABaseType(), lvalue.getTBAAOffset(), lvalue.isNontemporal()); } @@ -1477,7 +1477,7 @@ QualType Ty, SourceLocation Loc, LValueBaseInfo BaseInfo, - llvm::MDNode *TBAAInfo, + llvm::MDNode *TBAAAccessType, QualType TBAABaseType, uint64_t TBAAOffset, bool isNontemporal) { @@ -1508,7 +1508,7 @@ // Atomic operations have to be done on integral types. LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAAccessType); if (Ty->isAtomicType() || LValueIsSuitableForInlineAtomic(AtomicLValue)) { return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal(); } @@ -1519,11 +1519,11 @@ Load->getContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1))); Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); } - if (TBAAInfo) { + if (TBAAAccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias -? CGM.getTBAAInfo(getContext().CharTy) -: CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo, TBAAOffset); +? CGM.getTBAATypeInfo(getContext().CharTy) +: CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); if (TBAA) CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias); } @@ -1566,7 +1566,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, LValueBaseInfo BaseInfo, -llvm::MDNode *TBAAInfo, +llvm::MDNode *TBAAAccessType, bool isInit, QualType TBAABaseType, uint64_t TBAAOffset, bool isNontemporal) { @@ -1596,7 +1596,7 @@ Value = EmitToMemory(Value, Ty); LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAAccessType); if (Ty->isAtomicType() || (!isInit && LValueIsSuitableForInlineAtomic(AtomicLValue))) { EmitAtomicStore(RValue::get(Value), AtomicLValue, isInit); @@ -1610,11 +1610,11 @@ llvm::Consta
[PATCH] D38048: [clangd] Add textDocument/signatureHelp
ilya-biryukov added inline comments. Comment at: clangd/ClangdUnit.cpp:742 + Consumer->includeBriefComments(); + FrontendOpts.CodeCompleteOpts.IncludeBriefComments = + Consumer->includeBriefComments(); Duplicated line sneaked into commit. It looks like the intention was to set `IncludeCodePatterns`. Since we need to fill up `CodeCompleteOpts` in all callers when creating `CodeCompletionConsumer` anyway, maybe it's better to accept `CodeCompleteOpts` as a parameter? Otherwise there's a high chance to forget syncing some of `CodeCompleteOpts` flags with the ones from `CodeCompletionConsumer` when changing the code later. https://reviews.llvm.org/D38048 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38452: Mark test as a long-test
rogfer01 created this revision. This test creates a string of 2GiB which may make it too slow to run in a simulator. https://reviews.llvm.org/D38452 Files: test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp Index: test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp === --- test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp +++ test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp @@ -13,6 +13,8 @@ // class basic_streambuf; // void pbump(int n); +// +// REQUIRES: long_tests #include #include Index: test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp === --- test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp +++ test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp @@ -13,6 +13,8 @@ // class basic_streambuf; // void pbump(int n); +// +// REQUIRES: long_tests #include #include ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
ilya-biryukov requested changes to this revision. ilya-biryukov added a comment. This revision now requires changes to proceed. Some changes seem to be lost while merging with head. Comment at: clangd/GlobalCompilationDatabase.cpp:75 + auto CachedIt = CompilationDatabases.find(File); + std::string Error = ""; Maybe move `Error` closer to its usage (line 84: `auto CDB = tooling::CompilationDatabase::loadFromDirectory ...`)? Comment at: clangd/GlobalCompilationDatabase.cpp:90 + + // FIXME(ibiryukov): logging + // Output.log("Failed to find compilation database for " + Twine(File) + Please remove this FIXME, it is already deleted in head. Comment at: clangd/GlobalCompilationDatabase.cpp:97 - Logger.log("Failed to find compilation database for " + Twine(File) + "\n"); return nullptr; Please restore this logging statement. https://reviews.llvm.org/D37150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r314650 - Dependent Address Space Support Test File
On Mon, Oct 2, 2017 at 3:33 PM Andrew Gozillon via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: agozillon > Date: Sun Oct 1 23:31:25 2017 > New Revision: 314650 > > URL: http://llvm.org/viewvc/llvm-project?rev=314650&view=rev > Log: > Dependent Address Space Support Test File > > Adding regression test for Dependent Address Spaces in relation to > https://reviews.llvm.org/D33666 I forgot to svn add the test file > before commiting the prior changes. I appologies. > > > Added: > cfe/trunk/test/SemaTemplate/address_space-dependent.cpp > > Added: cfe/trunk/test/SemaTemplate/address_space-dependent.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/address_space-dependent.cpp?rev=314650&view=auto > > == > --- cfe/trunk/test/SemaTemplate/address_space-dependent.cpp (added) > +++ cfe/trunk/test/SemaTemplate/address_space-dependent.cpp Sun Oct 1 > 23:31:25 2017 > @@ -0,0 +1,119 @@ > +// RUN: %clang_cc1 -x c++ -std=c++14 -fsyntax-only -verify %s > + > +template > +void car() { > + int __attribute__((address_space(I))) __attribute__((address_space(J))) > * Y; // expected-error {{multiple address spaces specified for type}} > + int *__attribute__((address_space(I))) > __attribute__((address_space(J))) * Z; // expected-error {{multiple address > spaces specified for type}} > + > + __attribute__((address_space(I))) int local;// expected-error > {{automatic variable qualified with an address space}} > + __attribute__((address_space(J))) int array[5]; // expected-error > {{automatic variable qualified with an address space}} > + __attribute__((address_space(I))) int arrarr[5][5]; // expected-error > {{automatic variable qualified with an address space}} > + > + __attribute__((address_space(J))) * x; // expected-error {{C++ requires > a type specifier for all declarations}} > + > + __attribute__((address_space(I))) float *B; > + > + typedef __attribute__((address_space(J))) int AS2Int; > + struct HasASFields { > +AS2Int typedef_as_field; // expected-error {{field may not be > qualified with an address space}} > + }; > + > + struct _st { > +int x, y; > + } s __attribute((address_space(I))) = {1, 1}; > +} > + > +template > +struct HasASTemplateFields { > + __attribute__((address_space(I))) int as_field; // expected-error > {{field may not be qualified with an address space}} > +}; > + > +template > +void foo(__attribute__((address_space(I))) float *a, // expected-note > {{candidate template ignored: substitution failure [with I = 1, J = 2]: > parameter may not be qualified with an address space}} > + __attribute__((address_space(J))) float b) { > + *a = 5.0f + b; > +} > + > +template void foo<1, 2>(float *, float); // expected-error {{explicit > instantiation of 'foo' does not refer to a function template, variable > template, member function, member class, or static data member}} > + > +template > +void neg() { > + __attribute__((address_space(I))) int *bounds; // expected-error > {{address space is negative}} > +} > + > +template > +void toBig() { > + __attribute__((address_space(I))) int *bounds; // expected-error > {{address space is larger than the maximum supported (8388599)}} > +} > + > +template > +void correct() { > + __attribute__((address_space(I))) int *bounds; > +} > + > +template > +char *cmp(__attribute__((address_space(I))) char *x, > __attribute__((address_space(J))) char *y) { > + return x < y ? x : y; // expected-error {{comparison of distinct > pointer types ('__attribute__((address_space(1))) char *' and > '__attribute__((address_space(2))) char *')}} > +} > + > +typedef void ft(void); > + > +template > +struct fooFunction { > + __attribute__((address_space(I))) void **const base = 0; > + > + void *get_0(void) { > +return base[0]; // expected-error {{cannot initialize return object > of type 'void *' with an lvalue of type '__attribute__((address_space(1))) > void *}} > + } > + > + __attribute__((address_space(I))) ft qf; // expected-error {{function > type may not be qualified with an address space}} > + __attribute__((address_space(I))) char *test3_val; > + > + void test3(void) { > +extern void test3_helper(char *p); // expected-note {{passing > argument to parameter 'p' here}} > +test3_helper(test3_val); // expected-error {{cannot > initialize a parameter of type 'char *' with an lvalue of type > '__attribute__((address_space(1))) char *'}} > + } > +}; > + > +template > +int GetAddressSpaceValue(T __attribute__((address_space(N))) * p) { > + return N; > +} > + > +template int __attribute__((address_space(A))) > *same_template(); > +template int __attribute__((address_space(B))) > *same_template(); > +void test_same_template() { (void) same_template<0>(); } > + > +template int __attribute__((address_space(A))) > *different_template(); // expected-note {{candidate function [with A = 0]}} > +te
[PATCH] D38408: [CodeGen] Have a special function to get TBAA info for may-alias accesses
This revision was automatically updated to reflect the committed changes. Closed by commit rL314660: [CodeGen] Have a special function to get TBAA info for may-alias accesses (authored by kosarev). Changed prior to commit: https://reviews.llvm.org/D38408?vs=117162&id=117321#toc Repository: rL LLVM https://reviews.llvm.org/D38408 Files: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Index: cfe/trunk/lib/CodeGen/CodeGenModule.h === --- cfe/trunk/lib/CodeGen/CodeGenModule.h +++ cfe/trunk/lib/CodeGen/CodeGenModule.h @@ -662,6 +662,10 @@ llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, uint64_t O); + /// getTBAAMayAliasTypeInfo - Get TBAA information that represents + /// may-alias accesses. + llvm::MDNode *getTBAAMayAliasTypeInfo(); + bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor); bool isPaddedAtomicType(QualType type); Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -599,6 +599,12 @@ return TBAA->getTBAAStructTagInfo(BaseTy, AccessN, O); } +llvm::MDNode *CodeGenModule::getTBAAMayAliasTypeInfo() { + if (!TBAA) +return nullptr; + return TBAA->getMayAliasTypeInfo(); +} + /// Decorate the instruction with a TBAA tag. For both scalar TBAA /// and struct-path aware TBAA, the tag has the same format: /// base type, access type and offset. Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.h === --- cfe/trunk/lib/CodeGen/CodeGenTBAA.h +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.h @@ -116,6 +116,10 @@ /// Get the scalar tag MDNode for a given scalar type. llvm::MDNode *getTBAAScalarTagInfo(llvm::MDNode *AccessNode); + + /// getMayAliasTypeInfo - Get TBAA information that represents may-alias + /// accesses. + llvm::MDNode *getMayAliasTypeInfo(); }; } // end namespace CodeGen Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp === --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp @@ -326,3 +326,7 @@ return ScalarTagMetadataCache[AccessNode] = MDHelper.createTBAAStructTagNode(AccessNode, AccessNode, 0); } + +llvm::MDNode *CodeGenTBAA::getMayAliasTypeInfo() { + return getChar(); +} Index: cfe/trunk/lib/CodeGen/CGExpr.cpp === --- cfe/trunk/lib/CodeGen/CGExpr.cpp +++ cfe/trunk/lib/CodeGen/CGExpr.cpp @@ -1522,7 +1522,7 @@ if (TBAAAccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias -? CGM.getTBAATypeInfo(getContext().CharTy) +? CGM.getTBAAMayAliasTypeInfo() : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); if (TBAA) CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias); @@ -1613,7 +1613,7 @@ if (TBAAAccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias -? CGM.getTBAATypeInfo(getContext().CharTy) +? CGM.getTBAAMayAliasTypeInfo() : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); if (TBAA) CGM.DecorateInstructionWithTBAA(Store, TBAA, MayAlias); @@ -3724,11 +3724,8 @@ // Loading the reference will disable path-aware TBAA. TBAAPath = false; if (CGM.shouldUseTBAA()) { -llvm::MDNode *tbaa; -if (mayAlias) - tbaa = CGM.getTBAATypeInfo(getContext().CharTy); -else - tbaa = CGM.getTBAATypeInfo(type); +llvm::MDNode *tbaa = mayAlias ? CGM.getTBAAMayAliasTypeInfo() : +CGM.getTBAATypeInfo(type); if (tbaa) CGM.DecorateInstructionWithTBAA(load, tbaa); } @@ -3780,7 +3777,7 @@ // FIXME: this should get propagated down through anonymous structs // and unions. if (mayAlias && LV.getTBAAAccessType()) -LV.setTBAAAccessType(CGM.getTBAATypeInfo(getContext().CharTy)); +LV.setTBAAAccessType(CGM.getTBAAMayAliasTypeInfo()); return LV; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
Nebiroth updated this revision to Diff 117327. Nebiroth added a comment. Fixed changes that were lost while merging with head. https://reviews.llvm.org/D37150 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/GlobalCompilationDatabase.cpp clangd/GlobalCompilationDatabase.h clangd/tool/ClangdMain.cpp Index: clangd/tool/ClangdMain.cpp === --- clangd/tool/ClangdMain.cpp +++ clangd/tool/ClangdMain.cpp @@ -11,16 +11,22 @@ #include "JSONRPCDispatcher.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" #include "llvm/Support/Program.h" - #include #include #include #include using namespace clang; using namespace clang::clangd; +static llvm::cl::opt CompileCommandsDir( +"compile-commands-dir", +llvm::cl::desc("Specify a path to look for compile_commands.json. If path " + "is invalid, clangd will look in the current directory and " + "parent paths of each source file.")); + static llvm::cl::opt WorkerThreadsCount("j", llvm::cl::desc("Number of async workers used by clangd"), @@ -56,18 +62,37 @@ if (RunSynchronously) WorkerThreadsCount = 0; + /// Validate command line arguments. llvm::raw_ostream &Outs = llvm::outs(); llvm::raw_ostream &Logs = llvm::errs(); JSONOutput Out(Outs, Logs); - // Change stdin to binary to not lose \r\n on windows. - llvm::sys::ChangeStdinToBinary(); + // If --compile-commands-dir arg was invoked, check value and override default + // path. + namespace path = llvm::sys::path; + llvm::Optional CompileCommandsDirPath; + + if (CompileCommandsDir.empty()) { +CompileCommandsDirPath = llvm::None; + } else if (!llvm::sys::path::is_absolute(CompileCommandsDir) || + !llvm::sys::fs::exists(CompileCommandsDir)) { +llvm::errs() << "Path specified by --compile-commands-dir either does not " +"exist or is not an absolute " +"path. The argument will be ignored.\n"; +CompileCommandsDirPath = llvm::None; + } else { +CompileCommandsDirPath = CompileCommandsDir; + } llvm::Optional ResourceDirRef = None; if (!ResourceDir.empty()) ResourceDirRef = ResourceDir; + /// Change stdin to binary to not lose \r\n on windows. + llvm::sys::ChangeStdinToBinary(); + + /// Initialize and run ClangdLSPServer. ClangdLSPServer LSPServer(Out, WorkerThreadsCount, EnableSnippets, -ResourceDirRef); +ResourceDirRef, CompileCommandsDirPath); LSPServer.run(std::cin); } Index: clangd/GlobalCompilationDatabase.h === --- clangd/GlobalCompilationDatabase.h +++ clangd/GlobalCompilationDatabase.h @@ -47,15 +47,17 @@ class DirectoryBasedGlobalCompilationDatabase : public GlobalCompilationDatabase { public: - DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger); + DirectoryBasedGlobalCompilationDatabase( + clangd::Logger &Logger, llvm::Optional NewCompileCommandsDir); std::vector getCompileCommands(PathRef File) override; void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags); private: tooling::CompilationDatabase *getCompilationDatabase(PathRef File); + tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File); std::mutex Mutex; /// Caches compilation databases loaded from directories(keys are @@ -67,6 +69,9 @@ llvm::StringMap> ExtraFlagsForFile; /// Used for logging. clangd::Logger &Logger; + /// Used for command argument pointing to folder where compile_commands.json + /// is located. + llvm::Optional CompileCommandsDir; }; } // namespace clangd } // namespace clang Index: clangd/GlobalCompilationDatabase.cpp === --- clangd/GlobalCompilationDatabase.cpp +++ clangd/GlobalCompilationDatabase.cpp @@ -8,10 +8,10 @@ //===-===// #include "GlobalCompilationDatabase.h" +#include "Logger.h" #include "clang/Tooling/CompilationDatabase.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "Logger.h" namespace clang { namespace clangd { @@ -38,8 +38,9 @@ } DirectoryBasedGlobalCompilationDatabase:: -DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger) -: Logger(Logger) {} +DirectoryBasedGlobalCompilationDatabase( +clangd::Logger &Logger, llvm::Optional NewCompileCommandsDir) +: Logger(Logger), CompileCommandsDir(NewCompileCommandsDir) {} std::vector DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) { @@ -67,34 +68,46 @@ } tooling::CompilationDatabase * -DirectoryBasedGlobalCompilationDatabase::getCompilationDatabase(PathRef File) { - std::lock_guard
Fwd: clang-format: Incorrect BreakBeforeBraces documentation
Hello cfe-commits, I sent the following mail to cfe-dev, but didn't receive reply. I believe the attached patch to the Clang repo fixes this issue, if you're happy to accept it. Please let me know if you want it altered or if I've made a mistake. Thanks, Matt Forwarded Message Subject: clang-format: Incorrect BreakBeforeBraces documentation Date: Wed, 13 Sep 2017 18:11:57 -0700 From: Matthew Fernandez To: cfe-...@lists.llvm.org Hello cfe-dev, If this is not the right place for reporting issues with clang-format, please let me know where I should post this instead. The docs for the BreakBeforeBraces option of clang-format style [0] give the following example of Allman bracing: try { foo(); } catch () { } void foo() { bar(); } class foo { }; if (foo()) { } else { } enum X : int { A, B }; This does not seem to be Allman style. In fact clang-format itself will reflow this example: $ clang-format -style="{BreakBeforeBraces: Allman}" allman.cpp try { foo(); } catch () { } void foo() { bar(); } class foo { }; if (foo()) { } else { } enum X : int { A, B }; Is this a mistake in the documentation? Thanks, Matt [0]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html Index: docs/ClangFormatStyleOptions.rst === --- docs/ClangFormatStyleOptions.rst (revision 314636) +++ docs/ClangFormatStyleOptions.rst (working copy) @@ -891,19 +891,28 @@ .. code-block:: c++ - try { + try + { foo(); } - catch () { + catch () + { } void foo() { bar(); } - class foo { + class foo + { }; - if (foo()) { + if (foo()) + { } - else { + else + { } - enum X : int { A, B }; + enum X : int + { +A, +B + }; * ``BS_GNU`` (in configuration: ``GNU``) Always break before braces and add an extra level of indentation to ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314660 - [CodeGen] Have a special function to get TBAA info for may-alias accesses
Author: kosarev Date: Mon Oct 2 04:10:04 2017 New Revision: 314660 URL: http://llvm.org/viewvc/llvm-project?rev=314660&view=rev Log: [CodeGen] Have a special function to get TBAA info for may-alias accesses This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38408 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=314660&r1=314659&r2=314660&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 2 04:10:04 2017 @@ -1522,7 +1522,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf if (TBAAAccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias -? CGM.getTBAATypeInfo(getContext().CharTy) +? CGM.getTBAAMayAliasTypeInfo() : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); if (TBAA) CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias); @@ -1613,7 +1613,7 @@ void CodeGenFunction::EmitStoreOfScalar( if (TBAAAccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias -? CGM.getTBAATypeInfo(getContext().CharTy) +? CGM.getTBAAMayAliasTypeInfo() : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); if (TBAA) CGM.DecorateInstructionWithTBAA(Store, TBAA, MayAlias); @@ -3724,11 +3724,8 @@ LValue CodeGenFunction::EmitLValueForFie // Loading the reference will disable path-aware TBAA. TBAAPath = false; if (CGM.shouldUseTBAA()) { -llvm::MDNode *tbaa; -if (mayAlias) - tbaa = CGM.getTBAATypeInfo(getContext().CharTy); -else - tbaa = CGM.getTBAATypeInfo(type); +llvm::MDNode *tbaa = mayAlias ? CGM.getTBAAMayAliasTypeInfo() : +CGM.getTBAATypeInfo(type); if (tbaa) CGM.DecorateInstructionWithTBAA(load, tbaa); } @@ -3780,7 +3777,7 @@ LValue CodeGenFunction::EmitLValueForFie // FIXME: this should get propagated down through anonymous structs // and unions. if (mayAlias && LV.getTBAAAccessType()) -LV.setTBAAAccessType(CGM.getTBAATypeInfo(getContext().CharTy)); +LV.setTBAAAccessType(CGM.getTBAAMayAliasTypeInfo()); return LV; } Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=314660&r1=314659&r2=314660&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Oct 2 04:10:04 2017 @@ -599,6 +599,12 @@ llvm::MDNode *CodeGenModule::getTBAAStru return TBAA->getTBAAStructTagInfo(BaseTy, AccessN, O); } +llvm::MDNode *CodeGenModule::getTBAAMayAliasTypeInfo() { + if (!TBAA) +return nullptr; + return TBAA->getMayAliasTypeInfo(); +} + /// Decorate the instruction with a TBAA tag. For both scalar TBAA /// and struct-path aware TBAA, the tag has the same format: /// base type, access type and offset. Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=314660&r1=314659&r2=314660&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Oct 2 04:10:04 2017 @@ -662,6 +662,10 @@ public: llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, uint64_t O); + /// getTBAAMayAliasTypeInfo - Get TBAA information that represents + /// may-alias accesses. + llvm::MDNode *getTBAAMayAliasTypeInfo(); + bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor); bool isPaddedAtomicType(QualType type); Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=314660&r1=314659&r2=314660&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Mon Oct 2 04:10:04 2017 @@ -326,3 +326,7 @@ CodeGenTBAA::getTBAAScalarTagInfo(llvm:: return ScalarTagMetadataCache[AccessNode] = MDHelper.createTBAAStructTagNode(AccessNode, AccessNode, 0); } + +llvm::MDNode *CodeGenTBAA::getMayAliasTypeInfo() { + return getChar(); +} Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.h?r
r314657 - [CodeGen] Do not refer to complete TBAA info where we actually deal with just TBAA access types
Author: kosarev Date: Mon Oct 2 02:54:47 2017 New Revision: 314657 URL: http://llvm.org/viewvc/llvm-project?rev=314657&view=rev Log: [CodeGen] Do not refer to complete TBAA info where we actually deal with just TBAA access types This patch fixes misleading names of entities related to getting, setting and generation of TBAA access type descriptors. This is effectively an attempt to provide a review for D37826 by breaking it into smaller pieces. Differential Revision: https://reviews.llvm.org/D38404 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=314657&r1=314656&r2=314657&view=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Mon Oct 2 02:54:47 2017 @@ -98,7 +98,7 @@ namespace { LVal = LValue::MakeBitfield(Address(Addr, lvalue.getAlignment()), BFI, lvalue.getType(), lvalue.getBaseInfo()); -LVal.setTBAAInfo(lvalue.getTBAAInfo()); +LVal.setTBAAAccessType(lvalue.getTBAAAccessType()); AtomicTy = C.getIntTypeForBitwidth(AtomicSizeInBits, OrigBFI.IsSigned); if (AtomicTy.isNull()) { llvm::APInt Size( @@ -205,7 +205,7 @@ namespace { addr = CGF.Builder.CreateStructGEP(addr, 0, CharUnits()); return LValue::MakeAddr(addr, getValueType(), CGF.getContext(), - LVal.getBaseInfo(), LVal.getTBAAInfo()); + LVal.getBaseInfo(), LVal.getTBAAAccessType()); } /// \brief Emits atomic load. @@ -1425,8 +1425,8 @@ llvm::Value *AtomicInfo::EmitAtomicLoadO // Other decoration. if (IsVolatile) Load->setVolatile(true); - if (LVal.getTBAAInfo()) -CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAInfo()); + if (LVal.getTBAAAccessType()) +CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAAccessType()); return Load; } @@ -1692,8 +1692,8 @@ EmitAtomicUpdateValue(CodeGenFunction &C DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } -UpdateLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); -DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); +UpdateLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); +DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); UpRVal = CGF.EmitLoadOfLValue(UpdateLVal, SourceLocation()); } // Store new value in the corresponding memory area @@ -1789,7 +1789,7 @@ static void EmitAtomicUpdateValue(CodeGe DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } - DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); + DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); // Store new value in the corresponding memory area assert(UpdateRVal.isScalar()); CGF.EmitStoreThroughLValue(UpdateRVal, DesiredLVal); @@ -1942,8 +1942,8 @@ void CodeGenFunction::EmitAtomicStore(RV // Other decoration. if (IsVolatile) store->setVolatile(true); -if (dest.getTBAAInfo()) - CGM.DecorateInstructionWithTBAA(store, dest.getTBAAInfo()); +if (dest.getTBAAAccessType()) + CGM.DecorateInstructionWithTBAA(store, dest.getTBAAAccessType()); return; } Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=314657&r1=314656&r2=314657&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 2 02:54:47 2017 @@ -1165,7 +1165,7 @@ LValue CodeGenFunction::EmitLValue(const Scope.ForceCleanup({&V}); return LValue::MakeAddr(Address(V, LV.getAlignment()), LV.getType(), getContext(), LV.getBaseInfo(), - LV.getTBAAInfo()); + LV.getTBAAAccessType()); } // FIXME: Is it possible to create an ExprWithCleanups that produces a // bitfield lvalue or some other non-simple lvalue? @@ -1365,7 +1365,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf SourceLocation Loc) { return EmitLoadOfScalar(lvalue.getAddress(), lvalue.isVolatile(), lvalue.getType(), Loc, lvalue.getBaseInfo(), - lvalue.getTBAAInfo(), +
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
ilya-biryukov requested changes to this revision. ilya-biryukov added inline comments. This revision now requires changes to proceed. Comment at: clangd/GlobalCompilationDatabase.cpp:90 + + Logger.log("Failed to find compilation database for " + Twine(File) + "\n"); + return nullptr; This logging statement is misplaced, in the current HEAD it's outside of the loop. (i.e. it should be in the `getCompilationDatabase`, not in `tryLoadDatabaseFromPath`). Otherwise the output of clangd gets really spammy. Comment at: clangd/GlobalCompilationDatabase.cpp:100 + if (CompileCommandsDir.hasValue()) +return tryLoadDatabaseFromPath(CompileCommandsDir.getValue()); We should also log if we can't find compilation database in this code path. https://reviews.llvm.org/D37150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
Nebiroth updated this revision to Diff 117337. Nebiroth marked 2 inline comments as done. Nebiroth added a comment. Changed placement of logging instruction to reduce logging output. https://reviews.llvm.org/D37150 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/GlobalCompilationDatabase.cpp clangd/GlobalCompilationDatabase.h clangd/tool/ClangdMain.cpp Index: clangd/tool/ClangdMain.cpp === --- clangd/tool/ClangdMain.cpp +++ clangd/tool/ClangdMain.cpp @@ -11,16 +11,22 @@ #include "JSONRPCDispatcher.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" #include "llvm/Support/Program.h" - #include #include #include #include using namespace clang; using namespace clang::clangd; +static llvm::cl::opt CompileCommandsDir( +"compile-commands-dir", +llvm::cl::desc("Specify a path to look for compile_commands.json. If path " + "is invalid, clangd will look in the current directory and " + "parent paths of each source file.")); + static llvm::cl::opt WorkerThreadsCount("j", llvm::cl::desc("Number of async workers used by clangd"), @@ -56,18 +62,37 @@ if (RunSynchronously) WorkerThreadsCount = 0; + /// Validate command line arguments. llvm::raw_ostream &Outs = llvm::outs(); llvm::raw_ostream &Logs = llvm::errs(); JSONOutput Out(Outs, Logs); - // Change stdin to binary to not lose \r\n on windows. - llvm::sys::ChangeStdinToBinary(); + // If --compile-commands-dir arg was invoked, check value and override default + // path. + namespace path = llvm::sys::path; + llvm::Optional CompileCommandsDirPath; + + if (CompileCommandsDir.empty()) { +CompileCommandsDirPath = llvm::None; + } else if (!llvm::sys::path::is_absolute(CompileCommandsDir) || + !llvm::sys::fs::exists(CompileCommandsDir)) { +llvm::errs() << "Path specified by --compile-commands-dir either does not " +"exist or is not an absolute " +"path. The argument will be ignored.\n"; +CompileCommandsDirPath = llvm::None; + } else { +CompileCommandsDirPath = CompileCommandsDir; + } llvm::Optional ResourceDirRef = None; if (!ResourceDir.empty()) ResourceDirRef = ResourceDir; + /// Change stdin to binary to not lose \r\n on windows. + llvm::sys::ChangeStdinToBinary(); + + /// Initialize and run ClangdLSPServer. ClangdLSPServer LSPServer(Out, WorkerThreadsCount, EnableSnippets, -ResourceDirRef); +ResourceDirRef, CompileCommandsDirPath); LSPServer.run(std::cin); } Index: clangd/GlobalCompilationDatabase.h === --- clangd/GlobalCompilationDatabase.h +++ clangd/GlobalCompilationDatabase.h @@ -47,15 +47,17 @@ class DirectoryBasedGlobalCompilationDatabase : public GlobalCompilationDatabase { public: - DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger); + DirectoryBasedGlobalCompilationDatabase( + clangd::Logger &Logger, llvm::Optional NewCompileCommandsDir); std::vector getCompileCommands(PathRef File) override; void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags); private: tooling::CompilationDatabase *getCompilationDatabase(PathRef File); + tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File); std::mutex Mutex; /// Caches compilation databases loaded from directories(keys are @@ -67,6 +69,9 @@ llvm::StringMap> ExtraFlagsForFile; /// Used for logging. clangd::Logger &Logger; + /// Used for command argument pointing to folder where compile_commands.json + /// is located. + llvm::Optional CompileCommandsDir; }; } // namespace clangd } // namespace clang Index: clangd/GlobalCompilationDatabase.cpp === --- clangd/GlobalCompilationDatabase.cpp +++ clangd/GlobalCompilationDatabase.cpp @@ -8,10 +8,10 @@ //===-===// #include "GlobalCompilationDatabase.h" +#include "Logger.h" #include "clang/Tooling/CompilationDatabase.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "Logger.h" namespace clang { namespace clangd { @@ -38,8 +38,9 @@ } DirectoryBasedGlobalCompilationDatabase:: -DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger) -: Logger(Logger) {} +DirectoryBasedGlobalCompilationDatabase( +clangd::Logger &Logger, llvm::Optional NewCompileCommandsDir) +: Logger(Logger), CompileCommandsDir(NewCompileCommandsDir) {} std::vector DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) { @@ -67,31 +68,49 @@ } tooling::CompilationDatabase * -DirectoryBasedGlobalCompilationDatabase::g
r314668 - Dependent Address Space Support Test Fix
Author: agozillon Date: Mon Oct 2 06:32:59 2017 New Revision: 314668 URL: http://llvm.org/viewvc/llvm-project?rev=314668&view=rev Log: Dependent Address Space Support Test Fix Modifying a non-type template integer arguement that is causing errors in some builds as it's too large for 32-bit longs. This hopefully (and seems to when testing) should fix all of the build bot errors relating to this test. I also modified the name of the function call to be more apt. Differential Revision: https://reviews.llvm.org/D33666 Modified: cfe/trunk/test/SemaTemplate/address_space-dependent.cpp Modified: cfe/trunk/test/SemaTemplate/address_space-dependent.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/address_space-dependent.cpp?rev=314668&r1=314667&r2=314668&view=diff == --- cfe/trunk/test/SemaTemplate/address_space-dependent.cpp (original) +++ cfe/trunk/test/SemaTemplate/address_space-dependent.cpp Mon Oct 2 06:32:59 2017 @@ -42,7 +42,7 @@ void neg() { } template -void toBig() { +void tooBig() { __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388599)}} } @@ -102,7 +102,7 @@ int main() { HasASTemplateFields<1> HASTF; neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}} correct<0x77>(); - toBig<4294967500>(); // expected-note {{in instantiation of function template specialization 'toBig<4294967500>' requested here}} + tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650>' requested here}} __attribute__((address_space(1))) char *x; __attribute__((address_space(2))) char *y; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r314650 - Dependent Address Space Support Test File
Thank you very much for the help. I have committed a change that should fix this, I tested it with my normal build and the triple you referenced and it works in both cases. I shall continue to keep an eye on the build bot. Best Regards, Andrew Gozillon From: NAKAMURA Takumi Sent: 02 October 2017 11:09:51 To: Andrew Gozillon; cfe-commits@lists.llvm.org Subject: Re: r314650 - Dependent Address Space Support Test File On Mon, Oct 2, 2017 at 3:33 PM Andrew Gozillon via cfe-commits mailto:cfe-commits@lists.llvm.org>> wrote: Author: agozillon Date: Sun Oct 1 23:31:25 2017 New Revision: 314650 URL: http://llvm.org/viewvc/llvm-project?rev=314650&view=rev Log: Dependent Address Space Support Test File Adding regression test for Dependent Address Spaces in relation to https://reviews.llvm.org/D33666 I forgot to svn add the test file before commiting the prior changes. I appologies. Added: cfe/trunk/test/SemaTemplate/address_space-dependent.cpp Added: cfe/trunk/test/SemaTemplate/address_space-dependent.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/address_space-dependent.cpp?rev=314650&view=auto == --- cfe/trunk/test/SemaTemplate/address_space-dependent.cpp (added) +++ cfe/trunk/test/SemaTemplate/address_space-dependent.cpp Sun Oct 1 23:31:25 2017 @@ -0,0 +1,119 @@ +// RUN: %clang_cc1 -x c++ -std=c++14 -fsyntax-only -verify %s + +template +void car() { + int __attribute__((address_space(I))) __attribute__((address_space(J))) * Y; // expected-error {{multiple address spaces specified for type}} + int *__attribute__((address_space(I))) __attribute__((address_space(J))) * Z; // expected-error {{multiple address spaces specified for type}} + + __attribute__((address_space(I))) int local;// expected-error {{automatic variable qualified with an address space}} + __attribute__((address_space(J))) int array[5]; // expected-error {{automatic variable qualified with an address space}} + __attribute__((address_space(I))) int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}} + + __attribute__((address_space(J))) * x; // expected-error {{C++ requires a type specifier for all declarations}} + + __attribute__((address_space(I))) float *B; + + typedef __attribute__((address_space(J))) int AS2Int; + struct HasASFields { +AS2Int typedef_as_field; // expected-error {{field may not be qualified with an address space}} + }; + + struct _st { +int x, y; + } s __attribute((address_space(I))) = {1, 1}; +} + +template +struct HasASTemplateFields { + __attribute__((address_space(I))) int as_field; // expected-error {{field may not be qualified with an address space}} +}; + +template +void foo(__attribute__((address_space(I))) float *a, // expected-note {{candidate template ignored: substitution failure [with I = 1, J = 2]: parameter may not be qualified with an address space}} + __attribute__((address_space(J))) float b) { + *a = 5.0f + b; +} + +template void foo<1, 2>(float *, float); // expected-error {{explicit instantiation of 'foo' does not refer to a function template, variable template, member function, member class, or static data member}} + +template +void neg() { + __attribute__((address_space(I))) int *bounds; // expected-error {{address space is negative}} +} + +template +void toBig() { + __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388599)}} +} + +template +void correct() { + __attribute__((address_space(I))) int *bounds; +} + +template +char *cmp(__attribute__((address_space(I))) char *x, __attribute__((address_space(J))) char *y) { + return x < y ? x : y; // expected-error {{comparison of distinct pointer types ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *')}} +} + +typedef void ft(void); + +template +struct fooFunction { + __attribute__((address_space(I))) void **const base = 0; + + void *get_0(void) { +return base[0]; // expected-error {{cannot initialize return object of type 'void *' with an lvalue of type '__attribute__((address_space(1))) void *}} + } + + __attribute__((address_space(I))) ft qf; // expected-error {{function type may not be qualified with an address space}} + __attribute__((address_space(I))) char *test3_val; + + void test3(void) { +extern void test3_helper(char *p); // expected-note {{passing argument to parameter 'p' here}} +test3_helper(test3_val); // expected-error {{cannot initialize a parameter of type 'char *' with an lvalue of type '__attribute__((address_space(1))) char *'}} + } +}; + +template +int GetAddressSpaceValue(T __attribute__((address_space(N))) * p) { + return N; +} + +template int __attribute__((address_space(A))) *same_template(); +template int __attribute__((address_sp
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
ilya-biryukov accepted this revision. ilya-biryukov added a comment. Thanks. LGTM modulo minor NIT (see other inline comment). Do you need help to land this? Comment at: clangd/GlobalCompilationDatabase.cpp:102 +if (ReturnValue == nullptr) + Logger.log("Failed to find compilation database for " + Twine(File) + + "\n"); Message should probably mention that's clangd was looking for compile commands in an overridden directory. https://reviews.llvm.org/D37150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38456: [CodeGen] Introduce generic TBAA access descriptors
kosarev created this revision. kosarev added a project: clang. With this patch we implement a concept of TBAA access descriptors that are capable of representing both scalar and struct-path accesses in a generic way. This is part of https://reviews.llvm.org/D37826 reworked to be a separate patch to simplify review. Repository: rL LLVM https://reviews.llvm.org/D38456 Files: lib/CodeGen/CGExpr.cpp lib/CodeGen/CGValue.h lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/CodeGenTBAA.cpp lib/CodeGen/CodeGenTBAA.h Index: lib/CodeGen/CodeGenTBAA.h === --- lib/CodeGen/CodeGenTBAA.h +++ lib/CodeGen/CodeGenTBAA.h @@ -30,15 +30,43 @@ class Type; namespace CodeGen { - class CGRecordLayout; +class CGRecordLayout; - struct TBAAPathTag { -TBAAPathTag(const Type *B, const llvm::MDNode *A, uint64_t O) - : BaseT(B), AccessN(A), Offset(O) {} -const Type *BaseT; -const llvm::MDNode *AccessN; -uint64_t Offset; - }; +struct TBAAPathTag { + TBAAPathTag(const Type *B, const llvm::MDNode *A, uint64_t O) +: BaseT(B), AccessN(A), Offset(O) {} + const Type *BaseT; + const llvm::MDNode *AccessN; + uint64_t Offset; +}; + +// TBAAAccessInfo - Describes a memory access in terms of TBAA. +struct TBAAAccessInfo { + TBAAAccessInfo(QualType BaseType, llvm::MDNode *AccessType, uint64_t Offset) +: BaseType(BaseType), AccessType(AccessType), Offset(Offset) + {} + + explicit TBAAAccessInfo(llvm::MDNode *AccessType) +: TBAAAccessInfo(/* BaseType= */ QualType(), AccessType, /* Offset= */ 0) + {} + + TBAAAccessInfo() +: TBAAAccessInfo(/* AccessType= */ nullptr) + {} + + /// BaseType - The base/leading access type. May be null if this access + /// descriptor represents an access that is not considered to be an access + /// to an aggregate or union member. + QualType BaseType; + + /// AccessType - The final access type. May be null if there is no TBAA + /// information available about this access. + llvm::MDNode *AccessType; + + /// Offset - The byte offset of the final access within the base one. Must be + /// zero if the base access type is not specified. + uint64_t Offset; +}; /// CodeGenTBAA - This class organizes the cross-module state that is used /// while lowering AST types to LLVM types. @@ -109,10 +137,9 @@ /// Get the MDNode in the type DAG for given struct type QType. llvm::MDNode *getTBAAStructTypeInfo(QualType QType); - /// Get the tag MDNode for a given base type, the actual scalar access MDNode - /// and offset into the base type. - llvm::MDNode *getTBAAStructTagInfo(QualType BaseQType, - llvm::MDNode *AccessNode, uint64_t Offset); + + /// Get path-aware TBAA tag for a given memory access. + llvm::MDNode *getTBAAStructTagInfo(TBAAAccessInfo Info); /// Get the scalar tag MDNode for a given scalar type. llvm::MDNode *getTBAAScalarTagInfo(llvm::MDNode *AccessNode); Index: lib/CodeGen/CodeGenTBAA.cpp === --- lib/CodeGen/CodeGenTBAA.cpp +++ lib/CodeGen/CodeGenTBAA.cpp @@ -291,29 +291,28 @@ } /// Return a TBAA tag node for both scalar TBAA and struct-path aware TBAA. -llvm::MDNode * -CodeGenTBAA::getTBAAStructTagInfo(QualType BaseQTy, llvm::MDNode *AccessNode, - uint64_t Offset) { - if (!AccessNode) +llvm::MDNode *CodeGenTBAA::getTBAAStructTagInfo(TBAAAccessInfo Info) { + if (!Info.AccessType) return nullptr; if (!CodeGenOpts.StructPathTBAA) -return getTBAAScalarTagInfo(AccessNode); +return getTBAAScalarTagInfo(Info.AccessType); - const Type *BTy = Context.getCanonicalType(BaseQTy).getTypePtr(); - TBAAPathTag PathTag = TBAAPathTag(BTy, AccessNode, Offset); + const Type *BTy = Context.getCanonicalType(Info.BaseType).getTypePtr(); + TBAAPathTag PathTag = TBAAPathTag(BTy, Info.AccessType, Info.Offset); if (llvm::MDNode *N = StructTagMetadataCache[PathTag]) return N; llvm::MDNode *BNode = nullptr; - if (isTBAAPathStruct(BaseQTy)) -BNode = getTBAAStructTypeInfo(BaseQTy); + if (isTBAAPathStruct(Info.BaseType)) +BNode = getTBAAStructTypeInfo(Info.BaseType); if (!BNode) return StructTagMetadataCache[PathTag] = - MDHelper.createTBAAStructTagNode(AccessNode, AccessNode, 0); + MDHelper.createTBAAStructTagNode(Info.AccessType, Info.AccessType, +/* Offset= */ 0); return StructTagMetadataCache[PathTag] = -MDHelper.createTBAAStructTagNode(BNode, AccessNode, Offset); +MDHelper.createTBAAStructTagNode(BNode, Info.AccessType, Info.Offset); } llvm::MDNode * Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -658,9 +658,9 @@ llvm::MDNode *getTBAAInfoFor
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
Nebiroth updated this revision to Diff 117340. Nebiroth added a comment. Improved logging message when unable to find compilation database in specified overriden directory. https://reviews.llvm.org/D37150 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/GlobalCompilationDatabase.cpp clangd/GlobalCompilationDatabase.h clangd/tool/ClangdMain.cpp Index: clangd/tool/ClangdMain.cpp === --- clangd/tool/ClangdMain.cpp +++ clangd/tool/ClangdMain.cpp @@ -11,16 +11,22 @@ #include "JSONRPCDispatcher.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" #include "llvm/Support/Program.h" - #include #include #include #include using namespace clang; using namespace clang::clangd; +static llvm::cl::opt CompileCommandsDir( +"compile-commands-dir", +llvm::cl::desc("Specify a path to look for compile_commands.json. If path " + "is invalid, clangd will look in the current directory and " + "parent paths of each source file.")); + static llvm::cl::opt WorkerThreadsCount("j", llvm::cl::desc("Number of async workers used by clangd"), @@ -56,18 +62,37 @@ if (RunSynchronously) WorkerThreadsCount = 0; + /// Validate command line arguments. llvm::raw_ostream &Outs = llvm::outs(); llvm::raw_ostream &Logs = llvm::errs(); JSONOutput Out(Outs, Logs); - // Change stdin to binary to not lose \r\n on windows. - llvm::sys::ChangeStdinToBinary(); + // If --compile-commands-dir arg was invoked, check value and override default + // path. + namespace path = llvm::sys::path; + llvm::Optional CompileCommandsDirPath; + + if (CompileCommandsDir.empty()) { +CompileCommandsDirPath = llvm::None; + } else if (!llvm::sys::path::is_absolute(CompileCommandsDir) || + !llvm::sys::fs::exists(CompileCommandsDir)) { +llvm::errs() << "Path specified by --compile-commands-dir either does not " +"exist or is not an absolute " +"path. The argument will be ignored.\n"; +CompileCommandsDirPath = llvm::None; + } else { +CompileCommandsDirPath = CompileCommandsDir; + } llvm::Optional ResourceDirRef = None; if (!ResourceDir.empty()) ResourceDirRef = ResourceDir; + /// Change stdin to binary to not lose \r\n on windows. + llvm::sys::ChangeStdinToBinary(); + + /// Initialize and run ClangdLSPServer. ClangdLSPServer LSPServer(Out, WorkerThreadsCount, EnableSnippets, -ResourceDirRef); +ResourceDirRef, CompileCommandsDirPath); LSPServer.run(std::cin); } Index: clangd/GlobalCompilationDatabase.h === --- clangd/GlobalCompilationDatabase.h +++ clangd/GlobalCompilationDatabase.h @@ -47,15 +47,17 @@ class DirectoryBasedGlobalCompilationDatabase : public GlobalCompilationDatabase { public: - DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger); + DirectoryBasedGlobalCompilationDatabase( + clangd::Logger &Logger, llvm::Optional NewCompileCommandsDir); std::vector getCompileCommands(PathRef File) override; void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags); private: tooling::CompilationDatabase *getCompilationDatabase(PathRef File); + tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File); std::mutex Mutex; /// Caches compilation databases loaded from directories(keys are @@ -67,6 +69,9 @@ llvm::StringMap> ExtraFlagsForFile; /// Used for logging. clangd::Logger &Logger; + /// Used for command argument pointing to folder where compile_commands.json + /// is located. + llvm::Optional CompileCommandsDir; }; } // namespace clangd } // namespace clang Index: clangd/GlobalCompilationDatabase.cpp === --- clangd/GlobalCompilationDatabase.cpp +++ clangd/GlobalCompilationDatabase.cpp @@ -8,10 +8,10 @@ //===-===// #include "GlobalCompilationDatabase.h" +#include "Logger.h" #include "clang/Tooling/CompilationDatabase.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "Logger.h" namespace clang { namespace clangd { @@ -38,8 +38,9 @@ } DirectoryBasedGlobalCompilationDatabase:: -DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger) -: Logger(Logger) {} +DirectoryBasedGlobalCompilationDatabase( +clangd::Logger &Logger, llvm::Optional NewCompileCommandsDir) +: Logger(Logger), CompileCommandsDir(NewCompileCommandsDir) {} std::vector DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) { @@ -67,31 +68,50 @@ } tooling::CompilationDatabase * -DirectoryBasedGlobalCompilationDatabase::getCompila
[PATCH] D38458: Fix assertion failure in thread safety analysis (PR34800).
alexfh created this revision. Fix an assertion failure and clean up unused code relevant to the fixed logic. https://reviews.llvm.org/D38458 Files: include/clang/Analysis/Analyses/ThreadSafetyTIL.h test/SemaCXX/warn-thread-safety-analysis.cpp Index: test/SemaCXX/warn-thread-safety-analysis.cpp === --- test/SemaCXX/warn-thread-safety-analysis.cpp +++ test/SemaCXX/warn-thread-safety-analysis.cpp @@ -5233,3 +5233,18 @@ } // expected-warning {{mutex 'lock_' is still held at the end of function}} Mutex lock_ ACQUIRED_BEFORE(""); }; + +namespace PR34800 { +struct A { + operator int() const; +}; +struct B { + bool g() __attribute__((locks_excluded(h))); // expected-warning {{'locks_excluded' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'int'}} + int h; +}; +struct C { + B *operator[](int); +}; +C c; +void f() { c[A()]->g(); } +} // namespace PR34800 Index: include/clang/Analysis/Analyses/ThreadSafetyTIL.h === --- include/clang/Analysis/Analyses/ThreadSafetyTIL.h +++ include/clang/Analysis/Analyses/ThreadSafetyTIL.h @@ -909,15 +909,10 @@ public: static bool classof(const SExpr *E) { return E->opcode() == COP_Project; } - Project(SExpr *R, StringRef SName) - : SExpr(COP_Project), Rec(R), SlotName(SName), Cvdecl(nullptr) - { } Project(SExpr *R, const clang::ValueDecl *Cvd) - : SExpr(COP_Project), Rec(R), SlotName(Cvd->getName()), Cvdecl(Cvd) - { } - Project(const Project &P, SExpr *R) - : SExpr(P), Rec(R), SlotName(P.SlotName), Cvdecl(P.Cvdecl) - { } + : SExpr(COP_Project), Rec(R), Cvdecl(Cvd) { +assert(Cvd && "ValueDecl must not be null"); + } SExpr *record() { return Rec; } const SExpr *record() const { return Rec; } @@ -931,10 +926,15 @@ } StringRef slotName() const { -if (Cvdecl) +if (Cvdecl->getDeclName().isIdentifier()) return Cvdecl->getName(); -else - return SlotName; +if (!SlotName) { + std::string Buffer; + llvm::raw_string_ostream OS(Buffer); + Cvdecl->printName(OS); + SlotName = OS.str(); +} +return *SlotName; } template @@ -953,7 +953,7 @@ private: SExpr* Rec; - StringRef SlotName; + mutable llvm::Optional SlotName; const clang::ValueDecl *Cvdecl; }; Index: test/SemaCXX/warn-thread-safety-analysis.cpp === --- test/SemaCXX/warn-thread-safety-analysis.cpp +++ test/SemaCXX/warn-thread-safety-analysis.cpp @@ -5233,3 +5233,18 @@ } // expected-warning {{mutex 'lock_' is still held at the end of function}} Mutex lock_ ACQUIRED_BEFORE(""); }; + +namespace PR34800 { +struct A { + operator int() const; +}; +struct B { + bool g() __attribute__((locks_excluded(h))); // expected-warning {{'locks_excluded' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'int'}} + int h; +}; +struct C { + B *operator[](int); +}; +C c; +void f() { c[A()]->g(); } +} // namespace PR34800 Index: include/clang/Analysis/Analyses/ThreadSafetyTIL.h === --- include/clang/Analysis/Analyses/ThreadSafetyTIL.h +++ include/clang/Analysis/Analyses/ThreadSafetyTIL.h @@ -909,15 +909,10 @@ public: static bool classof(const SExpr *E) { return E->opcode() == COP_Project; } - Project(SExpr *R, StringRef SName) - : SExpr(COP_Project), Rec(R), SlotName(SName), Cvdecl(nullptr) - { } Project(SExpr *R, const clang::ValueDecl *Cvd) - : SExpr(COP_Project), Rec(R), SlotName(Cvd->getName()), Cvdecl(Cvd) - { } - Project(const Project &P, SExpr *R) - : SExpr(P), Rec(R), SlotName(P.SlotName), Cvdecl(P.Cvdecl) - { } + : SExpr(COP_Project), Rec(R), Cvdecl(Cvd) { +assert(Cvd && "ValueDecl must not be null"); + } SExpr *record() { return Rec; } const SExpr *record() const { return Rec; } @@ -931,10 +926,15 @@ } StringRef slotName() const { -if (Cvdecl) +if (Cvdecl->getDeclName().isIdentifier()) return Cvdecl->getName(); -else - return SlotName; +if (!SlotName) { + std::string Buffer; + llvm::raw_string_ostream OS(Buffer); + Cvdecl->printName(OS); + SlotName = OS.str(); +} +return *SlotName; } template @@ -953,7 +953,7 @@ private: SExpr* Rec; - StringRef SlotName; + mutable llvm::Optional SlotName; const clang::ValueDecl *Cvdecl; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
ilya-biryukov added a comment. Thanks for fixing the last comment. Do you want me to land this for you? Comment at: clangd/GlobalCompilationDatabase.cpp:103 + Logger.log("Failed to find compilation database for " + Twine(File) + + "in overriden directory " + CompileCommandsDir.getValue() + + "\n"); NIT: missing a space at the start of `"in overriden..."`. Otherwise filename will be concatenated with `"in"` https://reviews.llvm.org/D37150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
Nebiroth added a comment. In https://reviews.llvm.org/D37150#885749, @ilya-biryukov wrote: > Thanks for fixing the last comment. > Do you want me to land this for you? Yes please! https://reviews.llvm.org/D37150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314670 - [OPENMP] Simplify codegen for non-offloading code.
Author: abataev Date: Mon Oct 2 07:20:58 2017 New Revision: 314670 URL: http://llvm.org/viewvc/llvm-project?rev=314670&view=rev Log: [OPENMP] Simplify codegen for non-offloading code. Simplified and generalized codegen for non-offloading part that works if offloading is failed or condition of the `if` clause is `false`. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/test/OpenMP/target_codegen.cpp cfe/trunk/test/OpenMP/target_firstprivate_codegen.cpp cfe/trunk/test/OpenMP/target_parallel_codegen.cpp cfe/trunk/test/OpenMP/target_parallel_if_codegen.cpp cfe/trunk/test/OpenMP/target_parallel_num_threads_codegen.cpp cfe/trunk/test/OpenMP/target_teams_codegen.cpp cfe/trunk/test/OpenMP/target_teams_num_teams_codegen.cpp cfe/trunk/test/OpenMP/target_teams_thread_limit_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=314670&r1=314669&r2=314670&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Oct 2 07:20:58 2017 @@ -6865,8 +6865,6 @@ void CGOpenMPRuntime::emitTargetCall(Cod assert(OutlinedFn && "Invalid outlined function!"); - auto &Ctx = CGF.getContext(); - // Fill up the arrays with all the captured variables. MappableExprsHandler::MapValuesArrayTy KernelArgs; MappableExprsHandler::MapBaseValuesArrayTy BasePointers; @@ -6931,19 +6929,10 @@ void CGOpenMPRuntime::emitTargetCall(Cod MapTypes.append(CurMapTypes.begin(), CurMapTypes.end()); } - // Keep track on whether the host function has to be executed. - auto OffloadErrorQType = - Ctx.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/true); - auto OffloadError = CGF.MakeAddrLValue( - CGF.CreateMemTemp(OffloadErrorQType, ".run_host_version"), - OffloadErrorQType); - CGF.EmitStoreOfScalar(llvm::Constant::getNullValue(CGM.Int32Ty), -OffloadError); - // Fill up the pointer arrays and transfer execution to the device. - auto &&ThenGen = [&BasePointers, &Pointers, &Sizes, &MapTypes, Device, -OutlinedFnID, OffloadError, -&D](CodeGenFunction &CGF, PrePostActionTy &) { + auto &&ThenGen = [this, &BasePointers, &Pointers, &Sizes, &MapTypes, Device, +OutlinedFn, OutlinedFnID, &D, +&KernelArgs](CodeGenFunction &CGF, PrePostActionTy &) { auto &RT = CGF.CGM.getOpenMPRuntime(); // Emit the offloading arrays. TargetDataInfo Info; @@ -7034,13 +7023,26 @@ void CGOpenMPRuntime::emitTargetCall(Cod OffloadingArgs); } -CGF.EmitStoreOfScalar(Return, OffloadError); +// Check the error code and execute the host version if required. +llvm::BasicBlock *OffloadFailedBlock = +CGF.createBasicBlock("omp_offload.failed"); +llvm::BasicBlock *OffloadContBlock = +CGF.createBasicBlock("omp_offload.cont"); +llvm::Value *Failed = CGF.Builder.CreateIsNotNull(Return); +CGF.Builder.CreateCondBr(Failed, OffloadFailedBlock, OffloadContBlock); + +CGF.EmitBlock(OffloadFailedBlock); +emitOutlinedFunctionCall(CGF, D.getLocStart(), OutlinedFn, KernelArgs); +CGF.EmitBranch(OffloadContBlock); + +CGF.EmitBlock(OffloadContBlock, /*IsFinished=*/true); }; // Notify that the host version must be executed. - auto &&ElseGen = [OffloadError](CodeGenFunction &CGF, PrePostActionTy &) { -CGF.EmitStoreOfScalar(llvm::ConstantInt::get(CGF.Int32Ty, /*V=*/-1u), - OffloadError); + auto &&ElseGen = [this, &D, OutlinedFn, &KernelArgs](CodeGenFunction &CGF, + PrePostActionTy &) { +emitOutlinedFunctionCall(CGF, D.getLocStart(), OutlinedFn, + KernelArgs); }; // If we have a target function ID it means that we need to support @@ -7058,19 +7060,6 @@ void CGOpenMPRuntime::emitTargetCall(Cod RegionCodeGenTy ElseRCG(ElseGen); ElseRCG(CGF); } - - // Check the error code and execute the host version if required. - auto OffloadFailedBlock = CGF.createBasicBlock("omp_offload.failed"); - auto OffloadContBlock = CGF.createBasicBlock("omp_offload.cont"); - auto OffloadErrorVal = CGF.EmitLoadOfScalar(OffloadError, SourceLocation()); - auto Failed = CGF.Builder.CreateIsNotNull(OffloadErrorVal); - CGF.Builder.CreateCondBr(Failed, OffloadFailedBlock, OffloadContBlock); - - CGF.EmitBlock(OffloadFailedBlock); - emitOutlinedFunctionCall(CGF, D.getLocStart(), OutlinedFn, KernelArgs); - CGF.EmitBranch(OffloadContBlock); - - CGF.EmitBlock(OffloadContBlock, /*IsFinished=*/true); } void CGOpenMPRuntime::scanForTargetRegionsFunctions(const Stmt *S, Modified: cfe/trunk/test/OpenMP/target_codegen.cpp URL: http://llvm.org/viewvc/llvm-projec
[PATCH] D38458: Fix assertion failure in thread safety analysis (PR34800).
alexfh added inline comments. Comment at: include/clang/Analysis/Analyses/ThreadSafetyTIL.h:931-936 +if (!SlotName) { + std::string Buffer; + llvm::raw_string_ostream OS(Buffer); + Cvdecl->printName(OS); + SlotName = OS.str(); +} BTW, alternatively, I could do: ``` if (!SlotName) { SlotName = ""; llvm::raw_string_ostream OS(*SlotName); Cvdecl->printName(OS); } ``` Not sure which of these would be preferred in this code. https://reviews.llvm.org/D38458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314673 - [OPENMP] Fix test, NFC.
Author: abataev Date: Mon Oct 2 07:35:31 2017 New Revision: 314673 URL: http://llvm.org/viewvc/llvm-project?rev=314673&view=rev Log: [OPENMP] Fix test, NFC. Modified: cfe/trunk/test/OpenMP/target_codegen.cpp Modified: cfe/trunk/test/OpenMP/target_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen.cpp?rev=314673&r1=314672&r2=314673&view=diff == --- cfe/trunk/test/OpenMP/target_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/target_codegen.cpp Mon Oct 2 07:35:31 2017 @@ -183,7 +183,7 @@ int foo(int n) { // CHECK: [[CNSIZE:%.+]] = mul nuw i[[SZ]] [[CNELEMSIZE2]], 8 // CHECK: [[IF:%.+]] = icmp sgt i32 {{[^,]+}}, 20 - // CHECK: br i1 [[IF]], label %[[TRY:[^,]+]], label %[[FAIL:[^,]+]] + // CHECK: br i1 [[IF]], label %[[TRY:[^,]+]], label %[[IFELSE:[^,]+]] // CHECK: [[TRY]] // CHECK-DAG: [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 9, i8** [[BPR:%[^,]+]], i8** [[PR:%[^,]+]], i[[SZ]]* [[SR:%[^,]+]], i32* getelementptr inbounds ([9 x i32], [9 x i32]* [[MAPT4]], i32 0, i32 0)) // CHECK-DAG: [[BPR]] = getelementptr inbounds [9 x i8*], [9 x i8*]* [[BP:%[^,]+]], i32 0, i32 0 @@ -459,7 +459,7 @@ int bar(int n){ // CHECK: [[CSIZE:%.+]] = mul nuw i[[SZ]] [[CELEMSIZE2]], 2 // CHECK: [[IF:%.+]] = icmp sgt i32 {{[^,]+}}, 60 -// CHECK: br i1 [[IF]], label %[[TRY:[^,]+]], label %[[FAIL:[^,]+]] +// CHECK: br i1 [[IF]], label %[[TRY:[^,]+]], label %[[IFELSE:[^,]+]] // CHECK: [[TRY]] // CHECK-DAG: [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 5, i8** [[BPR:%[^,]+]], i8** [[PR:%[^,]+]], i[[SZ]]* [[SR:%[^,]+]], i32* getelementptr inbounds ([5 x i32], [5 x i32]* [[MAPT7]], i32 0, i32 0)) // CHECK-DAG: [[BPR]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BP:%.+]], i32 0, i32 0 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38460: [CodeGen] Fix propagation of TBAA info for atomic accesses
kosarev created this revision. kosarev added a project: clang. This patch fixes clang to propagate complete TBAA information for atomic accesses and not just the final access types. Prepared against https://reviews.llvm.org/D38456 and requires it to be committed first. This is part of https://reviews.llvm.org/D37826 reworked to be a separate patch to simplify review. Repository: rL LLVM https://reviews.llvm.org/D38460 Files: lib/CodeGen/CGAtomic.cpp Index: lib/CodeGen/CGAtomic.cpp === --- lib/CodeGen/CGAtomic.cpp +++ lib/CodeGen/CGAtomic.cpp @@ -98,7 +98,7 @@ LVal = LValue::MakeBitfield(Address(Addr, lvalue.getAlignment()), BFI, lvalue.getType(), lvalue.getBaseInfo()); -LVal.setTBAAAccessType(lvalue.getTBAAAccessType()); +LVal.setTBAAInfo(lvalue.getTBAAInfo()); AtomicTy = C.getIntTypeForBitwidth(AtomicSizeInBits, OrigBFI.IsSigned); if (AtomicTy.isNull()) { llvm::APInt Size( @@ -1692,8 +1692,8 @@ DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } -UpdateLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); -DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); +UpdateLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); +DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); UpRVal = CGF.EmitLoadOfLValue(UpdateLVal, SourceLocation()); } // Store new value in the corresponding memory area @@ -1789,7 +1789,7 @@ DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } - DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); + DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); // Store new value in the corresponding memory area assert(UpdateRVal.isScalar()); CGF.EmitStoreThroughLValue(UpdateRVal, DesiredLVal); Index: lib/CodeGen/CGAtomic.cpp === --- lib/CodeGen/CGAtomic.cpp +++ lib/CodeGen/CGAtomic.cpp @@ -98,7 +98,7 @@ LVal = LValue::MakeBitfield(Address(Addr, lvalue.getAlignment()), BFI, lvalue.getType(), lvalue.getBaseInfo()); -LVal.setTBAAAccessType(lvalue.getTBAAAccessType()); +LVal.setTBAAInfo(lvalue.getTBAAInfo()); AtomicTy = C.getIntTypeForBitwidth(AtomicSizeInBits, OrigBFI.IsSigned); if (AtomicTy.isNull()) { llvm::APInt Size( @@ -1692,8 +1692,8 @@ DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } -UpdateLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); -DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); +UpdateLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); +DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); UpRVal = CGF.EmitLoadOfLValue(UpdateLVal, SourceLocation()); } // Store new value in the corresponding memory area @@ -1789,7 +1789,7 @@ DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } - DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); + DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); // Store new value in the corresponding memory area assert(UpdateRVal.isScalar()); CGF.EmitStoreThroughLValue(UpdateRVal, DesiredLVal); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38425: [clangd] Document highlights for clangd
Nebiroth updated this revision to Diff 117351. Nebiroth marked 3 inline comments as done. Nebiroth added a comment. Addressed initial comments. Formatted ClangdUnit.h https://reviews.llvm.org/D38425 Files: clangd/ClangdLSPServer.cpp clangd/ClangdServer.cpp clangd/ClangdServer.h clangd/ClangdUnit.cpp clangd/ClangdUnit.h clangd/Protocol.cpp clangd/Protocol.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h test/clangd/documenthighlight.test Index: test/clangd/documenthighlight.test === --- /dev/null +++ test/clangd/documenthighlight.test @@ -0,0 +1,29 @@ +# RUN: clangd -run-synchronously < %s | FileCheck %s +# It is absolutely vital that this file has CRLF line endings. +# +Content-Length: 125 + +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} + +Content-Length: 455 + +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();}\n"}}} + +Content-Length: 156 + +{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}} +# Go to local variable +# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 16, "character": 4}, "end": {"line": 16, "character": 12}}, "number": 1},{"range": {"start": {"line": 17, "character": 0}, "end": {"line": 17, "character": 7}}, "number": 1}]} + +Content-Length: 157 + +{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":17}}} +# Go to local variable +# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 12, "character": 4}, "end": {"line": 12, "character": 9}}, "number": 1},{"range": {"start": {"line": 18, "character": 17}, "end": {"line": 18, "character": 21}}, "number": 1},{"range": {"start": {"line": 19, "character": 4}, "end": {"line": 19, "character": 8}}, "number": 1}]} + +Content-Length: 157 + +{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":21,"character":10}}} +# Go to local variable +# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 4, "character": 5}, "end": {"line": 4, "character": 22}}, "number": 1},{"range": {"start": {"line": 21, "character": 8}, "end": {"line": 21, "character": 25}}, "number": 1}]} + Index: clangd/ProtocolHandlers.h === --- clangd/ProtocolHandlers.h +++ clangd/ProtocolHandlers.h @@ -47,7 +47,9 @@ virtual void onCompletion(TextDocumentPositionParams Params, StringRef ID, JSONOutput &Out) = 0; virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID, -JSONOutput &Out) = 0; +JSONOutput &Out) = 0; + virtual void onDocumentHighlight(TextDocumentPositionParams Params, StringRef ID, +JSONOutput &Out) = 0; }; void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out, Index: clangd/ProtocolHandlers.cpp === --- clangd/ProtocolHandlers.cpp +++ clangd/ProtocolHandlers.cpp @@ -204,6 +204,24 @@ ProtocolCallbacks &Callbacks; }; +struct DocumentHighlightHandler : Handler { + DocumentHighlightHandler(JSONOutput &Output, ProtocolCallbacks &Callbacks) + : Handler(Output), Callbacks(Callbacks) {} + + void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override { +auto TDPP = TextDocumentPositionParams::parse(Params, Output); +if (!TDPP) { + Output.log("Failed to decode TextDocumentPositionParams!\n"); + return; +} + +Callbacks.onDocumentHighlight(*TDPP, ID, Output); + } + +private: + ProtocolCallbacks &Callbacks; +}; + } // namespace void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, @@ -240,4 +258,7 @@ Dispatcher.registerHandler( "textDocument/definition", llvm::make_unique(Out, Callbacks)); + Dispatcher.registerHandler( + "textDocument/documentHighlight", + llvm::make_unique(Out, Callbacks)); } Index: clangd/Protocol.h === --- clangd/Protocol.h +++ clangd/Protocol.h @@ -416,6 +416,41 @@ static std::string unparse(const CompletionItem &P); }; +enum class DocumentHighlightKind { + Text =
[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:1127 +// only consist of ObjC objects, and escapes of ObjC objects +// aren't so important (eg., retain count checker ignores them). +if (isa(Ex) || dcoughlin wrote: > Note that we do have other ObjC checkers that rely on escaping of ObjC > objects, such as the ObjCLoopChecker and ObjCDeallocChecker. I think having > the TODO is great, but I'd like you to remove the the bit about "escapes of > ObjC objects aren't so important". Hmm, should have double-checked. Will fix. Comment at: test/Analysis/objc-boxing.m:66 + BoxableStruct bs; + bs.str = strdup("dynamic string"); // The duped string shall be owned by val. + NSValue *val = @(bs); // no-warning dcoughlin wrote: > In this case the duped string is not owned by `val`. NSValue doesn't take > ownership of the string, so this *will* leak and we should warn about it. I mean, the pointer to the raw string is stored inside the `NSValue`, and can be used or freed from there. The caller can free this string by looking into the `val`, even though `val` itself won't release the pointer (i guess i messed up the comment again). From MallocChecker's perspective, this is an escape and no-warning. If we free the string in this function, it'd most likely cause use-after-free in the caller. I tested that the string is indeed not strduped during boxing: **`$ cat test.m`** ``` #import typedef struct __attribute__((objc_boxable)) { const char *str; } BoxableStruct; int main() { BoxableStruct bs; bs.str = strdup("dynamic string"); NSLog(@"%p\n", bs.str); NSValue *val = @(bs); BoxableStruct bs2; [val getValue:&bs2]; NSLog(@"%p\n", bs2.str); return 0; } ``` **`$ clang test.m -framework Foundation`** **`$ ./a.out`** ``` 2017-10-02 17:56:00.004 a.out[17933:1083757] 0x7ffd23407380 2017-10-02 17:56:00.004 a.out[17933:1083757] 0x7ffd23407380 ``` So it's possible to retrieve the exact same pointer from the boxed value. So if `val` is returned to the caller, like in the test, it shouldn't be freed. If the `NSValue` itself dies and never escapes, then of course it's a leak, but in order to see that we'd need to model contents of `NSValue`. https://reviews.llvm.org/D35216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r314677 - [clangd] Run clang-format on the source code. NFC.
Author: ibiryukov Date: Mon Oct 2 08:10:41 2017 New Revision: 314677 URL: http://llvm.org/viewvc/llvm-project?rev=314677&view=rev Log: [clangd] Run clang-format on the source code. NFC. Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.h Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.h?rev=314677&r1=314676&r2=314677&view=diff == --- clang-tools-extra/trunk/clangd/ProtocolHandlers.h (original) +++ clang-tools-extra/trunk/clangd/ProtocolHandlers.h Mon Oct 2 08:10:41 2017 @@ -50,11 +50,11 @@ public: virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID, JSONOutput &Out) = 0; virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID, -JSONOutput &Out) = 0; +JSONOutput &Out) = 0; }; void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out, - ProtocolCallbacks &Callbacks); + ProtocolCallbacks &Callbacks); } // namespace clangd } // namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r314678 - [clangd] Command line arg to specify compile_commands.json path
Author: ibiryukov Date: Mon Oct 2 08:13:20 2017 New Revision: 314678 URL: http://llvm.org/viewvc/llvm-project?rev=314678&view=rev Log: [clangd] Command line arg to specify compile_commands.json path Summary: Adds compileCommands command line argument to specify an absolute path directly to the requested compile_commands.json for flags. Reviewed By: ilya-biryukov Differential Revision: https://reviews.llvm.org/D37150 Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=314678&r1=314677&r2=314678&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Mon Oct 2 08:13:20 2017 @@ -196,8 +196,9 @@ void ClangdLSPServer::onSwitchSourceHead ClangdLSPServer::ClangdLSPServer(JSONOutput &Out, unsigned AsyncThreadsCount, bool SnippetCompletions, - llvm::Optional ResourceDir) -: Out(Out), CDB(/*Logger=*/Out), + llvm::Optional ResourceDir, + llvm::Optional CompileCommandsDir) +: Out(Out), CDB(/*Logger=*/Out, std::move(CompileCommandsDir)), Server(CDB, /*DiagConsumer=*/*this, FSProvider, AsyncThreadsCount, SnippetCompletions, /*Logger=*/Out, ResourceDir) {} Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=314678&r1=314677&r2=314678&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Mon Oct 2 08:13:20 2017 @@ -27,9 +27,13 @@ class JSONOutput; /// dispatch and ClangdServer together. class ClangdLSPServer : private DiagnosticsConsumer, private ProtocolCallbacks { public: + /// If \p CompileCommandsDir has a value, compile_commands.json will be + /// loaded only from \p CompileCommandsDir. Otherwise, clangd will look + /// for compile_commands.json in all parent directories of each file. ClangdLSPServer(JSONOutput &Out, unsigned AsyncThreadsCount, bool SnippetCompletions, - llvm::Optional ResourceDir); + llvm::Optional ResourceDir, + llvm::Optional CompileCommandsDir); /// 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 Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=314678&r1=314677&r2=314678&view=diff == --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original) +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Mon Oct 2 08:13:20 2017 @@ -8,10 +8,10 @@ //===-===// #include "GlobalCompilationDatabase.h" +#include "Logger.h" #include "clang/Tooling/CompilationDatabase.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "Logger.h" namespace clang { namespace clangd { @@ -38,8 +38,9 @@ tooling::CompileCommand getDefaultCompil } DirectoryBasedGlobalCompilationDatabase:: -DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger) -: Logger(Logger) {} +DirectoryBasedGlobalCompilationDatabase( +clangd::Logger &Logger, llvm::Optional CompileCommandsDir) +: Logger(Logger), CompileCommandsDir(std::move(CompileCommandsDir)) {} std::vector DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) { @@ -67,31 +68,50 @@ void DirectoryBasedGlobalCompilationData } tooling::CompilationDatabase * -DirectoryBasedGlobalCompilationDatabase::getCompilationDatabase(PathRef File) { - std::lock_guard Lock(Mutex); +DirectoryBasedGlobalCompilationDatabase::tryLoadDatabaseFromPath(PathRef File) { namespace path = llvm::sys::path; + auto CachedIt = CompilationDatabases.find(File); assert((path::is_absolute(File, path::Style::posix) || path::is_absolute(File, path::Style::windows)) && "path must be absolute"); - for (auto Path = path::parent_path(File); !Path.empty(); - Path = path::parent_path(Path)) { + if (CachedIt != CompilationDatabases.end(
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
This revision was automatically updated to reflect the committed changes. Closed by commit rL314678: [clangd] Command line arg to specify compile_commands.json path (authored by ibiryukov). Changed prior to commit: https://reviews.llvm.org/D37150?vs=117340&id=117354#toc Repository: rL LLVM https://reviews.llvm.org/D37150 Files: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp === --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp @@ -196,8 +196,9 @@ ClangdLSPServer::ClangdLSPServer(JSONOutput &Out, unsigned AsyncThreadsCount, bool SnippetCompletions, - llvm::Optional ResourceDir) -: Out(Out), CDB(/*Logger=*/Out), + llvm::Optional ResourceDir, + llvm::Optional CompileCommandsDir) +: Out(Out), CDB(/*Logger=*/Out, std::move(CompileCommandsDir)), Server(CDB, /*DiagConsumer=*/*this, FSProvider, AsyncThreadsCount, SnippetCompletions, /*Logger=*/Out, ResourceDir) {} Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp === --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp @@ -11,16 +11,22 @@ #include "JSONRPCDispatcher.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" #include "llvm/Support/Program.h" - #include #include #include #include using namespace clang; using namespace clang::clangd; +static llvm::cl::opt CompileCommandsDir( +"compile-commands-dir", +llvm::cl::desc("Specify a path to look for compile_commands.json. If path " + "is invalid, clangd will look in the current directory and " + "parent paths of each source file.")); + static llvm::cl::opt WorkerThreadsCount("j", llvm::cl::desc("Number of async workers used by clangd"), @@ -56,18 +62,37 @@ if (RunSynchronously) WorkerThreadsCount = 0; + /// Validate command line arguments. llvm::raw_ostream &Outs = llvm::outs(); llvm::raw_ostream &Logs = llvm::errs(); JSONOutput Out(Outs, Logs); - // Change stdin to binary to not lose \r\n on windows. - llvm::sys::ChangeStdinToBinary(); + // If --compile-commands-dir arg was invoked, check value and override default + // path. + namespace path = llvm::sys::path; + llvm::Optional CompileCommandsDirPath; + + if (CompileCommandsDir.empty()) { +CompileCommandsDirPath = llvm::None; + } else if (!llvm::sys::path::is_absolute(CompileCommandsDir) || + !llvm::sys::fs::exists(CompileCommandsDir)) { +llvm::errs() << "Path specified by --compile-commands-dir either does not " +"exist or is not an absolute " +"path. The argument will be ignored.\n"; +CompileCommandsDirPath = llvm::None; + } else { +CompileCommandsDirPath = CompileCommandsDir; + } llvm::Optional ResourceDirRef = None; if (!ResourceDir.empty()) ResourceDirRef = ResourceDir; + /// Change stdin to binary to not lose \r\n on windows. + llvm::sys::ChangeStdinToBinary(); + + /// Initialize and run ClangdLSPServer. ClangdLSPServer LSPServer(Out, WorkerThreadsCount, EnableSnippets, -ResourceDirRef); +ResourceDirRef, CompileCommandsDirPath); LSPServer.run(std::cin); } Index: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h === --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h @@ -47,15 +47,17 @@ class DirectoryBasedGlobalCompilationDatabase : public GlobalCompilationDatabase { public: - DirectoryBasedGlobalCompilationDatabase(clangd::Logger &Logger); + DirectoryBasedGlobalCompilationDatabase( + clangd::Logger &Logger, llvm::Optional CompileCommandsDir); std::vector getCompileCommands(PathRef File) override; void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags); private: tooling::CompilationDatabase *getCompilationDatabase(PathRef File); + tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File); std::mutex Mutex; /// Caches compilation databases loaded from directories(keys are @@ -67,6 +69,9 @@ llvm::StringMap> ExtraFlagsForFile; /// Used for logging. clangd::Logger &Logger; + /// Used for command argument pointing to fo
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
ilya-biryukov added a comment. Did a minor rename and added a few `std::move`s before submitting. Was not worth another round of code review. Repository: rL LLVM https://reviews.llvm.org/D37150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37973: [clang-format] Fix regression about short functions after #else
sammccall accepted this revision. sammccall added a comment. This revision is now accepted and ready to land. This test looks like it was intended to catch some case, maybe we're now mishandling some case like if (foo) { } else { // this can now be merged } But there's no testcase and I'm guessing, so let's fix the `#else` bug :-) https://reviews.llvm.org/D37973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314683 - [clang-format] Fix regression about short functions after #else
Author: krasimir Date: Mon Oct 2 08:53:37 2017 New Revision: 314683 URL: http://llvm.org/viewvc/llvm-project?rev=314683&view=rev Log: [clang-format] Fix regression about short functions after #else Summary: This patch fixes a regression introduced in r312904, where the formatter confuses the `else` in `#else` with an `else` of an `if-else` statement. For example, formatting this code with google style ``` #ifdef A int f() {} #else int f() {} #endif ``` resulted in ``` #ifdef A int f() {} #else int f() { } #endif ``` Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37973 Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=314683&r1=314682&r2=314683&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Mon Oct 2 08:53:37 2017 @@ -466,8 +466,7 @@ private: // Check that the current line allows merging. This depends on whether we // are in a control flow statements as well as several style flags. if (Line.First->isOneOf(tok::kw_else, tok::kw_case) || -(Line.First->Next && Line.First->Next->is(tok::kw_else)) || -(I != AnnotatedLines.begin() && I[-1]->Last->is(tok::kw_else))) +(Line.First->Next && Line.First->Next->is(tok::kw_else))) return 0; if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::kw_try, tok::kw___try, tok::kw_catch, tok::kw___finally, Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=314683&r1=314682&r2=314683&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Oct 2 08:53:37 2017 @@ -7102,6 +7102,16 @@ TEST_F(FormatTest, SplitEmptyFunction) { "}", Style); } +TEST_F(FormatTest, KeepShortFunctionAfterPPElse) { + FormatStyle Style = getLLVMStyle(); + Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All; + verifyFormat("#ifdef A\n" + "int f() {}\n" + "#else\n" + "int g() {}\n" + "#endif", + Style); +} TEST_F(FormatTest, SplitEmptyClass) { FormatStyle Style = getLLVMStyle(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37973: [clang-format] Fix regression about short functions after #else
This revision was automatically updated to reflect the committed changes. Closed by commit rL314683: [clang-format] Fix regression about short functions after #else (authored by krasimir). Repository: rL LLVM https://reviews.llvm.org/D37973 Files: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp cfe/trunk/unittests/Format/FormatTest.cpp Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp === --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp @@ -466,8 +466,7 @@ // Check that the current line allows merging. This depends on whether we // are in a control flow statements as well as several style flags. if (Line.First->isOneOf(tok::kw_else, tok::kw_case) || -(Line.First->Next && Line.First->Next->is(tok::kw_else)) || -(I != AnnotatedLines.begin() && I[-1]->Last->is(tok::kw_else))) +(Line.First->Next && Line.First->Next->is(tok::kw_else))) return 0; if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::kw_try, tok::kw___try, tok::kw_catch, tok::kw___finally, Index: cfe/trunk/unittests/Format/FormatTest.cpp === --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -7102,6 +7102,16 @@ "}", Style); } +TEST_F(FormatTest, KeepShortFunctionAfterPPElse) { + FormatStyle Style = getLLVMStyle(); + Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All; + verifyFormat("#ifdef A\n" + "int f() {}\n" + "#else\n" + "int g() {}\n" + "#endif", + Style); +} TEST_F(FormatTest, SplitEmptyClass) { FormatStyle Style = getLLVMStyle(); Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp === --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp @@ -466,8 +466,7 @@ // Check that the current line allows merging. This depends on whether we // are in a control flow statements as well as several style flags. if (Line.First->isOneOf(tok::kw_else, tok::kw_case) || -(Line.First->Next && Line.First->Next->is(tok::kw_else)) || -(I != AnnotatedLines.begin() && I[-1]->Last->is(tok::kw_else))) +(Line.First->Next && Line.First->Next->is(tok::kw_else))) return 0; if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::kw_try, tok::kw___try, tok::kw_catch, tok::kw___finally, Index: cfe/trunk/unittests/Format/FormatTest.cpp === --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -7102,6 +7102,16 @@ "}", Style); } +TEST_F(FormatTest, KeepShortFunctionAfterPPElse) { + FormatStyle Style = getLLVMStyle(); + Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All; + verifyFormat("#ifdef A\n" + "int f() {}\n" + "#else\n" + "int g() {}\n" + "#endif", + Style); +} TEST_F(FormatTest, SplitEmptyClass) { FormatStyle Style = getLLVMStyle(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38463: [OpenCL] Fix checking of vector type casting
yaxunl created this revision. Currently clang allows the following code int a; int b = (const int) a; However it does not the following code int4 a; int4 b = (const int4) a; This is because Clang compares the qualified types instead of unqualified types for vector type casting, which causes the inconsistency. This patch fixes that. https://reviews.llvm.org/D38463 Files: lib/Sema/SemaExpr.cpp test/SemaOpenCL/vector_conv_invalid.cl Index: test/SemaOpenCL/vector_conv_invalid.cl === --- test/SemaOpenCL/vector_conv_invalid.cl +++ test/SemaOpenCL/vector_conv_invalid.cl @@ -5,10 +5,18 @@ typedef int int3 __attribute((ext_vector_type(3))); typedef unsigned uint3 __attribute((ext_vector_type(3))); -void vector_conv_invalid() { +void vector_conv_invalid(const global int4 *const_global_ptr) { uint4 u = (uint4)(1); int4 i = u; // expected-error{{initializing 'int4' (vector of 4 'int' values) with an expression of incompatible type 'uint4' (vector of 4 'unsigned int' values)}} int4 e = (int4)u; // expected-error{{invalid conversion between ext-vector type 'int4' (vector of 4 'int' values) and 'uint4' (vector of 4 'unsigned int' values)}} uint3 u4 = (uint3)u; // expected-error{{invalid conversion between ext-vector type 'uint3' (vector of 3 'unsigned int' values) and 'uint4' (vector of 4 'unsigned int' values)}} + + e = (const int4)i; + e = (constant int4)i; + e = (private int4)i; + + private int4 *private_ptr = (const private int4 *)const_global_ptr; // expected-error{{casting 'const __global int4 *' to type 'const int4 *' changes address space of pointer}} + global int4 *global_ptr = const_global_ptr; // expected-warning {{initializing '__global int4 *' with an expression of type 'const __global int4 *' discards qualifiers}} + global_ptr = (global int4 *)const_global_ptr; } Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -6033,9 +6033,9 @@ // In OpenCL, casts between vectors of different types are not allowed. // (See OpenCL 6.2). if (SrcTy->isVectorType()) { -if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) -|| (getLangOpts().OpenCL && -(DestTy.getCanonicalType() != SrcTy.getCanonicalType( { +if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) || +(getLangOpts().OpenCL && + !Context.hasSameUnqualifiedType(DestTy, SrcTy))) { Diag(R.getBegin(),diag::err_invalid_conversion_between_ext_vectors) << DestTy << SrcTy << R; return ExprError(); Index: test/SemaOpenCL/vector_conv_invalid.cl === --- test/SemaOpenCL/vector_conv_invalid.cl +++ test/SemaOpenCL/vector_conv_invalid.cl @@ -5,10 +5,18 @@ typedef int int3 __attribute((ext_vector_type(3))); typedef unsigned uint3 __attribute((ext_vector_type(3))); -void vector_conv_invalid() { +void vector_conv_invalid(const global int4 *const_global_ptr) { uint4 u = (uint4)(1); int4 i = u; // expected-error{{initializing 'int4' (vector of 4 'int' values) with an expression of incompatible type 'uint4' (vector of 4 'unsigned int' values)}} int4 e = (int4)u; // expected-error{{invalid conversion between ext-vector type 'int4' (vector of 4 'int' values) and 'uint4' (vector of 4 'unsigned int' values)}} uint3 u4 = (uint3)u; // expected-error{{invalid conversion between ext-vector type 'uint3' (vector of 3 'unsigned int' values) and 'uint4' (vector of 4 'unsigned int' values)}} + + e = (const int4)i; + e = (constant int4)i; + e = (private int4)i; + + private int4 *private_ptr = (const private int4 *)const_global_ptr; // expected-error{{casting 'const __global int4 *' to type 'const int4 *' changes address space of pointer}} + global int4 *global_ptr = const_global_ptr; // expected-warning {{initializing '__global int4 *' with an expression of type 'const __global int4 *' discards qualifiers}} + global_ptr = (global int4 *)const_global_ptr; } Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -6033,9 +6033,9 @@ // In OpenCL, casts between vectors of different types are not allowed. // (See OpenCL 6.2). if (SrcTy->isVectorType()) { -if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) -|| (getLangOpts().OpenCL && -(DestTy.getCanonicalType() != SrcTy.getCanonicalType( { +if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) || +(getLangOpts().OpenCL && + !Context.hasSameUnqualifiedType(DestTy, SrcTy))) { Diag(R.getBegin(),diag::err_invalid_conversion_between_ext_vectors) << DestTy << SrcTy << R; return ExprError(); ___ cfe-commits mailing list cfe-commits@lists.llvm.o
[PATCH] D38358: [analyzer] Fix autodetection of getSVal()'s type argument.
NoQ updated this revision to Diff 117360. NoQ added a comment. Yeah, nice catch. So we need to either always tell the checkers to specify their `CharTy` when they are dealing with void pointers, or to do our substitution consistently, not only for `SymbolicRegion` but also for `AllocaRegion` (did that in this diff). https://reviews.llvm.org/D38358 Files: lib/StaticAnalyzer/Core/RegionStore.cpp test/Analysis/ctor.mm test/Analysis/exercise-ps.c test/Analysis/gtest.cpp Index: test/Analysis/gtest.cpp === --- test/Analysis/gtest.cpp +++ test/Analysis/gtest.cpp @@ -151,3 +151,17 @@ ASSERT_TRUE(false); clang_analyzer_warnIfReached(); // no-warning } + +void testAssertSymbolicPtr(const bool *b) { + ASSERT_TRUE(*b); // no-crash + + // FIXME: Our solver doesn't handle this well yet. + clang_analyzer_eval(*b); // expected-warning{{UNKNOWN}} +} + +void testAssertSymbolicRef(const bool &b) { + ASSERT_TRUE(b); // no-crash + + // FIXME: Our solver doesn't handle this well yet. + clang_analyzer_eval(b); // expected-warning{{UNKNOWN}} +} Index: test/Analysis/exercise-ps.c === --- test/Analysis/exercise-ps.c +++ test/Analysis/exercise-ps.c @@ -21,3 +21,11 @@ memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring library function 'memcpy' with type 'void *(void *, const void *}} \ // expected-note{{include the header or explicitly provide a declaration for 'memcpy'}} } + +// AllocaRegion is untyped. Void pointer isn't of much help either. Before +// realizing that the value is undefined, we need to somehow figure out +// what type of value do we expect. +void f3(void *dest) { + void *src = __builtin_alloca(5); + memcpy(dest, src, 1); // expected-warning{{2nd function call argument is a pointer to uninitialized value}} +} Index: test/Analysis/ctor.mm === --- test/Analysis/ctor.mm +++ test/Analysis/ctor.mm @@ -199,7 +199,7 @@ Inner p; }; - void testPOD() { + void testPOD(const POD &pp) { POD p; p.x = 1; POD p2 = p; // no-warning @@ -210,6 +210,15 @@ // Use rvalues as well. clang_analyzer_eval(POD(p3).x == 1); // expected-warning{{TRUE}} +// Copy from symbolic references correctly. +POD p4 = pp; +// Make sure that p4.x contains a symbol after copy. +if (p4.x > 0) + clang_analyzer_eval(p4.x > 0); // expected-warning{{TRUE}} +// FIXME: Element region gets in the way, so these aren't the same symbols +// as they should be. +clang_analyzer_eval(pp.x == p4.x); // expected-warning{{UNKNOWN}} + PODWrapper w; w.p.y = 1; PODWrapper w2 = w; // no-warning Index: lib/StaticAnalyzer/Core/RegionStore.cpp === --- lib/StaticAnalyzer/Core/RegionStore.cpp +++ lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1393,16 +1393,19 @@ return UnknownVal(); } - if (isa(MR) || - isa(MR) || - isa(MR)) { + if (!isa(MR)) { if (T.isNull()) { if (const TypedRegion *TR = dyn_cast(MR)) -T = TR->getLocationType(); - else { -const SymbolicRegion *SR = cast(MR); -T = SR->getSymbol()->getType(); - } +T = TR->getLocationType()->getPointeeType(); + else if (const SymbolicRegion *SR = dyn_cast(MR)) +T = SR->getSymbol()->getType()->getPointeeType(); + else if (isa(MR)) +T = Ctx.VoidTy; +} +assert(!T.isNull() && "Unable to auto-detect binding type!"); +if (T->isVoidType()) { + // When trying to dereference a void pointer, read the first byte. + T = Ctx.CharTy; } MR = GetElementZeroRegion(cast(MR), T); } Index: test/Analysis/gtest.cpp === --- test/Analysis/gtest.cpp +++ test/Analysis/gtest.cpp @@ -151,3 +151,17 @@ ASSERT_TRUE(false); clang_analyzer_warnIfReached(); // no-warning } + +void testAssertSymbolicPtr(const bool *b) { + ASSERT_TRUE(*b); // no-crash + + // FIXME: Our solver doesn't handle this well yet. + clang_analyzer_eval(*b); // expected-warning{{UNKNOWN}} +} + +void testAssertSymbolicRef(const bool &b) { + ASSERT_TRUE(b); // no-crash + + // FIXME: Our solver doesn't handle this well yet. + clang_analyzer_eval(b); // expected-warning{{UNKNOWN}} +} Index: test/Analysis/exercise-ps.c === --- test/Analysis/exercise-ps.c +++ test/Analysis/exercise-ps.c @@ -21,3 +21,11 @@ memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring library function 'memcpy' with type 'void *(void *, const void *}} \ // expected-note{{include the header or explicitly provide a declaration for 'memcpy'}} } + +// AllocaRegion is untyped. Void pointer isn't of much help either. Before +// realizing that the v
[PATCH] D38303: [Sema] Correct IUnknown to support Unknwnbase.h Header.
erichkeane added a comment. @chapuni Thanks for the fix! That 'novtable' line is there simply because that is supposed to be a minimized replica of what happens in the UnknwnBase.h header. I'll likely just remove the attribute and your fix, since the warning itself isn't important to the test itself otherwise. Thanks! Repository: rL LLVM https://reviews.llvm.org/D38303 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33029: [clang-format] add option for dangling parenthesis
stringham added a comment. @djasper should I move forward with extending the BracketAlignmentStyle option? I'm happy to do it, but I'd like to get the idea signed off on before I spend more time working on it. We've been using a version of clang-format with these changes since May, and we've been happy with it. Does my current approach seem reasonable, or should I follow a different pattern? https://reviews.llvm.org/D33029 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.
MontyKutyi updated this revision to Diff 117367. MontyKutyi added a comment. Updated to the latest trunk version. https://reviews.llvm.org/D34030 Files: include/clang/AST/RecursiveASTVisitor.h unittests/AST/PostOrderASTVisitor.cpp Index: unittests/AST/PostOrderASTVisitor.cpp === --- unittests/AST/PostOrderASTVisitor.cpp +++ unittests/AST/PostOrderASTVisitor.cpp @@ -15,6 +15,7 @@ #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Tooling/Tooling.h" #include "gtest/gtest.h" +#include using namespace clang; @@ -75,7 +76,33 @@ } }; -} + +// Serializes the AST. It is not complete! It only serializes the Statement +// and the Declaration nodes. +class ASTSerializerVisitor : public RecursiveASTVisitor { +private: + std::vector &VisitedNodes; + const bool PostOrderTraverse; + +public: + ASTSerializerVisitor(bool PostOrderTraverse, + std::vector &VisitedNodes) + : VisitedNodes(VisitedNodes), PostOrderTraverse(PostOrderTraverse) {} + + bool shouldTraversePostOrder() const { return PostOrderTraverse; } + + bool VisitStmt(Stmt *S) { +VisitedNodes.push_back(S); +return true; + } + + bool VisitDecl(Decl *D) { +VisitedNodes.push_back(D); +return true; + } +}; + +} // anonymous namespace TEST(RecursiveASTVisitor, PostOrderTraversal) { auto ASTUnit = tooling::buildASTFromCode( @@ -126,3 +153,30 @@ ASSERT_EQ(expected[I], Visitor.VisitedNodes[I]); } } + +TEST(RecursiveASTVisitor, PrePostComparisonTest) { + auto ASTUnit = tooling::buildASTFromCode("template class X {};" + "template class X;"); + + auto TU = ASTUnit->getASTContext().getTranslationUnitDecl(); + + std::vector PreorderNodeList, PostorderNodeList; + + ASTSerializerVisitor PreVisitor(false, PreorderNodeList); + PreVisitor.TraverseTranslationUnitDecl(TU); + + ASTSerializerVisitor PostVisitor(true, PostorderNodeList); + PostVisitor.TraverseTranslationUnitDecl(TU); + + // The number of visited nodes must be independent of the ordering mode. + ASSERT_EQ(PreorderNodeList.size(), PostorderNodeList.size()); + + std::sort(PreorderNodeList.begin(), PreorderNodeList.end()); + std::sort(PostorderNodeList.begin(), PostorderNodeList.end()); + + // Both traversal must visit the same nodes. + ASSERT_EQ(std::mismatch(PreorderNodeList.begin(), PreorderNodeList.end(), + PostorderNodeList.begin()) +.first, +PreorderNodeList.end()); +} Index: include/clang/AST/RecursiveASTVisitor.h === --- include/clang/AST/RecursiveASTVisitor.h +++ include/clang/AST/RecursiveASTVisitor.h @@ -1835,11 +1835,10 @@ TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); \ if (!getDerived().shouldVisitTemplateInstantiations() && \ D->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) \ - /* Returning from here skips traversing the \ - declaration context of the *TemplateSpecializationDecl \ - (embedded in the DEF_TRAVERSE_DECL() macro) \ - which contains the instantiated members of the template. */ \ - return true; \ + /* Skip traversing the declaration context of the \ + *TemplateSpecializationDecl (embedded in the DEF_TRAVERSE_DECL() \ + macro) which contains the instantiated members of the template. */ \ + ShouldVisitChildren = false; \ }) DEF_TRAVERSE_TMPL_SPEC_DECL(Class) Index: unittests/AST/PostOrderASTVisitor.cpp === --- unittests/AST/PostOrderASTVisitor.cpp +++ unittests/AST/PostOrderASTVisitor.cpp @@ -15,6 +15,7 @@ #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Tooling/Tooling.h" #include "gtest/gtest.h" +#include using namespace clang; @@ -75,7 +76,33 @@ } }; -} + +// Serializes the AST. It is not complete! It only serializes the Statement +// and the Declaration nodes. +class ASTSerializerVisitor : public RecursiveASTVisitor { +private: + std::vector &VisitedNodes; + const bool PostOrderTraverse; + +public: + ASTSerializerVisitor(bool PostOrderTraverse, + std::vector &VisitedNodes) + : VisitedNodes(VisitedNodes), PostOrderTraverse(PostOrderTraverse) {} + + bool shouldTraversePostOrder() const { return PostOrderTraverse; } + + bool VisitStmt(Stmt *S) { +VisitedNodes.push_back(S); +return true; + } + + bool VisitDecl(Decl *D) { +VisitedNodes.push_back(D); +return true; + } +}; + +} // anonymous namespace TEST(RecursiveASTVisitor, PostOrderTraversal) {
[PATCH] D38284: [clang-tidy] Fix google-readability-namespace-comments handling of C++17 nested namespaces
aaron.ballman added inline comments. Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:59 +static std::string getNamespaceComment(const std::string &s, + bool InsertLineBreak) { `s` should be renamed to `S` or something more descriptive that meets the coding guidelines. Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:92 + // to skip the next ones. + for (const auto &EndOfNameLocation : Ends) +if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin, While you *can* elide the braces for the `for` loop, I think it looks a bit strange (we usually do it for `if` statements but not loops). You might want to put the braces back around the `for` loop body. Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:114 while (Lexer::getRawToken(Loc, Tok, Sources, getLangOpts()) || - Tok.is(tok::semi)) { + Tok.is(tok::semi)) Loc = Loc.getLocWithOffset(1); Same here. Comment at: clang-tidy/readability/NamespaceCommentCheck.h:37 const unsigned SpacesBeforeComments; + std::vector Ends; }; I thought your use of `SmallVector` was appropriate, I was just wondering about the use of `7` as the expected size. I would have imagined we could get away with 2-4. Comment at: test/clang-tidy/google-readability-nested-namespace-comments.cpp:6 + + //So that namespace is not empty. + void f(); Space between `//` and the start of the comment. https://reviews.llvm.org/D38284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37466: D37461: fixups for existing InlineAsm tests + adding new ones
rnk added inline comments. Comment at: test/CodeGen/ms-inline-asm.cpp:37-38 - int lvar = 10; - __asm mov eax, offset Foo::ptr - __asm mov eax, offset Foo::Bar::ptr -// CHECK-LABEL: define void @_Z2t2v() coby wrote: > rnk wrote: > > These don't seem tested anywhere now > I've tested them against msvc, and they are seem to be unsupported there as > well, so I don't see any value in keeping this one around :\ Got it. Can we make a negative test for offset with namespace separators then? Repository: rL LLVM https://reviews.llvm.org/D37466 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38458: Fix assertion failure in thread safety analysis (PR34800).
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! https://reviews.llvm.org/D38458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314686 - [OPENMP] Capture argument of `device` clause for target-based
Author: abataev Date: Mon Oct 2 09:32:39 2017 New Revision: 314686 URL: http://llvm.org/viewvc/llvm-project?rev=314686&view=rev Log: [OPENMP] Capture argument of `device` clause for target-based directives. The argument of the `device` clause in target-based executable directives must be captured to support codegen for the `target` directives with the `depend` clauses. Modified: cfe/trunk/include/clang/AST/OpenMPClause.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/lib/AST/OpenMPClause.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp cfe/trunk/test/OpenMP/target_codegen.cpp Modified: cfe/trunk/include/clang/AST/OpenMPClause.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=314686&r1=314685&r2=314686&view=diff == --- cfe/trunk/include/clang/AST/OpenMPClause.h (original) +++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Oct 2 09:32:39 2017 @@ -3141,7 +3141,7 @@ public: /// In this example directive '#pragma omp target' has clause 'device' /// with single expression 'a'. /// -class OMPDeviceClause : public OMPClause { +class OMPDeviceClause : public OMPClause, public OMPClauseWithPreInit { friend class OMPClauseReader; /// \brief Location of '('. SourceLocation LParenLoc; @@ -3161,16 +3161,19 @@ public: /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. /// - OMPDeviceClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, - SourceLocation EndLoc) - : OMPClause(OMPC_device, StartLoc, EndLoc), LParenLoc(LParenLoc), -Device(E) {} + OMPDeviceClause(Expr *E, Stmt *HelperE, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation EndLoc) + : OMPClause(OMPC_device, StartLoc, EndLoc), OMPClauseWithPreInit(this), +LParenLoc(LParenLoc), Device(E) { +setPreInitStmt(HelperE); + } /// \brief Build an empty clause. /// OMPDeviceClause() - : OMPClause(OMPC_device, SourceLocation(), SourceLocation()), -LParenLoc(SourceLocation()), Device(nullptr) {} + : OMPClause(OMPC_device, SourceLocation(), SourceLocation()), +OMPClauseWithPreInit(this), LParenLoc(SourceLocation()), +Device(nullptr) {} /// \brief Sets the location of '('. void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } /// \brief Returns the location of '('. Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=314686&r1=314685&r2=314686&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Oct 2 09:32:39 2017 @@ -3109,6 +3109,7 @@ bool RecursiveASTVisitor::Visit template bool RecursiveASTVisitor::VisitOMPDeviceClause(OMPDeviceClause *C) { + TRY_TO(VisitOMPClauseWithPreInit(C)); TRY_TO(TraverseStmt(C->getDevice())); return true; } Modified: cfe/trunk/lib/AST/OpenMPClause.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=314686&r1=314685&r2=314686&view=diff == --- cfe/trunk/lib/AST/OpenMPClause.cpp (original) +++ cfe/trunk/lib/AST/OpenMPClause.cpp Mon Oct 2 09:32:39 2017 @@ -60,6 +60,8 @@ const OMPClauseWithPreInit *OMPClauseWit return static_cast(C); case OMPC_thread_limit: return static_cast(C); + case OMPC_device: +return static_cast(C); case OMPC_default: case OMPC_proc_bind: case OMPC_final: @@ -83,7 +85,6 @@ const OMPClauseWithPreInit *OMPClauseWit case OMPC_capture: case OMPC_seq_cst: case OMPC_depend: - case OMPC_device: case OMPC_threads: case OMPC_simd: case OMPC_map: Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=314686&r1=314685&r2=314686&view=diff == --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Oct 2 09:32:39 2017 @@ -2091,6 +2091,7 @@ void CodeGenFunction::EmitOMPTeamsDistri void CodeGenFunction::EmitOMPTargetTeamsDistributeDirective( const OMPTargetTeamsDistributeDirective &S) { + OMPLexicalScope Scope(*this, S, /*AsInlined=*/true); CGM.getOpenMPRuntime().emitInlinedDirective( *this, OMPD_target_teams_distribute, [&S](CodeGenFunction &CGF, PrePostActionTy &) { @@ -2101,6 +2102,7 @@ void CodeGenFunction::EmitOMPTargetTeams void CodeGenFunction::EmitOMPTargetTeamsDistributeParallelForDirective
[PATCH] D38464: [clangd] less boilerplate in RPC dispatch
sammccall created this revision. Make the ProtocolHandlers glue between JSONRPCDispatcher and ClangdLSPServer generic. Eliminate small differences between methods, de-emphasize the unimportant distinction between notifications and methods. ClangdLSPServer is no longer responsible for producing a complete JSON-RPC response, just the JSON of the result object. (In future, we should move that JSON serialization out, too). Handler methods now take a context object that we may hang more functionality off in the future. Added documentation to ProtocolHandlers. https://reviews.llvm.org/D38464 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/JSONRPCDispatcher.cpp clangd/JSONRPCDispatcher.h clangd/Protocol.cpp clangd/Protocol.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h test/clangd/fixits.test Index: test/clangd/fixits.test === --- test/clangd/fixits.test +++ test/clangd/fixits.test @@ -15,13 +15,13 @@ {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}} # -# CHECK: {"jsonrpc":"2.0","id":2, "result": [{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}] +# CHECK: {"jsonrpc":"2.0","id":2,"result":[{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}] # Content-Length: 771 {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"code":"1","source":"foo","message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}} # Make sure unused "code" and "source" fields ignored gracefully -# CHECK: {"jsonrpc":"2.0","id":2, "result": [{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}] +# CHECK: {"jsonrpc":"2.0","id":2,"result":[{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {
[PATCH] D38464: [clangd] less boilerplate in RPC dispatch
sammccall updated this revision to Diff 117374. sammccall added a comment. - clang-format https://reviews.llvm.org/D38464 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/JSONRPCDispatcher.cpp clangd/JSONRPCDispatcher.h clangd/Protocol.cpp clangd/Protocol.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h test/clangd/fixits.test Index: test/clangd/fixits.test === --- test/clangd/fixits.test +++ test/clangd/fixits.test @@ -15,13 +15,13 @@ {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}} # -# CHECK: {"jsonrpc":"2.0","id":2, "result": [{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}] +# CHECK: {"jsonrpc":"2.0","id":2,"result":[{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}] # Content-Length: 771 {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"code":"1","source":"foo","message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}} # Make sure unused "code" and "source" fields ignored gracefully -# CHECK: {"jsonrpc":"2.0","id":2, "result": [{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}] +# CHECK: {"jsonrpc":"2.0","id":2,"result":[{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}] # Content-Length: 44 Index: clangd/ProtocolHandlers.h === --- clangd/ProtocolHandlers.h +++ clangd
r314687 - Update IUnknown lit test to pass on Win32
Author: erichkeane Date: Mon Oct 2 09:49:32 2017 New Revision: 314687 URL: http://llvm.org/viewvc/llvm-project?rev=314687&view=rev Log: Update IUnknown lit test to pass on Win32 Modified: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp Modified: cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp?rev=314687&r1=314686&r2=314687&view=diff == --- cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp (original) +++ cfe/trunk/test/SemaCXX/ms-iunknown-template-function.cpp Mon Oct 2 09:49:32 2017 @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -fms-extensions %s +// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s +// expected-no-diagnostics typedef long HRESULT; typedef unsigned long ULONG; typedef struct _GUID { @@ -15,8 +16,7 @@ typedef GUID IID; extern "C" { extern "C++" { -// expected-warning@+1 {{__declspec attribute 'novtable'}} -struct __declspec(uuid("---C000-0046")) __declspec(novtable) +struct __declspec(uuid("---C000-0046")) IUnknown { public: virtual HRESULT __stdcall QueryInterface( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38456: [CodeGen] Introduce generic TBAA access descriptors
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. LGTM. Repository: rL LLVM https://reviews.llvm.org/D38456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38460: [CodeGen] Fix propagation of TBAA info for atomic accesses
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. LGTM, but is there a reason this isn't just part of that patch? Repository: rL LLVM https://reviews.llvm.org/D38460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.
dcoughlin accepted this revision. dcoughlin added inline comments. This revision is now accepted and ready to land. Comment at: test/Analysis/objc-boxing.m:66 + BoxableStruct bs; + bs.str = strdup("dynamic string"); // The duped string shall be owned by val. + NSValue *val = @(bs); // no-warning NoQ wrote: > dcoughlin wrote: > > In this case the duped string is not owned by `val`. NSValue doesn't take > > ownership of the string, so this *will* leak and we should warn about it. > I mean, the pointer to the raw string is stored inside the `NSValue`, and can > be used or freed from there. The caller can free this string by looking into > the `val`, even though `val` itself won't release the pointer (i guess i > messed up the comment again). From MallocChecker's perspective, this is an > escape and no-warning. If we free the string in this function, it'd most > likely cause use-after-free in the caller. > > I tested that the string is indeed not strduped during boxing: > > **`$ cat test.m`** > ``` > #import > > typedef struct __attribute__((objc_boxable)) { > const char *str; > } BoxableStruct; > > int main() { > BoxableStruct bs; > bs.str = strdup("dynamic string"); > NSLog(@"%p\n", bs.str); > > NSValue *val = @(bs); > > BoxableStruct bs2; > [val getValue:&bs2]; > NSLog(@"%p\n", bs2.str); > > return 0; > } > ``` > **`$ clang test.m -framework Foundation`** > **`$ ./a.out`** > ``` > 2017-10-02 17:56:00.004 a.out[17933:1083757] 0x7ffd23407380 > 2017-10-02 17:56:00.004 a.out[17933:1083757] 0x7ffd23407380 > ``` > So it's possible to retrieve the exact same pointer from the boxed value. So > if `val` is returned to the caller, like in the test, it shouldn't be freed. > > If the `NSValue` itself dies and never escapes, then of course it's a leak, > but in order to see that we'd need to model contents of `NSValue`. You're absolutely right about this. The documentation for NSValue even states: "Important: The NSValue object doesn’t copy the contents of the string, but the pointer itself. If you create an NSValue object with an allocated data item, don’t free the data’s memory while the NSValue object exists." Sorry! My mistake. https://reviews.llvm.org/D35216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24933: Enable configuration files in clang
sepavloff added a comment. Here is a list of design solutions used in this implementation of config files. **How config file is specified** There are two ways to specify config file: - To encode it into executable file name, such as `foo-clang`, - To pass config file in command line arguments. There were no objections to the variant `foo-clang`. It can be considered as a natural extension of the existing mechanism, in which invocation of `foo-clang` is equivalent to specifying target in command line: `clang --target=foo`. Config file allows to specify more than one option and its name is not confined to the registered targets. As for specifying config file in command line, there are two variants: - Use existing construct `@foo`. - Use special command line option `--config foo`. Each way has own advantages. Construct `@file` allows to reuse existing command line syntax. Indeed, config file is a collection of command line arguments and `@file` is just a way to inserts such arguments from a file. Config file may include other files and it uses `@file` with the exception that `file` is resolved relative to the including file, not to current directory. Config file could be considered as an extension of existing mechanism provided by `@file`. Using `@file` creates compatibility issues, because existing use of `@file` must not be broken. Obviously the file in `@file` may be treated as configuration only if it cannot be treated according to the existing semantics. Possible solution is to try loading `file` as configuration if it does not contain path separator and is not found in current directory. The drawback of this syntax is that the meaning of `@foo` in the invocation `clang @foo abc.cpp` depends on the content of current directory. If it contains file `foo`, `@foo` is an expansion of response file, otherwise it specifies a config file. This behavior causes error if current directory accidentally contains a file with the same name as the specified config file. Using dedicated option to apply config file makes the intention explicit. It also allow to use config files from arbitrary places. For instance, invocation `clang --config ./foo` allows to treat file `foo` in current directory as config file. Although config file contains command line arguments as conventional response file, it differs from the latter: - It resolves nested `@file` constructs differently, relative to including file, not current directory. - File is searched for in predefined set of directories, not in the current only. - Config file is more like a part of working environment. For instance, clang based SDK supplier could deliver a set config files as a part of their product. Response file in contrast is more close to transient build data, often generated by some tool. - Warning about unused options are suppressed in config files. - There was a proposal to extend syntax of config file to enable comments and using trailing backslash to split long lines, although these extensions are useful for response files as well. So, maybe, loading config file deserves a special option. This way has advantages: - it expresses intentions explicitly and reduce risk of accidental errors, - it allows using absolute paths to specify config file. **Where config files reside** There may be several places where config files can be kept: - Directory where clang executable resides. It is convenient for SDK developers as it simplifies packaging. User can use several instances of clang at the same time, they still may use their own set of config files without conflicts. - System directory (for instance, /etc/llvm), that keeps config files for use by several users. Such case is interesting for OS distribution maintainers and SDK developers. - User directory (for instance, ~/.llvm). A user can collect config file that tune compiler for their tasks in this directory and use them to select particular option set. - Config file can be specified by path, as in `clang --config ./foo`. This is convenient for developers to ensure that particular configuration is selected. For the sake of flexibility it make sense to enable all these locations as they are useful in different scenarios. Location of user and system directories are specified at configuration, by default they are absent. If user directory is specified, it should have higher priority over other places for search so that user could correct system supplied option sets. **Driver mode** If config file is encoded in executable name, such as `foo-clang`, there is concern of using different driver modes. What config file should be searched for if compiler is called as `foo-cpp`, `foo-cl` etc? These tools support different set of options, so a flexible solution should provide possibility to specify different config files for different driver modes. Clang implements flexible scheme of tool naming, in which a tool name has components: --[-][] The part
r314689 - Revert "[Sema] Warn on attribute nothrow conflicting with language specifiers"
Author: rnk Date: Mon Oct 2 10:16:14 2017 New Revision: 314689 URL: http://llvm.org/viewvc/llvm-project?rev=314689&view=rev Log: Revert "[Sema] Warn on attribute nothrow conflicting with language specifiers" This reverts r314461. It is warning on user code that uses END_COM_MAP(), which expands to declare QueryInterface with conflicting exception specifers. I've spent a while trying to understand why, but haven't been able to extract a reduced test case. Let's revert and I'll keep trying. Removed: cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDeclAttr.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=314689&r1=314688&r2=314689&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 2 10:16:14 2017 @@ -1419,10 +1419,6 @@ def err_noexcept_needs_constant_expressi "argument to noexcept specifier must be a constant expression">; def err_exception_spec_not_parsed : Error< "exception specification is not available until end of class definition">; -def warn_nothrow_attr_disagrees_with_exception_specification -: ExtWarn<"attribute 'nothrow' ignored due to conflicting exception " - "specification">, - InGroup; // C++ access checking def err_class_redeclared_with_different_access : Error< Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=314689&r1=314688&r2=314689&view=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Oct 2 10:16:14 2017 @@ -1985,25 +1985,6 @@ static void handleNoReturnAttr(Sema &S, Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); } -static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) { - assert(isa(D) && "attribute nothrow only valid on functions"); - - auto *FD = cast(D); - const auto *FPT = FD->getType()->getAs(); - - if (FPT && FPT->hasExceptionSpec() && - FPT->getExceptionSpecType() != EST_BasicNoexcept) { -S.Diag(Attrs.getLoc(), - diag::warn_nothrow_attr_disagrees_with_exception_specification); -S.Diag(FD->getExceptionSpecSourceRange().getBegin(), - diag::note_previous_decl) -<< "exception specification"; - } - - D->addAttr(::new (S.Context) NoThrowAttr( - Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); -} - static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (S.CheckNoCallerSavedRegsAttr(Attr)) @@ -6230,7 +6211,7 @@ static void ProcessDeclAttribute(Sema &S handleNoReturnAttr(S, D, Attr); break; case AttributeList::AT_NoThrow: -handleNoThrowAttr(S, D, Attr); +handleSimpleAttribute(S, D, Attr); break; case AttributeList::AT_CUDAShared: handleSharedAttr(S, D, Attr); Removed: cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp?rev=314688&view=auto == --- cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp (original) +++ cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp (removed) @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++14 - -struct S { - //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting exception specification}} - //expected-note@+1 {{exception specification declared here}} - __attribute__((nothrow)) S() noexcept(true); - //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting exception specification}} - //expected-note@+1 {{exception specification declared here}} - __attribute__((nothrow)) void Func1() noexcept(false); - __attribute__((nothrow)) void Func3() noexcept; -}; - -void throwing() noexcept(false); -void non_throwing(bool b = true) noexcept; - -template -struct T { -__attribute__((nothrow)) void f(Fn) noexcept(Fn()); -}; - -//expected-warning@-3 {{attribute 'nothrow' ignored due to conflicting exception specification}} -//expected-note@-4 {{exception specification declared here}} -template struct T; -template struct T; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38358: [analyzer] Fix autodetection of getSVal()'s type argument.
dcoughlin accepted this revision. dcoughlin added a comment. This revision is now accepted and ready to land. Looks great to me. I do wonder if long-term we should consider removing the auto-deduction when loading from the store. On the one hand it is really nice to avoid having to specify that at the call to getSVal(). On the other hand, this can lead to some really pathological weirdness and a bunch of corner-case code. For loads that result from actual program semantics the type of the loaded-from storage (from the loader's perspective) should always be easily available at the load site. There would still be cases where a checker might want to inspect what the store thinks is in memory, but I think that is a different function and in my opinion deserves a separate API. https://reviews.llvm.org/D38358 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38468: [CUDA] Fix name of __activemask()
Hahnfeld created this revision. The name has two underscores in the official CUDA documentation: http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#warp-vote-functions https://reviews.llvm.org/D38468 Files: lib/Headers/__clang_cuda_intrinsics.h Index: lib/Headers/__clang_cuda_intrinsics.h === --- lib/Headers/__clang_cuda_intrinsics.h +++ lib/Headers/__clang_cuda_intrinsics.h @@ -186,7 +186,7 @@ return __nvvm_vote_ballot_sync(mask, pred); } -inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); } +inline __device__ unsigned int __activemask() { return __nvvm_vote_ballot(1); } #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300 Index: lib/Headers/__clang_cuda_intrinsics.h === --- lib/Headers/__clang_cuda_intrinsics.h +++ lib/Headers/__clang_cuda_intrinsics.h @@ -186,7 +186,7 @@ return __nvvm_vote_ballot_sync(mask, pred); } -inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); } +inline __device__ unsigned int __activemask() { return __nvvm_vote_ballot(1); } #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r314689 - Revert "[Sema] Warn on attribute nothrow conflicting with language specifiers"
This is https://bugs.llvm.org/show_bug.cgi?id=34805 On Mon, Oct 2, 2017 at 10:16 AM, Reid Kleckner via cfe-commits wrote: > Author: rnk > Date: Mon Oct 2 10:16:14 2017 > New Revision: 314689 > > URL: http://llvm.org/viewvc/llvm-project?rev=314689&view=rev > Log: > Revert "[Sema] Warn on attribute nothrow conflicting with language specifiers" > > This reverts r314461. > > It is warning on user code that uses END_COM_MAP(), which expands to > declare QueryInterface with conflicting exception specifers. I've spent > a while trying to understand why, but haven't been able to extract a > reduced test case. Let's revert and I'll keep trying. > > Removed: > cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp > Modified: > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/lib/Sema/SemaDeclAttr.cpp > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=314689&r1=314688&r2=314689&view=diff > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 2 10:16:14 > 2017 > @@ -1419,10 +1419,6 @@ def err_noexcept_needs_constant_expressi >"argument to noexcept specifier must be a constant expression">; > def err_exception_spec_not_parsed : Error< >"exception specification is not available until end of class definition">; > -def warn_nothrow_attr_disagrees_with_exception_specification > -: ExtWarn<"attribute 'nothrow' ignored due to conflicting exception " > - "specification">, > - InGroup; > > // C++ access checking > def err_class_redeclared_with_different_access : Error< > > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=314689&r1=314688&r2=314689&view=diff > == > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Oct 2 10:16:14 2017 > @@ -1985,25 +1985,6 @@ static void handleNoReturnAttr(Sema &S, >Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); > } > > -static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) { > - assert(isa(D) && "attribute nothrow only valid on > functions"); > - > - auto *FD = cast(D); > - const auto *FPT = FD->getType()->getAs(); > - > - if (FPT && FPT->hasExceptionSpec() && > - FPT->getExceptionSpecType() != EST_BasicNoexcept) { > -S.Diag(Attrs.getLoc(), > - diag::warn_nothrow_attr_disagrees_with_exception_specification); > -S.Diag(FD->getExceptionSpecSourceRange().getBegin(), > - diag::note_previous_decl) > -<< "exception specification"; > - } > - > - D->addAttr(::new (S.Context) NoThrowAttr( > - Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); > -} > - > static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D, > const AttributeList &Attr) { >if (S.CheckNoCallerSavedRegsAttr(Attr)) > @@ -6230,7 +6211,7 @@ static void ProcessDeclAttribute(Sema &S > handleNoReturnAttr(S, D, Attr); > break; >case AttributeList::AT_NoThrow: > -handleNoThrowAttr(S, D, Attr); > +handleSimpleAttribute(S, D, Attr); > break; >case AttributeList::AT_CUDAShared: > handleSharedAttr(S, D, Attr); > > Removed: > cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp?rev=314688&view=auto > == > --- cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp > (original) > +++ cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp > (removed) > @@ -1,24 +0,0 @@ > -// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify > -std=c++14 > - > -struct S { > - //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting > exception specification}} > - //expected-note@+1 {{exception specification declared here}} > - __attribute__((nothrow)) S() noexcept(true); > - //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting > exception specification}} > - //expected-note@+1 {{exception specification declared here}} > - __attribute__((nothrow)) void Func1() noexcept(false); > - __attribute__((nothrow)) void Func3() noexcept; > -}; > - > -void throwing() noexcept(false); > -void non_throwing(bool b = true) noexcept; > - > -template > -struct T { > -__attribute__((nothrow)) void f(Fn) noexcept(Fn()); > -}; > - > -//expected-warning@-3 {{attribute 'nothrow' ignored due to conflicting > except
[PATCH] D38468: [CUDA] Fix name of __activemask()
jlebar accepted this revision. jlebar added a comment. This revision is now accepted and ready to land. Thank you for the fix! https://reviews.llvm.org/D38468 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314691 - [CUDA] Fix name of __activemask()
Author: hahnfeld Date: Mon Oct 2 10:50:11 2017 New Revision: 314691 URL: http://llvm.org/viewvc/llvm-project?rev=314691&view=rev Log: [CUDA] Fix name of __activemask() The name has two underscores in the official CUDA documentation: http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#warp-vote-functions Differential Revision: https://reviews.llvm.org/D38468 Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=314691&r1=314690&r2=314691&view=diff == --- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original) +++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Mon Oct 2 10:50:11 2017 @@ -186,7 +186,7 @@ inline __device__ unsigned int __ballot_ return __nvvm_vote_ballot_sync(mask, pred); } -inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); } +inline __device__ unsigned int __activemask() { return __nvvm_vote_ballot(1); } #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38468: [CUDA] Fix name of __activemask()
This revision was automatically updated to reflect the committed changes. Closed by commit rL314691: [CUDA] Fix name of __activemask() (authored by Hahnfeld). Changed prior to commit: https://reviews.llvm.org/D38468?vs=117384&id=117392#toc Repository: rL LLVM https://reviews.llvm.org/D38468 Files: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h === --- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h +++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h @@ -186,7 +186,7 @@ return __nvvm_vote_ballot_sync(mask, pred); } -inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); } +inline __device__ unsigned int __activemask() { return __nvvm_vote_ballot(1); } #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300 Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h === --- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h +++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h @@ -186,7 +186,7 @@ return __nvvm_vote_ballot_sync(mask, pred); } -inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); } +inline __device__ unsigned int __activemask() { return __nvvm_vote_ballot(1); } #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target
martell added a comment. `CODE_OWNERS.TXT` does not have a list of `driver` owners. It does have rsmith as an owner for all things not covered by someone else so I added him. Reid usually reviews driver patches I submit to clang and is on the owner list so I added him here initially. I think either should be fine. ping @rnk Repository: rL LLVM https://reviews.llvm.org/D38290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37115: [coroutines] Do not attempt to typo-correct when coroutine is looking for required members
GorNishanov added a comment. ping https://reviews.llvm.org/D37115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314692 - [Analyzer] Make testing scripts flake8 compliant
Author: george.karpenkov Date: Mon Oct 2 10:59:12 2017 New Revision: 314692 URL: http://llvm.org/viewvc/llvm-project?rev=314692&view=rev Log: [Analyzer] Make testing scripts flake8 compliant Differential Review: https://reviews.llvm.org/D38213 Modified: cfe/trunk/utils/analyzer/CmpRuns.py cfe/trunk/utils/analyzer/SATestAdd.py cfe/trunk/utils/analyzer/SATestBuild.py cfe/trunk/utils/analyzer/SATestUpdateDiffs.py cfe/trunk/utils/analyzer/SumTimerInfo.py cfe/trunk/utils/analyzer/ubiviz Modified: cfe/trunk/utils/analyzer/CmpRuns.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=314692&r1=314691&r2=314692&view=diff == --- cfe/trunk/utils/analyzer/CmpRuns.py (original) +++ cfe/trunk/utils/analyzer/CmpRuns.py Mon Oct 2 10:59:12 2017 @@ -6,8 +6,8 @@ which reports have been added, removed, This is designed to support automated testing using the static analyzer, from two perspectives: - 1. To monitor changes in the static analyzer's reports on real code bases, for - regression testing. + 1. To monitor changes in the static analyzer's reports on real code bases, + for regression testing. 2. For use by end users who want to integrate regular static analyzer testing into a buildbot like environment. @@ -29,6 +29,7 @@ Usage: import os import plistlib + # Information about analysis run: # path - the analysis output directory # root - the name of the root directory, which will be disregarded when @@ -39,6 +40,7 @@ class SingleRunInfo: self.root = root.rstrip("/\\") self.verboseLog = verboseLog + class AnalysisDiagnostic: def __init__(self, data, report, htmlReport): self._data = data @@ -50,7 +52,7 @@ class AnalysisDiagnostic: root = self._report.run.root fileName = self._report.files[self._loc['file']] if fileName.startswith(root) and len(root) > 0: -return fileName[len(root)+1:] +return fileName[len(root) + 1:] return fileName def getLine(self): @@ -65,12 +67,12 @@ class AnalysisDiagnostic: def getDescription(self): return self._data['description'] -def getIssueIdentifier(self) : +def getIssueIdentifier(self): id = self.getFileName() + "+" -if 'issue_context' in self._data : - id += self._data['issue_context'] + "+" -if 'issue_hash_content_of_line_in_context' in self._data : - id += str(self._data['issue_hash_content_of_line_in_context']) +if 'issue_context' in self._data: +id += self._data['issue_context'] + "+" +if 'issue_hash_content_of_line_in_context' in self._data: +id += str(self._data['issue_hash_content_of_line_in_context']) return id def getReport(self): @@ -88,18 +90,21 @@ class AnalysisDiagnostic: def getRawData(self): return self._data + class CmpOptions: def __init__(self, verboseLog=None, rootA="", rootB=""): self.rootA = rootA self.rootB = rootB self.verboseLog = verboseLog + class AnalysisReport: def __init__(self, run, files): self.run = run self.files = files self.diagnostics = [] + class AnalysisRun: def __init__(self, info): self.path = info.path @@ -120,14 +125,14 @@ class AnalysisRun: # reports. Assume that all reports were created using the same # clang version (this is always true and is more efficient). if 'clang_version' in data: -if self.clang_version == None: +if self.clang_version is None: self.clang_version = data.pop('clang_version') else: data.pop('clang_version') # Ignore/delete empty reports. if not data['files']: -if deleteEmpty == True: +if deleteEmpty: os.remove(p) return @@ -144,8 +149,7 @@ class AnalysisRun: report = AnalysisReport(self, data.pop('files')) diagnostics = [AnalysisDiagnostic(d, report, h) - for d,h in zip(data.pop('diagnostics'), - htmlFiles)] + for d, h in zip(data.pop('diagnostics'), htmlFiles)] assert not data @@ -154,15 +158,21 @@ class AnalysisRun: self.diagnostics.extend(diagnostics) -# Backward compatibility API. -def loadResults(path, opts, root = "", deleteEmpty=True): +def loadResults(path, opts, root="", deleteEmpty=True): +""" +Backwards compatibility API. +""" return loadResultsFromSingleRun(SingleRunInfo(path, root, opts.verboseLog), deleteEmpty) -# Load results of the analyzes from a given output folder. -# - info is the SingleRunInfo object -# - deleteEmpty specifies if the empty plist files should be deleted +
[clang-tools-extra] r314693 - [clangd] Handle workspace/didChangeWatchedFiles
Author: malaperle Date: Mon Oct 2 11:00:37 2017 New Revision: 314693 URL: http://llvm.org/viewvc/llvm-project?rev=314693&view=rev Log: [clangd] Handle workspace/didChangeWatchedFiles Summary: The client can send notifications when it detects watched files have changed. This patch adds the protocol handling for this type of notification. For now, the notification will be passed down to the ClangdServer, but it will not be acted upon. However, this will become useful for the indexer to react to file changes. The events could also potentially be used to invalidate other caches (compilation database, etc). This change also updates the VSCode extension so that it sends the events. Signed-off-by: Marc-Andre Laperle Reviewers: ilya-biryukov, Nebiroth Subscribers: ilya-biryukov Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D38422 Added: clang-tools-extra/trunk/test/clangd/did-change-watch-files.test Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/ClangdServer.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/ProtocolHandlers.h clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=314693&r1=314692&r2=314693&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Mon Oct 2 11:00:37 2017 @@ -73,6 +73,10 @@ void ClangdLSPServer::onDocumentDidChang Params.contentChanges[0].text); } +void ClangdLSPServer::onFileEvent(const DidChangeWatchedFilesParams &Params) { + Server.onFileEvent(Params); +} + void ClangdLSPServer::onDocumentDidClose(DidCloseTextDocumentParams Params, JSONOutput &Out) { Server.removeDocument(Params.textDocument.uri.file); Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=314693&r1=314692&r2=314693&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Mon Oct 2 11:00:37 2017 @@ -71,6 +71,7 @@ private: JSONOutput &Out) override; void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID, JSONOutput &Out) override; + void onFileEvent(const DidChangeWatchedFilesParams &Params) override; std::vector getFixIts(StringRef File, const clangd::Diagnostic &D); Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=314693&r1=314692&r2=314693&view=diff == --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Oct 2 11:00:37 2017 @@ -424,3 +424,8 @@ ClangdServer::scheduleCancelRebuild(std: std::move(DeferredCancel)); return DoneFuture; } + +void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams &Params) { + // FIXME: Do nothing for now. This will be used for indexing and potentially + // invalidating other caches. +} Modified: clang-tools-extra/trunk/clangd/ClangdServer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=314693&r1=314692&r2=314693&view=diff == --- clang-tools-extra/trunk/clangd/ClangdServer.h (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Oct 2 11:00:37 2017 @@ -268,6 +268,8 @@ public: /// Waits until all requests to worker thread are finished and dumps AST for /// \p File. \p File must be in the list of added documents. std::string dumpAST(PathRef File); + /// Called when an event occurs for a watched file in the workspace. + void onFileEvent(const DidChangeWatchedFilesParams &Params); private: std::future Modified: clang-tools-extra/trunk/clangd/Protocol.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=314693&r1=314692&r2=314693&view=diff == --- clang-tools-extra/trunk/clangd/Protocol.cpp (original) +++ clang-tools-extra/t
[PATCH] D38444: [compiler-rt] [cmake] Create dummy gtest target for stand-alone builds
george.karpenkov added a comment. > breaking stand-alone builds as a result That's a strong statement. Could you clarify? We have a lot of buildbots performing standalone builds, and they are still green. > and the likeliness of people mistakenly adding more unconditional dependencies That's a good point, however I'm not sure how your change would fix the problem. As far as I remember targets in compiler-rt had quite a few dependencies which required checking for whether it is a standalone build. In general, I'm not sure what this change would achieve, and the added complexity can always cause more bugs in the future. Repository: rL LLVM https://reviews.llvm.org/D38444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
JonasToth added a comment. ping. is there something obviously wrong with this check? https://reviews.llvm.org/D37808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r314695 - Fix building on macOS after SVN r314492
Author: mstorsjo Date: Mon Oct 2 11:14:06 2017 New Revision: 314695 URL: http://llvm.org/viewvc/llvm-project?rev=314695&view=rev Log: Fix building on macOS after SVN r314492 That commit incorrectly expanded the assumption that defined(__APPLE__) implies SjLj exception handling, which only is true within ARM code sections. Modified: libunwind/trunk/src/UnwindRegistersRestore.S libunwind/trunk/src/UnwindRegistersSave.S Modified: libunwind/trunk/src/UnwindRegistersRestore.S URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersRestore.S?rev=314695&r1=314694&r2=314695&view=diff == --- libunwind/trunk/src/UnwindRegistersRestore.S (original) +++ libunwind/trunk/src/UnwindRegistersRestore.S Mon Oct 2 11:14:06 2017 @@ -11,7 +11,7 @@ .text -#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) #if defined(__i386__) DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv) @@ -310,7 +310,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li ldpx0, x1, [x0, #0x000] // restore x0,x1 retx30// jump to pc -#elif defined(__arm__) +#elif defined(__arm__) && !defined(__APPLE__) #if !defined(__ARM_ARCH_ISA_ARM) .thumb @@ -493,7 +493,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li #endif -#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */ +#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */ NO_EXEC_STACK_DIRECTIVE Modified: libunwind/trunk/src/UnwindRegistersSave.S URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersSave.S?rev=314695&r1=314694&r2=314695&view=diff == --- libunwind/trunk/src/UnwindRegistersSave.S (original) +++ libunwind/trunk/src/UnwindRegistersSave.S Mon Oct 2 11:14:06 2017 @@ -11,7 +11,7 @@ .text -#if !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) #if defined(__i386__) @@ -291,7 +291,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext movx0, #0 // return UNW_ESUCCESS ret -#elif defined(__arm__) +#elif defined(__arm__) && !defined(__APPLE__) #if !defined(__ARM_ARCH_ISA_ARM) .thumb @@ -473,7 +473,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext l.sw 124(r3), r31 #endif -#endif /* !defined(__APPLE__) && !defined(__USING_SJLJ_EXCEPTIONS__) */ +#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */ NO_EXEC_STACK_DIRECTIVE ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38284: [clang-tidy] Fix google-readability-namespace-comments handling of C++17 nested namespaces
predator5047 updated this revision to Diff 117398. predator5047 marked 5 inline comments as done. predator5047 added a comment. Address review comments: - Use llvm::SmallVector instead of std::vector - Some formatting changes. https://reviews.llvm.org/D38284 Files: clang-tidy/readability/NamespaceCommentCheck.cpp clang-tidy/readability/NamespaceCommentCheck.h test/clang-tidy/google-readability-nested-namespace-comments.cpp Index: test/clang-tidy/google-readability-nested-namespace-comments.cpp === --- /dev/null +++ test/clang-tidy/google-readability-nested-namespace-comments.cpp @@ -0,0 +1,17 @@ +// RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- -std=c++17 + +namespace n1::n2 { +namespace n3 { + + // So that namespace is not empty. + void f(); + + +// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n3' not terminated with +// CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here +// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1::n2' not terminated with a closing comment [google-readability-namespace-comments] +// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1::n2' starts here +}} +// CHECK-FIXES: } // namespace n3 +// CHECK-FIXES: } // namespace n1::n2 + Index: clang-tidy/readability/NamespaceCommentCheck.h === --- clang-tidy/readability/NamespaceCommentCheck.h +++ clang-tidy/readability/NamespaceCommentCheck.h @@ -34,6 +34,7 @@ llvm::Regex NamespaceCommentPattern; const unsigned ShortNamespaceLines; const unsigned SpacesBeforeComments; + llvm::SmallVector Ends; }; } // namespace readability Index: clang-tidy/readability/NamespaceCommentCheck.cpp === --- clang-tidy/readability/NamespaceCommentCheck.cpp +++ clang-tidy/readability/NamespaceCommentCheck.cpp @@ -23,7 +23,7 @@ ClangTidyContext *Context) : ClangTidyCheck(Name, Context), NamespaceCommentPattern("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *" - "namespace( +([a-zA-Z0-9_]+))?\\.? *(\\*/)?$", + "namespace( +([a-zA-Z0-9_:]+))?\\.? *(\\*/)?$", llvm::Regex::IgnoreCase), ShortNamespaceLines(Options.get("ShortNamespaceLines", 1u)), SpacesBeforeComments(Options.get("SpacesBeforeComments", 1u)) {} @@ -56,6 +56,15 @@ return Fix; } +static std::string getNamespaceComment(const std::string &NameSpaceName, + bool InsertLineBreak) { + std::string Fix = "// namespace "; + Fix.append(NameSpaceName); + if (InsertLineBreak) +Fix.append("\n"); + return Fix; +} + void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) { const auto *ND = Result.Nodes.getNodeAs("namespace"); const SourceManager &Sources = *Result.SourceManager; @@ -74,11 +83,38 @@ SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1); SourceLocation Loc = AfterRBrace; Token Tok; + SourceLocation LBracketLocation = ND->getLocation(); + SourceLocation NestedNamespaceBegin = LBracketLocation; + + // Currently for nested namepsace (n1::n2::...) the AST matcher will match foo + // then bar instead of a single match. So if we got a nested namespace we have + // to skip the next ones. + for (const auto &EndOfNameLocation : Ends) { +if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin, + EndOfNameLocation)) + return; + } + while (Lexer::getRawToken(LBracketLocation, Tok, Sources, getLangOpts()) || + !Tok.is(tok::l_brace)) { +LBracketLocation = LBracketLocation.getLocWithOffset(1); + } + + auto TextRange = + Lexer::getAsCharRange(SourceRange(NestedNamespaceBegin, LBracketLocation), +Sources, getLangOpts()); + auto NestedNamespaceName = + Lexer::getSourceText(TextRange, Sources, getLangOpts()).rtrim(); + bool IsNested = NestedNamespaceName.contains(':'); + + if (IsNested) +Ends.push_back(LBracketLocation); + // Skip whitespace until we find the next token. while (Lexer::getRawToken(Loc, Tok, Sources, getLangOpts()) || Tok.is(tok::semi)) { Loc = Loc.getLocWithOffset(1); } + if (!locationsInSameFile(Sources, ND->getRBraceLoc(), Loc)) return; @@ -98,10 +134,14 @@ StringRef NamespaceNameInComment = Groups.size() > 5 ? Groups[5] : ""; StringRef Anonymous = Groups.size() > 3 ? Groups[3] : ""; - // Check if the namespace in the comment is the same. - if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty()) || - (ND->getNameAsString() == NamespaceNameInComment && - Anonymous.empty())) { + if (IsNested && NestedNamespaceName == NamespaceNameInComment) { +// C++17 nes
[PATCH] D38042: EmitAssemblyHelper: CodeGenOpts.DisableLLVMOpts should not overrule CodeGenOpts.VerifyModule.
aprantl abandoned this revision. aprantl added a comment. Abandoning in favor of https://reviews.llvm.org/D38184 https://reviews.llvm.org/D38042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314697 - Revert "Add /System/Library/PrivateFrameworks as a header search path."
Author: dgregor Date: Mon Oct 2 11:22:19 2017 New Revision: 314697 URL: http://llvm.org/viewvc/llvm-project?rev=314697&view=rev Log: Revert "Add /System/Library/PrivateFrameworks as a header search path." This reverts commit f7a95215a435aa8d5f64f43a8bb23ba077270755. Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=314697&r1=314696&r2=314697&view=diff == --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original) +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon Oct 2 11:22:19 2017 @@ -484,7 +484,6 @@ void InitHeaderSearch::AddDefaultInclude if (triple.isOSDarwin()) { AddPath("/System/Library/Frameworks", System, true); AddPath("/Library/Frameworks", System, true); - AddPath("/System/Library/PrivateFrameworks", System, true); } } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314700 - Add a testcase to check that debug info is upgraded when compiling LLVM IR
Author: adrian Date: Mon Oct 2 11:31:52 2017 New Revision: 314700 URL: http://llvm.org/viewvc/llvm-project?rev=314700&view=rev Log: Add a testcase to check that debug info is upgraded when compiling LLVM IR through clang. Added: cfe/trunk/test/CodeGen/verify-debuginfo.ll Added: cfe/trunk/test/CodeGen/verify-debuginfo.ll URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/verify-debuginfo.ll?rev=314700&view=auto == --- cfe/trunk/test/CodeGen/verify-debuginfo.ll (added) +++ cfe/trunk/test/CodeGen/verify-debuginfo.ll Mon Oct 2 11:31:52 2017 @@ -0,0 +1,17 @@ +; REQUIRES: x86-registered-target +; RUN: %clang_cc1 -triple i386-apple-darwin -disable-llvm-optzns -S %s -o - 2>&1 \ +; RUN: | FileCheck %s +; CHECK: invalid global variable ref +; CHECK: warning: ignoring invalid debug info in {{.*}}.ll + +@global = common global i32 0, align 4, !dbg !2 + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!5, !6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "adrian", emissionKind: FullDebug, globals: !{!3}) +!1 = !DIFile(filename: "broken.c", directory: "/") +!2 = !DIGlobalVariableExpression(var: !3, expr: !DIExpression()) +!3 = !DIGlobalVariable(name: "g", scope: !0, file: !1, line: 1, type: !1, isLocal: false, isDefinition: true) +!5 = !{i32 2, !"Dwarf Version", i32 4} +!6 = !{i32 1, !"Debug Info Version", i32 3} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37681: [refactor] Simplify the interface and remove some template magic
arphaman added a comment. I will commit this today. @klimek, let me know if there any issues in post-commit review. Repository: rL LLVM https://reviews.llvm.org/D37681 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r314703 - integer/sub_sat: Use clang builtin instead of llvm asm
Author: jvesely Date: Mon Oct 2 11:39:03 2017 New Revision: 314703 URL: http://llvm.org/viewvc/llvm-project?rev=314703&view=rev Log: integer/sub_sat: Use clang builtin instead of llvm asm reviewer: Tom Stellard Signed-off-by: Jan Vesely Removed: libclc/trunk/generic/lib/integer/sub_sat_if.ll libclc/trunk/generic/lib/integer/sub_sat_impl.ll libclc/trunk/ptx/lib/OVERRIDES libclc/trunk/ptx/lib/SOURCES libclc/trunk/ptx/lib/integer/sub_sat.ll Modified: libclc/trunk/generic/lib/SOURCES libclc/trunk/generic/lib/integer/sub_sat.cl Modified: libclc/trunk/generic/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=314703&r1=314702&r2=314703&view=diff == --- libclc/trunk/generic/lib/SOURCES (original) +++ libclc/trunk/generic/lib/SOURCES Mon Oct 2 11:39:03 2017 @@ -73,8 +73,6 @@ integer/mul_hi.cl integer/rhadd.cl integer/rotate.cl integer/sub_sat.cl -integer/sub_sat_if.ll -integer/sub_sat_impl.ll integer/upsample.cl math/acos.cl math/acosh.cl Modified: libclc/trunk/generic/lib/integer/sub_sat.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/sub_sat.cl?rev=314703&r1=314702&r2=314703&view=diff == --- libclc/trunk/generic/lib/integer/sub_sat.cl (original) +++ libclc/trunk/generic/lib/integer/sub_sat.cl Mon Oct 2 11:39:03 2017 @@ -1,46 +1,54 @@ #include #include "../clcmacro.h" -// From sub_sat.ll -_CLC_DECL char __clc_sub_sat_s8(char, char); -_CLC_DECL uchar __clc_sub_sat_u8(uchar, uchar); -_CLC_DECL short __clc_sub_sat_s16(short, short); -_CLC_DECL ushort __clc_sub_sat_u16(ushort, ushort); -_CLC_DECL int__clc_sub_sat_s32(int, int); -_CLC_DECL uint __clc_sub_sat_u32(uint, uint); -_CLC_DECL long __clc_sub_sat_s64(long, long); -_CLC_DECL ulong __clc_sub_sat_u64(ulong, ulong); - _CLC_OVERLOAD _CLC_DEF char sub_sat(char x, char y) { - return __clc_sub_sat_s8(x, y); + short r = x - y; + return convert_char_sat(r); } _CLC_OVERLOAD _CLC_DEF uchar sub_sat(uchar x, uchar y) { - return __clc_sub_sat_u8(x, y); + short r = x - y; + return convert_uchar_sat(r); } _CLC_OVERLOAD _CLC_DEF short sub_sat(short x, short y) { - return __clc_sub_sat_s16(x, y); + int r = x - y; + return convert_short_sat(r); } _CLC_OVERLOAD _CLC_DEF ushort sub_sat(ushort x, ushort y) { - return __clc_sub_sat_u16(x, y); + int r = x - y; + return convert_ushort_sat(r); } _CLC_OVERLOAD _CLC_DEF int sub_sat(int x, int y) { - return __clc_sub_sat_s32(x, y); + int r; + if (__builtin_ssub_overflow(x, y, &r)) +// The oveflow can only occur in the direction of the first operand +return x > 0 ? INT_MAX : INT_MIN; + return r; } _CLC_OVERLOAD _CLC_DEF uint sub_sat(uint x, uint y) { - return __clc_sub_sat_u32(x, y); + uint r; + if (__builtin_usub_overflow(x, y, &r)) + return 0; + return r; } _CLC_OVERLOAD _CLC_DEF long sub_sat(long x, long y) { - return __clc_sub_sat_s64(x, y); + long r; + if (__builtin_ssubl_overflow(x, y, &r)) +// The oveflow can only occur in the direction of the first operand +return x > 0 ? LONG_MAX : LONG_MIN; + return r; } _CLC_OVERLOAD _CLC_DEF ulong sub_sat(ulong x, ulong y) { - return __clc_sub_sat_u64(x, y); + ulong r; + if (__builtin_usubl_overflow(x, y, &r)) + return 0; + return r; } _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, char, sub_sat, char, char) Removed: libclc/trunk/generic/lib/integer/sub_sat_if.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/sub_sat_if.ll?rev=314702&view=auto == --- libclc/trunk/generic/lib/integer/sub_sat_if.ll (original) +++ libclc/trunk/generic/lib/integer/sub_sat_if.ll (removed) @@ -1,55 +0,0 @@ -declare i8 @__clc_sub_sat_impl_s8(i8 %x, i8 %y) - -define i8 @__clc_sub_sat_s8(i8 %x, i8 %y) nounwind readnone alwaysinline { - %call = call i8 @__clc_sub_sat_impl_s8(i8 %x, i8 %y) - ret i8 %call -} - -declare i8 @__clc_sub_sat_impl_u8(i8 %x, i8 %y) - -define i8 @__clc_sub_sat_u8(i8 %x, i8 %y) nounwind readnone alwaysinline { - %call = call i8 @__clc_sub_sat_impl_u8(i8 %x, i8 %y) - ret i8 %call -} - -declare i16 @__clc_sub_sat_impl_s16(i16 %x, i16 %y) - -define i16 @__clc_sub_sat_s16(i16 %x, i16 %y) nounwind readnone alwaysinline { - %call = call i16 @__clc_sub_sat_impl_s16(i16 %x, i16 %y) - ret i16 %call -} - -declare i16 @__clc_sub_sat_impl_u16(i16 %x, i16 %y) - -define i16 @__clc_sub_sat_u16(i16 %x, i16 %y) nounwind readnone alwaysinline { - %call = call i16 @__clc_sub_sat_impl_u16(i16 %x, i16 %y) - ret i16 %call -} - -declare i32 @__clc_sub_sat_impl_s32(i32 %x, i32 %y) - -define i32 @__clc_sub_sat_s32(i32 %x, i32 %y) nounwind readnone alwaysinline { - %call = call i32 @__clc_sub_sat_impl_s32(i32 %x, i32 %y) - ret i32 %call -} - -decl
[libclc] r314701 - integer/clz: Use clang builtin instead of llvm asm
Author: jvesely Date: Mon Oct 2 11:38:57 2017 New Revision: 314701 URL: http://llvm.org/viewvc/llvm-project?rev=314701&view=rev Log: integer/clz: Use clang builtin instead of llvm asm The generated llvm IR mostly identical. char/uchar case is a bit worse. reviewer: Tom Stellard Signed-off-by: Jan Vesely Removed: libclc/trunk/generic/lib/integer/clz_if.ll libclc/trunk/generic/lib/integer/clz_impl.ll Modified: libclc/trunk/generic/lib/SOURCES libclc/trunk/generic/lib/integer/clz.cl Modified: libclc/trunk/generic/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=314701&r1=314700&r2=314701&view=diff == --- libclc/trunk/generic/lib/SOURCES (original) +++ libclc/trunk/generic/lib/SOURCES Mon Oct 2 11:38:57 2017 @@ -67,8 +67,6 @@ integer/add_sat.cl integer/add_sat_if.ll integer/add_sat_impl.ll integer/clz.cl -integer/clz_if.ll -integer/clz_impl.ll integer/hadd.cl integer/mad24.cl integer/mad_sat.cl Modified: libclc/trunk/generic/lib/integer/clz.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/clz.cl?rev=314701&r1=314700&r2=314701&view=diff == --- libclc/trunk/generic/lib/integer/clz.cl (original) +++ libclc/trunk/generic/lib/integer/clz.cl Mon Oct 2 11:38:57 2017 @@ -1,46 +1,36 @@ #include #include "../clcmacro.h" -// From clz.ll -_CLC_DECL char __clc_clz_s8(char); -_CLC_DECL uchar __clc_clz_u8(uchar); -_CLC_DECL short __clc_clz_s16(short); -_CLC_DECL ushort __clc_clz_u16(ushort); -_CLC_DECL int__clc_clz_s32(int); -_CLC_DECL uint __clc_clz_u32(uint); -_CLC_DECL long __clc_clz_s64(long); -_CLC_DECL ulong __clc_clz_u64(ulong); - _CLC_OVERLOAD _CLC_DEF char clz(char x) { - return __clc_clz_s8(x); + return clz((ushort)(uchar)x) - 8; } _CLC_OVERLOAD _CLC_DEF uchar clz(uchar x) { - return __clc_clz_u8(x); + return clz((ushort)x) - 8; } _CLC_OVERLOAD _CLC_DEF short clz(short x) { - return __clc_clz_s16(x); + return x ? __builtin_clzs(x) : 16; } _CLC_OVERLOAD _CLC_DEF ushort clz(ushort x) { - return __clc_clz_u16(x); + return x ? __builtin_clzs(x) : 16; } _CLC_OVERLOAD _CLC_DEF int clz(int x) { - return __clc_clz_s32(x); + return x ? __builtin_clz(x) : 32; } _CLC_OVERLOAD _CLC_DEF uint clz(uint x) { - return __clc_clz_u32(x); + return x ? __builtin_clz(x) : 32; } _CLC_OVERLOAD _CLC_DEF long clz(long x) { - return __clc_clz_s64(x); + return x ? __builtin_clzl(x) : 64; } _CLC_OVERLOAD _CLC_DEF ulong clz(ulong x) { - return __clc_clz_u64(x); + return x ? __builtin_clzl(x) : 64; } _CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, char, clz, char) Removed: libclc/trunk/generic/lib/integer/clz_if.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/clz_if.ll?rev=314700&view=auto == --- libclc/trunk/generic/lib/integer/clz_if.ll (original) +++ libclc/trunk/generic/lib/integer/clz_if.ll (removed) @@ -1,55 +0,0 @@ -declare i8 @__clc_clz_impl_s8(i8 %x) - -define i8 @__clc_clz_s8(i8 %x) nounwind readnone alwaysinline { - %call = call i8 @__clc_clz_impl_s8(i8 %x) - ret i8 %call -} - -declare i8 @__clc_clz_impl_u8(i8 %x) - -define i8 @__clc_clz_u8(i8 %x) nounwind readnone alwaysinline { - %call = call i8 @__clc_clz_impl_u8(i8 %x) - ret i8 %call -} - -declare i16 @__clc_clz_impl_s16(i16 %x) - -define i16 @__clc_clz_s16(i16 %x) nounwind readnone alwaysinline { - %call = call i16 @__clc_clz_impl_s16(i16 %x) - ret i16 %call -} - -declare i16 @__clc_clz_impl_u16(i16 %x) - -define i16 @__clc_clz_u16(i16 %x) nounwind readnone alwaysinline { - %call = call i16 @__clc_clz_impl_u16(i16 %x) - ret i16 %call -} - -declare i32 @__clc_clz_impl_s32(i32 %x) - -define i32 @__clc_clz_s32(i32 %x) nounwind readnone alwaysinline { - %call = call i32 @__clc_clz_impl_s32(i32 %x) - ret i32 %call -} - -declare i32 @__clc_clz_impl_u32(i32 %x) - -define i32 @__clc_clz_u32(i32 %x) nounwind readnone alwaysinline { - %call = call i32 @__clc_clz_impl_u32(i32 %x) - ret i32 %call -} - -declare i64 @__clc_clz_impl_s64(i64 %x) - -define i64 @__clc_clz_s64(i64 %x) nounwind readnone alwaysinline { - %call = call i64 @__clc_clz_impl_s64(i64 %x) - ret i64 %call -} - -declare i64 @__clc_clz_impl_u64(i64 %x) - -define i64 @__clc_clz_u64(i64 %x) nounwind readnone alwaysinline { - %call = call i64 @__clc_clz_impl_u64(i64 %x) - ret i64 %call -} Removed: libclc/trunk/generic/lib/integer/clz_impl.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/clz_impl.ll?rev=314700&view=auto == --- libclc/trunk/generic/lib/integer/clz_impl.ll (original) +++ libclc/trunk/generic/lib/integer/clz_impl.ll (removed) @@ -1,44 +0,0 @@ -declare i8 @llvm.ctlz.i8(i8, i1) -d
[libclc] r314702 - integer/add_sat: Use clang builtin instead of llvm asm
Author: jvesely Date: Mon Oct 2 11:39:00 2017 New Revision: 314702 URL: http://llvm.org/viewvc/llvm-project?rev=314702&view=rev Log: integer/add_sat: Use clang builtin instead of llvm asm reviewer: Tom Stellard Signed-off-by: Jan Vesely Removed: libclc/trunk/generic/lib/integer/add_sat_if.ll libclc/trunk/generic/lib/integer/add_sat_impl.ll libclc/trunk/ptx/lib/integer/add_sat.ll Modified: libclc/trunk/generic/lib/SOURCES libclc/trunk/generic/lib/integer/add_sat.cl libclc/trunk/ptx/lib/OVERRIDES libclc/trunk/ptx/lib/SOURCES Modified: libclc/trunk/generic/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=314702&r1=314701&r2=314702&view=diff == --- libclc/trunk/generic/lib/SOURCES (original) +++ libclc/trunk/generic/lib/SOURCES Mon Oct 2 11:39:00 2017 @@ -64,8 +64,6 @@ geometric/normalize.cl integer/abs.cl integer/abs_diff.cl integer/add_sat.cl -integer/add_sat_if.ll -integer/add_sat_impl.ll integer/clz.cl integer/hadd.cl integer/mad24.cl Modified: libclc/trunk/generic/lib/integer/add_sat.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/add_sat.cl?rev=314702&r1=314701&r2=314702&view=diff == --- libclc/trunk/generic/lib/integer/add_sat.cl (original) +++ libclc/trunk/generic/lib/integer/add_sat.cl Mon Oct 2 11:39:00 2017 @@ -12,35 +12,55 @@ _CLC_DECL long __clc_add_sat_s64(long, _CLC_DECL ulong __clc_add_sat_u64(ulong, ulong); _CLC_OVERLOAD _CLC_DEF char add_sat(char x, char y) { - return __clc_add_sat_s8(x, y); + short r = x + y; + return convert_char_sat(r); } _CLC_OVERLOAD _CLC_DEF uchar add_sat(uchar x, uchar y) { - return __clc_add_sat_u8(x, y); + ushort r = x + y; + return convert_uchar_sat(r); } _CLC_OVERLOAD _CLC_DEF short add_sat(short x, short y) { - return __clc_add_sat_s16(x, y); + int r = x + y; + return convert_short_sat(r); } _CLC_OVERLOAD _CLC_DEF ushort add_sat(ushort x, ushort y) { - return __clc_add_sat_u16(x, y); + uint r = x + y; + return convert_ushort_sat(r); } _CLC_OVERLOAD _CLC_DEF int add_sat(int x, int y) { - return __clc_add_sat_s32(x, y); + int r; + if (__builtin_sadd_overflow(x, y, &r)) +// The oveflow can only occur if both are pos or both are neg, +// thus we only need to check one operand +return x > 0 ? INT_MAX : INT_MIN; + return r; } _CLC_OVERLOAD _CLC_DEF uint add_sat(uint x, uint y) { - return __clc_add_sat_u32(x, y); + uint r; + if (__builtin_uadd_overflow(x, y, &r)) + return UINT_MAX; + return r; } _CLC_OVERLOAD _CLC_DEF long add_sat(long x, long y) { - return __clc_add_sat_s64(x, y); + long r; + if (__builtin_saddl_overflow(x, y, &r)) +// The oveflow can only occur if both are pos or both are neg, +// thus we only need to check one operand +return x > 0 ? LONG_MAX : LONG_MIN; + return r; } _CLC_OVERLOAD _CLC_DEF ulong add_sat(ulong x, ulong y) { - return __clc_add_sat_u64(x, y); + ulong r; + if (__builtin_uaddl_overflow(x, y, &r)) + return ULONG_MAX; + return r; } _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, char, add_sat, char, char) Removed: libclc/trunk/generic/lib/integer/add_sat_if.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/add_sat_if.ll?rev=314701&view=auto == --- libclc/trunk/generic/lib/integer/add_sat_if.ll (original) +++ libclc/trunk/generic/lib/integer/add_sat_if.ll (removed) @@ -1,55 +0,0 @@ -declare i8 @__clc_add_sat_impl_s8(i8 %x, i8 %y) - -define i8 @__clc_add_sat_s8(i8 %x, i8 %y) nounwind readnone alwaysinline { - %call = call i8 @__clc_add_sat_impl_s8(i8 %x, i8 %y) - ret i8 %call -} - -declare i8 @__clc_add_sat_impl_u8(i8 %x, i8 %y) - -define i8 @__clc_add_sat_u8(i8 %x, i8 %y) nounwind readnone alwaysinline { - %call = call i8 @__clc_add_sat_impl_u8(i8 %x, i8 %y) - ret i8 %call -} - -declare i16 @__clc_add_sat_impl_s16(i16 %x, i16 %y) - -define i16 @__clc_add_sat_s16(i16 %x, i16 %y) nounwind readnone alwaysinline { - %call = call i16 @__clc_add_sat_impl_s16(i16 %x, i16 %y) - ret i16 %call -} - -declare i16 @__clc_add_sat_impl_u16(i16 %x, i16 %y) - -define i16 @__clc_add_sat_u16(i16 %x, i16 %y) nounwind readnone alwaysinline { - %call = call i16 @__clc_add_sat_impl_u16(i16 %x, i16 %y) - ret i16 %call -} - -declare i32 @__clc_add_sat_impl_s32(i32 %x, i32 %y) - -define i32 @__clc_add_sat_s32(i32 %x, i32 %y) nounwind readnone alwaysinline { - %call = call i32 @__clc_add_sat_impl_s32(i32 %x, i32 %y) - ret i32 %call -} - -declare i32 @__clc_add_sat_impl_u32(i32 %x, i32 %y) - -define i32 @__clc_add_sat_u32(i32 %x, i32 %y) nounwind readnone alwaysinline { - %call = call i32 @__clc_add_sat_impl_u32(i32 %x, i32 %y) - ret i32 %call -} - -declare i64 @__clc_add_sat_impl_s64(i64 %x,
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
srhines added a comment. Ping again. This is really trivial. https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314704 - [refactor] Simplify the refactoring interface
Author: arphaman Date: Mon Oct 2 11:42:43 2017 New Revision: 314704 URL: http://llvm.org/viewvc/llvm-project?rev=314704&view=rev Log: [refactor] Simplify the refactoring interface This commit simplifies the interface for the refactoring action rules and the refactoring requirements. It merges the selection constraints and the selection requirements into one class. The refactoring actions rules must now be implemented using subclassing instead of raw function / lambda pointers. This change also removes a bunch of template-based traits and other template definitions that are now redundant. Differential Revision: https://reviews.llvm.org/D37681 Removed: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h cfe/trunk/include/clang/Tooling/Refactoring/SourceSelectionConstraints.h cfe/trunk/lib/Tooling/Refactoring/SourceSelectionConstraints.cpp Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h?rev=314704&r1=314703&r2=314704&view=diff == --- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h (original) +++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h Mon Oct 2 11:42:43 2017 @@ -19,10 +19,12 @@ namespace tooling { class RefactoringResultConsumer; class RefactoringRuleContext; -/// A common refactoring action rule interface. -class RefactoringActionRule { +/// A common refactoring action rule interface that defines the 'invoke' +/// function that performs the refactoring operation (either fully or +/// partially). +class RefactoringActionRuleBase { public: - virtual ~RefactoringActionRule() {} + virtual ~RefactoringActionRuleBase() {} /// Initiates and performs a specific refactoring action. /// @@ -30,17 +32,19 @@ public: /// consumer to propagate the result of the refactoring action. virtual void invoke(RefactoringResultConsumer &Consumer, RefactoringRuleContext &Context) = 0; +}; +/// A refactoring action rule is a wrapper class around a specific refactoring +/// action rule (SourceChangeRefactoringRule, etc) that, in addition to invoking +/// the action, describes the requirements that determine when the action can be +/// initiated. +class RefactoringActionRule : public RefactoringActionRuleBase { +public: /// Returns true when the rule has a source selection requirement that has /// to be fullfilled before refactoring can be performed. virtual bool hasSelectionRequirement() = 0; }; -/// A set of refactoring action rules that should have unique initiation -/// requirements. -using RefactoringActionRules = -std::vector>; - } // end namespace tooling } // end namespace clang Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h?rev=314704&r1=314703&r2=314704&view=diff == --- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h (original) +++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h Mon Oct 2 11:42:43 2017 @@ -10,48 +10,49 @@ #ifndef LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_REQUIREMENTS_H #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_REQUIREMENTS_H -#include "clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h" +#include "clang/Basic/LLVM.h" +#include "clang/Tooling/Refactoring/RefactoringRuleContext.h" #include "llvm/Support/Error.h" #include namespace clang { namespace tooling { -namespace refactoring_action_rules { -/// Creates a selection requirement from the given requirement. +/// A refactoring action rule requirement determines when a refactoring action +/// rule can be invoked. The rule can be invoked only when all of the +/// requirements are satisfied. /// -/// Requirements must subclass \c selection::Requirement and implement -/// evaluateSelection member function. -template -internal::SourceSelectionRequirement< -typename selection::internal::EvaluateSelectionChecker< -decltype(&T::evaluateSele
[PATCH] D37681: [refactor] Simplify the interface and remove some template magic
This revision was automatically updated to reflect the committed changes. Closed by commit rL314704: [refactor] Simplify the refactoring interface (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D37681?vs=115211&id=117403#toc Repository: rL LLVM https://reviews.llvm.org/D37681 Files: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h cfe/trunk/include/clang/Tooling/Refactoring/SourceSelectionConstraints.h cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp cfe/trunk/lib/Tooling/Refactoring/SourceSelectionConstraints.cpp cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Index: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp === --- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp +++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp @@ -18,7 +18,6 @@ using namespace clang; using namespace tooling; -using namespace refactoring_action_rules; namespace { @@ -56,29 +55,39 @@ } TEST_F(RefactoringActionRulesTest, MyFirstRefactoringRule) { - auto ReplaceAWithB = - [](const RefactoringRuleContext &, - std::pair Selection) - -> Expected { -const SourceManager &SM = Selection.first.getSources(); -SourceLocation Loc = Selection.first.getRange().getBegin().getLocWithOffset( -Selection.second); -AtomicChange Change(SM, Loc); -llvm::Error E = Change.replace(SM, Loc, 1, "b"); -if (E) - return std::move(E); -return AtomicChanges{Change}; - }; - class SelectionRequirement : public selection::Requirement { - public: -std::pair -evaluateSelection(const RefactoringRuleContext &, - selection::SourceSelectionRange Selection) const { - return std::make_pair(Selection, 20); + class ReplaceAWithB : public SourceChangeRefactoringRule { +std::pair Selection; + + public: +ReplaceAWithB(std::pair Selection) +: Selection(Selection) {} + +Expected +createSourceReplacements(RefactoringRuleContext &Context) { + const SourceManager &SM = Context.getSources(); + SourceLocation Loc = + Selection.first.getBegin().getLocWithOffset(Selection.second); + AtomicChange Change(SM, Loc); + llvm::Error E = Change.replace(SM, Loc, 1, "b"); + if (E) +return std::move(E); + return AtomicChanges{Change}; +} + }; + + class SelectionRequirement : public SourceRangeSelectionRequirement { + public: +Expected> +evaluate(RefactoringRuleContext &Context) const { + Expected R = + SourceRangeSelectionRequirement::evaluate(Context); + if (!R) +return R.takeError(); + return std::make_pair(*R, 20); } }; - auto Rule = createRefactoringRule(ReplaceAWithB, -requiredSelection(SelectionRequirement())); + auto Rule = + createRefactoringActionRule(SelectionRequirement()); // When the requirements are satisifed, the rule's function must be invoked. { @@ -123,54 +132,24 @@ llvm::handleAllErrors( ErrorOrResult.takeError(), [&](llvm::StringError &Error) { Message = Error.getMessage(); }); -EXPECT_EQ(Message, "refactoring action can't be initiated with the " - "specified selection range"); +EXPECT_EQ(Message, + "refactoring action can't be initiated without a selection"); } } TEST_F(RefactoringActionRulesTest, ReturnError) { - Expected (*Func)(const RefactoringRuleContext &, - selection::SourceSelectionRange) = - [](const RefactoringRuleContext &, - selection::SourceSelectionRange) -> Expected { -return llvm::make_error( -"Error", llvm::make_error_code(llvm::errc::invalid_argument)); - }; - auto Rule = createRefactoringRule( - Func, requiredSelection( -selection::identity())); - - RefactoringRuleContext RefContext(Context.Sources); - SourceLocation Cursor = - Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID()); - RefContext.setSelectionRange({Cursor, Cursor}); - Expected Result = createReplacements(Rule, RefContext); - - ASSERT_TRUE(!Result); - std::string Message; - llvm::handleAllErrors(Result.takeError(), [&](llvm::StringError &Error) { -Message = Error.getMessage(); - }); - EXPECT_EQ(Message, "Error"); -} - -TEST_F(RefactoringActionRulesTest, ReturnInitiationDiagnostic) { - RefactoringRuleContext
r314706 - Add support for Myriad ma2x8x series of CPUs
Author: waltl Date: Mon Oct 2 11:50:57 2017 New Revision: 314706 URL: http://llvm.org/viewvc/llvm-project?rev=314706&view=rev Log: Add support for Myriad ma2x8x series of CPUs Summary: Also: - Add support for some older Myriad CPUs that were missing. - Fix some incorrect compiler defines for exisitng CPUs. Reviewers: jyknight Subscribers: fedor.sergeev Differential Revision: https://reviews.llvm.org/D37551 Modified: cfe/trunk/lib/Basic/Targets/Sparc.cpp cfe/trunk/lib/Basic/Targets/Sparc.h cfe/trunk/test/Preprocessor/predefined-arch-macros.c Modified: cfe/trunk/lib/Basic/Targets/Sparc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Sparc.cpp?rev=314706&r1=314705&r2=314706&view=diff == --- cfe/trunk/lib/Basic/Targets/Sparc.cpp (original) +++ cfe/trunk/lib/Basic/Targets/Sparc.cpp Mon Oct 2 11:50:57 2017 @@ -70,12 +70,21 @@ SparcTargetInfo::CPUKind SparcTargetInfo .Case("niagara4", CK_NIAGARA4) .Case("ma2100", CK_MYRIAD2100) .Case("ma2150", CK_MYRIAD2150) + .Case("ma2155", CK_MYRIAD2155) .Case("ma2450", CK_MYRIAD2450) + .Case("ma2455", CK_MYRIAD2455) + .Case("ma2x5x", CK_MYRIAD2x5x) + .Case("ma2080", CK_MYRIAD2080) + .Case("ma2085", CK_MYRIAD2085) + .Case("ma2480", CK_MYRIAD2480) + .Case("ma2485", CK_MYRIAD2485) + .Case("ma2x8x", CK_MYRIAD2x8x) // FIXME: the myriad2[.n] spellings are obsolete, // but a grace period is needed to allow updating dependent builds. - .Case("myriad2", CK_MYRIAD2100) + .Case("myriad2", CK_MYRIAD2x5x) .Case("myriad2.1", CK_MYRIAD2100) - .Case("myriad2.2", CK_MYRIAD2150) + .Case("myriad2.2", CK_MYRIAD2x5x) + .Case("myriad2.3", CK_MYRIAD2x8x) .Case("leon2", CK_LEON2) .Case("at697e", CK_LEON2_AT697E) .Case("at697f", CK_LEON2_AT697F) @@ -118,21 +127,57 @@ void SparcV8TargetInfo::getTargetDefines Builder.defineMacro("__sparc_v8__"); Builder.defineMacro("__leon__"); switch (CPU) { +case CK_MYRIAD2100: + MyriadArchValue = "__ma2100"; + Myriad2Value = "1"; + break; case CK_MYRIAD2150: MyriadArchValue = "__ma2150"; Myriad2Value = "2"; break; +case CK_MYRIAD2155: + MyriadArchValue = "__ma2155"; + Myriad2Value = "2"; + break; case CK_MYRIAD2450: MyriadArchValue = "__ma2450"; Myriad2Value = "2"; break; +case CK_MYRIAD2455: + MyriadArchValue = "__ma2455"; + Myriad2Value = "2"; + break; +case CK_MYRIAD2x5x: + Myriad2Value = "2"; + break; +case CK_MYRIAD2080: + MyriadArchValue = "__ma2080"; + Myriad2Value = "3"; + break; +case CK_MYRIAD2085: + MyriadArchValue = "__ma2085"; + Myriad2Value = "3"; + break; +case CK_MYRIAD2480: + MyriadArchValue = "__ma2480"; + Myriad2Value = "3"; + break; +case CK_MYRIAD2485: + MyriadArchValue = "__ma2485"; + Myriad2Value = "3"; + break; +case CK_MYRIAD2x8x: + Myriad2Value = "3"; + break; default: MyriadArchValue = "__ma2100"; Myriad2Value = "1"; break; } -Builder.defineMacro(MyriadArchValue, "1"); -Builder.defineMacro(MyriadArchValue + "__", "1"); +if (!MyriadArchValue.empty()) { + Builder.defineMacro(MyriadArchValue, "1"); + Builder.defineMacro(MyriadArchValue + "__", "1"); +} Builder.defineMacro("__myriad2__", Myriad2Value); Builder.defineMacro("__myriad2", Myriad2Value); } Modified: cfe/trunk/lib/Basic/Targets/Sparc.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Sparc.h?rev=314706&r1=314705&r2=314706&view=diff == --- cfe/trunk/lib/Basic/Targets/Sparc.h (original) +++ cfe/trunk/lib/Basic/Targets/Sparc.h Mon Oct 2 11:50:57 2017 @@ -107,7 +107,15 @@ public: CK_NIAGARA4, CK_MYRIAD2100, CK_MYRIAD2150, +CK_MYRIAD2155, CK_MYRIAD2450, +CK_MYRIAD2455, +CK_MYRIAD2x5x, +CK_MYRIAD2080, +CK_MYRIAD2085, +CK_MYRIAD2480, +CK_MYRIAD2485, +CK_MYRIAD2x8x, CK_LEON2, CK_LEON2_AT697E, CK_LEON2_AT697F, @@ -136,7 +144,15 @@ public: case CK_TSC701: case CK_MYRIAD2100: case CK_MYRIAD2150: +case CK_MYRIAD2155: case CK_MYRIAD2450: +case CK_MYRIAD2455: +case CK_MYRIAD2x5x: +case CK_MYRIAD2080: +case CK_MYRIAD2085: +case CK_MYRIAD2480: +case CK_MYRIAD2485: +case CK_MYRIAD2x8x: case CK_LEON2: case CK_LEON2_AT697E: case CK_LEON2_AT697F: Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=314706&r1=314705&r2=314706&view=diff == --- cfe/
[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.
rsmith added a comment. In https://reviews.llvm.org/D35216#856415, @NoQ wrote: > We already have the object's fields in the AST, with its AST record layout, > however field names and layouts are implementation-dependent, and it is > unsafe to try to understand how the specific standard library > implementation's layout works and what specific private fields we see in the > AST mean. This is precisely how the rest of the compiler handles `CXXStdInitializerListExpr`, is how it's intended to be used, and is really the only way it can work if you want to evaluate the members of `initializer_list` rather than hardcoding their meaning. Consumers of `CXXStdInitializerListExpr` are expected to handle two cases: 1) the class has no base classes and two fields of type `const T*` and `size_t` (begin and size), and 2) the class has no base classes and two fields, both of type `const T*` (begin and end). (Unfortunately, we reject all other cases during CodeGen rather than in Sema, so you may still see them for now.) https://reviews.llvm.org/D35216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314708 - Add std::move in RefactoringActionRulesTest.cpp
Author: arphaman Date: Mon Oct 2 12:02:42 2017 New Revision: 314708 URL: http://llvm.org/viewvc/llvm-project?rev=314708&view=rev Log: Add std::move in RefactoringActionRulesTest.cpp Should fix http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental Modified: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Modified: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp?rev=314708&r1=314707&r2=314708&view=diff == --- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp (original) +++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Mon Oct 2 12:02:42 2017 @@ -196,7 +196,7 @@ TEST_F(RefactoringActionRulesTest, Retur Occurrences.push_back(SymbolOccurrence(SymbolName("test"), SymbolOccurrence::MatchingSymbol, Selection.getBegin())); - return Occurrences; + return std::move(Occurrences); } }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38473: Include getting generated struct offsets in CodegenABITypes
This change adds a new function, CodeGen::getFieldNumber, that enables a user of clang's code generation to get the field number in a generated LLVM IR struct that corresponds to a particular field in a C struct. It is important to expose this information in Clang's code generation interface because there is no reasonable way for users of Clang's code generation to get this information. In particular: 1. LLVM struct types do not include field names. 2. Clang adds a non-trivial amount of logic to the code generation of LLVM IR types for structs, in particular to handle padding and bit fields. This in some ways is a philosophical continuation of https://reviews.llvm.org/D35180 . I'm working on a programming language that uses Clang to create seamless C interoperability. One of the language features is to create "extern records", which are just structs that have a definition in C code. The language needs to be able to code generate element access to particular structure fields by name, and without this patch, I need to use clang-internal headers to do so. diff --git a/include/clang/CodeGen/CodeGenABITypes.h b/include/clang/CodeGen/CodeGenABITypes.h index 615e55c8b6..f4fa28da1b 100644 --- a/include/clang/CodeGen/CodeGenABITypes.h +++ b/include/clang/CodeGen/CodeGenABITypes.h @@ -78,6 +78,10 @@ llvm::FunctionType *convertFreeFunctionType(CodeGenModule &CGM, llvm::Type *convertTypeForMemory(CodeGenModule &CGM, QualType T); +// Returns a field number for a struct suitable for GEP'ing +unsigned getFieldNumber(CodeGenModule &CGM, +const RecordDecl *RD, const FieldDecl *FD); + } // end namespace CodeGen } // end namespace clang diff --git a/lib/CodeGen/CodeGenABITypes.cpp b/lib/CodeGen/CodeGenABITypes.cpp index 0735a9c3df..759ad75897 100644 --- a/lib/CodeGen/CodeGenABITypes.cpp +++ b/lib/CodeGen/CodeGenABITypes.cpp @@ -17,6 +17,7 @@ //===--===// #include "clang/CodeGen/CodeGenABITypes.h" +#include "CGRecordLayout.h" #include "CodeGenModule.h" #include "clang/CodeGen/CGFunctionInfo.h" #include "clang/Frontend/CodeGenOptions.h" @@ -80,3 +81,8 @@ llvm::Type * CodeGen::convertTypeForMemory(CodeGenModule &CGM, QualType T) { return CGM.getTypes().ConvertTypeForMem(T); } + +unsigned CodeGen::getFieldNumber(CodeGenModule &CGM, + const RecordDecl *RD, const FieldDecl *FD) { + return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D38473: Include getting generated struct offsets in CodegenABITypes
I forgot to include the Phabricator URL for the patch in question. It is here: https://reviews.llvm.org/D38473 Thanks, -michael On Mon, Oct 2, 2017 at 3:19 PM, Michael Ferguson wrote: > This change adds a new function, CodeGen::getFieldNumber, that > enables a user of clang's code generation to get the field number > in a generated LLVM IR struct that corresponds to a particular field > in a C struct. > > It is important to expose this information in Clang's code generation > interface because there is no reasonable way for users of Clang's code > generation to get this information. In particular: > > 1. LLVM struct types do not include field names. > 2. Clang adds a non-trivial amount of logic to the code generation of > LLVM IR types for structs, in particular to handle padding and bit > fields. > > This in some ways is a philosophical continuation of > https://reviews.llvm.org/D35180 . > > I'm working on a programming language that uses Clang to create > seamless C interoperability. One of the language features is to create > "extern records", which are just structs that have a definition in C > code. The language needs to be able to code generate element access to > particular structure fields by name, and without this patch, I need to > use clang-internal headers to do so. > > > > diff --git a/include/clang/CodeGen/CodeGenABITypes.h > b/include/clang/CodeGen/CodeGenABITypes.h > index 615e55c8b6..f4fa28da1b 100644 > --- a/include/clang/CodeGen/CodeGenABITypes.h > +++ b/include/clang/CodeGen/CodeGenABITypes.h > @@ -78,6 +78,10 @@ llvm::FunctionType > *convertFreeFunctionType(CodeGenModule &CGM, > > llvm::Type *convertTypeForMemory(CodeGenModule &CGM, QualType T); > > +// Returns a field number for a struct suitable for GEP'ing > +unsigned getFieldNumber(CodeGenModule &CGM, > +const RecordDecl *RD, const FieldDecl *FD); > + > } // end namespace CodeGen > } // end namespace clang > > diff --git a/lib/CodeGen/CodeGenABITypes.cpp b/lib/CodeGen/CodeGenABITypes.cpp > index 0735a9c3df..759ad75897 100644 > --- a/lib/CodeGen/CodeGenABITypes.cpp > +++ b/lib/CodeGen/CodeGenABITypes.cpp > @@ -17,6 +17,7 @@ > > //===--===// > > #include "clang/CodeGen/CodeGenABITypes.h" > +#include "CGRecordLayout.h" > #include "CodeGenModule.h" > #include "clang/CodeGen/CGFunctionInfo.h" > #include "clang/Frontend/CodeGenOptions.h" > @@ -80,3 +81,8 @@ llvm::Type * > CodeGen::convertTypeForMemory(CodeGenModule &CGM, QualType T) { >return CGM.getTypes().ConvertTypeForMem(T); > } > + > +unsigned CodeGen::getFieldNumber(CodeGenModule &CGM, > + const RecordDecl *RD, const FieldDecl *FD) { > + return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD); > +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38444: [compiler-rt] [cmake] Create dummy gtest target for stand-alone builds
mgorny added a comment. In https://reviews.llvm.org/D38444#886138, @george.karpenkov wrote: > > breaking stand-alone builds as a result > > That's a strong statement. Could you clarify? We have a lot of buildbots > performing standalone builds, and they are still green. I didn't know anyone actually added bots doing that. Are you sure we're talking about the same meaning of 'stand-alone'? Stand-alone == out of LLVM, against installed copy of LLVM. ninja -v -j16 -l0 check-all ninja: error: '/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-/lib/asan/tests/gtest', needed by 'lib/asan/tests/dynamic/Asan-i386-calls-Dynamic-Test', missing and no known rule to make it It's as broken as it could be since it depends on target that does not exist. >> and the likeliness of people mistakenly adding more unconditional >> dependencies > > That's a good point, however I'm not sure how your change would fix the > problem. > As far as I remember targets in compiler-rt had quite a few dependencies > which required checking for whether it is a standalone build. > > In general, I'm not sure what this change would achieve, and the added > complexity can always cause more bugs in the future. My goal is to make things work again. Repository: rL LLVM https://reviews.llvm.org/D38444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. In https://reviews.llvm.org/D38290#885503, @ruiu wrote: > This patch virtually sets `ld64` the linker command name for macOS. I'd be a > bit reluctant doing that, because `ld64` sounds like a too generic name to > indicate "a linker for macOS". But that's probably okay because we don't have > a better name. It's not a good name, but I do believe it is recognizable as the Darwin linker. It's also consistent with the names we invent on other platforms, which are essentially "native linker binary name plus lld". > Can you get an LGTM from someone who owns the clang driver? lgtm Thinking *LONG LONG* term, what I want to see happen is: 1. Annotate the exported C++ API of libLLVM.so to ensure that this does not regress clang compilation time (avoids PLT indirection for calls internal to LLVM) 2. Build with -fvisibility=hidden, so MachO and ELF builds of LLVM work like COFF 3. Make building LLVM.dll/libLLVM.dylib/libLLVM.so the default 4. Stop busy-boxing the LLD ports, and have separate executables for each: ld64.lld, lld-link.exe, and ld.lld This will save disk space and potentially runtime if the loader keeps the LLVM shared object in memory, rather than loading a second copy for every link step in the buidl. Repository: rL LLVM https://reviews.llvm.org/D38290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D38444: [compiler-rt] [cmake] Create dummy gtest target for stand-alone builds
> On Oct 2, 2017, at 12:57 PM, Michał Górny via Phabricator > wrote: > > mgorny added a comment. > > In https://reviews.llvm.org/D38444#886138, @george.karpenkov wrote: > >>> breaking stand-alone builds as a result >> >> That's a strong statement. Could you clarify? We have a lot of buildbots >> performing standalone builds, and they are still green. > > > I didn't know anyone actually added bots doing that. Are you sure we're > talking about the same meaning of 'stand-alone'? Stand-alone == out of LLVM, > against installed copy of LLVM. Yes. You are right though that bots I was referring to do not run unit tests. > > ninja -v -j16 -l0 check-all > ninja: error: > '/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-/lib/asan/tests/gtest', > needed by 'lib/asan/tests/dynamic/Asan-i386-calls-Dynamic-Test', missing and > no known rule to make it > > It's as broken as it could be since it depends on target that does not exist. Right, by “works” I’ve meant that “it compiles”, not that “unit tests pass”. My understanding is that running unit tests never meant to work, as a freshly built clang is usually needed, and in standalone mode it is not available. I could be wrong though, in that case I do not know. Does everything magically work with this dummy target? > >>> and the likeliness of people mistakenly adding more unconditional >>> dependencies >> >> That's a good point, however I'm not sure how your change would fix the >> problem. >> As far as I remember targets in compiler-rt had quite a few dependencies >> which required checking for whether it is a standalone build. >> >> In general, I'm not sure what this change would achieve, and the added >> complexity can always cause more bugs in the future. > > My goal is to make things work again. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D38444 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38380: [libunwind] Add CMake support for building for MinGW
This revision was automatically updated to reflect the committed changes. Closed by commit rL314716: Add CMake support for building for MinGW (authored by mstorsjo). Changed prior to commit: https://reviews.llvm.org/D38380?vs=117046&id=117417#toc Repository: rL LLVM https://reviews.llvm.org/D38380 Files: libunwind/trunk/cmake/config-ix.cmake Index: libunwind/trunk/cmake/config-ix.cmake === --- libunwind/trunk/cmake/config-ix.cmake +++ libunwind/trunk/cmake/config-ix.cmake @@ -29,6 +29,19 @@ elseif (LIBUNWIND_HAS_GCC_S_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s) endif () + if (MINGW) +# Mingw64 requires quite a few "C" runtime libraries in order for basic +# programs to link successfully with -nodefaultlibs. +if (LIBUNWIND_USE_COMPILER_RT) + set(MINGW_RUNTIME ${LIBUNWIND_BUILTINS_LIBRARY}) +else () + set(MINGW_RUNTIME gcc_s gcc) +endif() +set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt advapi32 +shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME} +moldname mingwex msvcrt) +list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES}) + endif() if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all") endif () Index: libunwind/trunk/cmake/config-ix.cmake === --- libunwind/trunk/cmake/config-ix.cmake +++ libunwind/trunk/cmake/config-ix.cmake @@ -29,6 +29,19 @@ elseif (LIBUNWIND_HAS_GCC_S_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s) endif () + if (MINGW) +# Mingw64 requires quite a few "C" runtime libraries in order for basic +# programs to link successfully with -nodefaultlibs. +if (LIBUNWIND_USE_COMPILER_RT) + set(MINGW_RUNTIME ${LIBUNWIND_BUILTINS_LIBRARY}) +else () + set(MINGW_RUNTIME gcc_s gcc) +endif() +set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt advapi32 +shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME} +moldname mingwex msvcrt) +list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES}) + endif() if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all") endif () ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r314716 - Add CMake support for building for MinGW
Author: mstorsjo Date: Mon Oct 2 13:46:37 2017 New Revision: 314716 URL: http://llvm.org/viewvc/llvm-project?rev=314716&view=rev Log: Add CMake support for building for MinGW This section is similar to what already exists in libcxx and libcxxabi. Differential Revision: https://reviews.llvm.org/D38380 Modified: libunwind/trunk/cmake/config-ix.cmake Modified: libunwind/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=314716&r1=314715&r2=314716&view=diff == --- libunwind/trunk/cmake/config-ix.cmake (original) +++ libunwind/trunk/cmake/config-ix.cmake Mon Oct 2 13:46:37 2017 @@ -29,6 +29,19 @@ if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG) elseif (LIBUNWIND_HAS_GCC_S_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s) endif () + if (MINGW) +# Mingw64 requires quite a few "C" runtime libraries in order for basic +# programs to link successfully with -nodefaultlibs. +if (LIBUNWIND_USE_COMPILER_RT) + set(MINGW_RUNTIME ${LIBUNWIND_BUILTINS_LIBRARY}) +else () + set(MINGW_RUNTIME gcc_s gcc) +endif() +set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt advapi32 +shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME} +moldname mingwex msvcrt) +list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES}) + endif() if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all") endif () ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314722 - [Analyzer] Avoid copy and modifying passed reference in BodyFarm::create_call_once
Author: george.karpenkov Date: Mon Oct 2 14:01:46 2017 New Revision: 314722 URL: http://llvm.org/viewvc/llvm-project?rev=314722&view=rev Log: [Analyzer] Avoid copy and modifying passed reference in BodyFarm::create_call_once Differential Revision: https://reviews.llvm.org/D38475 Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=314722&r1=314721&r2=314722&view=diff == --- cfe/trunk/lib/Analysis/BodyFarm.cpp (original) +++ cfe/trunk/lib/Analysis/BodyFarm.cpp Mon Oct 2 14:01:46 2017 @@ -257,10 +257,9 @@ NamedDecl *ASTMaker::findMemberField(con typedef Stmt *(*FunctionFarmer)(ASTContext &C, const FunctionDecl *D); -static CallExpr * -create_call_once_funcptr_call(ASTContext &C, ASTMaker M, - const ParmVarDecl *Callback, - SmallVectorImpl &CallArgs) { +static CallExpr *create_call_once_funcptr_call(ASTContext &C, ASTMaker M, + const ParmVarDecl *Callback, + ArrayRef CallArgs) { return new (C) CallExpr( /*ASTContext=*/C, @@ -271,10 +270,10 @@ create_call_once_funcptr_call(ASTContext /*SourceLocation=*/SourceLocation()); } -static CallExpr * -create_call_once_lambda_call(ASTContext &C, ASTMaker M, - const ParmVarDecl *Callback, QualType CallbackType, - SmallVectorImpl &CallArgs) { +static CallExpr *create_call_once_lambda_call(ASTContext &C, ASTMaker M, + const ParmVarDecl *Callback, + QualType CallbackType, + ArrayRef CallArgs) { CXXRecordDecl *CallbackDecl = CallbackType->getAsCXXRecordDecl(); @@ -293,12 +292,6 @@ create_call_once_lambda_call(ASTContext /* T = */ callOperatorDecl->getType(), /* VK = */ VK_LValue); - CallArgs.insert( - CallArgs.begin(), - M.makeDeclRefExpr(Callback, -/* RefersToEnclosingVariableOrCapture= */ true, -/* GetNonReferenceType= */ true)); - return new (C) CXXOperatorCallExpr(/*AstContext=*/C, OO_Call, callOperatorDeclRef, /*args=*/CallArgs, @@ -335,15 +328,24 @@ static Stmt *create_call_once(ASTContext const ParmVarDecl *Callback = D->getParamDecl(1); QualType CallbackType = Callback->getType().getNonReferenceType(); + bool isLambdaCall = CallbackType->getAsCXXRecordDecl() && + CallbackType->getAsCXXRecordDecl()->isLambda(); + SmallVector CallArgs; + if (isLambdaCall) +// Lambda requires callback itself inserted as a first parameter. +CallArgs.push_back( +M.makeDeclRefExpr(Callback, + /* RefersToEnclosingVariableOrCapture= */ true, + /* GetNonReferenceType= */ true)); + // All arguments past first two ones are passed to the callback. for (unsigned int i = 2; i < D->getNumParams(); i++) CallArgs.push_back(M.makeLvalueToRvalue(D->getParamDecl(i))); CallExpr *CallbackCall; - if (CallbackType->getAsCXXRecordDecl() && - CallbackType->getAsCXXRecordDecl()->isLambda()) { + if (isLambdaCall) { CallbackCall = create_call_once_lambda_call(C, M, Callback, CallbackType, CallArgs); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D38444: [compiler-rt] [cmake] Create dummy gtest target for stand-alone builds
W dniu pon, 02.10.2017 o godzinie 13∶33 -0700, użytkownik George Karpenkov napisał: > > On Oct 2, 2017, at 12:57 PM, Michał Górny via Phabricator > > wrote: > > > > mgorny added a comment. > > > > In https://reviews.llvm.org/D38444#886138, @george.karpenkov wrote: > > > > > > breaking stand-alone builds as a result > > > > > > That's a strong statement. Could you clarify? We have a lot of buildbots > > > performing standalone builds, and they are still green. > > > > > > I didn't know anyone actually added bots doing that. Are you sure we're > > talking about the same meaning of 'stand-alone'? Stand-alone == out of > > LLVM, against installed copy of LLVM. > > Yes. > You are right though that bots I was referring to do not run unit tests. > > > > > ninja -v -j16 -l0 check-all > > ninja: error: > > '/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-/lib/asan/tests/gtest', > > needed by 'lib/asan/tests/dynamic/Asan-i386-calls-Dynamic-Test', missing > > and no known rule to make it > > > > It's as broken as it could be since it depends on target that does not > > exist. > > Right, by “works” I’ve meant that “it compiles”, not that “unit tests pass”. > My understanding is that running unit tests never meant to work, > as a freshly built clang is usually needed, and in standalone mode it is not > available. > I could be wrong though, in that case I do not know. Yes, it requires some extra work to prepare a local clang copy that works correctly but it's certainly doable. > > Does everything magically work with this dummy target? Yes, the tests work as well as they used to before the refactor (there are a few failures but those are unrelated to the change in question). -- Best regards, Michał Górny ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
hintonda added a comment. LGTM... https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38479: Make -mgeneral-regs-only more like GCC's
george.burgess.iv created this revision. Herald added a subscriber: javed.absar. (Copy/pasting the reviewer list from https://reviews.llvm.org/D26856.) Addresses https://bugs.llvm.org/show_bug.cgi?id=30792 . In GCC, -mgeneral-regs-only emits errors upon trying to emit floating-point or vector operations that originate from C/C++ (but not inline assembly). Currently, our behavior is to accept those, but we proceed to "try to form some new horribly unsupported soft-float ABI." Additionally, the way that we disable vector/FP ops causes us to crash when inline assembly uses any vector/FP operations, which is bad. This patch attempts to address these by: - making -mgeneral-regs-only behave exactly like -mno-implicit-float to the backend, which lets inline assembly use FP regs/operations as much as it wants, and - emitting errors for any floating-point expressions/operations we encounter in the frontend. The latter is the more interesting bit. We want to allow declarations with floats/vectors as much as possible, but the moment that we actually try to use a float/vector, we should diagnose it. In less words: float f(float a); // OK int j = f(1); // Not OK on two points: returns a float, takes a float float f(float a) { // Not OK: defines a function that takes a float and returns // a float return 0; // Not OK: 0 is converted to a float. } A trivial implementation of this leaves us with a terrible diagnostic experience (e.g. int r() { int i = 0, j = 0; return 1.0 + i + j; } emits many, many diagnostics about implicit float casts, floating adds, etc. Other kinds of diagnostics, like diagnosing default args, are also very low-quality), so the majority of this patch is an attempt to handle common cases more gracefully. Since the target audience for this is presumably very small, and the cost of not emitting a diagnostic when we should is *a lot* of debugging, I erred on the side of simplicity for a lot of this. I think this patch does a reasonably good job of offering targeted error messages in the majority of cases. There are a few cases where we'll allow floating-point/vector values to conceptually be used: int i = 1.0 + 1; // OK: guaranteed to fold to an int float foo(); int bar(int i = foo()); // OK: just a decl. int baz() { int a = bar(1); // OK: we never actually call foo(). int b = bar(); // Error: calling foo(). return a + b; } struct A { float b; }; void qux(struct A *a, struct A *b) { // OK: we've been codegening @llvm.memcpys for this seemingly since 2012. // For the moment, this bit is C-only, and very constrained (e.g. assignments // only, rhs must trivially be an lvalue, ...). *a = *b; } The vibe I got from the bug is that the soft-float incantations we currently emit when using -mgeneral-regs-only are basically unused, so I'm unsure if we want a flag/option that lets users flip back to the current -mgeneral-regs-only behavior. This patch lacks that feature, but I'm happy to add it if people believe doing so would be valuable. One final note: this may seem like a problem better solved in CodeGen. I avoided doing so because that approach had a few downsides: - how we codegen any expression that might have FP becomes observable, - checks for this become spread out across many, many places, making it really easy to miss a case/forget to add it in a new place (see the above "few users, bugs are expensive" point), and - it seems really difficult to "look upwards" in CodeGen to pattern match these into nicer diagnostics, especially in the case of default arguments, etc. https://reviews.llvm.org/D38479 Files: docs/UsersManual.rst include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/LangOptions.def include/clang/Driver/CC1Options.td include/clang/Sema/Sema.h lib/Driver/ToolChains/Arch/AArch64.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExprCXX.cpp test/CodeGen/aarch64-mgeneral_regs_only.c test/Driver/aarch64-mgeneral_regs_only.c test/Sema/aarch64-mgeneral_regs_only.c test/SemaCXX/aarch64-mgeneral_regs_only.cpp Index: test/SemaCXX/aarch64-mgeneral_regs_only.cpp === --- /dev/null +++ test/SemaCXX/aarch64-mgeneral_regs_only.cpp @@ -0,0 +1,124 @@ +// RUN: %clang_cc1 -triple aarch64-linux-eabi -std=c++11 -general-regs-only %s -verify -DBANNED=float -Wno-unused-value +// RUN: %clang_cc1 -triple aarch64-linux-eabi -std=c++11 -general-regs-only %s -verify -DBANNED=int '-DVECATTR=__attribute__((ext_vector_type(2)))' -Wno-unused-value +// RUN: %clang_cc1 -triple aarch64-linux-eabi -std=c++11 -general-regs-only %s -verify -DBANNED=FloatTypedef -Wno-unused-value + +using FloatTypedef = float; + +#ifndef VECATTR +#define VECATTR +#define BannedToInt(x) (x) +#else +#define BannedToInt(x) ((x)[0]) +#endif + +typedef BANNED BannedTy V
[PATCH] D38048: [clangd] Add textDocument/signatureHelp
rwols updated this revision to Diff 117427. rwols added a comment. - Update `invokeCodeComplete` function to also take a `CodeCompleteOptions`, we assign it to the `CompilerInstance`'s `FrontendOpts.CodeCompleteOpts`. - Remove unused variable in `SignatureHelpCollector::ProcessOverloadCandidate`. https://reviews.llvm.org/D38048 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/ClangdServer.cpp clangd/ClangdServer.h clangd/ClangdUnit.cpp clangd/ClangdUnit.h clangd/Protocol.cpp clangd/Protocol.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h test/clangd/formatting.test test/clangd/initialize-params-invalid.test test/clangd/initialize-params.test test/clangd/signature-help.test Index: test/clangd/signature-help.test === --- /dev/null +++ test/clangd/signature-help.test @@ -0,0 +1,42 @@ +# RUN: clangd -run-synchronously < %s | FileCheck %s +# It is absolutely vital that this file has CRLF line endings. + +# Start a session. +Content-Length: 125 + +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} + +# Modify the document. +Content-Length: 333 + +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"void foo(int x, int y);\nvoid foo(int x, float y);\nvoid foo(float x, int y);\nvoid foo(float x, float y);\nvoid bar(int x, int y = 0);\nvoid bar(float x = 0, int y = 42);\nint main() { foo("}}} + +# Ask for signature help. +Content-Length: 151 + +{"jsonrpc":"2.0","id":1,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":8,"character":9}}} +# CHECK: {"jsonrpc":"2.0","id":1,"result":{"activeSignature":0,"activeParameter":0,"signatures":[ +# CHECK-DAG: {"label":"foo(float x, float y) -> void","parameters":[{"label":"float x"},{"label":"float y"}]} +# CHECK-DAG: {"label":"foo(float x, int y) -> void","parameters":[{"label":"float x"},{"label":"int y"}]} +# CHECK-DAG: {"label":"foo(int x, float y) -> void","parameters":[{"label":"int x"},{"label":"float y"}]} +# CHECK-DAG: {"label":"foo(int x, int y) -> void","parameters":[{"label":"int x"},{"label":"int y"}]} +# CHECK: ]} + +# Modify the document +Content-Length: 333 + +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":2,"text":"void foo(int x, int y);\nvoid foo(int x, float y);\nvoid foo(float x, int y);\nvoid foo(float x, float y);\nvoid bar(int x, int y = 0);\nvoid bar(float x = 0, int y = 42);\nint main() { bar("}}} + +# Ask for signature help (this checks default argument handling). +Content-Length: 151 + +{"jsonrpc":"2.0","id":2,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":8,"character":9}}} +# CHECK: {"jsonrpc":"2.0","id":2,"result":{"activeSignature":0,"activeParameter":0,"signatures":[ +# CHECK-DAG: {"label":"bar(int x, int y = 0) -> void","parameters":[{"label":"int x"},{"label":"int y = 0"}]} +# CHECK-DAG: {"label":"bar(float x = 0, int y = 42) -> void","parameters":[{"label":"float x = 0"},{"label":"int y = 42"}]} +# CHECK: ]} + +# Shutdown. +Content-Length: 49 + +{"jsonrpc":"2.0","id":10,"method":"shutdown"} Index: test/clangd/initialize-params.test === --- test/clangd/initialize-params.test +++ test/clangd/initialize-params.test @@ -5,14 +5,15 @@ Content-Length: 143 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}} -# CHECK: Content-Length: 466 +# CHECK: Content-Length: 535 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{ # CHECK: "textDocumentSync": 1, # CHECK: "documentFormattingProvider": true, # CHECK: "documentRangeFormattingProvider": true, # CHECK: "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]}, # CHECK: "codeActionProvider": true, # CHECK: "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]}, +# CHECK: "signatureHelpProvider": {"triggerCharacters": ["(",","]}, # CHECK: "definitionProvider": true # CHECK: }}} # Index: test/clangd/initialize-params-invalid.test === --- test/clangd/initialize-params-invalid.test +++ test/clangd/initialize-params-invalid.test @@ -5,14 +5,15 @@ Content-Length: 142 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":"","rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}} -# CHECK: Content-Length: 466 +# CHECK: Content-Length: 535 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{ # CHECK: "textDocumentSync": 1, # CHECK: "documentFormattingProvider": true,
r314733 - PR33839: Fix -Wunused handling for structured binding declarations.
Author: rsmith Date: Mon Oct 2 15:43:36 2017 New Revision: 314733 URL: http://llvm.org/viewvc/llvm-project?rev=314733&view=rev Log: PR33839: Fix -Wunused handling for structured binding declarations. We warn about a structured binding declaration being unused only if none of its bindings are used. Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/test/SemaCXX/unused.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=314733&r1=314732&r2=314733&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Oct 2 15:43:36 2017 @@ -1604,7 +1604,24 @@ static bool ShouldDiagnoseUnusedDecl(con if (D->isInvalidDecl()) return false; - if (D->isReferenced() || D->isUsed() || D->hasAttr() || + bool Referenced = false; + if (auto *DD = dyn_cast(D)) { +// For a decomposition declaration, warn if none of the bindings are +// referenced, instead of if the variable itself is referenced (which +// it is, by the bindings' expressions). +for (auto *BD : DD->bindings()) { + if (BD->isReferenced()) { +Referenced = true; +break; + } +} + } else if (!D->getDeclName()) { +return false; + } else if (D->isReferenced() || D->isUsed()) { +Referenced = true; + } + + if (Referenced || D->hasAttr() || D->hasAttr()) return false; @@ -1727,7 +1744,7 @@ void Sema::DiagnoseUnusedDecl(const Name else DiagID = diag::warn_unused_variable; - Diag(D->getLocation(), DiagID) << D->getDeclName() << Hint; + Diag(D->getLocation(), DiagID) << D << Hint; } static void CheckPoppedLabel(LabelDecl *L, Sema &S) { @@ -1757,8 +1774,6 @@ void Sema::ActOnPopScope(SourceLocation assert(isa(TmpD) && "Decl isn't NamedDecl?"); NamedDecl *D = cast(TmpD); -if (!D->getDeclName()) continue; - // Diagnose unused variables in this scope. if (!S->hasUnrecoverableErrorOccurred()) { DiagnoseUnusedDecl(D); @@ -1766,6 +1781,8 @@ void Sema::ActOnPopScope(SourceLocation DiagnoseUnusedNestedTypedefs(RD); } +if (!D->getDeclName()) continue; + // If this was a forward reference to a label, verify it was defined. if (LabelDecl *LD = dyn_cast(D)) CheckPoppedLabel(LD, *this); @@ -6164,7 +6181,6 @@ NamedDecl *Sema::ActOnVariableDeclarator IdentifierInfo *II = Name.getAsIdentifierInfo(); if (D.isDecompositionDeclarator()) { -AddToScope = false; // Take the name of the first declarator as our name for diagnostic // purposes. auto &Decomp = D.getDecompositionDeclarator(); Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=314733&r1=314732&r2=314733&view=diff == --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Oct 2 15:43:36 2017 @@ -829,7 +829,10 @@ Sema::ActOnDecompositionDeclarator(Scope NamedDecl *New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, MultiTemplateParamsArg(), AddToScope, Bindings); - CurContext->addHiddenDecl(New); + if (AddToScope) { +S->AddDecl(New); +CurContext->addHiddenDecl(New); + } if (isInOpenMPDeclareTargetContext()) checkDeclIsAllowedInOpenMPTarget(nullptr, New); Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=314733&r1=314732&r2=314733&view=diff == --- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Oct 2 15:43:36 2017 @@ -677,6 +677,7 @@ TemplateDeclInstantiator::VisitTypeAlias Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) { auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(), D->getIdentifier()); + NewBD->setReferenced(D->isReferenced()); SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewBD); return NewBD; } Modified: cfe/trunk/test/SemaCXX/unused.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unused.cpp?rev=314733&r1=314732&r2=314733&view=diff == --- cfe/trunk/test/SemaCXX/unused.cpp (original) +++ cfe/trunk/test/SemaCXX/unused.cpp Mon Oct 2 15:43:36 2017 @@ -1,6 +1,7 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -
[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
bsdjhb updated this revision to Diff 117438. bsdjhb added a comment. - Fixes from review feedback. https://reviews.llvm.org/D38110 Files: include/__libunwind_config.h include/libunwind.h src/Registers.hpp src/UnwindCursor.hpp src/UnwindRegistersRestore.S src/UnwindRegistersSave.S src/config.h src/libunwind.cpp Index: src/libunwind.cpp === --- src/libunwind.cpp +++ src/libunwind.cpp @@ -58,8 +58,12 @@ # define REGISTER_KIND Registers_arm #elif defined(__or1k__) # define REGISTER_KIND Registers_or1k +#elif defined(__mips__) && _MIPS_SIM == _ABIO32 && defined(__mips_soft_float) +# define REGISTER_KIND Registers_mips_o32 +#elif defined(__mips__) && _MIPS_SIM == _ABI64 && defined(__mips_soft_float) +# define REGISTER_KIND Registers_mips_n64 #elif defined(__mips__) -# warning The MIPS architecture is not supported. +# warning The MIPS architecture is not supported with this ABI and environment! #else # error Architecture not supported #endif Index: src/config.h === --- src/config.h +++ src/config.h @@ -65,7 +65,7 @@ defined(__ppc__) || defined(__ppc64__) || \ (!defined(__APPLE__) && defined(__arm__)) || \ (defined(__arm64__) || defined(__aarch64__)) ||\ -(defined(__APPLE__) && defined(__mips__)) +defined(__mips__) #define _LIBUNWIND_BUILD_ZERO_COST_APIS #endif Index: src/UnwindRegistersSave.S === --- src/UnwindRegistersSave.S +++ src/UnwindRegistersSave.S @@ -87,6 +87,76 @@ xorl %eax, %eax# return UNW_ESUCCESS ret +#elif defined(__mips__) && _MIPS_SIM == _ABIO32 + +# +# extern int unw_getcontext(unw_context_t* thread_state) +# +# On entry: +# thread_state pointer is in a0 ($4) +# +# Only save registers preserved across calls. +# +DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) + .set push + .set noat + .set noreorder + .set nomacro + # s0 - s7 + sw$16, (4 * 16)($4) + sw$17, (4 * 17)($4) + sw$18, (4 * 18)($4) + sw$19, (4 * 19)($4) + sw$20, (4 * 20)($4) + sw$21, (4 * 21)($4) + sw$22, (4 * 22)($4) + sw$23, (4 * 23)($4) + # gp + sw$28, (4 * 28)($4) + # sp + sw$29, (4 * 29)($4) + # Store return address to pc + sw$31, (4 * 32)($4) + jr $31 + # fp (in delay slot) + sw$30, (4 * 30)($4) + .set pop + +#elif defined(__mips__) && _MIPS_SIM == _ABI64 + +# +# extern int unw_getcontext(unw_context_t* thread_state) +# +# On entry: +# thread_state pointer is in a0 ($4) +# +# Only save registers preserved across calls. +# +DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) + .set push + .set noat + .set noreorder + .set nomacro + # s0 - s7 + sd$16, (8 * 16)($4) + sd$17, (8 * 17)($4) + sd$18, (8 * 18)($4) + sd$19, (8 * 19)($4) + sd$20, (8 * 20)($4) + sd$21, (8 * 21)($4) + sd$22, (8 * 22)($4) + sd$23, (8 * 23)($4) + # gp + sd$28, (8 * 28)($4) + # sp + sd$29, (8 * 29)($4) + # Store return address to pc + sd$31, (8 * 32)($4) + jr $31 + # fp (in delay slot) + sd$30, (8 * 30)($4) + .set pop + # elif defined(__mips__) # Index: src/UnwindRegistersRestore.S === --- src/UnwindRegistersRestore.S +++ src/UnwindRegistersRestore.S @@ -489,6 +489,108 @@ l.jr r9 l.nop +#elif defined(__mips__) && _MIPS_SIM == _ABIO32 + +// +// void libunwind::Registers_mips_o32::jumpto() +// +// On entry: +// thread state pointer is in a0 ($4) +// +DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv) + .set push + .set noat + .set noreorder + .set nomacro + // r0 is zero + lw$1, (4 * 1)($4) + lw$2, (4 * 2)($4) + lw$3, (4 * 3)($4) + // skip a0 for now + lw$5, (4 * 5)($4) + lw$6, (4 * 6)($4) + lw$7, (4 * 7)($4) + lw$8, (4 * 8)($4) + lw$9, (4 * 9)($4) + lw$10, (4 * 10)($4) + lw$11, (4 * 11)($4) + lw$12, (4 * 12)($4) + lw$13, (4 * 13)($4) + lw$14, (4 * 14)($4) + lw$15, (4 * 15)($4) + lw$16, (4 * 16)($4) + lw$17, (4 * 17)($4) + lw$18, (4 * 18)($4) + lw$19, (4 * 19)($4) + lw$20, (4 * 20)($4) + lw$21, (4 * 21)($4) + lw$22, (4 * 22)($4) + lw$23, (4 * 23)($4) + lw$24, (4 * 24)($4) + lw$25, (4 * 25)($4) + lw$26, (4 * 26)($4) + lw$27, (4 * 27)($4) + lw$28, (4 * 28)($4) + lw$29, (4 * 29)($4) + lw$30, (4 * 30)($4) + // load new pc into ra + lw$31, (4 * 32)($4) + // jump to ra, load a0 in the delay slot + jr$31 + lw$4, (4 * 4)($4) + .set pop + +#elif defined(__mips__) && _MIPS_SIM == _ABI64 + +// +// void libunwind::Registers_mips_n64::jumpto() +// +// On entry: +// thread state pointer is in a0 ($4) +// +DEFINE_LIBUNWIND_PRIVATE_FUNC
[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
bsdjhb marked 14 inline comments as done. bsdjhb added a comment. I have only tested this (test programs as mentioned earlier) with clang 5.0.0 (with a few patches) on o32 and n64. I am in the process of performing the same tests with GCC 6.3.0. I will also spend some time figuring out how to cross-build libunwind tests and run them inside of a qemu instance. https://reviews.llvm.org/D38110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r314735 - Improve test runner output for broken configurations.
Author: ericwf Date: Mon Oct 2 15:52:51 2017 New Revision: 314735 URL: http://llvm.org/viewvc/llvm-project?rev=314735&view=rev Log: Improve test runner output for broken configurations. Previously LIT would often fail while attempting to set up/configure the test compiler; normally when attempting to dump the builtin macros. This sort of failure provided no useful information about what went wrong with the compiler, making the actual issues hard --- if not impossible --- to debug easily. This patch changes the LIT configuration to report the failure explicitly, including the failed compile command and the stdout/stderr output. Modified: libcxx/trunk/utils/libcxx/compiler.py libcxx/trunk/utils/libcxx/test/config.py Modified: libcxx/trunk/utils/libcxx/compiler.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/compiler.py?rev=314735&r1=314734&r2=314735&view=diff == --- libcxx/trunk/utils/libcxx/compiler.py (original) +++ libcxx/trunk/utils/libcxx/compiler.py Mon Oct 2 15:52:51 2017 @@ -204,7 +204,7 @@ class CXXCompiler(object): flags = ['-dM'] + flags cmd, out, err, rc = self.preprocess(source_files, flags=flags, cwd=cwd) if rc != 0: -return None +return cmd, out, err, rc parsed_macros = {} lines = [l.strip() for l in out.split('\n') if l.strip()] for l in lines: Modified: libcxx/trunk/utils/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=314735&r1=314734&r2=314735&view=diff == --- libcxx/trunk/utils/libcxx/test/config.py (original) +++ libcxx/trunk/utils/libcxx/test/config.py Mon Oct 2 15:52:51 2017 @@ -259,6 +259,16 @@ class Configuration(object): compile_flags=compile_flags, link_flags=link_flags) +def _dump_macros_verbose(self, *args, **kwargs): +macros_or_error = self.cxx.dumpMacros(*args, **kwargs) +if isinstance(macros_or_error, tuple): +cmd, out, err, rc = macros_or_error +report = libcxx.util.makeReport(cmd, out, err, rc) +report += "Compiler failed unexpectedly when dumping macros!" +self.lit_config.fatal(report) +return None +assert isinstance(macros_or_error, dict) +return macros_or_error def configure_src_root(self): self.libcxx_src_root = self.get_lit_conf( @@ -446,7 +456,7 @@ class Configuration(object): if self.get_lit_bool('has_libatomic', False): self.config.available_features.add('libatomic') -macros = self.cxx.dumpMacros() +macros = self._dump_macros_verbose() if '__cpp_if_constexpr' not in macros: self.config.available_features.add('libcpp-no-if-constexpr') @@ -468,7 +478,7 @@ class Configuration(object): # Attempt to detect the glibc version by querying for __GLIBC__ # in 'features.h'. -macros = self.cxx.dumpMacros(flags=['-include', 'features.h']) +macros = self._dump_macros_verbose(flags=['-include', 'features.h']) if macros is not None and '__GLIBC__' in macros: maj_v, min_v = (macros['__GLIBC__'], macros['__GLIBC_MINOR__']) self.config.available_features.add('glibc') @@ -627,8 +637,8 @@ class Configuration(object): """ # Parse the macro contents of __config_site by dumping the macros # using 'c++ -dM -E' and filtering the predefines. -predefines = self.cxx.dumpMacros() -macros = self.cxx.dumpMacros(header) +predefines = self._dump_macros_verbose() +macros = self._dump_macros_verbose(header) feature_macros_keys = set(macros.keys()) - set(predefines.keys()) feature_macros = {} for k in feature_macros_keys: @@ -980,7 +990,7 @@ class Configuration(object): def configure_coroutines(self): if self.cxx.hasCompileFlag('-fcoroutines-ts'): -macros = self.cxx.dumpMacros(flags=['-fcoroutines-ts']) +macros = self._dump_macros_verbose(flags=['-fcoroutines-ts']) if '__cpp_coroutines' not in macros: self.lit_config.warning('-fcoroutines-ts is supported but ' '__cpp_coroutines is not defined') ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime
hfinkel added a comment. Is this still being worked on? https://reviews.llvm.org/D31417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
LLVM buildmaster will be updated and restarted tonight
Hello everyone, LLVM buildmaster will be updated and restarted after 7 PM Pacific time. Thanks Galina ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38483: [ExprConstant] Allow constexpr ctor to modify non static data members in body
erik.pilkington created this revision. Previously, clang rejected the following (copied from PR19741): struct A { int a = 0; constexpr A() { a = 1; } }; constexpr bool f() { constexpr A a; static_assert(a.a == 1, ""); return a.a == 1; } static_assert(f(), ""); Clang didn't like the assignment to `a` in `A()` because it doesn't know that A is being constructed and therefore considers the subobject A.a to be const. The fix in this patch (which @rsmith suggested in the PR) is just to keep track of the set of objects that are currently being constructed, and strip away the const whenever we encounter a subobject of an object under construction. https://bugs.llvm.org/show_bug.cgi?id=19741 Thanks for taking a look! Erik https://reviews.llvm.org/D38483 Files: lib/AST/ExprConstant.cpp test/SemaCXX/constant-expression-cxx1y.cpp Index: test/SemaCXX/constant-expression-cxx1y.cpp === --- test/SemaCXX/constant-expression-cxx1y.cpp +++ test/SemaCXX/constant-expression-cxx1y.cpp @@ -988,3 +988,36 @@ void(); } constexpr int void_test = (Void(0), 1); + +namespace PR19741 { +constexpr void addone(int &m) { m++; } + +struct S { + int m = 0; + constexpr S() { addone(m); } +}; +constexpr bool evalS() { + constexpr S s; + return s.m == 1; +} +static_assert(evalS(), ""); + +struct Nested { + struct First { int x = 42; }; + union { +First first; +int second; + }; + int x; + constexpr Nested(int x) : first(), x(x) { x = 4; } + constexpr Nested() : Nested(42) { +addone(first.x); +x = 3; + } +}; +constexpr bool evalNested() { + constexpr Nested N; + return N.first.x == 43; +} +static_assert(evalNested(), ""); +} // namespace PR19741 Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -573,6 +573,30 @@ /// declaration whose initializer is being evaluated, if any. APValue *EvaluatingDeclValue; +typedef std::pair EvaluatingObject; + +/// EvaluatingConstructors - Set of objects that are currently being +/// constructed. +llvm::DenseSet EvaluatingConstructors; + +struct EvaluatingConstructorRAII { + EvalInfo &EI; + EvaluatingObject Object; + bool DidInsert; + EvaluatingConstructorRAII(EvalInfo &EI, EvaluatingObject Object) + : EI(EI), Object(Object) { +DidInsert = EI.EvaluatingConstructors.insert(Object).second; + } + ~EvaluatingConstructorRAII() { +if (DidInsert) EI.EvaluatingConstructors.erase(Object); + } +}; + +bool isEvaluatingConstructor(APValue::LValueBase Decl, unsigned CallIndex) { + return Decl == EvaluatingDecl || +EvaluatingConstructors.count(EvaluatingObject(Decl, CallIndex)); +} + /// The current array initialization index, if we're performing array /// initialization. uint64_t ArrayInitIndex = -1; @@ -3101,7 +3125,7 @@ // FIXME: We don't set up EvaluatingDecl for local variables or temporaries, // and this doesn't do quite the right thing for const subobjects of the // object under construction. - if (LVal.getLValueBase() == Info.EvaluatingDecl) { + if (Info.isEvaluatingConstructor(LVal.getLValueBase(), LVal.CallIndex)) { BaseType = Info.Ctx.getCanonicalType(BaseType); BaseType.removeLocalConst(); } @@ -4254,6 +4278,8 @@ return false; } + EvalInfo::EvaluatingConstructorRAII EvalObj( + Info, {This.getLValueBase(), This.CallIndex}); CallStackFrame Frame(Info, CallLoc, Definition, &This, ArgValues); // FIXME: Creating an APValue just to hold a nonexistent return value is Index: test/SemaCXX/constant-expression-cxx1y.cpp === --- test/SemaCXX/constant-expression-cxx1y.cpp +++ test/SemaCXX/constant-expression-cxx1y.cpp @@ -988,3 +988,36 @@ void(); } constexpr int void_test = (Void(0), 1); + +namespace PR19741 { +constexpr void addone(int &m) { m++; } + +struct S { + int m = 0; + constexpr S() { addone(m); } +}; +constexpr bool evalS() { + constexpr S s; + return s.m == 1; +} +static_assert(evalS(), ""); + +struct Nested { + struct First { int x = 42; }; + union { +First first; +int second; + }; + int x; + constexpr Nested(int x) : first(), x(x) { x = 4; } + constexpr Nested() : Nested(42) { +addone(first.x); +x = 3; + } +}; +constexpr bool evalNested() { + constexpr Nested N; + return N.first.x == 43; +} +static_assert(evalNested(), ""); +} // namespace PR19741 Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -573,6 +573,30 @@ /// declaration whose initializer is being evaluated, if any. APValue *EvaluatingDeclValue; +typedef std::pair EvaluatingObject; + +/// EvaluatingCon
RE: D31417: [OpenMP] Add support for omp simd pragmas without runtime
Yes, actually, I will have a meeting with ARM team on this. Xinmin -Original Message- From: Hal Finkel via Phabricator [mailto:revi...@reviews.llvm.org] Sent: Monday, October 2, 2017 4:19 PM To: graham.hun...@arm.com; kkw...@gmail.com; Tian, Xinmin ; a.bat...@hotmail.com Cc: hfin...@anl.gov; francesco.petroga...@arm.com; renato.go...@linaro.org; cfe-commits@lists.llvm.org Subject: [PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime hfinkel added a comment. Is this still being worked on? https://reviews.llvm.org/D31417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r270962 - [OPENMP] Fixed processing of '-fopenmp-version=' option and test.
Hi, Alexey, At what point can we switch, by default, to reporting a version for _OPENMP corresponding to 4.x? We're missing out on some OpenMP simd directives because the source code guards them with '#if _OPENMP >= 201307' or similar. Thanks again, Hal On 05/26/2016 11:13 PM, Alexey Bataev via cfe-commits wrote: Author: abataev Date: Thu May 26 23:13:39 2016 New Revision: 270962 URL: http://llvm.org/viewvc/llvm-project?rev=270962&view=rev Log: [OPENMP] Fixed processing of '-fopenmp-version=' option and test. Modified: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/test/OpenMP/driver.c Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=270962&r1=270961&r2=270962&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Thu May 26 23:13:39 2016 @@ -4864,7 +4864,6 @@ void Clang::ConstructJob(Compilation &C, // Forward flags for OpenMP if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ, options::OPT_fno_openmp, false)) { -Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ); switch (getOpenMPRuntime(getToolChain(), Args)) { case OMPRT_OMP: case OMPRT_IOMP5: @@ -4877,6 +4876,7 @@ void Clang::ConstructJob(Compilation &C, if (!Args.hasFlag(options::OPT_fopenmp_use_tls, options::OPT_fnoopenmp_use_tls, /*Default=*/true)) CmdArgs.push_back("-fnoopenmp-use-tls"); + Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ); break; default: // By default, if Clang doesn't know how to generate useful OpenMP code Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=270962&r1=270961&r2=270962&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu May 26 23:13:39 2016 @@ -1954,15 +1954,16 @@ static void ParseLangArgs(LangOptions &O } // Check if -fopenmp is specified. - Opts.OpenMP = Args.hasArg(options::OPT_fopenmp); + Opts.OpenMP = Args.hasArg(options::OPT_fopenmp) ? 1 : 0; Opts.OpenMPUseTLS = Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls); Opts.OpenMPIsDevice = Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device); if (Opts.OpenMP) { -if (int Version = getLastArgIntValue(Args, OPT_fopenmp_version_EQ, - Opts.OpenMP, Diags)) +int Version = +getLastArgIntValue(Args, OPT_fopenmp_version_EQ, Opts.OpenMP, Diags); +if (Version != 0) Opts.OpenMP = Version; // Provide diagnostic when a given target is not expected to be an OpenMP // device or host. Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=270962&r1=270961&r2=270962&view=diff == --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu May 26 23:13:39 2016 @@ -922,24 +922,24 @@ static void InitializePredefinedMacros(c } // OpenMP definition - if (LangOpts.OpenMP) { -// OpenMP 2.2: -// In implementations that support a preprocessor, the _OPENMP -// macro name is defined to have the decimal value mm where -// and mm are the year and the month designations of the -// version of the OpenMP API that the implementation support. -switch (LangOpts.OpenMP) { -case 40: - Builder.defineMacro("_OPENMP", "201307"); - break; -case 45: - Builder.defineMacro("_OPENMP", "201511"); - break; -default: - // Default version is OpenMP 3.1 - Builder.defineMacro("_OPENMP", "201107"); - break; -} + // OpenMP 2.2: + // In implementations that support a preprocessor, the _OPENMP + // macro name is defined to have the decimal value mm where + // and mm are the year and the month designations of the + // version of the OpenMP API that the implementation support. + switch (LangOpts.OpenMP) { + case 0: +break; + case 40: +Builder.defineMacro("_OPENMP", "201307"); +break; + case 45: +Builder.defineMacro("_OPENMP", "201511"); +break; + default: +// Default version is OpenMP 3.1 +Builder.defineMacro("_OPENMP", "201107"); +break; } // CUDA device path compilaton Modified: cfe/trunk/test/OpenMP/driver.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/driver.c?rev=270962&r1=270961&r2=270962
[PATCH] D38483: [ExprConstant] Allow constexpr ctor to modify non static data members in body
rsmith added inline comments. Comment at: lib/AST/ExprConstant.cpp:576 +typedef std::pair EvaluatingObject; + Please add a comment explaining what the two fields mean. Comment at: lib/AST/ExprConstant.cpp:588 + : EI(EI), Object(Object) { +DidInsert = EI.EvaluatingConstructors.insert(Object).second; + } Can the `DidInsert == false` case actually happen? Comment at: lib/AST/ExprConstant.cpp:596 +bool isEvaluatingConstructor(APValue::LValueBase Decl, unsigned CallIndex) { + return Decl == EvaluatingDecl || +EvaluatingConstructors.count(EvaluatingObject(Decl, CallIndex)); Hmm, should we check the `CallIndex` is 0 in this case? I think we technically don't need to, but only because we happen to only evaluate the initializer of local variables before the enclosing function has its body attached. Perhaps we could insert `EvaluatingDecl` into the `EvaluatingConstructors` list and simplify this check to just the `DenseSet` lookup? https://reviews.llvm.org/D38483 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits