[PATCH] D44539: [Sema][Objective-C] Add check to warn when property of objc type has assign attribute
rjmccall added a comment. Herald added a subscriber: jfb. Hey, still working on this? Repository: rC Clang https://reviews.llvm.org/D44539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339317 - Correctly initialise global blocks on Windows.
Author: theraven Date: Thu Aug 9 01:02:42 2018 New Revision: 339317 URL: http://llvm.org/viewvc/llvm-project?rev=339317&view=rev Log: Correctly initialise global blocks on Windows. Summary: Windows does not allow globals to be initialised to point to globals in another DLL. Exported globals may be referenced only from code. Work around this by creating an initialiser that runs in early library initialisation and sets the isa pointer. Reviewers: rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50436 Added: cfe/trunk/test/CodeGen/global-blocks-win32.c Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=339317&r1=339316&r2=339317&view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Aug 9 01:02:42 2018 @@ -1213,9 +1213,13 @@ static llvm::Constant *buildGlobalBlock( auto fields = builder.beginStruct(); bool IsOpenCL = CGM.getLangOpts().OpenCL; + bool IsWindows = CGM.getTarget().getTriple().isOSWindows(); if (!IsOpenCL) { // isa -fields.add(CGM.getNSConcreteGlobalBlock()); +if (IsWindows) + fields.addNullPointer(CGM.Int8PtrPtrTy); +else + fields.add(CGM.getNSConcreteGlobalBlock()); // __flags BlockFlags flags = BLOCK_IS_GLOBAL | BLOCK_HAS_SIGNATURE; @@ -1250,7 +1254,27 @@ static llvm::Constant *buildGlobalBlock( llvm::Constant *literal = fields.finishAndCreateGlobal( "__block_literal_global", blockInfo.BlockAlign, - /*constant*/ true, llvm::GlobalVariable::InternalLinkage, AddrSpace); + /*constant*/ !IsWindows, llvm::GlobalVariable::InternalLinkage, AddrSpace); + + // Windows does not allow globals to be initialised to point to globals in + // different DLLs. Any such variables must run code to initialise them. + if (IsWindows) { +auto *Init = llvm::Function::Create(llvm::FunctionType::get(CGM.VoidTy, + {}), llvm::GlobalValue::InternalLinkage, ".block_isa_init", +&CGM.getModule()); +llvm::IRBuilder<> b(llvm::BasicBlock::Create(CGM.getLLVMContext(), "entry", + Init)); +b.CreateAlignedStore(CGM.getNSConcreteGlobalBlock(), +b.CreateStructGEP(literal, 0), CGM.getPointerAlign().getQuantity()); +b.CreateRetVoid(); +// We can't use the normal LLVM global initialisation array, because we +// need to specify that this runs early in library initialisation. +auto *InitVar = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), +/*isConstant*/true, llvm::GlobalValue::InternalLinkage, +Init, ".block_isa_init_ptr"); +InitVar->setSection(".CRT$XCLa"); +CGM.addUsedGlobal(InitVar); + } // Return a constant of the appropriately-casted type. llvm::Type *RequiredType = Added: cfe/trunk/test/CodeGen/global-blocks-win32.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/global-blocks-win32.c?rev=339317&view=auto == --- cfe/trunk/test/CodeGen/global-blocks-win32.c (added) +++ cfe/trunk/test/CodeGen/global-blocks-win32.c Thu Aug 9 01:02:42 2018 @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fblocks -triple i386-pc-windows-msvc %s -emit-llvm -o - -fblocks | FileCheck %s + + +int (^x)(void) = ^() { return 21; }; + + +// Check that the block literal is emitted with a null isa pointer +// CHECK: @__block_literal_global = internal global { i8**, i32, i32, i8*, %struct.__block_descriptor* } { i8** null, + +// Check that _NSConcreteGlobalBlock has the correct dllimport specifier. +// CHECK: @_NSConcreteGlobalBlock = external dllimport global i8* +// Check that we create an initialiser pointer in the correct section (early library initialisation). +// CHECK: @.block_isa_init_ptr = internal constant void ()* @.block_isa_init, section ".CRT$XCLa" + +// Check that we emit an initialiser for it. +// CHECK: define internal void @.block_isa_init() { +// CHECK: store i8** @_NSConcreteGlobalBlock, i8*** getelementptr inbounds ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }, { i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global, i32 0, i32 0), align 4 + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50436: Correctly initialise global blocks on Windows.
This revision was automatically updated to reflect the committed changes. Closed by commit rL339317: Correctly initialise global blocks on Windows. (authored by theraven, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D50436 Files: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/test/CodeGen/global-blocks-win32.c Index: cfe/trunk/test/CodeGen/global-blocks-win32.c === --- cfe/trunk/test/CodeGen/global-blocks-win32.c +++ cfe/trunk/test/CodeGen/global-blocks-win32.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fblocks -triple i386-pc-windows-msvc %s -emit-llvm -o - -fblocks | FileCheck %s + + +int (^x)(void) = ^() { return 21; }; + + +// Check that the block literal is emitted with a null isa pointer +// CHECK: @__block_literal_global = internal global { i8**, i32, i32, i8*, %struct.__block_descriptor* } { i8** null, + +// Check that _NSConcreteGlobalBlock has the correct dllimport specifier. +// CHECK: @_NSConcreteGlobalBlock = external dllimport global i8* +// Check that we create an initialiser pointer in the correct section (early library initialisation). +// CHECK: @.block_isa_init_ptr = internal constant void ()* @.block_isa_init, section ".CRT$XCLa" + +// Check that we emit an initialiser for it. +// CHECK: define internal void @.block_isa_init() { +// CHECK: store i8** @_NSConcreteGlobalBlock, i8*** getelementptr inbounds ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }, { i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global, i32 0, i32 0), align 4 + Index: cfe/trunk/lib/CodeGen/CGBlocks.cpp === --- cfe/trunk/lib/CodeGen/CGBlocks.cpp +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp @@ -1213,9 +1213,13 @@ auto fields = builder.beginStruct(); bool IsOpenCL = CGM.getLangOpts().OpenCL; + bool IsWindows = CGM.getTarget().getTriple().isOSWindows(); if (!IsOpenCL) { // isa -fields.add(CGM.getNSConcreteGlobalBlock()); +if (IsWindows) + fields.addNullPointer(CGM.Int8PtrPtrTy); +else + fields.add(CGM.getNSConcreteGlobalBlock()); // __flags BlockFlags flags = BLOCK_IS_GLOBAL | BLOCK_HAS_SIGNATURE; @@ -1250,7 +1254,27 @@ llvm::Constant *literal = fields.finishAndCreateGlobal( "__block_literal_global", blockInfo.BlockAlign, - /*constant*/ true, llvm::GlobalVariable::InternalLinkage, AddrSpace); + /*constant*/ !IsWindows, llvm::GlobalVariable::InternalLinkage, AddrSpace); + + // Windows does not allow globals to be initialised to point to globals in + // different DLLs. Any such variables must run code to initialise them. + if (IsWindows) { +auto *Init = llvm::Function::Create(llvm::FunctionType::get(CGM.VoidTy, + {}), llvm::GlobalValue::InternalLinkage, ".block_isa_init", +&CGM.getModule()); +llvm::IRBuilder<> b(llvm::BasicBlock::Create(CGM.getLLVMContext(), "entry", + Init)); +b.CreateAlignedStore(CGM.getNSConcreteGlobalBlock(), +b.CreateStructGEP(literal, 0), CGM.getPointerAlign().getQuantity()); +b.CreateRetVoid(); +// We can't use the normal LLVM global initialisation array, because we +// need to specify that this runs early in library initialisation. +auto *InitVar = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), +/*isConstant*/true, llvm::GlobalValue::InternalLinkage, +Init, ".block_isa_init_ptr"); +InitVar->setSection(".CRT$XCLa"); +CGM.addUsedGlobal(InitVar); + } // Return a constant of the appropriately-casted type. llvm::Type *RequiredType = Index: cfe/trunk/test/CodeGen/global-blocks-win32.c === --- cfe/trunk/test/CodeGen/global-blocks-win32.c +++ cfe/trunk/test/CodeGen/global-blocks-win32.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fblocks -triple i386-pc-windows-msvc %s -emit-llvm -o - -fblocks | FileCheck %s + + +int (^x)(void) = ^() { return 21; }; + + +// Check that the block literal is emitted with a null isa pointer +// CHECK: @__block_literal_global = internal global { i8**, i32, i32, i8*, %struct.__block_descriptor* } { i8** null, + +// Check that _NSConcreteGlobalBlock has the correct dllimport specifier. +// CHECK: @_NSConcreteGlobalBlock = external dllimport global i8* +// Check that we create an initialiser pointer in the correct section (early library initialisation). +// CHECK: @.block_isa_init_ptr = internal constant void ()* @.block_isa_init, section ".CRT$XCLa" + +// Check that we emit an initialiser for it. +// CHECK: define internal void @.block_isa_init() { +// CHECK: store i8** @_NSConcreteGlobalBlock, i8*** getelementptr inbounds ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }, { i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global, i32 0, i32 0), align 4 + Index: cfe/trunk/lib/CodeGen/CGBlocks.cpp ==
[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.
theraven updated this revision to Diff 159868. theraven added a comment. - Address rjmcall's review comments. - Revert blocks part of the patch to put in a separate review. Repository: rC Clang https://reviews.llvm.org/D50144 Files: include/clang/Driver/Options.td lib/AST/MicrosoftMangle.cpp lib/CodeGen/CGException.cpp lib/CodeGen/CGObjCGNU.cpp lib/CodeGen/CGObjCRuntime.cpp lib/CodeGen/CGObjCRuntime.h lib/CodeGen/CodeGenFunction.h lib/Driver/ToolChains/Clang.cpp test/CodeGenObjC/gnu-init.m test/CodeGenObjC/gnustep2-proto.m test/CodeGenObjCXX/arc-marker-funclet.mm test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm test/CodeGenObjCXX/msabi-objc-extensions.mm test/CodeGenObjCXX/msabi-objc-types.mm Index: test/CodeGenObjCXX/msabi-objc-types.mm === --- test/CodeGenObjCXX/msabi-objc-types.mm +++ test/CodeGenObjCXX/msabi-objc-types.mm @@ -3,166 +3,166 @@ @class I; id kid; -// CHECK: @"?kid@@3PAUobjc_object@@A" = dso_local global +// CHECK: @"?kid@@3PAU.objc_object@@A" = dso_local global Class klass; -// CHECK: @"?klass@@3PAUobjc_class@@A" = dso_local global +// CHECK: @"?klass@@3PAU.objc_class@@A" = dso_local global I *kI; -// CHECK: @"?kI@@3PAUI@@A" = dso_local global +// CHECK: @"?kI@@3PAU.objc_cls_I@@A" = dso_local global void f(I *) {} -// CHECK-LABEL: "?f@@YAXPAUI@@@Z" +// CHECK-LABEL: "?f@@YAXPAU.objc_cls_I@@@Z" void f(const I *) {} -// CHECK-LABEL: "?f@@YAXPBUI@@@Z" +// CHECK-LABEL: "?f@@YAXPBU.objc_cls_I@@@Z" void f(I &) {} -// CHECK-LABEL: "?f@@YAXAAUI@@@Z" +// CHECK-LABEL: "?f@@YAXAAU.objc_cls_I@@@Z" void f(const I &) {} -// CHECK-LABEL: "?f@@YAXABUI@@@Z" +// CHECK-LABEL: "?f@@YAXABU.objc_cls_I@@@Z" void f(const I &&) {} -// CHECK-LABEL: "?f@@YAX$$QBUI@@@Z" +// CHECK-LABEL: "?f@@YAX$$QBU.objc_cls_I@@@Z" void g(id) {} -// CHECK-LABEL: "?g@@YAXPAUobjc_object@@@Z" +// CHECK-LABEL: "?g@@YAXPAU.objc_object@@@Z" void g(id &) {} -// CHECK-LABEL: "?g@@YAXAAPAUobjc_object@@@Z" +// CHECK-LABEL: "?g@@YAXAAPAU.objc_object@@@Z" void g(const id &) {} -// CHECK-LABEL: "?g@@YAXABQAUobjc_object@@@Z" +// CHECK-LABEL: "?g@@YAXABQAU.objc_object@@@Z" void g(id &&) {} -// CHECK-LABEL: "?g@@YAX$$QAPAUobjc_object@@@Z" +// CHECK-LABEL: "?g@@YAX$$QAPAU.objc_object@@@Z" void h(Class) {} -// CHECK-LABEL: "?h@@YAXPAUobjc_class@@@Z" +// CHECK-LABEL: "?h@@YAXPAU.objc_class@@@Z" void h(Class &) {} -// CHECK-LABEL: "?h@@YAXAAPAUobjc_class@@@Z" +// CHECK-LABEL: "?h@@YAXAAPAU.objc_class@@@Z" void h(const Class &) {} -// CHECK-LABEL: "?h@@YAXABQAUobjc_class@@@Z" +// CHECK-LABEL: "?h@@YAXABQAU.objc_class@@@Z" void h(Class &&) {} -// CHECK-LABEL: "?h@@YAX$$QAPAUobjc_class@@@Z" +// CHECK-LABEL: "?h@@YAX$$QAPAU.objc_class@@@Z" I *i() { return nullptr; } -// CHECK-LABEL: "?i@@YAPAUI@@XZ" +// CHECK-LABEL: "?i@@YAPAU.objc_cls_I@@XZ" const I *j() { return nullptr; } -// CHECK-LABEL: "?j@@YAPBUI@@XZ" +// CHECK-LABEL: "?j@@YAPBU.objc_cls_I@@XZ" I &k() { return *kI; } -// CHECK-LABEL: "?k@@YAAAUI@@XZ" +// CHECK-LABEL: "?k@@YAAAU.objc_cls_I@@XZ" const I &l() { return *kI; } -// CHECK-LABEL: "?l@@YAABUI@@XZ" +// CHECK-LABEL: "?l@@YAABU.objc_cls_I@@XZ" void m(const id) {} -// CHECK-LABEL: "?m@@YAXQAUobjc_object@@@Z" +// CHECK-LABEL: "?m@@YAXQAU.objc_object@@@Z" void m(const I *) {} -// CHECK-LABEL: "?m@@YAXPBUI@@@Z" +// CHECK-LABEL: "?m@@YAXPBU.objc_cls_I@@@Z" void n(SEL) {} -// CHECK-LABEL: "?n@@YAXPAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXPAU.objc_selector@@@Z" void n(SEL *) {} -// CHECK-LABEL: "?n@@YAXPAPAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXPAPAU.objc_selector@@@Z" void n(const SEL *) {} -// CHECK-LABEL: "?n@@YAXPBQAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXPBQAU.objc_selector@@@Z" void n(SEL &) {} -// CHECK-LABEL: "?n@@YAXAAPAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXAAPAU.objc_selector@@@Z" void n(const SEL &) {} -// CHECK-LABEL: "?n@@YAXABQAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXABQAU.objc_selector@@@Z" void n(SEL &&) {} -// CHECK-LABEL: "?n@@YAX$$QAPAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAX$$QAPAU.objc_selector@@@Z" struct __declspec(dllexport) s { struct s &operator=(const struct s &) = delete; void m(I *) {} - // CHECK-LABEL: "?m@s@@QAAXPAUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAXPAU.objc_cls_I@@@Z" void m(const I *) {} - // CHECK-LABEL: "?m@s@@QAAXPBUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAXPBU.objc_cls_I@@@Z" void m(I &) {} - // CHECK-LABEL: "?m@s@@QAAXAAUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAXAAU.objc_cls_I@@@Z" void m(const I &) {} - // CHECK-LABEL: "?m@s@@QAAXABUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAXABU.objc_cls_I@@@Z" void m(I &&) {} - // CHECK-LABEL: "?m@s@@QAAX$$QAUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAX$$QAU.objc_cls_I@@@Z" void m(const I &&) {} - // CHECK-LABEL: "?m@s@@QAAX$$QBUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAX$$QBU.objc_cls_I@@@Z" void m(id) {} - // CHECK-LABEL: "?m@s@@QAAXPAUobj
[PATCH] D50455: Continue emitting diagnostics after a fatal error
ilya-biryukov added a comment. The new behavior looks reasonable for interactive tools like clangd, but I'm a bit worried that clang may emit too many irrelevant errors, because it may not cope nicely with those fatal errors, i.e. wasn't tested that thoroughly in that mode. Nevertheless, I think this is moving clangd in the right direction and if we see too many irrelevant errors, we should look into improving clang to show less of those. Comment at: test/clangd/missing-includes.test:1 +# RUN: clangd -lit-test < %s | FileCheck %s +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} This tests looks useful, but could we also unit-test (with a C++ gtest) that fatal errors do not block other errors when: 1. building the preamble (i.e. when calling `buildPreamble`), 2. building the AST (i.e. when calling `ParsedAST::build`). To have a regression test for potential changes in those areas. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50455 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48687: [clangd] Avoid duplicates in findDefinitions response
hokein added a comment. Sorry for the delay. I thought there was a dependent patch of this patch, but it seems resolved, right? A rough round of review. > New version. I tried to share the code between this and SymbolCollector, but > didn't find a good clean way. Do you have concrete suggestions on how to do > this? Otherwise, would it be acceptable to merge it as-is? Yeah, I'm fine with the current change. I was not aware of the `getAbsoluteFilePath` has been pulled out to the `SourceCode.h`. I think the SymbolCollector could use this function as well (but that's out of scope of this patch). Comment at: clangd/SourceCode.h:65 /// Get the absolute file path of a given file entry. -llvm::Optional getAbsoluteFilePath(const FileEntry *F, -const SourceManager &SourceMgr); +llvm::Optional getRealPath(const FileEntry *F, +const SourceManager &SourceMgr); Why rename this function? Is it guaranteed that `RealPath` is always an absolute path? Comment at: unittests/clangd/TestFS.cpp:52 CommandLine.insert(CommandLine.begin(), "clang"); - CommandLine.insert(CommandLine.end(), UseRelPaths ? FileName : File); - return {tooling::CompileCommand(sys::path::parent_path(File), FileName, - std::move(CommandLine), "")}; + if (RelPathPrefix == StringRef()) { +// Use the absolute path in the compile command. Can we use `RelPathPrefix.empty()` instead of comparing with `StringRef()`? Comment at: unittests/clangd/XRefsTests.cpp:325 + + Annotations HeaderInPreambleAnnotations(R"cpp( +int [[bar_preamble]]; It seems that there is no difference between `HeaderInPreambleAnnotations` and `HeaderNotInPreambleAnnotations` in the test. Both of them are treated equally. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature
avt77 added a comment. In https://reviews.llvm.org/D45619#1192803, @craig.topper wrote: > I'm unclear why the we would want to assign clang's FrontendTimesIsEnabled > from inside CodeGenAction. If I'm understanding the intentions here, the goal > was to add more timing infrastructure to clang. But if the enabling is tied > to CodeGenAction, then doesn't that mean any new clang timers wouldn't work > under -fsyntax-only? Historically, it was done to get compilation times for separate files (to find the longest times). Because of that I did not assume usage of -fsyntax-only. Is it important? Should I move this activity into another place? If YES could you give me a hint where it should be done? Repository: rL LLVM https://reviews.llvm.org/D45619 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50415: [clangd] extend the publishDiagnostics response to send back fixits to the client directly as well (if requested)
ilya-biryukov added inline comments. Comment at: clangd/ClangdLSPServer.cpp:441 const clangd::CodeCompleteOptions &CCOpts, + const ClangdDiagnosticOptions &DiagOpts, llvm::Optional CompileCommandsDir, Maybe remove this parameter now that we configure these via LSP? We don't set it to anything other than the default anyway. https://reviews.llvm.org/D50415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49722: [CStringSyntaxChecker] Check strlcat sizeof check
devnexen added a comment. ping but will be for 8.0 :) https://reviews.llvm.org/D49722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50446: [clangd] Record the file being processed in a TUScheduler thread in context.
ilya-biryukov accepted this revision. ilya-biryukov added a comment. This revision is now accepted and ready to land. LGTM. Thanks! Comment at: clangd/TUScheduler.h:145 }; + } // namespace clangd NIT: accidental whitespace change? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50446 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45045: [DebugInfo] Generate debug information for labels.
HsiangKai added a comment. Hi @vext01, It should be fixed in https://reviews.llvm.org/D50495. Please help me to confirm it in your environment. Thanks so much. :) Repository: rL LLVM https://reviews.llvm.org/D45045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r339320 - [clangd] Record the file being processed in a TUScheduler thread in context.
Author: ioeric Date: Thu Aug 9 02:05:45 2018 New Revision: 339320 URL: http://llvm.org/viewvc/llvm-project?rev=339320&view=rev Log: [clangd] Record the file being processed in a TUScheduler thread in context. Summary: This allows implementations like different symbol indexes to know what the current active file is. For example, some customized index implementation might decide to only return results for some files. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: javed.absar, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50446 Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp clang-tools-extra/trunk/clangd/TUScheduler.h clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=339320&r1=339319&r2=339320&view=diff == --- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original) +++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Thu Aug 9 02:05:45 2018 @@ -63,6 +63,14 @@ namespace { class ASTWorker; } +static const clang::clangd::Key kFileBeingProcessed; + +llvm::Optional TUScheduler::getFileBeingProcessedInContext() { + if (auto *File = Context::current().get(kFileBeingProcessed)) +return StringRef(*File); + return llvm::None; +} + /// An LRU cache of idle ASTs. /// Because we want to limit the overall number of these we retain, the cache /// owns ASTs (and may evict them) while their workers are idle. @@ -491,8 +499,9 @@ void ASTWorker::startTask(llvm::StringRe { std::lock_guard Lock(Mutex); assert(!Done && "running a task after stop()"); -Requests.push_back({std::move(Task), Name, steady_clock::now(), -Context::current().clone(), UpdateType}); +Requests.push_back( +{std::move(Task), Name, steady_clock::now(), + Context::current().derive(kFileBeingProcessed, FileName), UpdateType}); } RequestsCV.notify_all(); } @@ -734,10 +743,12 @@ void TUScheduler::runWithPreamble( Action(InputsAndPreamble{Contents, Command, Preamble.get()}); }; - PreambleTasks->runAsync("task:" + llvm::sys::path::filename(File), - Bind(Task, std::string(Name), std::string(File), - It->second->Contents, It->second->Command, - Context::current().clone(), std::move(Action))); + PreambleTasks->runAsync( + "task:" + llvm::sys::path::filename(File), + Bind(Task, std::string(Name), std::string(File), It->second->Contents, + It->second->Command, + Context::current().derive(kFileBeingProcessed, File), + std::move(Action))); } std::vector> Modified: clang-tools-extra/trunk/clangd/TUScheduler.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.h?rev=339320&r1=339319&r2=339320&view=diff == --- clang-tools-extra/trunk/clangd/TUScheduler.h (original) +++ clang-tools-extra/trunk/clangd/TUScheduler.h Thu Aug 9 02:05:45 2018 @@ -122,6 +122,13 @@ public: /// an LRU cache. class ASTCache; + // The file being built/processed in the current thread. This is a hack in + // order to get the file name into the index implementations. Do not depend on + // this inside clangd. + // FIXME: remove this when there is proper index support via build system + // integration. + static llvm::Optional getFileBeingProcessedInContext(); + private: const bool StorePreamblesInMemory; const std::shared_ptr PCHOps; @@ -135,6 +142,7 @@ private: llvm::Optional WorkerThreads; std::chrono::steady_clock::duration UpdateDebounce; }; + } // namespace clangd } // namespace clang Modified: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp?rev=339320&r1=339319&r2=339320&view=diff == --- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Thu Aug 9 02:05:45 2018 @@ -197,20 +197,22 @@ TEST_F(TUSchedulerTests, ManyUpdates) { { WithContextValue WithNonce(NonceKey, ++Nonce); S.update(File, Inputs, WantDiagnostics::Auto, - [Nonce, &Mut, + [File, Nonce, &Mut, &TotalUpdates](llvm::Optional> Diags) { EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce)); std::lock_guard Lock(Mut); ++TotalUpdates; + EXPECT_EQ(File, +
[PATCH] D50446: [clangd] Record the file being processed in a TUScheduler thread in context.
This revision was automatically updated to reflect the committed changes. Closed by commit rL339320: [clangd] Record the file being processed in a TUScheduler thread in context. (authored by ioeric, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D50446 Files: clang-tools-extra/trunk/clangd/TUScheduler.cpp clang-tools-extra/trunk/clangd/TUScheduler.h clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Index: clang-tools-extra/trunk/clangd/TUScheduler.cpp === --- clang-tools-extra/trunk/clangd/TUScheduler.cpp +++ clang-tools-extra/trunk/clangd/TUScheduler.cpp @@ -63,6 +63,14 @@ class ASTWorker; } +static const clang::clangd::Key kFileBeingProcessed; + +llvm::Optional TUScheduler::getFileBeingProcessedInContext() { + if (auto *File = Context::current().get(kFileBeingProcessed)) +return StringRef(*File); + return llvm::None; +} + /// An LRU cache of idle ASTs. /// Because we want to limit the overall number of these we retain, the cache /// owns ASTs (and may evict them) while their workers are idle. @@ -491,8 +499,9 @@ { std::lock_guard Lock(Mutex); assert(!Done && "running a task after stop()"); -Requests.push_back({std::move(Task), Name, steady_clock::now(), -Context::current().clone(), UpdateType}); +Requests.push_back( +{std::move(Task), Name, steady_clock::now(), + Context::current().derive(kFileBeingProcessed, FileName), UpdateType}); } RequestsCV.notify_all(); } @@ -734,10 +743,12 @@ Action(InputsAndPreamble{Contents, Command, Preamble.get()}); }; - PreambleTasks->runAsync("task:" + llvm::sys::path::filename(File), - Bind(Task, std::string(Name), std::string(File), - It->second->Contents, It->second->Command, - Context::current().clone(), std::move(Action))); + PreambleTasks->runAsync( + "task:" + llvm::sys::path::filename(File), + Bind(Task, std::string(Name), std::string(File), It->second->Contents, + It->second->Command, + Context::current().derive(kFileBeingProcessed, File), + std::move(Action))); } std::vector> Index: clang-tools-extra/trunk/clangd/TUScheduler.h === --- clang-tools-extra/trunk/clangd/TUScheduler.h +++ clang-tools-extra/trunk/clangd/TUScheduler.h @@ -122,6 +122,13 @@ /// an LRU cache. class ASTCache; + // The file being built/processed in the current thread. This is a hack in + // order to get the file name into the index implementations. Do not depend on + // this inside clangd. + // FIXME: remove this when there is proper index support via build system + // integration. + static llvm::Optional getFileBeingProcessedInContext(); + private: const bool StorePreamblesInMemory; const std::shared_ptr PCHOps; @@ -135,6 +142,7 @@ llvm::Optional WorkerThreads; std::chrono::steady_clock::duration UpdateDebounce; }; + } // namespace clangd } // namespace clang Index: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp === --- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp +++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp @@ -197,20 +197,22 @@ { WithContextValue WithNonce(NonceKey, ++Nonce); S.update(File, Inputs, WantDiagnostics::Auto, - [Nonce, &Mut, + [File, Nonce, &Mut, &TotalUpdates](llvm::Optional> Diags) { EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce)); std::lock_guard Lock(Mut); ++TotalUpdates; + EXPECT_EQ(File, + *TUScheduler::getFileBeingProcessedInContext()); }); } { WithContextValue WithNonce(NonceKey, ++Nonce); S.runWithAST("CheckAST", File, - [Inputs, Nonce, &Mut, + [File, Inputs, Nonce, &Mut, &TotalASTReads](llvm::Expected AST) { EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce)); @@ -221,23 +223,27 @@ std::lock_guard Lock(Mut); ++TotalASTReads; + EXPECT_EQ( + File, + *TUScheduler::getFileBeingProcessedInContext()); }); } { WithContextValue WithNonce(NonceKey, ++Nonce); - S.runWithPreamble("CheckPreamble", File, -[Inputs, Nonce, &Mut, &TotalPreambleR
[clang-tools-extra] r339322 - [clangd] Try to fix buildbot after r339320.
Author: ioeric Date: Thu Aug 9 02:25:26 2018 New Revision: 339322 URL: http://llvm.org/viewvc/llvm-project?rev=339322&view=rev Log: [clangd] Try to fix buildbot after r339320. http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/5487 Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=339322&r1=339321&r2=339322&view=diff == --- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original) +++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Thu Aug 9 02:25:26 2018 @@ -63,7 +63,7 @@ namespace { class ASTWorker; } -static const clang::clangd::Key kFileBeingProcessed; +static clang::clangd::Key kFileBeingProcessed; llvm::Optional TUScheduler::getFileBeingProcessedInContext() { if (auto *File = Context::current().get(kFileBeingProcessed)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50385: [clangd] Collect symbol occurrences from AST.
hokein added a comment. In https://reviews.llvm.org/D50385#1191914, @ioeric wrote: > 2 high-level questions: > > 1. What's the reason for having a separate `SymbolOccurrenceSlab`? Could > store occurrences as extra payload of `Symbol`? Storing occurrences in `Symbol` structure is easy to misuse by users IMO -- if we go through this way, we will end up having a `getOccurrences`-like method in `Symbol` structure. Once users get the `Symbol` instance, it is natural for them to call `getOccurrences` to get all occurrences of the symbol. However this `getOccurrences` method doesn't do what users expected (just returning an incomplete set of results or empty). To query the symbol occurrences, we should always use index interface. Therefore, I think we should try to avoid these confusions in the design. > 2. Could we merge `SymbolOccurrenceCollector` into the existing > `SymbolCollector`? They look a lot alike. Having another index data consumer > seems like more overhead on the user side. The `SymbolOccurrenceCollector` has many responsibilities (collecting declaration, definition, code completion information etc), and the code is growing complex now. Merging the `SymbolOccurrenceCollector` to it will make it more complicated -- we will introduce more option flags like `collect-symbol-only`, `collect-occurrence-only` to configure it for our different use cases (we need to the implementation detail clearly in order to make a correct option for `SymbolCollector`). And I can foresee these two collectors might be run at different point (runWithPreamble vs runWithAST) in dynamic index. They might use same facilities, but we could always share them. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50500: [clangd] Allow consuming limited number of items
kbobyrev created this revision. kbobyrev added reviewers: ioeric, ilya-biryukov. kbobyrev added a project: clang-tools-extra. Herald added subscribers: arphaman, jkorous, MaskRay. This patch modifies `consume` function to allow retrieval of limited number of symbols. This is the "cheap" implementation of top-level limiting iterator. In the future we would like to have a complete limit iterator implementation to insert it into the query subtrees, but in the meantime this version would be enough for a fully-functional proof-of-concept Dex implementation. https://reviews.llvm.org/D50500 Files: clang-tools-extra/clangd/index/dex/Iterator.cpp clang-tools-extra/clangd/index/dex/Iterator.h Index: clang-tools-extra/clangd/index/dex/Iterator.h === --- clang-tools-extra/clangd/index/dex/Iterator.h +++ clang-tools-extra/clangd/index/dex/Iterator.h @@ -101,9 +101,12 @@ virtual llvm::raw_ostream &dump(llvm::raw_ostream &OS) const = 0; }; -/// Exhausts given iterator and returns all processed DocIDs. The result -/// contains sorted DocumentIDs. -std::vector consume(Iterator &It); +/// Advances the iterator until it is either exhausted or the number of +/// requested items is reached. The result contains sorted DocumentIDs. Size of +/// the returned vector is min(Limit, IteratorSize) where IteratorSize stands +/// for the number of elements obtained before the iterator is exhausted. +std::vector consume(Iterator &It, + size_t Limit = std::numeric_limits::max()); /// Returns a document iterator over given PostingList. std::unique_ptr create(PostingListRef Documents); Index: clang-tools-extra/clangd/index/dex/Iterator.cpp === --- clang-tools-extra/clangd/index/dex/Iterator.cpp +++ clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -218,9 +218,10 @@ } // end namespace -std::vector consume(Iterator &It) { +std::vector consume(Iterator &It, size_t Limit) { std::vector Result; - for (; !It.reachedEnd(); It.advance()) + for (size_t Retreived = 0; !It.reachedEnd() && Retreived < Limit; + It.advance()) Result.push_back(It.peek()); return Result; } Index: clang-tools-extra/clangd/index/dex/Iterator.h === --- clang-tools-extra/clangd/index/dex/Iterator.h +++ clang-tools-extra/clangd/index/dex/Iterator.h @@ -101,9 +101,12 @@ virtual llvm::raw_ostream &dump(llvm::raw_ostream &OS) const = 0; }; -/// Exhausts given iterator and returns all processed DocIDs. The result -/// contains sorted DocumentIDs. -std::vector consume(Iterator &It); +/// Advances the iterator until it is either exhausted or the number of +/// requested items is reached. The result contains sorted DocumentIDs. Size of +/// the returned vector is min(Limit, IteratorSize) where IteratorSize stands +/// for the number of elements obtained before the iterator is exhausted. +std::vector consume(Iterator &It, + size_t Limit = std::numeric_limits::max()); /// Returns a document iterator over given PostingList. std::unique_ptr create(PostingListRef Documents); Index: clang-tools-extra/clangd/index/dex/Iterator.cpp === --- clang-tools-extra/clangd/index/dex/Iterator.cpp +++ clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -218,9 +218,10 @@ } // end namespace -std::vector consume(Iterator &It) { +std::vector consume(Iterator &It, size_t Limit) { std::vector Result; - for (; !It.reachedEnd(); It.advance()) + for (size_t Retreived = 0; !It.reachedEnd() && Retreived < Limit; + It.advance()) Result.push_back(It.peek()); return Result; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50385: [clangd] Collect symbol occurrences from AST.
ioeric added a comment. In https://reviews.llvm.org/D50385#1193545, @hokein wrote: > In https://reviews.llvm.org/D50385#1191914, @ioeric wrote: > > > 2 high-level questions: > > > > 1. What's the reason for having a separate `SymbolOccurrenceSlab`? Could > > store occurrences as extra payload of `Symbol`? > > > Storing occurrences in `Symbol` structure is easy to misuse by users IMO -- > if we go through this way, we will end up having a `getOccurrences`-like > method in `Symbol` structure. Once users get the `Symbol` instance, it is > natural for them to call `getOccurrences` to get all occurrences of the > symbol. However this `getOccurrences` method doesn't do what users expected > (just returning an incomplete set of results or empty). To query the symbol > occurrences, we should always use index interface. > > Therefore, I think we should try to avoid these confusions in the design. Hmm, I think this is the same for other symbol payload e.g. definition can be missing for a symbol. And it seems to me that the concern is on the SymbolSlab level: if a slab is for a single TU, users should expect missing information; if a slab is merged from all TUs, then users can expect "complete" information. I think it's reasonable to assume that users of SymbolSlab are aware of this. I think it's probably not worth the overhead of maintaining and using two separate slabs. >> 2. Could we merge `SymbolOccurrenceCollector` into the existing >> `SymbolCollector`? They look a lot alike. Having another index data consumer >> seems like more overhead on the user side. > > The `SymbolOccurrenceCollector` has many responsibilities (collecting > declaration, definition, code completion information etc), and the code is > growing complex now. Merging the `SymbolOccurrenceCollector` to it will make > it more Although the existing `SymbolCollector` supports different options, I think it still has a pretty well-defined responsibility: gather information about symbols. IMO, cross-reference is one of the property of symbol, and I don't see strong reasons to keep them separated. > complicated -- we will introduce more option flags like > `collect-symbol-only`, `collect-occurrence-only` to configure it for our > different use cases (we need to the implementation detail clearly in order to > make a correct option for `SymbolCollector`). I think these options are reasonable if they turn out to be necessary. And making the SymbolCollector more complicated doesn't seem to be a problem if we are indeed doing more complicated work, but I don't think this would turn into a big problem as logic of xrefs seems pretty isolated. Conversely, I think implementing xrefs in a separate class would likely to cause more duplicate and maintenance, e.g. two sets of options, two sets of initializations or life-time tracking of collectors (they look a lot alike), the same boilerplate factory code in tests, passing around two collectors in user code. > And I can foresee these two collectors might be run at different point > (runWithPreamble vs runWithAST) in dynamic index. With some options, this should be a problem I think? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.
theraven updated this revision to Diff 159887. theraven added a comment. - Address Dustin's review comments. - Fix an issue in protocol generation. - Fix failing test. - Address rjmcall's review comments. - Add some missing comments and factor out SEH check. Repository: rC Clang https://reviews.llvm.org/D50144 Files: include/clang/Driver/Options.td lib/AST/MicrosoftMangle.cpp lib/CodeGen/CGException.cpp lib/CodeGen/CGObjCGNU.cpp lib/CodeGen/CGObjCRuntime.cpp lib/CodeGen/CGObjCRuntime.h lib/CodeGen/CodeGenFunction.h lib/Driver/ToolChains/Clang.cpp test/CodeGenObjC/gnu-init.m test/CodeGenObjC/gnustep2-proto.m test/CodeGenObjCXX/arc-marker-funclet.mm test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm test/CodeGenObjCXX/msabi-objc-extensions.mm test/CodeGenObjCXX/msabi-objc-types.mm Index: test/CodeGenObjCXX/msabi-objc-types.mm === --- test/CodeGenObjCXX/msabi-objc-types.mm +++ test/CodeGenObjCXX/msabi-objc-types.mm @@ -3,166 +3,166 @@ @class I; id kid; -// CHECK: @"?kid@@3PAUobjc_object@@A" = dso_local global +// CHECK: @"?kid@@3PAU.objc_object@@A" = dso_local global Class klass; -// CHECK: @"?klass@@3PAUobjc_class@@A" = dso_local global +// CHECK: @"?klass@@3PAU.objc_class@@A" = dso_local global I *kI; -// CHECK: @"?kI@@3PAUI@@A" = dso_local global +// CHECK: @"?kI@@3PAU.objc_cls_I@@A" = dso_local global void f(I *) {} -// CHECK-LABEL: "?f@@YAXPAUI@@@Z" +// CHECK-LABEL: "?f@@YAXPAU.objc_cls_I@@@Z" void f(const I *) {} -// CHECK-LABEL: "?f@@YAXPBUI@@@Z" +// CHECK-LABEL: "?f@@YAXPBU.objc_cls_I@@@Z" void f(I &) {} -// CHECK-LABEL: "?f@@YAXAAUI@@@Z" +// CHECK-LABEL: "?f@@YAXAAU.objc_cls_I@@@Z" void f(const I &) {} -// CHECK-LABEL: "?f@@YAXABUI@@@Z" +// CHECK-LABEL: "?f@@YAXABU.objc_cls_I@@@Z" void f(const I &&) {} -// CHECK-LABEL: "?f@@YAX$$QBUI@@@Z" +// CHECK-LABEL: "?f@@YAX$$QBU.objc_cls_I@@@Z" void g(id) {} -// CHECK-LABEL: "?g@@YAXPAUobjc_object@@@Z" +// CHECK-LABEL: "?g@@YAXPAU.objc_object@@@Z" void g(id &) {} -// CHECK-LABEL: "?g@@YAXAAPAUobjc_object@@@Z" +// CHECK-LABEL: "?g@@YAXAAPAU.objc_object@@@Z" void g(const id &) {} -// CHECK-LABEL: "?g@@YAXABQAUobjc_object@@@Z" +// CHECK-LABEL: "?g@@YAXABQAU.objc_object@@@Z" void g(id &&) {} -// CHECK-LABEL: "?g@@YAX$$QAPAUobjc_object@@@Z" +// CHECK-LABEL: "?g@@YAX$$QAPAU.objc_object@@@Z" void h(Class) {} -// CHECK-LABEL: "?h@@YAXPAUobjc_class@@@Z" +// CHECK-LABEL: "?h@@YAXPAU.objc_class@@@Z" void h(Class &) {} -// CHECK-LABEL: "?h@@YAXAAPAUobjc_class@@@Z" +// CHECK-LABEL: "?h@@YAXAAPAU.objc_class@@@Z" void h(const Class &) {} -// CHECK-LABEL: "?h@@YAXABQAUobjc_class@@@Z" +// CHECK-LABEL: "?h@@YAXABQAU.objc_class@@@Z" void h(Class &&) {} -// CHECK-LABEL: "?h@@YAX$$QAPAUobjc_class@@@Z" +// CHECK-LABEL: "?h@@YAX$$QAPAU.objc_class@@@Z" I *i() { return nullptr; } -// CHECK-LABEL: "?i@@YAPAUI@@XZ" +// CHECK-LABEL: "?i@@YAPAU.objc_cls_I@@XZ" const I *j() { return nullptr; } -// CHECK-LABEL: "?j@@YAPBUI@@XZ" +// CHECK-LABEL: "?j@@YAPBU.objc_cls_I@@XZ" I &k() { return *kI; } -// CHECK-LABEL: "?k@@YAAAUI@@XZ" +// CHECK-LABEL: "?k@@YAAAU.objc_cls_I@@XZ" const I &l() { return *kI; } -// CHECK-LABEL: "?l@@YAABUI@@XZ" +// CHECK-LABEL: "?l@@YAABU.objc_cls_I@@XZ" void m(const id) {} -// CHECK-LABEL: "?m@@YAXQAUobjc_object@@@Z" +// CHECK-LABEL: "?m@@YAXQAU.objc_object@@@Z" void m(const I *) {} -// CHECK-LABEL: "?m@@YAXPBUI@@@Z" +// CHECK-LABEL: "?m@@YAXPBU.objc_cls_I@@@Z" void n(SEL) {} -// CHECK-LABEL: "?n@@YAXPAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXPAU.objc_selector@@@Z" void n(SEL *) {} -// CHECK-LABEL: "?n@@YAXPAPAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXPAPAU.objc_selector@@@Z" void n(const SEL *) {} -// CHECK-LABEL: "?n@@YAXPBQAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXPBQAU.objc_selector@@@Z" void n(SEL &) {} -// CHECK-LABEL: "?n@@YAXAAPAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXAAPAU.objc_selector@@@Z" void n(const SEL &) {} -// CHECK-LABEL: "?n@@YAXABQAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAXABQAU.objc_selector@@@Z" void n(SEL &&) {} -// CHECK-LABEL: "?n@@YAX$$QAPAUobjc_selector@@@Z" +// CHECK-LABEL: "?n@@YAX$$QAPAU.objc_selector@@@Z" struct __declspec(dllexport) s { struct s &operator=(const struct s &) = delete; void m(I *) {} - // CHECK-LABEL: "?m@s@@QAAXPAUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAXPAU.objc_cls_I@@@Z" void m(const I *) {} - // CHECK-LABEL: "?m@s@@QAAXPBUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAXPBU.objc_cls_I@@@Z" void m(I &) {} - // CHECK-LABEL: "?m@s@@QAAXAAUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAXAAU.objc_cls_I@@@Z" void m(const I &) {} - // CHECK-LABEL: "?m@s@@QAAXABUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAXABU.objc_cls_I@@@Z" void m(I &&) {} - // CHECK-LABEL: "?m@s@@QAAX$$QAUI@@@Z" + // CHECK-LABEL: "?m@s@@QAAX$$QAU.objc_cls_I@@@Z" void m(const I &&) {} - // CHECK-LABEL: "?m@s@@QAAX$$QBUI@@@Z" + // CHECK-LABEL: "?
[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.
theraven marked an inline comment as done. theraven added a comment. I believe that this is now ready to land. Comment at: lib/CodeGen/CGObjCGNU.cpp:915 +return name; + } /// The GCC ABI superclass message lookup function. Takes a pointer to a rjmccall wrote: > theraven wrote: > > rjmccall wrote: > > > Can this section-names cleanup also just be in a separate patch? > > This is difficult to extract, because it's mostly needed for the COFF part > > where we need to modify the section names. For ELF, it was fine to keep > > them as separate `const char*`s > I don't mind if the extracted patch seems unmotivated on its own, but I do > think it should be a separate patch. None of the changes to do this are in a separate commit, and they touch enough of the code that it's very difficult to separate them without ending up with conflicts in this branch (which touches the code surrounding the changes in multiple places). I cannot extract the code in such a way that this patch would cleanly rebase on top, because various things (e.g. the null section code) needed restructuring to work with Windows and touch this logic. Comment at: lib/CodeGen/CGObjCGNU.cpp:3817 + if (isRethrow && CGF.CGM.getTarget().getTriple().isWindowsMSVCEnvironment()) { +CGF.EmitRuntimeCallOrInvoke(ExceptionReThrowFn).setDoesNotReturn(); + } rjmccall wrote: > theraven wrote: > > rjmccall wrote: > > > You're sure here that the static information aligns with the dynamic? > > I'm not sure I understand this question. > Your new code path no longer uses `ExceptionAsObject`, which is our static > notion of the current exception value. Instead, you call a runtime function > which presumably relies on a dynamically-stored current exception value. I'm > just asking if, in this lexical position, you're definitely rethrowing the > right exception. Ah, I see. This code path is hit only as a `@throw;`, not a `@throw obj` (in the latter case, there is a non-null return from `S.getThrowExpr()`). In this case, the value of ExceptionAsObject may not be useful. In the case of a catchall, this is a load from a stack location with no corresponding store. The Windows unwind logic keeps the object on the stack during funclet execution and then continues the unwind at the end, without ever providing this frame's funclets with a pointer to it. That's probably not very obvious, so I've added an explanatory comment. Comment at: lib/CodeGen/CGObjCGNU.cpp:3542 + allSelectors.push_back(entry.first); +std::sort(allSelectors.begin(), allSelectors.end()); rjmccall wrote: > mgrang wrote: > > Please use llvm::sort instead of std::sort. See > > https://llvm.org/docs/CodingStandards.html#beware-of-non-deterministic-sorting-order-of-equal-elements. > Also, why is the sort necessary? Should this change be separately committed > and tested? Ooops, this was a fix for PR35277, which was meant to be a separate review. I forgot to remove it from this branch after cherry-picking it to another one. Removed. Repository: rC Clang https://reviews.llvm.org/D50144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50502: [clangd] Initial cancellation mechanism for LSP requests.
kadircet created this revision. kadircet added a reviewer: ilya-biryukov. Herald added subscribers: cfe-commits, jfb, arphaman, jkorous, MaskRay, ioeric, mgorny. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50502 Files: clangd/CMakeLists.txt clangd/Cancellation.cpp clangd/Cancellation.h clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/ClangdServer.cpp clangd/JSONRPCDispatcher.cpp clangd/JSONRPCDispatcher.h clangd/Protocol.cpp clangd/Protocol.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h unittests/clangd/CMakeLists.txt unittests/clangd/CancellationTests.cpp Index: unittests/clangd/CancellationTests.cpp === --- /dev/null +++ unittests/clangd/CancellationTests.cpp @@ -0,0 +1,34 @@ +#include "Cancellation.h" +#include "Context.h" +#include "llvm/Support/Error.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include +#include + +namespace clang { +namespace clangd { +namespace { + +TEST(CancellationTest, CancellationTest) { + { +std::shared_ptr> CancellationToken = +std::make_shared>(); +WithContext ContextWithCancellation( +CancellationHandler::SetCurrentCancellationToken(CancellationToken)); +*CancellationToken = true; +EXPECT_TRUE(CancellationHandler::HasCancelled()); + } + EXPECT_FALSE(CancellationHandler::HasCancelled()); +} + +TEST(CancellationTest, CheckForError) { + llvm::Error e = handleErrors(CancellationHandler::GetCancellationError(), + [](const TaskCancelledError &) {}); + EXPECT_TRUE(!e); +} + +} // namespace +} // namespace clangd +} // namespace clang Index: unittests/clangd/CMakeLists.txt === --- unittests/clangd/CMakeLists.txt +++ unittests/clangd/CMakeLists.txt @@ -10,6 +10,7 @@ add_extra_unittest(ClangdTests Annotations.cpp + CancellationTests.cpp ClangdTests.cpp ClangdUnitTests.cpp CodeCompleteTests.cpp Index: clangd/ProtocolHandlers.h === --- clangd/ProtocolHandlers.h +++ clangd/ProtocolHandlers.h @@ -55,6 +55,7 @@ virtual void onDocumentHighlight(TextDocumentPositionParams &Params) = 0; virtual void onHover(TextDocumentPositionParams &Params) = 0; virtual void onChangeConfiguration(DidChangeConfigurationParams &Params) = 0; + virtual void onCancelRequest(CancelParams &Params) = 0; }; void registerCallbackHandlers(JSONRPCDispatcher &Dispatcher, Index: clangd/ProtocolHandlers.cpp === --- clangd/ProtocolHandlers.cpp +++ clangd/ProtocolHandlers.cpp @@ -75,4 +75,5 @@ Register("workspace/didChangeConfiguration", &ProtocolCallbacks::onChangeConfiguration); Register("workspace/symbol", &ProtocolCallbacks::onWorkspaceSymbol); + Register("$/cancelRequest", &ProtocolCallbacks::onCancelRequest); } Index: clangd/Protocol.h === --- clangd/Protocol.h +++ clangd/Protocol.h @@ -846,6 +846,13 @@ llvm::json::Value toJSON(const DocumentHighlight &DH); llvm::raw_ostream &operator<<(llvm::raw_ostream &, const DocumentHighlight &); +struct CancelParams { + std::string ID; +}; +llvm::json::Value toJSON(const CancelParams &); +llvm::raw_ostream &operator<<(llvm::raw_ostream &, const CancelParams &); +bool fromJSON(const llvm::json::Value &, CancelParams &); + } // namespace clangd } // namespace clang Index: clangd/Protocol.cpp === --- clangd/Protocol.cpp +++ clangd/Protocol.cpp @@ -605,5 +605,31 @@ O.map("compilationDatabaseChanges", CCPC.compilationDatabaseChanges); } +json::Value toJSON(const CancelParams &CP) { + return json::Object{{"id", CP.ID}}; +} + +llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const CancelParams &CP) { + O << toJSON(CP); + return O; +} + +bool fromJSON(const json::Value &Params, CancelParams &CP) { + elog("Cancel params: {0}", Params); + json::ObjectMapper O(Params); + if (!O) +return false; + // ID is either a number or a string, check for both. + if (O.map("id", CP.ID)) +return true; + + int64_t id_number; + if (O.map("id", id_number)) { +CP.ID = utostr(id_number); +return true; + } + return false; +} + } // namespace clangd } // namespace clang Index: clangd/JSONRPCDispatcher.h === --- clangd/JSONRPCDispatcher.h +++ clangd/JSONRPCDispatcher.h @@ -111,6 +111,7 @@ JSONStreamStyle InputStyle, JSONRPCDispatcher &Dispatcher, bool &IsDone); +const llvm::json::Value *GetRequestId(); } // namespace clangd } // namespace clang Index: clangd/JSONRPCDispatcher.cpp === --- clangd
[PATCH] D50503: [analyzer][UninitializedObjectChecker] Refactoring p1.: ImmutableList factory is no longer static
Szelethus created this revision. Szelethus added reviewers: NoQ, xazax.hun, rnkovacs, george.karpenkov. Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, whisperity. This diff is the first part of a series of patches to refactor `UninitializedObjectChecker`. The goal of this effort is to - Separate pointer chasing from the rest of the checker, - Increase readability and reliability, - Don't impact performance (too bad). In this patch, `ImmutableList`'s factory is moved to `FindUninitializedFields`. Repository: rC Clang https://reviews.llvm.org/D50503 Files: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp @@ -73,17 +73,21 @@ /// Note that this class is immutable, and new fields may only be added through /// constructor calls. class FieldChainInfo { +public: using FieldChain = llvm::ImmutableList; +private: + FieldChain::Factory &Factory; FieldChain Chain; const bool IsDereferenced = false; public: - FieldChainInfo() = default; + FieldChainInfo() = delete; + FieldChainInfo(FieldChain::Factory &F) : Factory(F) {} FieldChainInfo(const FieldChainInfo &Other, const bool IsDereferenced) - : Chain(Other.Chain), IsDereferenced(IsDereferenced) {} + : Factory(Other.Factory), Chain(Other.Chain), IsDereferenced(IsDereferenced) {} FieldChainInfo(const FieldChainInfo &Other, const FieldRegion *FR, const bool IsDereferenced = false); @@ -128,6 +132,7 @@ bool IsAnyFieldInitialized = false; + FieldChainInfo::FieldChain::Factory Factory; UninitFieldSet UninitFields; public: @@ -217,10 +222,6 @@ } // end of anonymous namespace -// Static variable instantionations. - -static llvm::ImmutableListFactory Factory; - // Utility function declarations. /// Returns the object that was constructed by CtorDecl, or None if that isn't @@ -355,7 +356,7 @@ CheckPointeeInitialization(CheckPointeeInitialization) {} const UninitFieldSet &FindUninitializedFields::getUninitFields() { - isNonUnionUninit(ObjectR, FieldChainInfo()); + isNonUnionUninit(ObjectR, FieldChainInfo(Factory)); if (!IsPedantic && !IsAnyFieldInitialized) UninitFields.clear(); Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp @@ -73,17 +73,21 @@ /// Note that this class is immutable, and new fields may only be added through /// constructor calls. class FieldChainInfo { +public: using FieldChain = llvm::ImmutableList; +private: + FieldChain::Factory &Factory; FieldChain Chain; const bool IsDereferenced = false; public: - FieldChainInfo() = default; + FieldChainInfo() = delete; + FieldChainInfo(FieldChain::Factory &F) : Factory(F) {} FieldChainInfo(const FieldChainInfo &Other, const bool IsDereferenced) - : Chain(Other.Chain), IsDereferenced(IsDereferenced) {} + : Factory(Other.Factory), Chain(Other.Chain), IsDereferenced(IsDereferenced) {} FieldChainInfo(const FieldChainInfo &Other, const FieldRegion *FR, const bool IsDereferenced = false); @@ -128,6 +132,7 @@ bool IsAnyFieldInitialized = false; + FieldChainInfo::FieldChain::Factory Factory; UninitFieldSet UninitFields; public: @@ -217,10 +222,6 @@ } // end of anonymous namespace -// Static variable instantionations. - -static llvm::ImmutableListFactory Factory; - // Utility function declarations. /// Returns the object that was constructed by CtorDecl, or None if that isn't @@ -355,7 +356,7 @@ CheckPointeeInitialization(CheckPointeeInitialization) {} const UninitFieldSet &FindUninitializedFields::getUninitFields() { - isNonUnionUninit(ObjectR, FieldChainInfo()); + isNonUnionUninit(ObjectR, FieldChainInfo(Factory)); if (!IsPedantic && !IsAnyFieldInitialized) UninitFields.clear(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50504: [analyzer][UninitializedObjectChecker] Refactoring p2.: Moving pointer chasing to a separate file
Szelethus created this revision. Szelethus added reviewers: george.karpenkov, NoQ, xazax.hun, rnkovacs. Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, whisperity, mgorny. In this patch, the following classes and functions have been moved to a header file: - `FieldChainInfo` - `FindUninitializedFields` - `isPrimitiveType` This also meant that they moved from anonymous namespace to `clang::ento`. Code related to pointer chasing now relies in its own file. There's absolutely no functional change in this patch -- its literally just copy pasting, Repository: rC Clang https://reviews.llvm.org/D50504 Files: lib/StaticAnalyzer/Checkers/CMakeLists.txt lib/StaticAnalyzer/Checkers/UninitializedObject.h lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp Index: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp === --- /dev/null +++ lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp @@ -0,0 +1,170 @@ +//===- UninitializedPointer.cpp --*- C++ -*-==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// This file defines functions and methods for handling pointers and references +// to reduce the size and complexity of UninitializedObjectChecker.cpp. +// +// To read about command line options and a description what this checker does, +// refer to UninitializedObjectChecker.cpp. +// +// To read about how the checker works, refer to the comments in +// UninitializedObject.h. +// +//===--===// + +#include "UninitializedObject.h" +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" +#include "clang/StaticAnalyzer/Core/Checker.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h" + +using namespace clang; +using namespace clang::ento; + +// Utility function declarations. + +/// Returns whether T can be (transitively) dereferenced to a void pointer type +/// (void*, void**, ...). The type of the region behind a void pointer isn't +/// known, and thus FD can not be analyzed. +static bool isVoidPointer(QualType T); + +//===--===// +// Methods for FindUninitializedFields. +//===--===// + +// Note that pointers/references don't contain fields themselves, so in this +// function we won't add anything to LocalChain. +bool FindUninitializedFields::isPointerOrReferenceUninit( +const FieldRegion *FR, FieldChainInfo LocalChain) { + + assert((FR->getDecl()->getType()->isPointerType() || + FR->getDecl()->getType()->isReferenceType()) && + "This method only checks pointer/reference objects!"); + + SVal V = State->getSVal(FR); + + if (V.isUnknown() || V.getAs()) { +IsAnyFieldInitialized = true; +return false; + } + + if (V.isUndef()) { +return addFieldToUninits({LocalChain, FR}); + } + + if (!CheckPointeeInitialization) { +IsAnyFieldInitialized = true; +return false; + } + + assert(V.getAs() && + "At this point V must be loc::MemRegionVal!"); + auto L = V.castAs(); + + // We can't reason about symbolic regions, assume its initialized. + // Note that this also avoids a potential infinite recursion, because + // constructors for list-like classes are checked without being called, and + // the Static Analyzer will construct a symbolic region for Node *next; or + // similar code snippets. + if (L.getRegion()->getSymbolicBase()) { +IsAnyFieldInitialized = true; +return false; + } + + DynamicTypeInfo DynTInfo = getDynamicTypeInfo(State, L.getRegion()); + if (!DynTInfo.isValid()) { +IsAnyFieldInitialized = true; +return false; + } + + QualType DynT = DynTInfo.getType(); + + if (isVoidPointer(DynT)) { +IsAnyFieldInitialized = true; +return false; + } + + // At this point the pointer itself is initialized and points to a valid + // location, we'll now check the pointee. + SVal DerefdV = State->getSVal(V.castAs(), DynT); + + // If DerefdV is still a pointer value, we'll dereference it again (e.g.: + // int** -> int*). + while (auto Tmp = DerefdV.getAs()) { +if (Tmp->getRegion()->getSymbolicBase()) { + IsAnyFieldInitialized = true; + return false; +} + +DynTInfo = getDynamicTypeInfo(State, Tmp->getRegion()); +if (!DynTInfo.isValid()) { + IsAnyFieldInitialized = true; + return false; +} + +DynT = DynTInfo.getType(); +if (isVoidPointer(DynT)
[PATCH] D50505: [analyzer][UninitializedObjectChecker] Refactoring p3.: printTail moved out from FieldChainInfo
Szelethus created this revision. Szelethus added reviewers: xazax.hun, george.karpenkov, NoQ, rnkovacs. Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, whisperity. Szelethus added a dependency: D50504: [analyzer][UninitializedObjectChecker] Refactoring p2.: Moving pointer chasing to a separate file. This is a standalone part of the effort to reduce `FieldChainInfo`s inteerface. Repository: rC Clang https://reviews.llvm.org/D50505 Files: lib/StaticAnalyzer/Checkers/UninitializedObject.h lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp Index: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp @@ -18,8 +18,8 @@ // //===--===// -#include "UninitializedObject.h" #include "ClangSACheckers.h" +#include "UninitializedObject.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp @@ -40,8 +40,8 @@ // //===--===// -#include "UninitializedObject.h" #include "ClangSACheckers.h" +#include "UninitializedObject.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" @@ -81,7 +81,7 @@ /// (e.g. if the object is a field of another object, in which case we'd check /// it multiple times). static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor, - CheckerContext &Context); + CheckerContext &Context); /// Constructs a note message for a given FieldChainInfo object. static void printNoteMessage(llvm::raw_ostream &Out, @@ -305,7 +305,6 @@ return false; } - bool FindUninitializedFields::isPrimitiveUninit(const SVal &V) { if (V.isUndef()) return true; @@ -341,6 +340,13 @@ return (*Chain.begin())->getDecl(); } +/// Prints every element except the last to `Out`. Since ImmutableLists store +/// elements in reverse order, and have no reverse iterators, we use a +/// recursive function to print the fieldchain correctly. The last element in +/// the chain is to be printed by `print`. +static void printTail(llvm::raw_ostream &Out, + const FieldChainInfo::FieldChainImpl *L); + // TODO: This function constructs an incorrect string if a void pointer is a // part of the chain: // @@ -378,15 +384,13 @@ if (Chain.isEmpty()) return; - const llvm::ImmutableListImpl *L = - Chain.getInternalPointer(); + const FieldChainImpl *L = Chain.getInternalPointer(); printTail(Out, L->getTail()); Out << getVariableName(L->getHead()->getDecl()); } -void FieldChainInfo::printTail( -llvm::raw_ostream &Out, -const llvm::ImmutableListImpl *L) { +static void printTail(llvm::raw_ostream &Out, + const FieldChainInfo::FieldChainImpl *L) { if (!L) return; @@ -415,7 +419,7 @@ } static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor, - CheckerContext &Context) { + CheckerContext &Context) { Optional CurrentObject = getObjectVal(Ctor, Context); if (!CurrentObject) Index: lib/StaticAnalyzer/Checkers/UninitializedObject.h === --- lib/StaticAnalyzer/Checkers/UninitializedObject.h +++ lib/StaticAnalyzer/Checkers/UninitializedObject.h @@ -35,6 +35,7 @@ /// constructor calls. class FieldChainInfo { public: + using FieldChainImpl = llvm::ImmutableListImpl; using FieldChain = llvm::ImmutableList; private: @@ -48,7 +49,8 @@ FieldChainInfo(FieldChain::Factory &F) : Factory(F) {} FieldChainInfo(const FieldChainInfo &Other, const bool IsDereferenced) - : Factory(Other.Factory), Chain(Other.Chain), IsDereferenced(IsDereferenced) {} + : Factory(Other.Factory), Chain(Other.Chain), +IsDereferenced(IsDereferenced) {} FieldChainInfo(const FieldChainInfo &Other, const FieldRegion *FR, const bool IsDereferenced = false); @@ -64,12 +66,6 @@ void print(llvm::raw_ostream &Out) const; private: - /// Prints every element except the last to `Out`. Since ImmutableLists store - /// elements in reverse order, and have no reverse iterators, we use a - /// recur
[PATCH] D50506: [analyzer][UninitializedObjectChecker] Refactoring p4.: Wrap FieldRegions and reduce weight on FieldChainInfo
Szelethus created this revision. Szelethus added reviewers: xazax.hun, rnkovacs, NoQ, george.karpenkov. Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, whisperity. This patch is the bread and butter of the refactoring effort. Currently on trunk, `FieldChainInfo` is a spaghetti: it takes care of way too many cases, even though it was always meant as a wrapper around `ImmutableList`. This problem is solved by introducing a lightweight polymorphic wrapper around `const FieldRegion *`, `FieldNode`. It is an interface that abstracts away special cases like pointers/references, objects that need to be casted to another type for a proper note messages. I also plan to solve base class related issues with the help on this interface. Changes to `FieldChainInfo`: - Now wraps `ImmutableList`. - Any pointer/reference related fields and methods were removed - Got a new `add` method. This replaces it's former constructors as a way to create a new `FieldChainInfo` objects with a new element. Changes to `FindUninitializedField`: - In order not to deal with dynamic memory management, when an uninitialized field is found, the note message for it is constructed and is stored instead of a `FieldChainInfo` object. (see doc around `addFieldToUninits`). Some of the test files are changed too, from now on uninitialized pointees of references always print "uninitialized pointee" instead of "uninitialized field" (which should've really been like this from the beginning). I also updated every comment according to these changes. Repository: rC Clang https://reviews.llvm.org/D50506 Files: lib/StaticAnalyzer/Checkers/UninitializedObject.h lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp test/Analysis/cxx-uninitialized-object.cpp Index: test/Analysis/cxx-uninitialized-object.cpp === --- test/Analysis/cxx-uninitialized-object.cpp +++ test/Analysis/cxx-uninitialized-object.cpp @@ -781,7 +781,7 @@ void fLambdaTest2() { int b; - auto equals = [&b](int a) { return a == b; }; // expected-note{{uninitialized field 'this->functor.b'}} + auto equals = [&b](int a) { return a == b; }; // expected-note{{uninitialized pointee 'this->functor.b'}} LambdaTest2(equals, int()); } #else @@ -857,8 +857,8 @@ void fMultipleLambdaCapturesTest1() { int b1, b2 = 3, b3; - auto equals = [&b1, &b2, &b3](int a) { return a == b1 == b2 == b3; }; // expected-note{{uninitialized field 'this->functor.b1'}} - // expected-note@-1{{uninitialized field 'this->functor.b3'}} + auto equals = [&b1, &b2, &b3](int a) { return a == b1 == b2 == b3; }; // expected-note{{uninitialized pointee 'this->functor.b1'}} + // expected-note@-1{{uninitialized pointee 'this->functor.b3'}} MultipleLambdaCapturesTest1(equals, int()); } @@ -872,7 +872,7 @@ void fMultipleLambdaCapturesTest2() { int b1, b2 = 3, b3; - auto equals = [b1, &b2, &b3](int a) { return a == b1 == b2 == b3; }; // expected-note{{uninitialized field 'this->functor.b3'}} + auto equals = [b1, &b2, &b3](int a) { return a == b1 == b2 == b3; }; // expected-note{{uninitialized pointee 'this->functor.b3'}} MultipleLambdaCapturesTest2(equals, int()); } Index: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp @@ -28,6 +28,40 @@ using namespace clang; using namespace clang::ento; +namespace { + +/// Represents a pointer or a reference field. +class LocField : public FieldNode { + /// We'll store whether the pointee or the pointer itself is uninitialited. + const bool IsDereferenced; + +public: + LocField(const FieldRegion *FR, const bool IsDereferenced = true) + : FieldNode(FR), IsDereferenced(IsDereferenced) {} + + virtual void printNoteMsg(llvm::raw_ostream &Out) const override { +if (IsDereferenced) + Out << "uninitialized pointee "; +else + Out << "uninitialized pointer "; + } + + virtual void printPrefix(llvm::raw_ostream &Out) const override {} + + virtual void printNode(llvm::raw_ostream &Out) const override { +Out << getVariableName(getDecl()); + } + + virtual void printSeparator(llvm::raw_ostream &Out) const override { +if (getDecl()->getType()->isPointerType()) + Out << "->"; +else + Out << '.'; + } +}; + +} // end of anonymous namespace + // Utility function declarations. /// Returns whether T can be (transitively) dereferenced to a void pointer type @@ -56,7 +90,8 @@ } if (V.isUndef()) { -return addFieldToUninits({LocalChain, FR}); +return addFieldToUninits( +LocalChain.add(LocField(FR, /*IsDereferenced*/ false))); } if (!CheckPointeeInitialization) { @@ -125,11 +160,11 @@ const TypedValueRegion *R = RecordV->getRegion
[PATCH] D50507: [CodeGen][ARM] Coerce FP16 vectors to integer vectors when needed
miyuki created this revision. miyuki added reviewers: eli.friedman, olista01, SjoerdMeijer. Herald added a reviewer: javed.absar. Herald added subscribers: chrib, kristof.beyls. On targets that do not support FP16 natively LLVM currently legalizes vectors of FP16 values by scalarizing them and promoting to FP32. This causes problems for the following code: void foo(int, ...); typedef __attribute__((neon_vector_type(4))) __fp16 float16x4_t; void bar(float16x4_t x) { foo(42, x); } According to the AAPCS (appendix A.2) float16x4_t is a containerized vector fundamental type, so 'foo' expects that the 4 16-bit FP values are packed into 2 32-bit registers, but instead bar promotes them to 4 single precision values. Since we already handle scalar FP16 values in the frontend by bitcasting them to/from integers, this patch adds similar handling for vector types. One existing test required some adjustments because we now generate more bitcasts (so the patch changes the test to target a machine with native FP16 support). https://reviews.llvm.org/D50507 Files: lib/CodeGen/TargetInfo.cpp test/CodeGen/arm-vfp16-arguments.c test/CodeGen/arm_neon_intrinsics.c Index: test/CodeGen/arm_neon_intrinsics.c === --- test/CodeGen/arm_neon_intrinsics.c +++ test/CodeGen/arm_neon_intrinsics.c @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -triple thumbv7s-apple-darwin -target-abi apcs-gnu\ -// RUN: -target-cpu swift -fallow-half-arguments-and-returns -ffreestanding \ +// RUN: -target-cpu swift -fallow-half-arguments-and-returns \ +// RUN: -target-feature +fullfp16 -ffreestanding \ // RUN: -disable-O0-optnone -emit-llvm -o - %s \ // RUN: | opt -S -mem2reg | FileCheck %s @@ -3896,9 +3897,8 @@ // CHECK-LABEL: @test_vld1q_f16( // CHECK: [[TMP0:%.*]] = bitcast half* %a to i8* -// CHECK: [[VLD1:%.*]] = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8* [[TMP0]], i32 2) -// CHECK: [[TMP1:%.*]] = bitcast <8 x i16> [[VLD1]] to <8 x half> -// CHECK: ret <8 x half> [[TMP1]] +// CHECK: [[VLD1:%.*]] = call <8 x half> @llvm.arm.neon.vld1.v8f16.p0i8(i8* [[TMP0]], i32 2) +// CHECK: ret <8 x half> [[VLD1]] float16x8_t test_vld1q_f16(float16_t const * a) { return vld1q_f16(a); } @@ -3990,9 +3990,8 @@ // CHECK-LABEL: @test_vld1_f16( // CHECK: [[TMP0:%.*]] = bitcast half* %a to i8* -// CHECK: [[VLD1:%.*]] = call <4 x i16> @llvm.arm.neon.vld1.v4i16.p0i8(i8* [[TMP0]], i32 2) -// CHECK: [[TMP1:%.*]] = bitcast <4 x i16> [[VLD1]] to <4 x half> -// CHECK: ret <4 x half> [[TMP1]] +// CHECK: [[VLD1:%.*]] = call <4 x half> @llvm.arm.neon.vld1.v4f16.p0i8(i8* [[TMP0]], i32 2) +// CHECK: ret <4 x half> [[VLD1]] float16x4_t test_vld1_f16(float16_t const * a) { return vld1_f16(a); } @@ -4106,12 +4105,11 @@ // CHECK-LABEL: @test_vld1q_dup_f16( // CHECK: [[TMP0:%.*]] = bitcast half* %a to i8* -// CHECK: [[TMP1:%.*]] = bitcast i8* [[TMP0]] to i16* -// CHECK: [[TMP2:%.*]] = load i16, i16* [[TMP1]], align 2 -// CHECK: [[TMP3:%.*]] = insertelement <8 x i16> undef, i16 [[TMP2]], i32 0 -// CHECK: [[LANE:%.*]] = shufflevector <8 x i16> [[TMP3]], <8 x i16> [[TMP3]], <8 x i32> zeroinitializer -// CHECK: [[TMP4:%.*]] = bitcast <8 x i16> [[LANE]] to <8 x half> -// CHECK: ret <8 x half> [[TMP4]] +// CHECK: [[TMP1:%.*]] = bitcast i8* [[TMP0]] to half* +// CHECK: [[TMP2:%.*]] = load half, half* [[TMP1]], align 2 +// CHECK: [[TMP3:%.*]] = insertelement <8 x half> undef, half [[TMP2]], i32 0 +// CHECK: [[LANE:%.*]] = shufflevector <8 x half> [[TMP3]], <8 x half> [[TMP3]], <8 x i32> zeroinitializer +// CHECK: ret <8 x half> [[LANE]] float16x8_t test_vld1q_dup_f16(float16_t const * a) { return vld1q_dup_f16(a); } @@ -4233,12 +4231,11 @@ // CHECK-LABEL: @test_vld1_dup_f16( // CHECK: [[TMP0:%.*]] = bitcast half* %a to i8* -// CHECK: [[TMP1:%.*]] = bitcast i8* [[TMP0]] to i16* -// CHECK: [[TMP2:%.*]] = load i16, i16* [[TMP1]], align 2 -// CHECK: [[TMP3:%.*]] = insertelement <4 x i16> undef, i16 [[TMP2]], i32 0 -// CHECK: [[LANE:%.*]] = shufflevector <4 x i16> [[TMP3]], <4 x i16> [[TMP3]], <4 x i32> zeroinitializer -// CHECK: [[TMP4:%.*]] = bitcast <4 x i16> [[LANE]] to <4 x half> -// CHECK: ret <4 x half> [[TMP4]] +// CHECK: [[TMP1:%.*]] = bitcast i8* [[TMP0]] to half* +// CHECK: [[TMP2:%.*]] = load half, half* [[TMP1]], align 2 +// CHECK: [[TMP3:%.*]] = insertelement <4 x half> undef, half [[TMP2]], i32 0 +// CHECK: [[LANE:%.*]] = shufflevector <4 x half> [[TMP3]], <4 x half> [[TMP3]], <4 x i32> zeroinitializer +// CHECK: ret <4 x half> [[LANE]] float16x4_t test_vld1_dup_f16(float16_t const * a) { return vld1_dup_f16(a); } @@ -4365,12 +4362,11 @@ // CHECK-LABEL: @test_vld1q_lane_f16( // CHECK: [[TMP0:%.*]] = bitcast half* %a to i8* // CHECK: [[TMP1:%.*]] = bitcast <8 x half> %b to <16 x i8> -// CHECK: [[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <8 x i16> -// CHECK: [[TMP3:%.*]] = b
[PATCH] D47400: [libcxx] [test] Allow a standard library that implements LWG 1203 in istream.rvalue/rvalue.pass.cpp
ldionne accepted this revision. ldionne added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D47400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339334 - Add support for importing imaginary literals
Author: martong Date: Thu Aug 9 05:18:07 2018 New Revision: 339334 URL: http://llvm.org/viewvc/llvm-project?rev=339334&view=rev Log: Add support for importing imaginary literals Reviewers: a_sidorin, r.stahl, xazax.hun Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D50428 Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp cfe/trunk/unittests/AST/ASTImporterTest.cpp Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=339334&r1=339333&r2=339334&view=diff == --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Aug 9 05:18:07 2018 @@ -1975,6 +1975,11 @@ extern const internal::VariadicDynCastAl extern const internal::VariadicDynCastAllOfMatcher floatLiteral; +/// Matches imaginary literals, which are based on integer and floating +/// point literals e.g.: 1i, 1.0i +extern const internal::VariadicDynCastAllOfMatcher +imaginaryLiteral; + /// Matches user defined literal operator call. /// /// Example match: "foo"_suffix Modified: cfe/trunk/lib/AST/ASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=339334&r1=339333&r2=339334&view=diff == --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Aug 9 05:18:07 2018 @@ -434,6 +434,7 @@ namespace clang { Expr *VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E); Expr *VisitIntegerLiteral(IntegerLiteral *E); Expr *VisitFloatingLiteral(FloatingLiteral *E); +Expr *VisitImaginaryLiteral(ImaginaryLiteral *E); Expr *VisitCharacterLiteral(CharacterLiteral *E); Expr *VisitStringLiteral(StringLiteral *E); Expr *VisitCompoundLiteralExpr(CompoundLiteralExpr *E); @@ -5613,6 +5614,18 @@ Expr *ASTNodeImporter::VisitFloatingLite Importer.Import(E->getLocation())); } +Expr *ASTNodeImporter::VisitImaginaryLiteral(ImaginaryLiteral *E) { + QualType T = Importer.Import(E->getType()); + if (T.isNull()) +return nullptr; + + Expr *SubE = Importer.Import(E->getSubExpr()); + if (!SubE) +return nullptr; + + return new (Importer.getToContext()) ImaginaryLiteral(SubE, T); +} + Expr *ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp?rev=339334&r1=339333&r2=339334&view=diff == --- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp (original) +++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp Thu Aug 9 05:18:07 2018 @@ -710,6 +710,7 @@ const internal::VariadicDynCastAllOfMatc const internal::VariadicDynCastAllOfMatcher integerLiteral; const internal::VariadicDynCastAllOfMatcher floatLiteral; +const internal::VariadicDynCastAllOfMatcher imaginaryLiteral; const internal::VariadicDynCastAllOfMatcher userDefinedLiteral; const internal::VariadicDynCastAllOfMatcher Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=339334&r1=339333&r2=339334&view=diff == --- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original) +++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Thu Aug 9 05:18:07 2018 @@ -553,6 +553,14 @@ TEST_P(ImportExpr, ImportFloatinglLitera floatLiteral(equals(1.0e-5f), hasType(asString("float")); } +TEST_P(ImportExpr, ImportImaginaryLiteralExpr) { + MatchVerifier Verifier; + testImport( + "void declToImport() { (void)1.0i; }", + Lang_CXX14, "", Lang_CXX14, Verifier, + functionDecl(hasDescendant(imaginaryLiteral(; +} + TEST_P(ImportExpr, ImportCompoundLiteralExpr) { MatchVerifier Verifier; testImport( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50508: [analyzer][UninitializedObjectChecker] Refactoring p5.: Handle pedantic mode in the checker class only
Szelethus created this revision. Szelethus added reviewers: NoQ, george.karpenkov, rnkovacs, xazax.hun. Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, whisperity. A class named `FindUninitializedFields` shouldn't care about whether the checker will outright ignore all of its results. Repository: rC Clang https://reviews.llvm.org/D50508 Files: lib/StaticAnalyzer/Checkers/UninitializedObject.h lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp @@ -130,14 +130,20 @@ if (!Object) return; - FindUninitializedFields F(Context.getState(), Object->getRegion(), IsPedantic, + FindUninitializedFields F(Context.getState(), Object->getRegion(), CheckPointeeInitialization); const UninitFieldMap &UninitFields = F.getUninitFields(); if (UninitFields.empty()) return; + // In non-pedantic mode, if Object's region doesn't contain a single + // initialized field, we'll assume that Object was intentionally left + // uninitialized. + if (!IsPedantic && !F.isAnyFieldInitialized()) +return; + // There are uninitialized fields in the record. ExplodedNode *Node = Context.generateNonFatalErrorNode(Context.getState()); @@ -186,18 +192,12 @@ //===--===// FindUninitializedFields::FindUninitializedFields( -ProgramStateRef State, const TypedValueRegion *const R, bool IsPedantic, +ProgramStateRef State, const TypedValueRegion *const R, bool CheckPointeeInitialization) -: State(State), ObjectR(R), IsPedantic(IsPedantic), - CheckPointeeInitialization(CheckPointeeInitialization) {} +: State(State), ObjectR(R), + CheckPointeeInitialization(CheckPointeeInitialization) { -const UninitFieldMap &FindUninitializedFields::getUninitFields() { isNonUnionUninit(ObjectR, FieldChainInfo(ChainFactory)); - - if (!IsPedantic && !IsAnyFieldInitialized) -UninitFields.clear(); - - return UninitFields; } bool FindUninitializedFields::addFieldToUninits(FieldChainInfo Chain) { Index: lib/StaticAnalyzer/Checkers/UninitializedObject.h === --- lib/StaticAnalyzer/Checkers/UninitializedObject.h +++ lib/StaticAnalyzer/Checkers/UninitializedObject.h @@ -111,9 +111,7 @@ ProgramStateRef State; const TypedValueRegion *const ObjectR; - const bool IsPedantic; const bool CheckPointeeInitialization; - bool IsAnyFieldInitialized = false; FieldChainInfo::FieldChain::Factory ChainFactory; @@ -131,10 +129,17 @@ UninitFieldMap UninitFields; public: + /// Constructs the FindUninitializedField object, searches for and stores + /// uninitialized fields in R. FindUninitializedFields(ProgramStateRef State, - const TypedValueRegion *const R, bool IsPedantic, + const TypedValueRegion *const R, bool CheckPointeeInitialization); - const UninitFieldMap &getUninitFields(); + + const UninitFieldMap &getUninitFields() { return UninitFields; } + + /// Returns whether the analyzed region contains at least one initialized + /// field. + bool isAnyFieldInitialized() { return IsAnyFieldInitialized; } private: // For the purposes of this checker, we'll regard the object under checking as Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp @@ -130,14 +130,20 @@ if (!Object) return; - FindUninitializedFields F(Context.getState(), Object->getRegion(), IsPedantic, + FindUninitializedFields F(Context.getState(), Object->getRegion(), CheckPointeeInitialization); const UninitFieldMap &UninitFields = F.getUninitFields(); if (UninitFields.empty()) return; + // In non-pedantic mode, if Object's region doesn't contain a single + // initialized field, we'll assume that Object was intentionally left + // uninitialized. + if (!IsPedantic && !F.isAnyFieldInitialized()) +return; + // There are uninitialized fields in the record. ExplodedNode *Node = Context.generateNonFatalErrorNode(Context.getState()); @@ -186,18 +192,12 @@ //===--===// FindUninitializedFields::FindUninitializedFields( -ProgramStateRef State, const TypedValueRegion *const R, bool IsPedantic, +ProgramStateRef State, const TypedValueRegion *const R, bool CheckPointeeInitialization) -: State(State), ObjectR(R)
[PATCH] D50428: [ASTImporter] Add support for importing imaginary literals
This revision was automatically updated to reflect the committed changes. Closed by commit rL339334: Add support for importing imaginary literals (authored by martong, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50428?vs=159662&id=159902#toc Repository: rL LLVM https://reviews.llvm.org/D50428 Files: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp cfe/trunk/unittests/AST/ASTImporterTest.cpp Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h === --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h @@ -1975,6 +1975,11 @@ extern const internal::VariadicDynCastAllOfMatcher floatLiteral; +/// Matches imaginary literals, which are based on integer and floating +/// point literals e.g.: 1i, 1.0i +extern const internal::VariadicDynCastAllOfMatcher +imaginaryLiteral; + /// Matches user defined literal operator call. /// /// Example match: "foo"_suffix Index: cfe/trunk/lib/AST/ASTImporter.cpp === --- cfe/trunk/lib/AST/ASTImporter.cpp +++ cfe/trunk/lib/AST/ASTImporter.cpp @@ -434,6 +434,7 @@ Expr *VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E); Expr *VisitIntegerLiteral(IntegerLiteral *E); Expr *VisitFloatingLiteral(FloatingLiteral *E); +Expr *VisitImaginaryLiteral(ImaginaryLiteral *E); Expr *VisitCharacterLiteral(CharacterLiteral *E); Expr *VisitStringLiteral(StringLiteral *E); Expr *VisitCompoundLiteralExpr(CompoundLiteralExpr *E); @@ -5613,6 +5614,18 @@ Importer.Import(E->getLocation())); } +Expr *ASTNodeImporter::VisitImaginaryLiteral(ImaginaryLiteral *E) { + QualType T = Importer.Import(E->getType()); + if (T.isNull()) +return nullptr; + + Expr *SubE = Importer.Import(E->getSubExpr()); + if (!SubE) +return nullptr; + + return new (Importer.getToContext()) ImaginaryLiteral(SubE, T); +} + Expr *ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) Index: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp === --- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp +++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -710,6 +710,7 @@ const internal::VariadicDynCastAllOfMatcher integerLiteral; const internal::VariadicDynCastAllOfMatcher floatLiteral; +const internal::VariadicDynCastAllOfMatcher imaginaryLiteral; const internal::VariadicDynCastAllOfMatcher userDefinedLiteral; const internal::VariadicDynCastAllOfMatcher Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp === --- cfe/trunk/unittests/AST/ASTImporterTest.cpp +++ cfe/trunk/unittests/AST/ASTImporterTest.cpp @@ -553,6 +553,14 @@ floatLiteral(equals(1.0e-5f), hasType(asString("float")); } +TEST_P(ImportExpr, ImportImaginaryLiteralExpr) { + MatchVerifier Verifier; + testImport( + "void declToImport() { (void)1.0i; }", + Lang_CXX14, "", Lang_CXX14, Verifier, + functionDecl(hasDescendant(imaginaryLiteral(; +} + TEST_P(ImportExpr, ImportCompoundLiteralExpr) { MatchVerifier Verifier; testImport( Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h === --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h @@ -1975,6 +1975,11 @@ extern const internal::VariadicDynCastAllOfMatcher floatLiteral; +/// Matches imaginary literals, which are based on integer and floating +/// point literals e.g.: 1i, 1.0i +extern const internal::VariadicDynCastAllOfMatcher +imaginaryLiteral; + /// Matches user defined literal operator call. /// /// Example match: "foo"_suffix Index: cfe/trunk/lib/AST/ASTImporter.cpp === --- cfe/trunk/lib/AST/ASTImporter.cpp +++ cfe/trunk/lib/AST/ASTImporter.cpp @@ -434,6 +434,7 @@ Expr *VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E); Expr *VisitIntegerLiteral(IntegerLiteral *E); Expr *VisitFloatingLiteral(FloatingLiteral *E); +Expr *VisitImaginaryLiteral(ImaginaryLiteral *E); Expr *VisitCharacterLiteral(CharacterLiteral *E); Expr *VisitStringLiteral(StringLiteral *E); Expr *VisitCompoundLiteralExpr(CompoundLiteralExpr *E); @@ -5613,6 +5614,18 @@ Importer.Import(E->getLocation())); } +Expr *ASTNodeImporter::VisitImaginaryLiteral(ImaginaryLiteral *E) { + QualType T = Importer.Import(E->getType()); + if (T.isNull()) +return nullptr; + + Expr *SubE = Importer.Import(E
[PATCH] D50344: [libc++] Enable aligned allocation based on feature test macro, irrespective of standard
ldionne updated this revision to Diff 159903. ldionne marked an inline comment as done. ldionne added a comment. Address vsapsai's comments Repository: rCXX libc++ https://reviews.llvm.org/D50344 Files: libcxx/include/__config libcxx/include/new libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp Index: libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp === --- /dev/null +++ libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp @@ -0,0 +1,25 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// XFAIL: with_system_cxx_lib=macosx10.12 +// XFAIL: with_system_cxx_lib=macosx10.11 +// XFAIL: with_system_cxx_lib=macosx10.10 +// XFAIL: with_system_cxx_lib=macosx10.9 +// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: with_system_cxx_lib=macosx10.7 + +#include + + +#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +# error "libc++ should have aligned allocation in C++17 and up when targeting a platform that supports it" +#endif + +int main() { } Index: libcxx/include/new === --- libcxx/include/new +++ libcxx/include/new @@ -108,13 +108,6 @@ # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION #endif -#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ -(!(defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_STD_VER > 14 || \ -(defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606))) -# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION -#endif - - #if !__has_builtin(__builtin_operator_new) || \ __has_builtin(__builtin_operator_new) < 201802L || \ defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \ Index: libcxx/include/__config === --- libcxx/include/__config +++ libcxx/include/__config @@ -988,6 +988,11 @@ # endif #endif // defined(__APPLE__) +#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ +!defined(_LIBCPP_BUILDING_LIBRARY) && \ +(!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) +# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +#endif #if defined(__APPLE__) || defined(__FreeBSD__) #define _LIBCPP_HAS_DEFAULTRUNELOCALE Index: libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp === --- /dev/null +++ libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp @@ -0,0 +1,25 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// XFAIL: with_system_cxx_lib=macosx10.12 +// XFAIL: with_system_cxx_lib=macosx10.11 +// XFAIL: with_system_cxx_lib=macosx10.10 +// XFAIL: with_system_cxx_lib=macosx10.9 +// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: with_system_cxx_lib=macosx10.7 + +#include + + +#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +# error "libc++ should have aligned allocation in C++17 and up when targeting a platform that supports it" +#endif + +int main() { } Index: libcxx/include/new === --- libcxx/include/new +++ libcxx/include/new @@ -108,13 +108,6 @@ # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION #endif -#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ -(!(defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_STD_VER > 14 || \ -(defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606))) -# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION -#endif - - #if !__has_builtin(__builtin_operator_new) || \ __has_builtin(__builtin_operator_new) < 201802L || \ defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \ Index: libcxx/include/__config === --- libcxx/include/__config +++ libcxx/include/__config @@ -988,6 +988,11 @@ # endif #endif // defined(__APPLE__) +#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ +!defined(_LIBCPP_BUILDING_LIBRARY) && \ +(!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) +# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +#endif #if defined(__APPLE__) || defined(__FreeBSD__) #define _LIBCPP_HAS_DEFAULTRUNELOCALE ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50344: [libc++] Enable aligned allocation based on feature test macro, irrespective of standard
ldionne added inline comments. Comment at: libcxx/include/new:111-116 #if !__has_builtin(__builtin_operator_new) || \ __has_builtin(__builtin_operator_new) < 201802L || \ defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \ !defined(__cpp_aligned_new) || __cpp_aligned_new < 201606 #define _LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE #endif vsapsai wrote: > Maybe move this to `__config` too? This way we'll have > `__cpp_aligned_new`-related macros together. The big difference is that `_LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE` is only used in ``, whereas `_LIBCPP_HAS_NO_ALIGNED_ALLOCATION` was used in other files as well. Hence, I feel like it makes more sense to lift `_LIBCPP_HAS_NO_ALIGNED_ALLOCATION` into `<__config>`, but not `_LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE `. Repository: rCXX libc++ https://reviews.llvm.org/D50344 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50344: [libc++] Enable aligned allocation based on feature test macro, irrespective of standard
ldionne marked an inline comment as done. ldionne added inline comments. Comment at: libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp:11 +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// XFAIL: with_system_cxx_lib=macosx10.12 +// XFAIL: with_system_cxx_lib=macosx10.11 vsapsai wrote: > Initially `with_system_cxx_lib` made me suspicious because macro > `_LIBCPP_HAS_NO_ALIGNED_ALLOCATION` doesn't need specific dylib. And `XFAIL: > availability=macosx10.12` seems to be working. > > [Documentation](https://github.com/llvm-mirror/libcxx/blob/master/docs/DesignDocs/AvailabilityMarkup.rst#testing) > describes which feature should be used in different cases but in this case I > cannot definitely say if test uses unavailable feature. I think it is > acceptable to stick with `with_system_cxx_lib` but I decided to brought to > your attention the alternative. My understanding is that the `availability` feature may not be there if we're not using availability macros, since they can be disabled entirely. Repository: rCXX libc++ https://reviews.llvm.org/D50344 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50444: [ASTImporter] Fix structural inequivalency of forward EnumDecl
This revision was automatically updated to reflect the committed changes. Closed by commit rL339336: Fix structural inequivalency of forward EnumDecl (authored by martong, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50444?vs=159697&id=159905#toc Repository: rL LLVM https://reviews.llvm.org/D50444 Files: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp Index: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp === --- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp +++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp @@ -1178,6 +1178,14 @@ /// Determine structural equivalence of two enums. static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, EnumDecl *D1, EnumDecl *D2) { + + // Compare the definitions of these two enums. If either or both are + // incomplete (i.e. forward declared), we assume that they are equivalent. + D1 = D1->getDefinition(); + D2 = D2->getDefinition(); + if (!D1 || !D2) +return true; + EnumDecl::enumerator_iterator EC2 = D2->enumerator_begin(), EC2End = D2->enumerator_end(); for (EnumDecl::enumerator_iterator EC1 = D1->enumerator_begin(), Index: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp === --- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp +++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp @@ -642,13 +642,67 @@ EXPECT_FALSE(testStructuralMatch(t)); } +TEST_F(StructuralEquivalenceRecordTest, +FwdDeclRecordShouldBeEqualWithFwdDeclRecord) { + auto t = makeNamedDecls("class foo;", "class foo;", Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceRecordTest, + FwdDeclRecordShouldBeEqualWithRecordWhichHasDefinition) { + auto t = + makeNamedDecls("class foo;", "class foo { int A; };", Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceRecordTest, + RecordShouldBeEqualWithRecordWhichHasDefinition) { + auto t = makeNamedDecls("class foo { int A; };", "class foo { int A; };", + Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceRecordTest, RecordsWithDifferentBody) { + auto t = makeNamedDecls("class foo { int B; };", "class foo { int A; };", + Lang_CXX11); + EXPECT_FALSE(testStructuralMatch(t)); +} + TEST_F(StructuralEquivalenceTest, CompareSameDeclWithMultiple) { auto t = makeNamedDecls( "struct A{ }; struct B{ }; void foo(A a, A b);", "struct A{ }; struct B{ }; void foo(A a, B b);", Lang_CXX); EXPECT_FALSE(testStructuralMatch(t)); } +struct StructuralEquivalenceEnumTest : StructuralEquivalenceTest {}; + +TEST_F(StructuralEquivalenceEnumTest, FwdDeclEnumShouldBeEqualWithFwdDeclEnum) { + auto t = makeNamedDecls("enum class foo;", "enum class foo;", Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceEnumTest, + FwdDeclEnumShouldBeEqualWithEnumWhichHasDefinition) { + auto t = + makeNamedDecls("enum class foo;", "enum class foo { A };", Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceEnumTest, + EnumShouldBeEqualWithEnumWhichHasDefinition) { + auto t = makeNamedDecls("enum class foo { A };", "enum class foo { A };", + Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceEnumTest, EnumsWithDifferentBody) { + auto t = makeNamedDecls("enum class foo { B };", "enum class foo { A };", + Lang_CXX11); + EXPECT_FALSE(testStructuralMatch(t)); +} + + } // end namespace ast_matchers } // end namespace clang Index: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp === --- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp +++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp @@ -1178,6 +1178,14 @@ /// Determine structural equivalence of two enums. static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, EnumDecl *D1, EnumDecl *D2) { + + // Compare the definitions of these two enums. If either or both are + // incomplete (i.e. forward declared), we assume that they are equivalent. + D1 = D1->getDefinition(); + D2 = D2->getDefinition(); + if (!D1 || !D2) +return true; + EnumDecl::enumerator_iterator EC2 = D2->enumerator_begin(), EC2End = D2->enumerator_end(); for (EnumDecl::enumerator_iterator EC1 = D1->enumerator_begin(), Index: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp === --- cfe/trunk/unittests/AS
r339336 - Fix structural inequivalency of forward EnumDecl
Author: martong Date: Thu Aug 9 05:36:25 2018 New Revision: 339336 URL: http://llvm.org/viewvc/llvm-project?rev=339336&view=rev Log: Fix structural inequivalency of forward EnumDecl Summary: Currently we consider one forward declared RecordDecl and another with a definition equal. We have to do the same in case of enums. Reviewers: a_sidorin, r.stahl, xazax.hun Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D50444 Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=339336&r1=339335&r2=339336&view=diff == --- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original) +++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Thu Aug 9 05:36:25 2018 @@ -1178,6 +1178,14 @@ static bool IsStructurallyEquivalent(Str /// Determine structural equivalence of two enums. static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, EnumDecl *D1, EnumDecl *D2) { + + // Compare the definitions of these two enums. If either or both are + // incomplete (i.e. forward declared), we assume that they are equivalent. + D1 = D1->getDefinition(); + D2 = D2->getDefinition(); + if (!D1 || !D2) +return true; + EnumDecl::enumerator_iterator EC2 = D2->enumerator_begin(), EC2End = D2->enumerator_end(); for (EnumDecl::enumerator_iterator EC1 = D1->enumerator_begin(), Modified: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp?rev=339336&r1=339335&r2=339336&view=diff == --- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp (original) +++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp Thu Aug 9 05:36:25 2018 @@ -642,6 +642,32 @@ TEST_F(StructuralEquivalenceRecordTest, EXPECT_FALSE(testStructuralMatch(t)); } +TEST_F(StructuralEquivalenceRecordTest, +FwdDeclRecordShouldBeEqualWithFwdDeclRecord) { + auto t = makeNamedDecls("class foo;", "class foo;", Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceRecordTest, + FwdDeclRecordShouldBeEqualWithRecordWhichHasDefinition) { + auto t = + makeNamedDecls("class foo;", "class foo { int A; };", Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceRecordTest, + RecordShouldBeEqualWithRecordWhichHasDefinition) { + auto t = makeNamedDecls("class foo { int A; };", "class foo { int A; };", + Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceRecordTest, RecordsWithDifferentBody) { + auto t = makeNamedDecls("class foo { int B; };", "class foo { int A; };", + Lang_CXX11); + EXPECT_FALSE(testStructuralMatch(t)); +} + TEST_F(StructuralEquivalenceTest, CompareSameDeclWithMultiple) { auto t = makeNamedDecls( "struct A{ }; struct B{ }; void foo(A a, A b);", @@ -650,5 +676,33 @@ TEST_F(StructuralEquivalenceTest, Compar EXPECT_FALSE(testStructuralMatch(t)); } +struct StructuralEquivalenceEnumTest : StructuralEquivalenceTest {}; + +TEST_F(StructuralEquivalenceEnumTest, FwdDeclEnumShouldBeEqualWithFwdDeclEnum) { + auto t = makeNamedDecls("enum class foo;", "enum class foo;", Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceEnumTest, + FwdDeclEnumShouldBeEqualWithEnumWhichHasDefinition) { + auto t = + makeNamedDecls("enum class foo;", "enum class foo { A };", Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceEnumTest, + EnumShouldBeEqualWithEnumWhichHasDefinition) { + auto t = makeNamedDecls("enum class foo { A };", "enum class foo { A };", + Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceEnumTest, EnumsWithDifferentBody) { + auto t = makeNamedDecls("enum class foo { B };", "enum class foo { A };", + Lang_CXX11); + EXPECT_FALSE(testStructuralMatch(t)); +} + + } // end namespace ast_matchers } // end namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r339317 - Correctly initialise global blocks on Windows.
Merged to 7.0 in r339339. On Thu, Aug 9, 2018 at 10:02 AM, David Chisnall via cfe-commits wrote: > Author: theraven > Date: Thu Aug 9 01:02:42 2018 > New Revision: 339317 > > URL: http://llvm.org/viewvc/llvm-project?rev=339317&view=rev > Log: > Correctly initialise global blocks on Windows. > > Summary: > Windows does not allow globals to be initialised to point to globals in > another DLL. Exported globals may be referenced only from code. Work > around this by creating an initialiser that runs in early library > initialisation and sets the isa pointer. > > Reviewers: rjmccall > > Reviewed By: rjmccall > > Subscribers: cfe-commits > > Differential Revision: https://reviews.llvm.org/D50436 > > Added: > cfe/trunk/test/CodeGen/global-blocks-win32.c > Modified: > cfe/trunk/lib/CodeGen/CGBlocks.cpp > > Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=339317&r1=339316&r2=339317&view=diff > == > --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Aug 9 01:02:42 2018 > @@ -1213,9 +1213,13 @@ static llvm::Constant *buildGlobalBlock( >auto fields = builder.beginStruct(); > >bool IsOpenCL = CGM.getLangOpts().OpenCL; > + bool IsWindows = CGM.getTarget().getTriple().isOSWindows(); >if (!IsOpenCL) { > // isa > -fields.add(CGM.getNSConcreteGlobalBlock()); > +if (IsWindows) > + fields.addNullPointer(CGM.Int8PtrPtrTy); > +else > + fields.add(CGM.getNSConcreteGlobalBlock()); > > // __flags > BlockFlags flags = BLOCK_IS_GLOBAL | BLOCK_HAS_SIGNATURE; > @@ -1250,7 +1254,27 @@ static llvm::Constant *buildGlobalBlock( > >llvm::Constant *literal = fields.finishAndCreateGlobal( >"__block_literal_global", blockInfo.BlockAlign, > - /*constant*/ true, llvm::GlobalVariable::InternalLinkage, AddrSpace); > + /*constant*/ !IsWindows, llvm::GlobalVariable::InternalLinkage, > AddrSpace); > + > + // Windows does not allow globals to be initialised to point to globals in > + // different DLLs. Any such variables must run code to initialise them. > + if (IsWindows) { > +auto *Init = llvm::Function::Create(llvm::FunctionType::get(CGM.VoidTy, > + {}), llvm::GlobalValue::InternalLinkage, ".block_isa_init", > +&CGM.getModule()); > +llvm::IRBuilder<> b(llvm::BasicBlock::Create(CGM.getLLVMContext(), > "entry", > + Init)); > +b.CreateAlignedStore(CGM.getNSConcreteGlobalBlock(), > +b.CreateStructGEP(literal, 0), CGM.getPointerAlign().getQuantity()); > +b.CreateRetVoid(); > +// We can't use the normal LLVM global initialisation array, because we > +// need to specify that this runs early in library initialisation. > +auto *InitVar = new llvm::GlobalVariable(CGM.getModule(), > Init->getType(), > +/*isConstant*/true, llvm::GlobalValue::InternalLinkage, > +Init, ".block_isa_init_ptr"); > +InitVar->setSection(".CRT$XCLa"); > +CGM.addUsedGlobal(InitVar); > + } > >// Return a constant of the appropriately-casted type. >llvm::Type *RequiredType = > > Added: cfe/trunk/test/CodeGen/global-blocks-win32.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/global-blocks-win32.c?rev=339317&view=auto > == > --- cfe/trunk/test/CodeGen/global-blocks-win32.c (added) > +++ cfe/trunk/test/CodeGen/global-blocks-win32.c Thu Aug 9 01:02:42 2018 > @@ -0,0 +1,18 @@ > +// RUN: %clang_cc1 -fblocks -triple i386-pc-windows-msvc %s -emit-llvm -o - > -fblocks | FileCheck %s > + > + > +int (^x)(void) = ^() { return 21; }; > + > + > +// Check that the block literal is emitted with a null isa pointer > +// CHECK: @__block_literal_global = internal global { i8**, i32, i32, i8*, > %struct.__block_descriptor* } { i8** null, > + > +// Check that _NSConcreteGlobalBlock has the correct dllimport specifier. > +// CHECK: @_NSConcreteGlobalBlock = external dllimport global i8* > +// Check that we create an initialiser pointer in the correct section (early > library initialisation). > +// CHECK: @.block_isa_init_ptr = internal constant void ()* > @.block_isa_init, section ".CRT$XCLa" > + > +// Check that we emit an initialiser for it. > +// CHECK: define internal void @.block_isa_init() { > +// CHECK: store i8** @_NSConcreteGlobalBlock, i8*** getelementptr inbounds > ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }, { i8**, i32, i32, i8*, > %struct.__block_descriptor* }* @__block_literal_global, i32 0, i32 0), align 4 > + > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.or
Re: r339281 - [CodeGen][Timers] Enable llvm::TimePassesIsEnabled when -ftime-report is specified
Merged to 7.0 in r339341. On Wed, Aug 8, 2018 at 9:14 PM, Craig Topper via cfe-commits wrote: > Author: ctopper > Date: Wed Aug 8 12:14:23 2018 > New Revision: 339281 > > URL: http://llvm.org/viewvc/llvm-project?rev=339281&view=rev > Log: > [CodeGen][Timers] Enable llvm::TimePassesIsEnabled when -ftime-report is > specified > > r330571 added a new FrontendTimesIsEnabled variable and replaced many usages > of llvm::TimePassesIsEnabled. Including the place that set > llvm::TimePassesIsEnabled for -ftime-report. The effect of this is that > -ftime-report now only contains the timers specifically referenced in > CodeGenAction.cpp and none of the timers in the backend. > > This commit adds back the assignment, but otherwise leaves everything else > unchanged. > > Modified: > cfe/trunk/lib/CodeGen/CodeGenAction.cpp > > Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=339281&r1=339280&r2=339281&view=diff > == > --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) > +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Wed Aug 8 12:14:23 2018 > @@ -127,6 +127,7 @@ namespace clang { > CodeGenOpts, C, CoverageInfo)), >LinkModules(std::move(LinkModules)) { >FrontendTimesIsEnabled = TimePasses; > + llvm::TimePassesIsEnabled = TimePasses; > } > llvm::Module *getModule() const { return Gen->GetModule(); } > std::unique_ptr takeModule() { > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50390: [SEMA]Uniform printing of Attributes
erichkeane abandoned this revision. erichkeane added a comment. After talking to Aaron, we're going to try to use the lexical names for ALL cases. This requires a bunch of of accessory work (in order to get the Identifier from the SourceRange), so it'll be split up into a couple of commits and done separately. I'll likely do the part that gives Attr a diagnostic operator<< as an NFC change in the near future. https://reviews.llvm.org/D50390 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50337: [clangd] DexIndex implementation prototype
kbobyrev updated this revision to Diff 159908. kbobyrev marked 15 inline comments as done. kbobyrev added a comment. Address a round of comments. Also put `FIXME`s where appropriate for the future changes. https://reviews.llvm.org/D50337 Files: clang-tools-extra/clangd/CMakeLists.txt clang-tools-extra/clangd/index/dex/DexIndex.cpp clang-tools-extra/clangd/index/dex/DexIndex.h clang-tools-extra/clangd/index/dex/Token.cpp clang-tools-extra/clangd/index/dex/Token.h clang-tools-extra/unittests/clangd/CMakeLists.txt clang-tools-extra/unittests/clangd/DexIndexTests.cpp clang-tools-extra/unittests/clangd/IndexTests.cpp clang-tools-extra/unittests/clangd/TestIndexOperations.cpp clang-tools-extra/unittests/clangd/TestIndexOperations.h Index: clang-tools-extra/unittests/clangd/TestIndexOperations.h === --- /dev/null +++ clang-tools-extra/unittests/clangd/TestIndexOperations.h @@ -0,0 +1,57 @@ +//===-- IndexHelpers.h --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_INDEXTESTCOMMON_H +#define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_INDEXTESTCOMMON_H + +#include "index/Index.h" +#include "index/Merge.h" +#include "index/dex/DexIndex.h" +#include "index/dex/Iterator.h" +#include "index/dex/Token.h" +#include "index/dex/Trigram.h" + +namespace clang { +namespace clangd { + +Symbol symbol(llvm::StringRef QName); + +struct SlabAndPointers { + SymbolSlab Slab; + std::vector Pointers; +}; + +// Create a slab of symbols with the given qualified names as both IDs and +// names. The life time of the slab is managed by the returned shared pointer. +// If \p WeakSymbols is provided, it will be pointed to the managed object in +// the returned shared pointer. +std::shared_ptr> +generateSymbols(std::vector QualifiedNames, +std::weak_ptr *WeakSymbols = nullptr); + +// Create a slab of symbols with IDs and names [Begin, End], otherwise identical +// to the `generateSymbols` above. +std::shared_ptr> +generateNumSymbols(int Begin, int End, + std::weak_ptr *WeakSymbols = nullptr); + +std::string getQualifiedName(const Symbol &Sym); + +std::vector match(const SymbolIndex &I, + const FuzzyFindRequest &Req, + bool *Incomplete = nullptr); + +// Returns qualified names of symbols with any of IDs in the index. +std::vector lookup(const SymbolIndex &I, +llvm::ArrayRef IDs); + +} // namespace clangd +} // namespace clang + +#endif Index: clang-tools-extra/unittests/clangd/TestIndexOperations.cpp === --- /dev/null +++ clang-tools-extra/unittests/clangd/TestIndexOperations.cpp @@ -0,0 +1,89 @@ +//===-- IndexHelpers.cpp *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "TestIndexOperations.h" + +namespace clang { +namespace clangd { + +Symbol symbol(llvm::StringRef QName) { + Symbol Sym; + Sym.ID = SymbolID(QName.str()); + size_t Pos = QName.rfind("::"); + if (Pos == llvm::StringRef::npos) { +Sym.Name = QName; +Sym.Scope = ""; + } else { +Sym.Name = QName.substr(Pos + 2); +Sym.Scope = QName.substr(0, Pos + 2); + } + return Sym; +} + +// Create a slab of symbols with the given qualified names as both IDs and +// names. The life time of the slab is managed by the returned shared pointer. +// If \p WeakSymbols is provided, it will be pointed to the managed object in +// the returned shared pointer. +std::shared_ptr> +generateSymbols(std::vector QualifiedNames, +std::weak_ptr *WeakSymbols) { + SymbolSlab::Builder Slab; + for (llvm::StringRef QName : QualifiedNames) +Slab.insert(symbol(QName)); + + auto Storage = std::make_shared(); + Storage->Slab = std::move(Slab).build(); + for (const auto &Sym : Storage->Slab) +Storage->Pointers.push_back(&Sym); + if (WeakSymbols) +*WeakSymbols = Storage; + auto *Pointers = &Storage->Pointers; + return {std::move(Storage), Pointers}; +} + +// Create a slab of symbols with IDs and names [Begin, End], otherwise identical +// to the `generateSymbols` above. +std::shared_ptr> +generateNumSymbols(int Begin, int End, + std::weak_ptr *WeakSymbols) { + std::vector Names; + for (int i = Begin; i <= End; i++) +Names.push_back(std::to_string(i)); + return generateSym
[PATCH] D50175: [AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests
olista01 added inline comments. Comment at: test/Driver/aarch64-cpus.c:10 +// GENERIC: "-cc1"{{.*}} "-triple" "aarch64"{{.*}} "-target-cpu" "generic" +// GENERIC-LE: "-cc1"{{.*}} "-triple" "aarch64--"{{.*}} "-target-cpu" "generic" SjoerdMeijer wrote: > olista01 wrote: > > Why do these need new check prefixes? All of the RUN lines above are > > selecting little-endian, so I'd expect GENERIC and GENERIC-LE to be the > > same. > Ok, good point. The output is slightly different. For the little-endian runs > above the output is: > > "-triple" "aarch64" > > and with "-target aarch64_be -mlittle-endian" the output is: > > "-triple" "aarch64--" > > As we don't want to be too generic and match "aarch64{{.*}}", I will > therefore change the GENERIC checks to match "aarch64{{[--]*}}", and indeed > remove GENERIC-LE. I think that works, but it's a strange way to write the regex. You have "-" twice inside a character set, which is the same as only having it once, so "[--]*" matches zero or more occurrences of "-". I'd suggest using something like "(--)?" which matches either "--" or nothing. https://reviews.llvm.org/D50175 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339344 - Implement diagnostic stream operator for ParsedAttr.
Author: erichkeane Date: Thu Aug 9 06:21:32 2018 New Revision: 339344 URL: http://llvm.org/viewvc/llvm-project?rev=339344&view=rev Log: Implement diagnostic stream operator for ParsedAttr. As a part of attempting to clean up the way attributes are printed, this patch adds an operator << to the diagnostics/ partialdiagnostics so that ParsedAttr can be sent directly. This patch also rewrites a large amount* of the times when ParsedAttr was printed using its IdentifierInfo object instead of being printed itself. *"a large amount" == "All I could find". Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaStmtAttr.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339344&r1=339343&r2=339344&view=diff == --- cfe/trunk/include/clang/Sema/ParsedAttr.h (original) +++ cfe/trunk/include/clang/Sema/ParsedAttr.h Thu Aug 9 06:21:32 2018 @@ -16,6 +16,7 @@ #define LLVM_CLANG_SEMA_ATTRIBUTELIST_H #include "clang/Basic/AttrSubjectMatchRules.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/TargetInfo.h" #include "clang/Sema/Ownership.h" @@ -939,6 +940,34 @@ enum AttributeDeclKind { ExpectedFunctionWithProtoType, }; +inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, + const ParsedAttr &At) { + DB.AddTaggedVal(reinterpret_cast(At.getName()), + DiagnosticsEngine::ak_identifierinfo); + return DB; +} + +inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, + const ParsedAttr &At) { + PD.AddTaggedVal(reinterpret_cast(At.getName()), + DiagnosticsEngine::ak_identifierinfo); + return PD; +} + +inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, + const ParsedAttr *At) { + DB.AddTaggedVal(reinterpret_cast(At->getName()), + DiagnosticsEngine::ak_identifierinfo); + return DB; +} + +inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, + const ParsedAttr *At) { + PD.AddTaggedVal(reinterpret_cast(At->getName()), + DiagnosticsEngine::ak_identifierinfo); + return PD; +} + } // namespace clang #endif // LLVM_CLANG_SEMA_ATTRIBUTELIST_H Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=339344&r1=339343&r2=339344&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Aug 9 06:21:32 2018 @@ -2456,11 +2456,11 @@ public: unsigned AttrSpellingListIndex); OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex); - InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, SourceRange Range, -IdentifierInfo *Ident, -unsigned AttrSpellingListIndex); - CommonAttr *mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, - unsigned AttrSpellingListIndex); + InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL); + InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, +const InternalLinkageAttr &AL); + CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL); + CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL); void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK = AMK_Redeclaration); Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=339344&r1=339343&r2=339344&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug 9 06:21:32 2018 @@ -2474,14 +2474,9 @@ static bool mergeDeclAttribute(Sema &S, else if (const auto *OA = dyn_cast(Attr)) NewAttr = S.mergeOptimizeNoneAttr(D, OA->getRange(), AttrSpellingListIndex); else if (const auto *InternalLinkageA = dyn_cast(Attr)) -NewAttr = S.mergeInternalLinkageAttr( -D, InternalLinkageA->getRange(), -&S.Context.Idents.get(InternalLinkageA->getSpelling()), -AttrSpellingListIndex); +NewAttr = S.mer
[PATCH] D50509: [analyzer][UninitializedObjectChecker] Refactoring p6.: Move dereferencing to a function
Szelethus created this revision. Szelethus added reviewers: george.karpenkov, NoQ, xazax.hun, rnkovacs. Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, whisperity. Now that it has it's own file, it makes little sense for `isPointerOrReferenceUninit` to be this large, so I moved dereferencing to a separate function. Note that this is part 6, but only relies on https://reviews.llvm.org/D50504, not part https://reviews.llvm.org/D50508. Repository: rC Clang https://reviews.llvm.org/D50509 Files: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp Index: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp @@ -69,6 +69,14 @@ /// known, and thus FD can not be analyzed. static bool isVoidPointer(QualType T); +/// Dereferences V, and stores the dereferences value in it, the dynamic type +/// of V in DynT, and whether it needs to be casted back in NeedsCastBack. +/// +/// V must be loc::MemRegionVal. +/// +/// If for whatever reason dereferencing fails, returns with false. +static bool dereference(ProgramStateRef State, SVal &V, QualType &DynT); + //===--===// // Methods for FindUninitializedFields. //===--===// @@ -101,61 +109,19 @@ assert(V.getAs() && "At this point V must be loc::MemRegionVal!"); - auto L = V.castAs(); - - // We can't reason about symbolic regions, assume its initialized. - // Note that this also avoids a potential infinite recursion, because - // constructors for list-like classes are checked without being called, and - // the Static Analyzer will construct a symbolic region for Node *next; or - // similar code snippets. - if (L.getRegion()->getSymbolicBase()) { -IsAnyFieldInitialized = true; -return false; - } - - DynamicTypeInfo DynTInfo = getDynamicTypeInfo(State, L.getRegion()); - if (!DynTInfo.isValid()) { -IsAnyFieldInitialized = true; -return false; - } - - QualType DynT = DynTInfo.getType(); - if (isVoidPointer(DynT)) { -IsAnyFieldInitialized = true; -return false; - } + QualType DynT; // At this point the pointer itself is initialized and points to a valid // location, we'll now check the pointee. - SVal DerefdV = State->getSVal(V.castAs(), DynT); - - // If DerefdV is still a pointer value, we'll dereference it again (e.g.: - // int** -> int*). - while (auto Tmp = DerefdV.getAs()) { -if (Tmp->getRegion()->getSymbolicBase()) { - IsAnyFieldInitialized = true; - return false; -} - -DynTInfo = getDynamicTypeInfo(State, Tmp->getRegion()); -if (!DynTInfo.isValid()) { - IsAnyFieldInitialized = true; - return false; -} - -DynT = DynTInfo.getType(); -if (isVoidPointer(DynT)) { - IsAnyFieldInitialized = true; - return false; -} - -DerefdV = State->getSVal(*Tmp, DynT); + if (!dereference(State, V, DynT)) { +IsAnyFieldInitialized = true; +return false; } // If FR is a pointer pointing to a non-primitive type. if (Optional RecordV = - DerefdV.getAs()) { + V.getAs()) { const TypedValueRegion *R = RecordV->getRegion(); @@ -184,7 +150,7 @@ "At this point FR must either have a primitive dynamic type, or it " "must be a null, undefined, unknown or concrete pointer!"); - if (isPrimitiveUninit(DerefdV)) + if (isPrimitiveUninit(V)) return addFieldToUninits(LocalChain.add(LocField(FR))); IsAnyFieldInitialized = true; @@ -203,3 +169,32 @@ } return false; } + +static bool dereference(ProgramStateRef State, SVal &V, QualType &DynT) { + // If V is multiple pointer value, we'll dereference it again (e.g.: int** -> + // int*). + while (auto Tmp = V.getAs()) { +// We can't reason about symbolic regions, assume its initialized. +// Note that this also avoids a potential infinite recursion, because +// constructors for list-like classes are checked without being called, and +// the Static Analyzer will construct a symbolic region for Node *next; or +// similar code snippets. +if (Tmp->getRegion()->getSymbolicBase()) { + return false; +} + +DynamicTypeInfo DynTInfo = getDynamicTypeInfo(State, Tmp->getRegion()); +if (!DynTInfo.isValid()) { + return false; +} + +DynT = DynTInfo.getType(); + +if (isVoidPointer(DynT)) { + return false; +} + +V = State->getSVal(*Tmp, DynT); + } + return true; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50500: [clangd] Allow consuming limited number of items
ioeric added a comment. Could you add test? ;) Comment at: clang-tools-extra/clangd/index/dex/Iterator.cpp:223 std::vector Result; - for (; !It.reachedEnd(); It.advance()) + for (size_t Retreived = 0; !It.reachedEnd() && Retreived < Limit; + It.advance()) Where do we increment `Retrieved`? Comment at: clang-tools-extra/clangd/index/dex/Iterator.cpp:223 std::vector Result; - for (; !It.reachedEnd(); It.advance()) + for (size_t Retreived = 0; !It.reachedEnd() && Retreived < Limit; + It.advance()) ioeric wrote: > Where do we increment `Retrieved`? nit: `s/Retreived/Retrieved/` Comment at: clang-tools-extra/clangd/index/dex/Iterator.h:108 +/// for the number of elements obtained before the iterator is exhausted. +std::vector consume(Iterator &It, + size_t Limit = std::numeric_limits::max()); nit: I think `Size of the returned ...` is just repeating the first two sentences. Maybe drop? https://reviews.llvm.org/D50500 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50175: [AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests
SjoerdMeijer added inline comments. Comment at: test/Driver/aarch64-cpus.c:10 +// GENERIC: "-cc1"{{.*}} "-triple" "aarch64"{{.*}} "-target-cpu" "generic" +// GENERIC-LE: "-cc1"{{.*}} "-triple" "aarch64--"{{.*}} "-target-cpu" "generic" olista01 wrote: > SjoerdMeijer wrote: > > olista01 wrote: > > > Why do these need new check prefixes? All of the RUN lines above are > > > selecting little-endian, so I'd expect GENERIC and GENERIC-LE to be the > > > same. > > Ok, good point. The output is slightly different. For the little-endian > > runs above the output is: > > > > "-triple" "aarch64" > > > > and with "-target aarch64_be -mlittle-endian" the output is: > > > > "-triple" "aarch64--" > > > > As we don't want to be too generic and match "aarch64{{.*}}", I will > > therefore change the GENERIC checks to match "aarch64{{[--]*}}", and indeed > > remove GENERIC-LE. > I think that works, but it's a strange way to write the regex. You have "-" > twice inside a character set, which is the same as only having it once, so > "[--]*" matches zero or more occurrences of "-". I'd suggest using something > like "(--)?" which matches either "--" or nothing. Ah, of course, thanks! That was a bit silly, will fix. https://reviews.llvm.org/D50175 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50175: [AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests
SjoerdMeijer updated this revision to Diff 159915. SjoerdMeijer added a comment. Addressed comments. https://reviews.llvm.org/D50175 Files: test/Driver/aarch64-cpus.c Index: test/Driver/aarch64-cpus.c === --- test/Driver/aarch64-cpus.c +++ test/Driver/aarch64-cpus.c @@ -6,7 +6,7 @@ // RUN: %clang -target aarch64 -mlittle-endian -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s // RUN: %clang -target aarch64_be -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s -// GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s // RUN: %clang -target arm64 -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s @@ -29,8 +29,8 @@ // RUN: %clang -target aarch64 -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s // RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s -// CA35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a35" -// CA35-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA35: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a35" +// CA35-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA35 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA35 %s @@ -44,8 +44,8 @@ // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s // RUN: %clang -target aarch64 -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-TUNE %s -// CA53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a53" -// CA53-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA53: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a53" +// CA53-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s @@ -59,8 +59,8 @@ // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55 %s // RUN: %clang -target aarch64 -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55-TUNE %s -// CA55: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a55" -// CA55-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA55: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a55" +// CA55-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s @@ -75,8 +75,8 @@ // RUN: %clang -target aarch64 -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-TUNE %s // RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-TUNE %s -// CA57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a57" -// CA57-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA57: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a57" +// CA57-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57 %s @@ -91,8 +91,8 @@ // RUN: %clang -target aarch64 -mtune=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CA72-TUNE %s // RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CA72-TUNE %s // RUN: %clang -target aarch64_be -mlittle
[PATCH] D50509: [analyzer][UninitializedObjectChecker] Refactoring p6.: Move dereferencing to a function
Szelethus updated this revision to Diff 159916. Szelethus added a comment. Fixed a comment. https://reviews.llvm.org/D50509 Files: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp Index: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp @@ -69,6 +69,14 @@ /// known, and thus FD can not be analyzed. static bool isVoidPointer(QualType T); +/// Dereferences V, stores the dereferenced value back into it, and stores it's +/// dynamic type in DynT. +/// +/// V must be loc::MemRegionVal. +/// +/// If for whatever reason dereferencing fails, returns with false. +static bool dereference(ProgramStateRef State, SVal &V, QualType &DynT); + //===--===// // Methods for FindUninitializedFields. //===--===// @@ -101,61 +109,19 @@ assert(V.getAs() && "At this point V must be loc::MemRegionVal!"); - auto L = V.castAs(); - - // We can't reason about symbolic regions, assume its initialized. - // Note that this also avoids a potential infinite recursion, because - // constructors for list-like classes are checked without being called, and - // the Static Analyzer will construct a symbolic region for Node *next; or - // similar code snippets. - if (L.getRegion()->getSymbolicBase()) { -IsAnyFieldInitialized = true; -return false; - } - - DynamicTypeInfo DynTInfo = getDynamicTypeInfo(State, L.getRegion()); - if (!DynTInfo.isValid()) { -IsAnyFieldInitialized = true; -return false; - } - - QualType DynT = DynTInfo.getType(); - if (isVoidPointer(DynT)) { -IsAnyFieldInitialized = true; -return false; - } + QualType DynT; // At this point the pointer itself is initialized and points to a valid // location, we'll now check the pointee. - SVal DerefdV = State->getSVal(V.castAs(), DynT); - - // If DerefdV is still a pointer value, we'll dereference it again (e.g.: - // int** -> int*). - while (auto Tmp = DerefdV.getAs()) { -if (Tmp->getRegion()->getSymbolicBase()) { - IsAnyFieldInitialized = true; - return false; -} - -DynTInfo = getDynamicTypeInfo(State, Tmp->getRegion()); -if (!DynTInfo.isValid()) { - IsAnyFieldInitialized = true; - return false; -} - -DynT = DynTInfo.getType(); -if (isVoidPointer(DynT)) { - IsAnyFieldInitialized = true; - return false; -} - -DerefdV = State->getSVal(*Tmp, DynT); + if (!dereference(State, V, DynT)) { +IsAnyFieldInitialized = true; +return false; } // If FR is a pointer pointing to a non-primitive type. if (Optional RecordV = - DerefdV.getAs()) { + V.getAs()) { const TypedValueRegion *R = RecordV->getRegion(); @@ -184,7 +150,7 @@ "At this point FR must either have a primitive dynamic type, or it " "must be a null, undefined, unknown or concrete pointer!"); - if (isPrimitiveUninit(DerefdV)) + if (isPrimitiveUninit(V)) return addFieldToUninits(LocalChain.add(LocField(FR))); IsAnyFieldInitialized = true; @@ -203,3 +169,32 @@ } return false; } + +static bool dereference(ProgramStateRef State, SVal &V, QualType &DynT) { + // If V is multiple pointer value, we'll dereference it again (e.g.: int** -> + // int*). + while (auto Tmp = V.getAs()) { +// We can't reason about symbolic regions, assume its initialized. +// Note that this also avoids a potential infinite recursion, because +// constructors for list-like classes are checked without being called, and +// the Static Analyzer will construct a symbolic region for Node *next; or +// similar code snippets. +if (Tmp->getRegion()->getSymbolicBase()) { + return false; +} + +DynamicTypeInfo DynTInfo = getDynamicTypeInfo(State, Tmp->getRegion()); +if (!DynTInfo.isValid()) { + return false; +} + +DynT = DynTInfo.getType(); + +if (isVoidPointer(DynT)) { + return false; +} + +V = State->getSVal(*Tmp, DynT); + } + return true; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50175: [AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests
olista01 accepted this revision. olista01 added a comment. This revision is now accepted and ready to land. LGTM, thanks! https://reviews.llvm.org/D50175 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50447: [clang-tidy] Add a whitelistClasses option in performance-for-range-copy check.
hokein updated this revision to Diff 159919. hokein marked an inline comment as done. hokein added a comment. Adress review comment - ignore the case in the check. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50447 Files: clang-tidy/performance/ForRangeCopyCheck.cpp test/clang-tidy/performance-for-range-copy.cpp Index: test/clang-tidy/performance-for-range-copy.cpp === --- test/clang-tidy/performance-for-range-copy.cpp +++ test/clang-tidy/performance-for-range-copy.cpp @@ -260,3 +260,8 @@ bool result = ConstOperatorInvokee != Mutable(); } } + +void IgnoreLoopVariableNotUsedInLoopBody() { + for (auto _ : View>()) { + } +} Index: clang-tidy/performance/ForRangeCopyCheck.cpp === --- clang-tidy/performance/ForRangeCopyCheck.cpp +++ clang-tidy/performance/ForRangeCopyCheck.cpp @@ -8,6 +8,7 @@ //===--===// #include "ForRangeCopyCheck.h" +#include "../utils/DeclRefExprUtils.h" #include "../utils/ExprMutationAnalyzer.h" #include "../utils/FixItHintUtils.h" #include "../utils/TypeTraits.h" @@ -79,15 +80,27 @@ utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context); if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive) return false; - if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context) - .isMutated(&LoopVar)) -return false; - diag(LoopVar.getLocation(), - "loop variable is copied but only used as const reference; consider " - "making it a const reference") - << utils::fixit::changeVarDeclToConst(LoopVar) - << utils::fixit::changeVarDeclToReference(LoopVar, Context); - return true; + // We omit the case where the loop variable is not used in the loop body. E.g. + // + // for (auto _ : benchmark_state) { + // } + // + // Because the fix (changing to `const auto &`) will introduce an unused + // compiler warning which can't be suppressed. + // Since this case is very rare, it is safe to ignore it. + if (!utils::ExprMutationAnalyzer(ForRange.getBody(), &Context) + .isMutated(&LoopVar) && + !utils::decl_ref_expr::allDeclRefExprs(LoopVar, *ForRange.getBody(), + Context) + .empty()) { +diag(LoopVar.getLocation(), + "loop variable is copied but only used as const reference; consider " + "making it a const reference") +<< utils::fixit::changeVarDeclToConst(LoopVar) +<< utils::fixit::changeVarDeclToReference(LoopVar, Context); +return true; + } + return false; } } // namespace performance Index: test/clang-tidy/performance-for-range-copy.cpp === --- test/clang-tidy/performance-for-range-copy.cpp +++ test/clang-tidy/performance-for-range-copy.cpp @@ -260,3 +260,8 @@ bool result = ConstOperatorInvokee != Mutable(); } } + +void IgnoreLoopVariableNotUsedInLoopBody() { + for (auto _ : View>()) { + } +} Index: clang-tidy/performance/ForRangeCopyCheck.cpp === --- clang-tidy/performance/ForRangeCopyCheck.cpp +++ clang-tidy/performance/ForRangeCopyCheck.cpp @@ -8,6 +8,7 @@ //===--===// #include "ForRangeCopyCheck.h" +#include "../utils/DeclRefExprUtils.h" #include "../utils/ExprMutationAnalyzer.h" #include "../utils/FixItHintUtils.h" #include "../utils/TypeTraits.h" @@ -79,15 +80,27 @@ utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context); if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive) return false; - if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context) - .isMutated(&LoopVar)) -return false; - diag(LoopVar.getLocation(), - "loop variable is copied but only used as const reference; consider " - "making it a const reference") - << utils::fixit::changeVarDeclToConst(LoopVar) - << utils::fixit::changeVarDeclToReference(LoopVar, Context); - return true; + // We omit the case where the loop variable is not used in the loop body. E.g. + // + // for (auto _ : benchmark_state) { + // } + // + // Because the fix (changing to `const auto &`) will introduce an unused + // compiler warning which can't be suppressed. + // Since this case is very rare, it is safe to ignore it. + if (!utils::ExprMutationAnalyzer(ForRange.getBody(), &Context) + .isMutated(&LoopVar) && + !utils::decl_ref_expr::allDeclRefExprs(LoopVar, *ForRange.getBody(), + Context) + .empty()) { +diag(LoopVar.getLocation(), + "loop variable is copied but only used as const reference; consider " + "making it a const reference") +
[PATCH] D50447: [clang-tidy] Add a whitelistClasses option in performance-for-range-copy check.
hokein added inline comments. Comment at: clang-tidy/performance/ForRangeCopyCheck.cpp:39 + auto WhitelistClassMatcher = + cxxRecordDecl(hasAnyName(SmallVector( + WhitelistClasses.begin(), WhitelistClasses.end(; JonasToth wrote: > I have seens this pattern now multiple times in various checks, we should > have some utility wrapping the `hasAnyName(MyList)`. (Just in general, does > not need to happen with this check) no needed for this patch. But yes! Moving to utility is reasonable to me. Comment at: clang-tidy/performance/ForRangeCopyCheck.cpp:93 return false; if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context) .isMutated(&LoopVar)) JonasToth wrote: > Adding a `..IsMutated(&LoopVar) && IsReferenced(ForScope, LoopVar))` here > should fix the warning as well. I think ignoring `for (auto _ : state)` is a sensible solution. Thanks! Comment at: test/clang-tidy/performance-for-range-copy.cpp:1 -// RUN: %check_clang_tidy %s performance-for-range-copy %t -- -- -std=c++11 -fno-delayed-template-parsing +// RUN: %check_clang_tidy %s performance-for-range-copy %t -config="{CheckOptions: [{key: "performance-for-range-copy.WhitelistClasses", value: "WhitelistFoo"}]}" -- -std=c++11 -fno-delayed-template-parsing JonasToth wrote: > I would prefer a single file, that has the configuration and leave the > standard test like it is. > > with this, you can always track what is actually done by default and what is > done with different conigurations + potential inconsistencies that might > occur by bugs in the configured code. no needed this configuration now. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50447 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49228: [analyzer][UninitializedObjectChecker] Void pointer objects are casted back to their dynmic type in note message
Szelethus updated this revision to Diff 159918. Szelethus added a comment. The solution now relies on the refactored version of the checker. Note that it modifies roughly 75% less code ;). https://reviews.llvm.org/D49228 Files: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp test/Analysis/cxx-uninitialized-object-ptr-ref.cpp Index: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp === --- test/Analysis/cxx-uninitialized-object-ptr-ref.cpp +++ test/Analysis/cxx-uninitialized-object-ptr-ref.cpp @@ -292,7 +292,7 @@ } struct IntDynTypedVoidPointerTest1 { - void *vptr; // expected-note{{uninitialized pointee 'this->vptr'}} + void *vptr; // expected-note{{uninitialized pointee 'static_cast(this->vptr)'}} int dontGetFilteredByNonPedanticMode = 0; IntDynTypedVoidPointerTest1(void *vptr) : vptr(vptr) {} // expected-warning{{1 uninitialized field}} @@ -305,8 +305,8 @@ struct RecordDynTypedVoidPointerTest { struct RecordType { -int x; // expected-note{{uninitialized field 'this->vptr->x'}} -int y; // expected-note{{uninitialized field 'this->vptr->y'}} +int x; // expected-note{{uninitialized field 'static_cast(this->vptr)->x'}} +int y; // expected-note{{uninitialized field 'static_cast(this->vptr)->y'}} }; void *vptr; @@ -322,9 +322,9 @@ struct NestedNonVoidDynTypedVoidPointerTest { struct RecordType { -int x; // expected-note{{uninitialized field 'this->vptr->x'}} -int y; // expected-note{{uninitialized field 'this->vptr->y'}} -void *vptr; // expected-note{{uninitialized pointee 'this->vptr->vptr'}} +int x; // expected-note{{uninitialized field 'static_cast(this->vptr)->x'}} +int y; // expected-note{{uninitialized field 'static_cast(this->vptr)->y'}} +void *vptr; // expected-note{{uninitialized pointee 'static_cast(static_cast(this->vptr)->vptr)'}} }; void *vptr; Index: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp @@ -60,6 +60,32 @@ } }; +/// Represents a void* field that needs to be casted back to its dynamic type +/// for a correct note message. +class NeedsCastLocField : public FieldNode { + QualType CastBackType; + +public: + NeedsCastLocField(const FieldRegion *FR, const QualType &T) + : FieldNode(FR), CastBackType(T) {} + + virtual void printNoteMsg(llvm::raw_ostream &Out) const override { +Out << "uninitialized pointee "; + } + + virtual void printPrefix(llvm::raw_ostream &Out) const override { +Out << "static_cast" << '<' << CastBackType.getAsString() << ">("; + } + + virtual void printNode(llvm::raw_ostream &Out) const { +Out << getVariableName(getDecl()) << ')'; + } + + virtual void printSeparator(llvm::raw_ostream &Out) const override { +Out << "->"; + } +}; + } // end of anonymous namespace // Utility function declarations. @@ -110,6 +136,10 @@ assert(V.getAs() && "At this point V must be loc::MemRegionVal!"); + // If the static type of the field is a void pointer, we need to cast it back + // to the dynamic type before dereferencing. + bool NeedsCastBack = isVoidPointer(FR->getDecl()->getType()); + QualType DynT; // At this point the pointer itself is initialized and points to a valid @@ -125,11 +155,16 @@ const TypedValueRegion *R = RecordV->getRegion(); -if (DynT->getPointeeType()->isStructureOrClassType()) +if (DynT->getPointeeType()->isStructureOrClassType()) { + if (NeedsCastBack) +return isNonUnionUninit(R, LocalChain.add(NeedsCastLocField(FR, DynT))); return isNonUnionUninit(R, LocalChain.add(LocField(FR))); +} if (DynT->getPointeeType()->isUnionType()) { if (isUnionUninit(R)) { +if (NeedsCastBack) + return addFieldToUninits(LocalChain.add(NeedsCastLocField(FR, DynT))); return addFieldToUninits(LocalChain.add(LocField(FR))); } else { IsAnyFieldInitialized = true; @@ -150,8 +185,11 @@ "At this point FR must either have a primitive dynamic type, or it " "must be a null, undefined, unknown or concrete pointer!"); - if (isPrimitiveUninit(V)) + if (isPrimitiveUninit(V)) { +if (NeedsCastBack) + return addFieldToUninits(LocalChain.add(NeedsCastLocField(FR, DynT))); return addFieldToUninits(LocalChain.add(LocField(FR))); + } IsAnyFieldInitialized = true; return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339347 - [AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests
Author: sjoerdmeijer Date: Thu Aug 9 07:07:27 2018 New Revision: 339347 URL: http://llvm.org/viewvc/llvm-project?rev=339347&view=rev Log: [AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests Differential Revision: https://reviews.llvm.org/D50175 Modified: cfe/trunk/test/Driver/aarch64-cpus.c Modified: cfe/trunk/test/Driver/aarch64-cpus.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?rev=339347&r1=339346&r2=339347&view=diff == --- cfe/trunk/test/Driver/aarch64-cpus.c (original) +++ cfe/trunk/test/Driver/aarch64-cpus.c Thu Aug 9 07:07:27 2018 @@ -6,7 +6,7 @@ // RUN: %clang -target aarch64 -mlittle-endian -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s // RUN: %clang -target aarch64_be -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s -// GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s // RUN: %clang -target arm64 -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s @@ -29,8 +29,8 @@ // RUN: %clang -target aarch64 -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s // RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s -// CA35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a35" -// CA35-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA35: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a35" +// CA35-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA35 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA35 %s @@ -44,8 +44,8 @@ // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s // RUN: %clang -target aarch64 -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-TUNE %s -// CA53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a53" -// CA53-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA53: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a53" +// CA53-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s @@ -59,8 +59,8 @@ // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55 %s // RUN: %clang -target aarch64 -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55-TUNE %s -// CA55: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a55" -// CA55-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA55: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a55" +// CA55-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s @@ -75,8 +75,8 @@ // RUN: %clang -target aarch64 -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-TUNE %s // RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-TUNE %s -// CA57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a57" -// CA57-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA57: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a57" +// CA57-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57 %s // RUN: %clang -target a
[PATCH] D50175: [AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests
This revision was automatically updated to reflect the committed changes. Closed by commit rL339347: [AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests (authored by SjoerdMeijer, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50175?vs=159915&id=159920#toc Repository: rL LLVM https://reviews.llvm.org/D50175 Files: cfe/trunk/test/Driver/aarch64-cpus.c Index: cfe/trunk/test/Driver/aarch64-cpus.c === --- cfe/trunk/test/Driver/aarch64-cpus.c +++ cfe/trunk/test/Driver/aarch64-cpus.c @@ -6,7 +6,7 @@ // RUN: %clang -target aarch64 -mlittle-endian -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s // RUN: %clang -target aarch64_be -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s -// GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s // RUN: %clang -target arm64 -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s @@ -29,8 +29,8 @@ // RUN: %clang -target aarch64 -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s // RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s -// CA35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a35" -// CA35-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA35: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a35" +// CA35-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA35 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA35 %s @@ -44,8 +44,8 @@ // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s // RUN: %clang -target aarch64 -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-TUNE %s -// CA53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a53" -// CA53-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA53: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a53" +// CA53-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s @@ -59,8 +59,8 @@ // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55 %s // RUN: %clang -target aarch64 -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55-TUNE %s -// CA55: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a55" -// CA55-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA55: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a55" +// CA55-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s @@ -75,8 +75,8 @@ // RUN: %clang -target aarch64 -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-TUNE %s // RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-TUNE %s // RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-TUNE %s -// CA57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a57" -// CA57-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" +// CA57: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "cortex-a57" +// CA57-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{(--)?}}"{{.*}} "-target-cpu" "generic" // RUN: %clang -target arm64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57 %s // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefi
[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions
ahatanak updated this revision to Diff 159926. ahatanak marked 2 inline comments as done. ahatanak added a comment. Address review comments. Repository: rC Clang https://reviews.llvm.org/D50152 Files: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGBlocks.h lib/CodeGen/CGDecl.cpp lib/CodeGen/CGNonTrivialStruct.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h lib/Sema/SemaDecl.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/CodeGen/blocks-1.c test/CodeGen/blocks.c test/CodeGen/sanitize-thread-no-checking-at-run-time.m test/CodeGenCXX/block-byref-cxx-objc.cpp test/CodeGenCXX/blocks.cpp test/CodeGenCXX/cxx-block-objects.cpp test/CodeGenObjC/arc-blocks.m test/CodeGenObjC/debug-info-block-helper.m test/CodeGenObjC/debug-info-blocks.m test/CodeGenObjC/mrc-weak.m test/CodeGenObjC/strong-in-c-struct.m test/CodeGenObjCXX/arc-blocks.mm test/CodeGenObjCXX/lambda-to-block.mm test/CodeGenObjCXX/mrc-weak.mm test/PCH/block-helpers.cpp test/PCH/block-helpers.h Index: test/PCH/block-helpers.h === --- /dev/null +++ test/PCH/block-helpers.h @@ -0,0 +1,12 @@ +struct S0 { + S0(); + S0(const S0 &) noexcept(false); + int a; +}; + +struct S { + void m() { +__block S0 x, y; +^{ (void)x; (void)y; }; + } +}; Index: test/PCH/block-helpers.cpp === --- /dev/null +++ test/PCH/block-helpers.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -x c++-header -triple x86_64-apple-darwin11 -emit-pch -fblocks -fexceptions -o %t %S/block-helpers.h +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -include-pch %t -emit-llvm -fblocks -fexceptions -o - %s | FileCheck %s + +// The second call to block_object_assign should be an invoke. + +// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_e8_32rc40rc( +// CHECK: call void @_Block_object_assign( +// CHECK: invoke void @_Block_object_assign( +// CHECK: call void @_Block_object_dispose( + +// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_e8_32r40r( +void test() { + S s; + s.m(); +} Index: test/CodeGenObjCXX/mrc-weak.mm === --- test/CodeGenObjCXX/mrc-weak.mm +++ test/CodeGenObjCXX/mrc-weak.mm @@ -119,10 +119,10 @@ // CHECK: call void @use_block // CHECK: call void @objc_destroyWeak -// CHECK-LABEL: define internal void @__copy_helper_block +// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block // CHECK: @objc_copyWeak -// CHECK-LABEL: define internal void @__destroy_helper_block +// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block // CHECK: @objc_destroyWeak void test8(void) { @@ -142,8 +142,8 @@ // CHECK: call void @objc_destroyWeak // CHECK-LABEL: define void @_Z14test9_baselinev() -// CHECK: define internal void @__copy_helper -// CHECK: define internal void @__destroy_helper +// CHECK: define linkonce_odr hidden void @__copy_helper +// CHECK: define linkonce_odr hidden void @__destroy_helper void test9_baseline(void) { Foo *p = get_object(); use_block(^{ [p run]; }); Index: test/CodeGenObjCXX/lambda-to-block.mm === --- test/CodeGenObjCXX/lambda-to-block.mm +++ test/CodeGenObjCXX/lambda-to-block.mm @@ -12,7 +12,7 @@ void hasLambda(Copyable x) { takesBlock([x] () { }); } -// CHECK-LABEL: define internal void @__copy_helper_block_ +// CHECK-LABEL: define internal void @"__copy_helper_block_ // CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_" // CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_" // CHECK: call void @_ZN8CopyableC1ERKS_ Index: test/CodeGenObjCXX/arc-blocks.mm === --- test/CodeGenObjCXX/arc-blocks.mm +++ test/CodeGenObjCXX/arc-blocks.mm @@ -1,8 +1,10 @@ // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -o - %s | FileCheck -check-prefix CHECK %s // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -O1 -o - %s | FileCheck -check-prefix CHECK-O1 %s +// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s // CHECK: [[A:.*]] = type { i64, [10 x i8*] } // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 } +// CHECK: %[[STRUCT_TRIVIAL_INTERNAL:.*]] = type { i32 } // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 } // CHECK: [[LAYOUT0:@.*]] = private unnamed_addr constant [3 x i8] c" 9\00" @@ -55,34 +57,34 @@ //
[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions
ahatanak added inline comments. Comment at: lib/CodeGen/CGBlocks.cpp:1682 + if (IsCopyHelper && Ctx.getBlockVarCopyInits(Var).CanThrow) +Name += "c"; +} rjmccall wrote: > ahatanak wrote: > > rjmccall wrote: > > > I don't think you need to add `d` to the name of a copy helper. It's a > > > bit weird, but while copying a `__block` variable can cause its copy > > > helper to run, destroying it immediately afterwards can never cause its > > > destroy helper to run. That's because a newly-copied `__block` variable > > > always has a reference count of 2: the new reference in the copy and the > > > forwarding reference from the original. > > > > > > I think that means you can just add a single letter which specifies > > > whether the corresponding `__block` variable operation is known to be > > > able to throw. > > I added 'd' to the name of the copy helper functions only because IRGen > > generates different code depending on whether the destructor can throw or > > not. > > > > For example, if I compile the following code with -DTHROWS, IRGen uses > > 'invoke' (which jumps to the terminate block) for the calls to > > `_Block_object_dispose` on the EH path whereas it uses 'call' if the > > destructor doesn't throw. > > > > ``` > > struct S { > > S(); > > #ifdef THROWS > > ~S() noexcept(false); > > #else > > ~S() noexcept(true); > > #endif > > S(const S &); > > int a; > > }; > > > > void test() { > > __block S s0, s1, s2; > > ^{ (void)s0, (void)s1; (void)s2; }; > > } > > ``` > > > > It seems like IRGen doesn't have to use 'invoke' when emitting a call to > > `_Block_object_dispose` even when the class has a destructor that can > > throw, if I understood your explanation correctly? > Right. It's specifically only true when unwinding after a copy, which is > very atypical for C++ code, but nonetheless it's true. We should make the > call `nounwind` in these situations and leave a comment explaining why. Did > my explanation make any sense? Yes, it makes sense. Since the reference count is two after the `__block` variable is copied, calling `_Block_object_dispose` on it won't cause the destructor to be called. Repository: rC Clang https://reviews.llvm.org/D50152 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50513: clang-cl: Support /guard:cf,nochecks
hans created this revision. hans added reviewers: rnk, thakis. This extension emits the guard cf table without inserting the instrumentation. Currently that's what clang-cl does with /guard:cf anyway, but this allows a user to request that explicitly. https://reviews.llvm.org/D50513 Files: include/clang/Driver/CLCompatOptions.td lib/CodeGen/CodeGenModule.cpp lib/Driver/ToolChains/Clang.cpp test/CodeGen/cfguardtable.c test/Driver/cl-options.c Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -420,8 +420,6 @@ // RUN: /Gr \ // RUN: /GS \ // RUN: /GT \ -// RUN: /guard:cf \ -// RUN: /guard:cf- \ // RUN: /GX \ // RUN: /Gv \ // RUN: /Gz \ @@ -562,6 +560,18 @@ // RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s // LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld +// RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s +// RUN: %clang_cl /guard:cf- -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s +// NOCFGUARD-NOT: -guardcf + +// RUN: %clang_cl /guard:cf -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s +// RUN: %clang_cl /guard:cf,nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s +// RUN: %clang_cl /guard:nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s +// CFGUARD: -cfguard + +// RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDINVALID %s +// CFGUARDINVALID: invalid value 'foo' in '/guard:' + // Accept "core" clang options. // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ Index: test/CodeGen/cfguardtable.c === --- /dev/null +++ test/CodeGen/cfguardtable.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -cfguard -emit-llvm %s -o - | FileCheck %s + +void f() {} + +// Check that the cfguardtable metadata flag gets set on the module. +// CHECK: !"cfguardtable", i32 1} Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -5273,9 +5273,28 @@ CmdArgs.push_back("msvc"); } - if (Args.hasArg(options::OPT__SLASH_Guard) && - Args.getLastArgValue(options::OPT__SLASH_Guard).equals_lower("cf")) -CmdArgs.push_back("-cfguard"); + if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) { +SmallVector SplitArgs; +StringRef(A->getValue()).split(SplitArgs, ","); +bool Instrument = false; +bool NoChecks = false; +for (StringRef Arg : SplitArgs) { + if (Arg.equals_lower("cf")) +Instrument = true; + else if (Arg.equals_lower("cf-")) +Instrument = false; + else if (Arg.equals_lower("nochecks")) +NoChecks = true; + else if (Arg.equals_lower("nochecks-")) +NoChecks = false; + else +D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << Arg; +} +// Currently there's no support emitting CFG instrumentation; the flag only +// emits the table of address-taken functions. +if (Instrument || NoChecks) + CmdArgs.push_back("-cfguard"); + } } visualstudio::Compiler *Clang::getCLFallback() const { Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -460,7 +460,7 @@ } if (CodeGenOpts.ControlFlowGuard) { // We want function ID tables for Control Flow Guard. -getModule().addModuleFlag(llvm::Module::Warning, "cfguard", 1); +getModule().addModuleFlag(llvm::Module::Warning, "cfguardtable", 1); } if (CodeGenOpts.OptimizationLevel > 0 && CodeGenOpts.StrictVTablePointers) { // We don't support LTO with 2 with different StrictVTablePointers Index: include/clang/Driver/CLCompatOptions.td === --- include/clang/Driver/CLCompatOptions.td +++ include/clang/Driver/CLCompatOptions.td @@ -240,8 +240,8 @@ def _SLASH_Fo : CLCompileJoined<"Fo">, HelpText<"Set output object file, or directory (ends in / or \\) (with /c)">, MetaVarName<"">; -def _SLASH_Guard : CLJoined<"guard:">, - HelpText<"Enable Control Flow Guard with /guard:cf">; +def _SLASH_guard : CLJoined<"guard:">, + HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with /guard:cf,nochecks">; def _SLASH_GX : CLFlag<"GX">, HelpText<"Enable exception handling">; def _SLASH_GX_ : CLFlag<"GX-">, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50513: clang-cl: Support /guard:cf,nochecks
hans added inline comments. Comment at: lib/CodeGen/CodeGenModule.cpp:463 // We want function ID tables for Control Flow Guard. -getModule().addModuleFlag(llvm::Module::Warning, "cfguard", 1); +getModule().addModuleFlag(llvm::Module::Warning, "cfguardtable", 1); } I'll update the LLVM side before landing this, but I think this name better explains what's being emitted. https://reviews.llvm.org/D50513 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49549: Change 'clang-test' to 'check-clang' on the hacking webpage
acoomans added a comment. Ping Repository: rC Clang https://reviews.llvm.org/D49549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49549: Change 'clang-test' to 'check-clang' on the hacking webpage
JDevlieghere accepted this revision. JDevlieghere added a comment. This revision is now accepted and ready to land. Looks good, thanks! PS: I don't think it hurts, but it's sufficient to add cfe-commits as a subscriber. I believe it's an automation account (so it won't be able to accept on phab) and replies via e-mail are posted under the corresponding user's account. Repository: rC Clang https://reviews.llvm.org/D49549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49486: [cfe][CMake] Export the clang resource directory
philip.pfaffe added a comment. Ping. https://reviews.llvm.org/D49486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49549: Change 'clang-test' to 'check-clang' on the hacking webpage
acoomans added a comment. @JDevlieghere Thanks! subscribers -> makes sense, will do Repository: rC Clang https://reviews.llvm.org/D49549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50179: [AArch64][ARM] Context sensitive meaning of option "crypto"
SjoerdMeijer added inline comments. Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:430 + if (ArchName.find_lower("+noaes") == StringRef::npos) +Features.push_back("+aes"); +} else if (ArchName.find_lower("-crypto") != StringRef::npos) { efriedma wrote: > The ARM backend doesn't support features named "sha2" and "aes" at the moment. These ARM target features were introduced in rL335953. https://reviews.llvm.org/D50179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50515: Re-push "[Option] Fix PR37006 prefix choice in findNearest"
acoomans created this revision. acoomans added a reviewer: cfe-commits. Original changeset (https://reviews.llvm.org/D46776) by @modocache. It was reverted after the PS4 bot failed. The issue has been determined to be with the way the PS4 SDK handles this particular option. https://reviews.llvm.org/D50410 removes this test, so we can push this again. Repository: rC Clang https://reviews.llvm.org/D50515 Files: lib/Option/OptTable.cpp unittests/Option/OptionParsingTest.cpp unittests/Option/Opts.td Index: unittests/Option/Opts.td === --- unittests/Option/Opts.td +++ unittests/Option/Opts.td @@ -30,6 +30,7 @@ def SlurpJoined : Option<["-"], "slurpjoined", KIND_REMAINING_ARGS_JOINED>; def Blorp : Flag<["-", "--"], "blorp">, HelpText<"The blorp option">, Flags<[OptFlag1]>; +def Blarn : Flag<["--", "-"], "blarn">, HelpText<"The blarn option">, Flags<[OptFlag1]>; def Cramb : Joined<["/"], "cramb:">, HelpText<"The cramb option">, MetaVarName<"CRAMB">, Flags<[OptFlag1]>; def Doopf1 : Flag<["-"], "doopf1">, HelpText<"The doopf1 option">, Flags<[OptFlag1]>; def Doopf2 : Flag<["-"], "doopf2">, HelpText<"The doopf2 option">, Flags<[OptFlag2]>; Index: unittests/Option/OptionParsingTest.cpp === --- unittests/Option/OptionParsingTest.cpp +++ unittests/Option/OptionParsingTest.cpp @@ -283,6 +283,10 @@ EXPECT_EQ(Nearest, "-blorp"); EXPECT_EQ(1U, T.findNearest("--blorm", Nearest)); EXPECT_EQ(Nearest, "--blorp"); + EXPECT_EQ(1U, T.findNearest("-blarg", Nearest)); + EXPECT_EQ(Nearest, "-blarn"); + EXPECT_EQ(1U, T.findNearest("--blarm", Nearest)); + EXPECT_EQ(Nearest, "--blarn"); EXPECT_EQ(1U, T.findNearest("-fjormp", Nearest)); EXPECT_EQ(Nearest, "--fjormp"); Index: lib/Option/OptTable.cpp === --- lib/Option/OptTable.cpp +++ lib/Option/OptTable.cpp @@ -252,38 +252,33 @@ unsigned MinimumLength) const { assert(!Option.empty()); - // Consider each option as a candidate, finding the closest match. + // Consider each [option prefix + option name] pair as a candidate, finding + // the closest match. unsigned BestDistance = UINT_MAX; for (const Info &CandidateInfo : ArrayRef(OptionInfos).drop_front(FirstSearchableIndex)) { StringRef CandidateName = CandidateInfo.Name; -// Ignore option candidates with empty names, such as "--", or names -// that do not meet the minimum length. +// We can eliminate some option prefix/name pairs as candidates right away: +// * Ignore option candidates with empty names, such as "--", or names +// that do not meet the minimum length. if (CandidateName.empty() || CandidateName.size() < MinimumLength) continue; -// If FlagsToInclude were specified, ignore options that don't include -// those flags. +// * If FlagsToInclude were specified, ignore options that don't include +// those flags. if (FlagsToInclude && !(CandidateInfo.Flags & FlagsToInclude)) continue; -// Ignore options that contain the FlagsToExclude. +// * Ignore options that contain the FlagsToExclude. if (CandidateInfo.Flags & FlagsToExclude) continue; -// Ignore positional argument option candidates (which do not -// have prefixes). +// * Ignore positional argument option candidates (which do not +// have prefixes). if (!CandidateInfo.Prefixes) continue; -// Find the most appropriate prefix. For example, if a user asks for -// "--helm", suggest "--help" over "-help". -StringRef Prefix = CandidateInfo.Prefixes[0]; -for (int P = 1; CandidateInfo.Prefixes[P]; P++) { - if (Option.startswith(CandidateInfo.Prefixes[P])) -Prefix = CandidateInfo.Prefixes[P]; -} -// Check if the candidate ends with a character commonly used when +// Now check if the candidate ends with a character commonly used when // delimiting an option from its value, such as '=' or ':'. If it does, // attempt to split the given option based on that delimiter. std::string Delimiter = ""; @@ -297,14 +292,19 @@ else std::tie(LHS, RHS) = Option.split(Last); -std::string NormalizedName = -(LHS.drop_front(Prefix.size()) + Delimiter).str(); -unsigned Distance = -CandidateName.edit_distance(NormalizedName, /*AllowReplacements=*/true, -/*MaxEditDistance=*/BestDistance); -if (Distance < BestDistance) { - BestDistance = Distance; - NearestString = (Prefix + CandidateName + RHS).str(); +// Consider each possible prefix for each candidate to find the most +// appropriate one. For example, if a user asks for "--helm", suggest +// "--help" over "-help". +for (int P = 0; const char *const CandidatePrefix = CandidateInfo.Prefixes[
[PATCH] D50516: [ASTImporter] Improved import of friend templates.
balazske created this revision. Herald added subscribers: cfe-commits, martong. Herald added a reviewer: a.sidorin. When importing a friend class template declaration, this declaration should not be merged with any other existing declaration for the same type. Otherwise the getFriendDecl of the FriendDecl can point to an other already referenced declaration, this case causes problems. Additionally the previous decl of class templates is set at import. Repository: rC Clang https://reviews.llvm.org/D50516 Files: lib/AST/ASTImporter.cpp unittests/AST/ASTImporterTest.cpp Index: unittests/AST/ASTImporterTest.cpp === --- unittests/AST/ASTImporterTest.cpp +++ unittests/AST/ASTImporterTest.cpp @@ -2683,6 +2683,93 @@ EXPECT_EQ(FromIndex, 3u); } +TEST_P( +ASTImporterTestBase, +ImportOfFriendRecordDoesNotMergeDefinition) { + Decl *FromTU = getTuDecl( + R"( + class A { +template class F {}; +class X { + template friend class F; +}; + }; + )", + Lang_CXX, "input0.cc"); + + auto *FromClass = FirstDeclMatcher().match( + FromTU, cxxRecordDecl(hasName("F"), isDefinition())); + auto *FromFriendClass = LastDeclMatcher().match( + FromTU, cxxRecordDecl(hasName("F"))); + + ASSERT_TRUE(FromClass); + ASSERT_TRUE(FromFriendClass); + ASSERT_NE(FromClass, FromFriendClass); + ASSERT_EQ(FromFriendClass->getDefinition(), FromClass); + ASSERT_EQ(FromFriendClass->getPreviousDecl(), FromClass); + ASSERT_EQ( + FromFriendClass->getDescribedClassTemplate()->getPreviousDecl(), + FromClass->getDescribedClassTemplate()); + + auto *ToClass = cast(Import(FromClass, Lang_CXX)); + auto *ToFriendClass = cast(Import(FromFriendClass, Lang_CXX)); + + ASSERT_TRUE(ToClass); + ASSERT_TRUE(ToFriendClass); + EXPECT_NE(ToClass, ToFriendClass); + EXPECT_EQ(ToFriendClass->getDefinition(), ToClass); + ASSERT_EQ(ToFriendClass->getPreviousDecl(), ToClass); + ASSERT_EQ( + ToFriendClass->getDescribedClassTemplate()->getPreviousDecl(), + ToClass->getDescribedClassTemplate()); +} + +TEST_P( +ASTImporterTestBase, +ImportOfRecursiveFriendClass) { + Decl *FromTu = getTuDecl( + R"( + class declToImport { +friend class declToImport; + }; + )", + Lang_CXX, "input.cc"); + + auto *FromD = FirstDeclMatcher().match( + FromTu, cxxRecordDecl(hasName("declToImport"))); + auto *ToD = Import(FromD, Lang_CXX); + auto Pattern = cxxRecordDecl(hasName("declToImport"), has(friendDecl())); + ASSERT_TRUE(MatchVerifier{}.match(FromD, Pattern)); + EXPECT_TRUE(MatchVerifier{}.match(ToD, Pattern)); +} + +TEST_P( +ASTImporterTestBase, +ImportOfRecursiveFriendClassTemplate) { + Decl *FromTu = getTuDecl( + R"( + template class declToImport { +template friend class declToImport; + }; + )", + Lang_CXX, "input.cc"); + + auto *FromD = FirstDeclMatcher().match( + FromTu, classTemplateDecl(hasName("declToImport"))); + auto *ToD = Import(FromD, Lang_CXX); + + auto Pattern = classTemplateDecl( + has(cxxRecordDecl(has(friendDecl(has(classTemplateDecl())); + ASSERT_TRUE(MatchVerifier{}.match(FromD, Pattern)); + EXPECT_TRUE(MatchVerifier{}.match(ToD, Pattern)); + + auto *Class = + FirstDeclMatcher().match(ToD, classTemplateDecl()); + auto *Friend = FirstDeclMatcher().match(ToD, friendDecl()); + EXPECT_NE(Friend->getFriendDecl(), Class); + EXPECT_EQ(Friend->getFriendDecl()->getPreviousDecl(), Class); +} + struct DeclContextTest : ASTImporterTestBase {}; TEST_P(DeclContextTest, removeDeclOfClassTemplateSpecialization) { Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -2164,11 +2164,21 @@ } Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { + bool IsFriendTemplate = false; + if (auto *DCXX = dyn_cast(D)) { +IsFriendTemplate = +DCXX->getDescribedClassTemplate() && +DCXX->getDescribedClassTemplate()->getFriendObjectKind() != +Decl::FOK_None; + } + // If this record has a definition in the translation unit we're coming from, // but this particular declaration is not that definition, import the // definition and map to that. TagDecl *Definition = D->getDefinition(); if (Definition && Definition != D && + // Friend template declaration must be imported on its own. + !IsFriendTemplate && // In contrast to a normal CXXRecordDecl, the implicit // CXXRecordDecl of ClassTemplateSpecializationDecl is its redeclaration. // The definition of the implicit CXXRecordDecl in this case is the @@ -2241,7 +2251,7 @@ PrevDecl = FoundRecord; if (RecordDecl *FoundDef = FoundRecord->getDefinition()) { - if ((SearchName && !D->isCompleteDefinition()) + if ((SearchName && !D->is
[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index
kbobyrev created this revision. kbobyrev added reviewers: ioeric, ilya-biryukov. Herald added subscribers: arphaman, jkorous, MaskRay. https://reviews.llvm.org/D50517 Files: clang-tools-extra/clangd/index/dex/Trigram.cpp clang-tools-extra/clangd/index/dex/Trigram.h clang-tools-extra/unittests/clangd/DexIndexTests.cpp Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp === --- clang-tools-extra/unittests/clangd/DexIndexTests.cpp +++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp @@ -250,30 +250,44 @@ } TEST(DexIndexTrigrams, IdentifierTrigrams) { - EXPECT_THAT(generateIdentifierTrigrams("X86"), trigramsAre({"x86"})); + EXPECT_THAT(generateIdentifierTrigrams("X86"), + trigramsAre({"x86", "x$$", "8$$", "6$$", "x8$", "86$"})); - EXPECT_THAT(generateIdentifierTrigrams("nl"), trigramsAre({})); + EXPECT_THAT(generateIdentifierTrigrams("nl"), + trigramsAre({"nl$", "n$$", "l$$"})); - EXPECT_THAT(generateIdentifierTrigrams("clangd"), - trigramsAre({"cla", "lan", "ang", "ngd"})); - - EXPECT_THAT(generateIdentifierTrigrams("abc_def"), - trigramsAre({"abc", "abd", "ade", "bcd", "bde", "cde", "def"})); + EXPECT_THAT(generateIdentifierTrigrams("n"), trigramsAre({"n$$"})); EXPECT_THAT( - generateIdentifierTrigrams("a_b_c_d_e_"), - trigramsAre({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde"})); + generateIdentifierTrigrams("clangd"), + trigramsAre({"cla", "lan", "ang", "ngd", "an$", "n$$", "g$$", "cl$", + "ng$", "d$$", "l$$", "a$$", "c$$", "gd$", "la$"})); - EXPECT_THAT( - generateIdentifierTrigrams("unique_ptr"), - trigramsAre({"uni", "unp", "upt", "niq", "nip", "npt", "iqu", "iqp", - "ipt", "que", "qup", "qpt", "uep", "ept", "ptr"})); + EXPECT_THAT(generateIdentifierTrigrams("abc_def"), + trigramsAre({"abc", "abd", "ade", "bcd", "bde", "cde", "def", + "a$$", "b$$", "c$$", "d$$", "e$$", "f$$", "ab$", + "ad$", "bc$", "bd$", "cd$", "de$", "ef$"})); + + EXPECT_THAT(generateIdentifierTrigrams("a_b_c_d_e_"), + trigramsAre({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", + "cde", "a$$", "ab$", "ac$", "b$$", "bc$", "bd$", + "c$$", "cd$", "ce$", "d$$", "de$", "e$$"})); + + EXPECT_THAT(generateIdentifierTrigrams("unique_ptr"), + trigramsAre({"uni", "unp", "upt", "niq", "nip", "npt", "iqu", + "iqp", "ipt", "que", "qup", "qpt", "uep", "ept", + "ptr", "u$$", "un$", "up$", "n$$", "ni$", "np$", + "i$$", "iq$", "ip$", "q$$", "qu$", "qp$", "ue$", + "e$$", "ep$", "p$$", "pt$", "t$$", "tr$", "r$$"})); EXPECT_THAT(generateIdentifierTrigrams("TUDecl"), - trigramsAre({"tud", "tde", "ude", "dec", "ecl"})); + trigramsAre({"tud", "tde", "ude", "dec", "ecl", "t$$", "tu$", + "td$", "u$$", "ud$", "d$$", "de$", "e$$", "ec$", + "c$$", "cl$", "l$$"})); EXPECT_THAT(generateIdentifierTrigrams("IsOK"), - trigramsAre({"iso", "iok", "sok"})); + trigramsAre({"iso", "iok", "sok", "i$$", "is$", "io$", "s$$", + "so$", "o$$", "ok$", "k$$"})); EXPECT_THAT(generateIdentifierTrigrams("abc_defGhij__klm"), trigramsAre({ Index: clang-tools-extra/clangd/index/dex/Trigram.h === --- clang-tools-extra/clangd/index/dex/Trigram.h +++ clang-tools-extra/clangd/index/dex/Trigram.h @@ -31,6 +31,11 @@ namespace clangd { namespace dex { +/// This is used to mark unigrams and bigrams and distinct them from complete +/// trigrams. Since '$' is not present in valid identifier names, it is safe to +/// use it as the special symbol. +const auto END_SYMBOL = '$'; + /// Returns list of unique fuzzy-search trigrams from unqualified symbol. /// /// First, given Identifier (unqualified symbol name) is segmented using Index: clang-tools-extra/clangd/index/dex/Trigram.cpp === --- clang-tools-extra/clangd/index/dex/Trigram.cpp +++ clang-tools-extra/clangd/index/dex/Trigram.cpp @@ -10,11 +10,9 @@ #include "Trigram.h" #include "../../FuzzyMatch.h" #include "Token.h" - #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringExtras.h" - #include #include #include @@ -59,15 +57,31 @@ } } + // Iterate through valid seqneces of three characters Fuzzy Matcher can + // process. DenseSet UniqueTrigrams; std::array Chars; for (size_t I = 0; I < LowercaseIdentifier.size(); ++I) { // Skip delimiters. if (Roles[I] != Head && Roles[I] != Tail) continue; + +
[PATCH] D49486: [cfe][CMake] Export the clang resource directory
beanz added a comment. I’m not opposed to this patch, but is there a real need for this? Have you considered just running clang with the `-print-resource-dir` flag? https://reviews.llvm.org/D49486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50447: [clang-tidy] Omit cases where loop variable is not used in loop body in performance-for-range-copy.
JonasToth added a comment. LGTM, but alex or aaron should allow the commit ;) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50447 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50517: [clangd] Generate incomplete trigrams for the Dex index
kbobyrev planned changes to this revision. kbobyrev added a comment. This patch is in preview mode and can be useful for the discussion. It's not functional yet, but this will be changed in the future. The upcoming changes would allow handling short queries introduced in https://reviews.llvm.org/D50337 in a more efficient manner. @ioeric proposed to generate unigrams for the first letter of the identifier so that the index would only perform prefix match for one-letter completion requests, which I think would be a great performance improvement. https://reviews.llvm.org/D50517 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50500: [clangd] Allow consuming limited number of items
kbobyrev planned changes to this revision. kbobyrev added a comment. Oops, I thought I pushed "Plan Changes" for this one. https://reviews.llvm.org/D50500 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47757: [Sema] Produce diagnostics when unavailable aligned allocation/deallocation functions are called
ahatanak added a comment. ping Repository: rC Clang https://reviews.llvm.org/D47757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49486: [cfe][CMake] Export the clang resource directory
philip.pfaffe added a comment. I had not, but it should work just as well! https://reviews.llvm.org/D49486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50493: AMDGPU: Add another missing builtin
kzhuravl accepted this revision. kzhuravl added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D50493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50449: [clangd] Support textEdit in addition to insertText.
ilya-biryukov added inline comments. Comment at: clangd/CodeComplete.cpp:289 } + std::stable_sort(Completion.FixIts.begin(), Completion.FixIts.end(), + [](const TextEdit &X, const TextEdit &Y) { We shouldn't have duplicate/overlapping fix-its, right? Maybe use `std::sort`? Comment at: clangd/CodeComplete.cpp:291 + [](const TextEdit &X, const TextEdit &Y) { + return X.range.start.line < Y.range.start.line || +X.range.start.character < use built-in tuples comparison `std::tie(X.line, X.column) < std::tie(Y.line, Y.column)`? Comment at: clangd/CodeComplete.cpp:1057 +Range TextEditRange; +if (CodeCompletionRange.isValid()) { + TextEditRange = halfOpenToRange(Recorder->CCSema->getSourceManager(), Maybe add a comment describing the cases where `isValid()` is false? Does it happen when we complete with empty identifier? Comment at: clangd/CodeComplete.cpp:1310 + // other. + for (const auto &FixIt : FixIts) { +if (IsRangeConsecutive(FixIt.range, LSP.textEdit->range)) { Maybe keep the `reserve` call? (we could reserve one extra element, but that's fine) Comment at: clangd/CodeComplete.h:126 + TextEdit textEdit; + Could we avoid adding `textEdit` here? It's an intermediate representation that is only used in clangd, and we should be able materialize the actual `textEdit` when converting to LSP. Comment at: unittests/clangd/SourceCodeTests.cpp:40 +Range range(const std::pair p1, +const std::pair p2) { we convert those `uint64_t` into `int` when setting the positions anyway. Maybe use `int` here too? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50449 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49486: [cfe][CMake] Export the clang resource directory
beanz added a comment. Please check and see if that works for you. In general I prefer to avoid adding new features that aren't used in-tree unless it is unavoidable or would be difficult to work around out-of-tree. This one seems pretty straightforward to me. https://reviews.llvm.org/D49486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50500: [clangd] Allow consuming limited number of items
kbobyrev updated this revision to Diff 159959. kbobyrev marked 3 inline comments as done. kbobyrev added a comment. Fix the implementation and add test coverage. https://reviews.llvm.org/D50500 Files: clang-tools-extra/clangd/index/dex/Iterator.cpp clang-tools-extra/clangd/index/dex/Iterator.h clang-tools-extra/unittests/clangd/DexIndexTests.cpp Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp === --- clang-tools-extra/unittests/clangd/DexIndexTests.cpp +++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp @@ -240,6 +240,29 @@ "(& (& [1, 3, 5, 8, 9] [1, 5, 7, 9]) (| [0, 5] [0, 1, 5] []))"); } +TEST(DexIndexIterators, Limit) { + const PostingList L0 = {4, 7, 8, 20, 42, 100}; + const PostingList L1 = {1, 3, 5, 8, 9}; + const PostingList L2 = {1, 5, 7, 9}; + const PostingList L3 = {0, 5}; + const PostingList L4 = {0, 1, 5}; + const PostingList L5; + + auto DocIterator = create(L0); + EXPECT_THAT(consume(*DocIterator, 42), ElementsAre(4, 7, 8, 20, 42, 100)); + + DocIterator = create(L0); + EXPECT_THAT(consume(*DocIterator, 3), ElementsAre(4, 7, 8)); + + DocIterator = create(L0); + EXPECT_THAT(consume(*DocIterator, 0), ElementsAre()); + + auto Root = createAnd(createAnd(create(L1), create(L2)), +createOr(create(L3), create(L4), create(L5))); + + EXPECT_THAT(consume(*Root, 42), ElementsAre(1, 5)); +} + testing::Matcher> trigramsAre(std::initializer_list Trigrams) { std::vector Tokens; Index: clang-tools-extra/clangd/index/dex/Iterator.h === --- clang-tools-extra/clangd/index/dex/Iterator.h +++ clang-tools-extra/clangd/index/dex/Iterator.h @@ -101,9 +101,10 @@ virtual llvm::raw_ostream &dump(llvm::raw_ostream &OS) const = 0; }; -/// Exhausts given iterator and returns all processed DocIDs. The result -/// contains sorted DocumentIDs. -std::vector consume(Iterator &It); +/// Advances the iterator until it is either exhausted or the number of +/// requested items is reached. The result contains sorted DocumentIDs. +std::vector consume(Iterator &It, + size_t Limit = std::numeric_limits::max()); /// Returns a document iterator over given PostingList. std::unique_ptr create(PostingListRef Documents); Index: clang-tools-extra/clangd/index/dex/Iterator.cpp === --- clang-tools-extra/clangd/index/dex/Iterator.cpp +++ clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -218,9 +218,10 @@ } // end namespace -std::vector consume(Iterator &It) { +std::vector consume(Iterator &It, size_t Limit) { std::vector Result; - for (; !It.reachedEnd(); It.advance()) + for (size_t Retrieved = 0; !It.reachedEnd() && Retrieved < Limit; + It.advance(), ++Retrieved) Result.push_back(It.peek()); return Result; } Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp === --- clang-tools-extra/unittests/clangd/DexIndexTests.cpp +++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp @@ -240,6 +240,29 @@ "(& (& [1, 3, 5, 8, 9] [1, 5, 7, 9]) (| [0, 5] [0, 1, 5] []))"); } +TEST(DexIndexIterators, Limit) { + const PostingList L0 = {4, 7, 8, 20, 42, 100}; + const PostingList L1 = {1, 3, 5, 8, 9}; + const PostingList L2 = {1, 5, 7, 9}; + const PostingList L3 = {0, 5}; + const PostingList L4 = {0, 1, 5}; + const PostingList L5; + + auto DocIterator = create(L0); + EXPECT_THAT(consume(*DocIterator, 42), ElementsAre(4, 7, 8, 20, 42, 100)); + + DocIterator = create(L0); + EXPECT_THAT(consume(*DocIterator, 3), ElementsAre(4, 7, 8)); + + DocIterator = create(L0); + EXPECT_THAT(consume(*DocIterator, 0), ElementsAre()); + + auto Root = createAnd(createAnd(create(L1), create(L2)), +createOr(create(L3), create(L4), create(L5))); + + EXPECT_THAT(consume(*Root, 42), ElementsAre(1, 5)); +} + testing::Matcher> trigramsAre(std::initializer_list Trigrams) { std::vector Tokens; Index: clang-tools-extra/clangd/index/dex/Iterator.h === --- clang-tools-extra/clangd/index/dex/Iterator.h +++ clang-tools-extra/clangd/index/dex/Iterator.h @@ -101,9 +101,10 @@ virtual llvm::raw_ostream &dump(llvm::raw_ostream &OS) const = 0; }; -/// Exhausts given iterator and returns all processed DocIDs. The result -/// contains sorted DocumentIDs. -std::vector consume(Iterator &It); +/// Advances the iterator until it is either exhausted or the number of +/// requested items is reached. The result contains sorted DocumentIDs. +std::vector consume(Iterator &It, + size_t Limit = std::numeric_limits::max()); /// Returns a document iterator over given PostingList. std::unique_ptr create(PostingListRef Documents); Index: clang-tools-extr
r339085 - Performing a test commmit as requested by Chris Lattner.
Author: bviyer Date: Mon Aug 6 17:31:44 2018 New Revision: 339085 URL: http://llvm.org/viewvc/llvm-project?rev=339085&view=rev Log: Performing a test commmit as requested by Chris Lattner. -This line, and those below, will be ignored-- MTemplateBase.h Modified: cfe/trunk/include/clang/AST/TemplateBase.h Modified: cfe/trunk/include/clang/AST/TemplateBase.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateBase.h?rev=339085&r1=339084&r2=339085&view=diff == --- cfe/trunk/include/clang/AST/TemplateBase.h (original) +++ cfe/trunk/include/clang/AST/TemplateBase.h Mon Aug 6 17:31:44 2018 @@ -467,7 +467,7 @@ public: : Argument(Argument), LocInfo(E) { // Permit any kind of template argument that can be represented with an -// expression +// expression. assert(Argument.getKind() == TemplateArgument::NullPtr || Argument.getKind() == TemplateArgument::Integral || Argument.getKind() == TemplateArgument::Declaration || ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D40526: [WebAssembly] Change size_t to `unsigned long`
This has also shown up in a game engine middleware codebase, so it may be a broader issue - people seem to assume size_t is one of the int*_t types. On Wed, Aug 8, 2018 at 10:55 AM, Sam Clegg via Phabricator < revi...@reviews.llvm.org> wrote: > sbc100 added a comment. > > In https://reviews.llvm.org/D40526#1192688, @sunfish wrote: > > > Is this related to the issue reported in the thread here < > https://groups.google.com/forum/m/#!topic/emscripten-discuss/97HYhPgd6Ag>? > > > Ah yes, I'll follow up there. > > > Repository: > rC Clang > > https://reviews.llvm.org/D40526 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r339224 - Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa.
Author: kadircet Date: Wed Aug 8 01:59:29 2018 New Revision: 339224 URL: http://llvm.org/viewvc/llvm-project?rev=339224&view=rev Log: Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa. Summary: Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: yvvan, ioeric, jkorous, arphaman, cfe-commits, kadircet Differential Revision: https://reviews.llvm.org/D50193 Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp clang-tools-extra/trunk/clangd/CodeComplete.h clang-tools-extra/trunk/clangd/Diagnostics.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/clangd/Quality.cpp clang-tools-extra/trunk/clangd/Quality.h clang-tools-extra/trunk/clangd/SourceCode.cpp clang-tools-extra/trunk/clangd/SourceCode.h clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=339224&r1=339223&r2=339224&view=diff == --- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Wed Aug 8 01:59:29 2018 @@ -22,6 +22,7 @@ #include "AST.h" #include "CodeCompletionStrings.h" #include "Compiler.h" +#include "Diagnostics.h" #include "FileDistance.h" #include "FuzzyMatch.h" #include "Headers.h" @@ -280,6 +281,10 @@ struct CodeCompletionBuilder { } Completion.Kind = toCompletionItemKind(C.SemaResult->Kind, C.SemaResult->Declaration); + for (const auto &FixIt : C.SemaResult->FixIts) { +Completion.FixIts.push_back( +toTextEdit(FixIt, ASTCtx.getSourceManager(), ASTCtx.getLangOpts())); + } } if (C.IndexResult) { Completion.Origin |= C.IndexResult->Origin; @@ -906,6 +911,7 @@ clang::CodeCompleteOptions CodeCompleteO // the index can provide results from the preamble. // Tell Sema not to deserialize the preamble to look for results. Result.LoadExternal = !Index; + Result.IncludeFixIts = IncludeFixIts; return Result; } @@ -1090,8 +1096,8 @@ private: // Groups overloads if desired, to form CompletionCandidate::Bundles. // The bundles are scored and top results are returned, best to worst. std::vector - mergeResults(const std::vector &SemaResults, - const SymbolSlab &IndexResults) { + mergeResults(const std::vector &SemaResults, + const SymbolSlab &IndexResults) { trace::Span Tracer("Merge and score results"); std::vector Bundles; llvm::DenseMap BundleLookup; @@ -1272,13 +1278,18 @@ CompletionItem CodeCompletion::render(co LSP.documentation = Documentation; LSP.sortText = sortText(Score.Total, Name); LSP.filterText = Name; + // FIXME(kadircet): Use LSP.textEdit instead of insertText, because it causes + // undesired behaviours. Like completing "this.^" into "this-push_back". LSP.insertText = RequiredQualifier + Name; if (Opts.EnableSnippets) LSP.insertText += SnippetSuffix; LSP.insertTextFormat = Opts.EnableSnippets ? InsertTextFormat::Snippet : InsertTextFormat::PlainText; + LSP.additionalTextEdits.reserve(FixIts.size() + (HeaderInsertion ? 1 : 0)); + for (const auto &FixIt : FixIts) +LSP.additionalTextEdits.push_back(FixIt); if (HeaderInsertion) -LSP.additionalTextEdits = {*HeaderInsertion}; +LSP.additionalTextEdits.push_back(*HeaderInsertion); return LSP; } Modified: clang-tools-extra/trunk/clangd/CodeComplete.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.h?rev=339224&r1=339223&r2=339224&view=diff == --- clang-tools-extra/trunk/clangd/CodeComplete.h (original) +++ clang-tools-extra/trunk/clangd/CodeComplete.h Wed Aug 8 01:59:29 2018 @@ -77,6 +77,10 @@ struct CodeCompleteOptions { /// FIXME(ioeric): we might want a better way to pass the index around inside /// clangd. const SymbolIndex *Index = nullptr; + + /// Include completions that require small corrections, e.g. change '.' to + /// '->' on member access etc. + bool IncludeFixIts = false; }; // Semi-structured representation of a code-complete suggestion for our C++ API. @@ -115,6 +119,10 @@ struct CodeCompletion { // Present if Header is set and should be inserted to use this item. llvm::Optional HeaderInsertion; + /// Holds information about small corrections that needs to be done. Like + /// converting '->' to '.' on member access. + std::vector FixIts; + // Scores are used to rank completion items. struct Scores { // The score that items are ranked by.
[PATCH] D50344: [libc++] Enable aligned allocation based on feature test macro, irrespective of standard
vsapsai accepted this revision. vsapsai added inline comments. This revision is now accepted and ready to land. Comment at: libcxx/include/new:111-116 #if !__has_builtin(__builtin_operator_new) || \ __has_builtin(__builtin_operator_new) < 201802L || \ defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \ !defined(__cpp_aligned_new) || __cpp_aligned_new < 201606 #define _LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE #endif ldionne wrote: > vsapsai wrote: > > Maybe move this to `__config` too? This way we'll have > > `__cpp_aligned_new`-related macros together. > The big difference is that > `_LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE` is only used in ``, > whereas `_LIBCPP_HAS_NO_ALIGNED_ALLOCATION` was used in other files as well. > Hence, I feel like it makes more sense to lift > `_LIBCPP_HAS_NO_ALIGNED_ALLOCATION` into `<__config>`, but not > `_LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE `. Agree with your reasoning. Comment at: libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp:11 +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// XFAIL: with_system_cxx_lib=macosx10.12 +// XFAIL: with_system_cxx_lib=macosx10.11 ldionne wrote: > vsapsai wrote: > > Initially `with_system_cxx_lib` made me suspicious because macro > > `_LIBCPP_HAS_NO_ALIGNED_ALLOCATION` doesn't need specific dylib. And > > `XFAIL: availability=macosx10.12` seems to be working. > > > > [Documentation](https://github.com/llvm-mirror/libcxx/blob/master/docs/DesignDocs/AvailabilityMarkup.rst#testing) > > describes which feature should be used in different cases but in this case > > I cannot definitely say if test uses unavailable feature. I think it is > > acceptable to stick with `with_system_cxx_lib` but I decided to brought to > > your attention the alternative. > My understanding is that the `availability` feature may not be there if we're > not using availability macros, since they can be disabled entirely. `availability` feature [will be present](https://github.com/llvm-mirror/libcxx/blob/5428c6b9d64dd4cc65fd5665c977c11dc6f8a547/utils/libcxx/test/config.py#L403-L426) when tests are invoked with `use_system_cxx_lib`. I suspect in this case both `with_system_cxx_lib` and `availability` will work, so let's keep `with_system_cxx_lib`. Repository: rCXX libc++ https://reviews.llvm.org/D50344 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50341: [libcxx] Mark aligned allocation tests as XFAIL on old OSX versions
ldionne added inline comments. Comment at: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.fail.cpp:15 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8 vsapsai wrote: > In what cases are we supposed to run these tests? Such extensive collection > of unsupported C++ standards looks suspicious and I guess that is the reason > why I haven't seen test failures with older libc++ dylibs. That's an excellent question. I would assume those should be enabled in C++17 and above, I'm not sure why they're disabled. @mclow.lists was the one to introduce those tests, perhaps he can shed light on why they were disabled in C++17? Repository: rCXX libc++ https://reviews.llvm.org/D50341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339369 - [analyzer] Fix the bug in UninitializedObjectChecker caused by not handling block pointers
Author: george.karpenkov Date: Thu Aug 9 12:03:12 2018 New Revision: 339369 URL: http://llvm.org/viewvc/llvm-project?rev=339369&view=rev Log: [analyzer] Fix the bug in UninitializedObjectChecker caused by not handling block pointers Differential Revision: https://reviews.llvm.org/D50523 Added: cfe/trunk/test/Analysis/objcpp-uninitialized-object.mm Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp?rev=339369&r1=339368&r2=339369&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp Thu Aug 9 12:03:12 2018 @@ -417,7 +417,7 @@ bool FindUninitializedFields::isNonUnion continue; } -if (T->isPointerType() || T->isReferenceType()) { +if (T->isPointerType() || T->isReferenceType() || T->isBlockPointerType()) { if (isPointerOrReferenceUninit(FR, LocalChain)) ContainsUninitField = true; continue; @@ -478,7 +478,8 @@ bool FindUninitializedFields::isPointerO const FieldRegion *FR, FieldChainInfo LocalChain) { assert((FR->getDecl()->getType()->isPointerType() || - FR->getDecl()->getType()->isReferenceType()) && + FR->getDecl()->getType()->isReferenceType() || + FR->getDecl()->getType()->isBlockPointerType()) && "This method only checks pointer/reference objects!"); SVal V = State->getSVal(FR); Added: cfe/trunk/test/Analysis/objcpp-uninitialized-object.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/objcpp-uninitialized-object.mm?rev=339369&view=auto == --- cfe/trunk/test/Analysis/objcpp-uninitialized-object.mm (added) +++ cfe/trunk/test/Analysis/objcpp-uninitialized-object.mm Thu Aug 9 12:03:12 2018 @@ -0,0 +1,22 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s + +typedef void (^myBlock) (); + +struct StructWithBlock { + int a; + myBlock z; // expected-note{{uninitialized field 'this->z'}} + + StructWithBlock() : a(0), z(^{}) {} + + // Miss initialization of field `z`. + StructWithBlock(int pA) : a(pA) {} // expected-warning{{1 uninitialized field at the end of the constructor call}} + +}; + +void warnOnUninitializedBlock() { + StructWithBlock a(10); +} + +void noWarningWhenInitialized() { + StructWithBlock a; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50523: [analyzer] Fix the bug in UninitializedObjectChecker caused by not handling block pointers
This revision was automatically updated to reflect the committed changes. Closed by commit rC339369: [analyzer] Fix the bug in UninitializedObjectChecker caused by not handling… (authored by george.karpenkov, committed by ). Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D50523?vs=159968&id=159971#toc Repository: rC Clang https://reviews.llvm.org/D50523 Files: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp test/Analysis/objcpp-uninitialized-object.mm Index: test/Analysis/objcpp-uninitialized-object.mm === --- test/Analysis/objcpp-uninitialized-object.mm +++ test/Analysis/objcpp-uninitialized-object.mm @@ -0,0 +1,22 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s + +typedef void (^myBlock) (); + +struct StructWithBlock { + int a; + myBlock z; // expected-note{{uninitialized field 'this->z'}} + + StructWithBlock() : a(0), z(^{}) {} + + // Miss initialization of field `z`. + StructWithBlock(int pA) : a(pA) {} // expected-warning{{1 uninitialized field at the end of the constructor call}} + +}; + +void warnOnUninitializedBlock() { + StructWithBlock a(10); +} + +void noWarningWhenInitialized() { + StructWithBlock a; +} Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp @@ -417,7 +417,7 @@ continue; } -if (T->isPointerType() || T->isReferenceType()) { +if (T->isPointerType() || T->isReferenceType() || T->isBlockPointerType()) { if (isPointerOrReferenceUninit(FR, LocalChain)) ContainsUninitField = true; continue; @@ -478,7 +478,8 @@ const FieldRegion *FR, FieldChainInfo LocalChain) { assert((FR->getDecl()->getType()->isPointerType() || - FR->getDecl()->getType()->isReferenceType()) && + FR->getDecl()->getType()->isReferenceType() || + FR->getDecl()->getType()->isBlockPointerType()) && "This method only checks pointer/reference objects!"); SVal V = State->getSVal(FR); Index: test/Analysis/objcpp-uninitialized-object.mm === --- test/Analysis/objcpp-uninitialized-object.mm +++ test/Analysis/objcpp-uninitialized-object.mm @@ -0,0 +1,22 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s + +typedef void (^myBlock) (); + +struct StructWithBlock { + int a; + myBlock z; // expected-note{{uninitialized field 'this->z'}} + + StructWithBlock() : a(0), z(^{}) {} + + // Miss initialization of field `z`. + StructWithBlock(int pA) : a(pA) {} // expected-warning{{1 uninitialized field at the end of the constructor call}} + +}; + +void warnOnUninitializedBlock() { + StructWithBlock a(10); +} + +void noWarningWhenInitialized() { + StructWithBlock a; +} Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp @@ -417,7 +417,7 @@ continue; } -if (T->isPointerType() || T->isReferenceType()) { +if (T->isPointerType() || T->isReferenceType() || T->isBlockPointerType()) { if (isPointerOrReferenceUninit(FR, LocalChain)) ContainsUninitField = true; continue; @@ -478,7 +478,8 @@ const FieldRegion *FR, FieldChainInfo LocalChain) { assert((FR->getDecl()->getType()->isPointerType() || - FR->getDecl()->getType()->isReferenceType()) && + FR->getDecl()->getType()->isReferenceType() || + FR->getDecl()->getType()->isBlockPointerType()) && "This method only checks pointer/reference objects!"); SVal V = State->getSVal(FR); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48687: [clangd] Avoid duplicates in findDefinitions response
simark marked 3 inline comments as done. simark added a comment. In https://reviews.llvm.org/D48687#1193470, @hokein wrote: > Sorry for the delay. I thought there was a dependent patch of this patch, but > it seems resolved, right? > > A rough round of review. Right, the patch this one depends on is in clang, and there does not seem to be regressions this time. >> New version. I tried to share the code between this and SymbolCollector, but >> didn't find a good clean way. Do you have concrete suggestions on how to do >> this? Otherwise, would it be acceptable to merge it as-is? > > Yeah, I'm fine with the current change. I was not aware of the > `getAbsoluteFilePath` has been pulled out to the `SourceCode.h`. I think the > SymbolCollector could use this function as well (but that's out of scope of > this patch). Thanks. Comment at: clangd/SourceCode.h:65 /// Get the absolute file path of a given file entry. -llvm::Optional getAbsoluteFilePath(const FileEntry *F, -const SourceManager &SourceMgr); +llvm::Optional getRealPath(const FileEntry *F, +const SourceManager &SourceMgr); hokein wrote: > Why rename this function? > > Is it guaranteed that `RealPath` is always an absolute path? Before, it only made sure that the path was absolute, now it goes a step further and makes it a "real path", resolving symlinks and removing `.` and `..`. When we talk about a "real path", it refers to the unix realpath syscall: http://man7.org/linux/man-pages/man3/realpath.3.html So yes, the result is guaranteed to be absolute too. Comment at: unittests/clangd/TestFS.cpp:52 CommandLine.insert(CommandLine.begin(), "clang"); - CommandLine.insert(CommandLine.end(), UseRelPaths ? FileName : File); - return {tooling::CompileCommand(sys::path::parent_path(File), FileName, - std::move(CommandLine), "")}; + if (RelPathPrefix == StringRef()) { +// Use the absolute path in the compile command. hokein wrote: > Can we use `RelPathPrefix.empty()` instead of comparing with `StringRef()`? Done. Comment at: unittests/clangd/XRefsTests.cpp:325 + + Annotations HeaderInPreambleAnnotations(R"cpp( +int [[bar_preamble]]; hokein wrote: > It seems that there is no difference between `HeaderInPreambleAnnotations` > and `HeaderNotInPreambleAnnotations` in the test. Both of them are treated > equally. > The difference is that one is included in the main file as part of the preamble and the other is out of the preamble. Since they take different code paths in clang, I think it's good to test both. At some point, I had a similar bug that would only happen with a header included in the preamble. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48687: [clangd] Avoid duplicates in findDefinitions response
simark updated this revision to Diff 159972. simark marked an inline comment as done. simark added a comment. Replace RelPathPrefix == StringRef() with RelPathPrefix.empty() Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48687 Files: clangd/FindSymbols.cpp clangd/SourceCode.cpp clangd/SourceCode.h clangd/XRefs.cpp unittests/clangd/TestFS.cpp unittests/clangd/TestFS.h unittests/clangd/XRefsTests.cpp Index: unittests/clangd/XRefsTests.cpp === --- unittests/clangd/XRefsTests.cpp +++ unittests/clangd/XRefsTests.cpp @@ -312,27 +312,65 @@ } TEST(GoToDefinition, RelPathsInCompileCommand) { + // The source is in "/clangd-test/src". + // We build in "/clangd-test/build". + Annotations SourceAnnotations(R"cpp( +#include "header_in_preamble.h" int [[foo]]; -int baz = f^oo; +#include "header_not_in_preamble.h" +int baz = f$p1^oo + bar_pre$p2^amble + bar_not_pre$p3^amble; +)cpp"); + + Annotations HeaderInPreambleAnnotations(R"cpp( +int [[bar_preamble]]; +)cpp"); + + Annotations HeaderNotInPreambleAnnotations(R"cpp( +int [[bar_not_preamble]]; )cpp"); + // Make the compilation paths appear as ../src/foo.cpp in the compile + // commands. + SmallString<32> RelPathPrefix(".."); + llvm::sys::path::append(RelPathPrefix, "src"); + std::string BuildDir = testPath("build"); + MockCompilationDatabase CDB(BuildDir, RelPathPrefix); + IgnoreDiagnostics DiagConsumer; - MockCompilationDatabase CDB(/*UseRelPaths=*/true); MockFSProvider FS; ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest()); - auto FooCpp = testPath("foo.cpp"); + // Fill the filesystem. + auto FooCpp = testPath("src/foo.cpp"); FS.Files[FooCpp] = ""; + auto HeaderInPreambleH = testPath("src/header_in_preamble.h"); + FS.Files[HeaderInPreambleH] = HeaderInPreambleAnnotations.code(); + auto HeaderNotInPreambleH = testPath("src/header_not_in_preamble.h"); + FS.Files[HeaderNotInPreambleH] = HeaderNotInPreambleAnnotations.code(); - Server.addDocument(FooCpp, SourceAnnotations.code()); runAddDocument(Server, FooCpp, SourceAnnotations.code()); + + // Go to a definition in main source file. auto Locations = - runFindDefinitions(Server, FooCpp, SourceAnnotations.point()); + runFindDefinitions(Server, FooCpp, SourceAnnotations.point("p1")); EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error"; - EXPECT_THAT(*Locations, ElementsAre(Location{URIForFile{FooCpp}, SourceAnnotations.range()})); + + // Go to a definition in header_in_preamble.h. + Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("p2")); + EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error"; + EXPECT_THAT(*Locations, + ElementsAre(Location{URIForFile{HeaderInPreambleH}, + HeaderInPreambleAnnotations.range()})); + + // Go to a definition in header_not_in_preamble.h. + Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("p3")); + EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error"; + EXPECT_THAT(*Locations, + ElementsAre(Location{URIForFile{HeaderNotInPreambleH}, + HeaderNotInPreambleAnnotations.range()})); } TEST(Hover, All) { Index: unittests/clangd/TestFS.h === --- unittests/clangd/TestFS.h +++ unittests/clangd/TestFS.h @@ -40,15 +40,22 @@ // A Compilation database that returns a fixed set of compile flags. class MockCompilationDatabase : public GlobalCompilationDatabase { public: - /// When \p UseRelPaths is true, uses relative paths in compile commands. - /// When \p UseRelPaths is false, uses absoulte paths. - MockCompilationDatabase(bool UseRelPaths = false); + /// If \p Directory is not null, use that as the Directory field of the + /// CompileCommand. + /// + /// If \p RelPathPrefix is not null, use that as a prefix in front of the + /// source file name, instead of using an absolute path. + MockCompilationDatabase(StringRef Directory = StringRef(), + StringRef RelPathPrefix = StringRef()); llvm::Optional getCompileCommand(PathRef File) const override; std::vector ExtraClangFlags; - const bool UseRelPaths; + +private: + StringRef Directory; + StringRef RelPathPrefix; }; // Returns an absolute (fake) test directory for this OS. Index: unittests/clangd/TestFS.cpp === --- unittests/clangd/TestFS.cpp +++ unittests/clangd/TestFS.cpp @@ -32,22 +32,36 @@ return MemFS; } -MockCompilationDatabase::MockCompilationDatabase(bool UseRelPaths) -: ExtraClangFlags({"-ffreestanding"}), UseRelPaths(UseRelPaths) { +MockCompilationDatabase::MockCompilationDatabase(StringRef Directory, +
[PATCH] D50179: [AArch64][ARM] Context sensitive meaning of option "crypto"
efriedma added inline comments. Comment at: lib/Driver/ToolChains/Arch/AArch64.cpp:266 + const bool HasV83a = (std::find(ItBegin, ItEnd, "+v8.3a") != ItEnd); + const bool HasV84a = (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd); + const bool HasV85a = (std::find(ItBegin, ItEnd, "+v8.5a") != ItEnd); HasV84a is always false; you checked it a few lines earlier. And I think that implies HasV85a is also false? Not sure. Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:430 + if (ArchName.find_lower("+noaes") == StringRef::npos) +Features.push_back("+aes"); +} else if (ArchName.find_lower("-crypto") != StringRef::npos) { SjoerdMeijer wrote: > efriedma wrote: > > The ARM backend doesn't support features named "sha2" and "aes" at the > > moment. > These ARM target features were introduced in rL335953. Hmm, I missed that somehow; okay. https://reviews.llvm.org/D50179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50526: Model type attributes as regular Attrs
rsmith created this revision. rsmith added a reviewer: aaron.ballman. rsmith added a project: clang. Specifically, `AttributedType` now tracks a regular `attr::Kind` rather than having its own parallel `Kind` enumeration, and `AttributedTypeLoc` now holds an `Attr*` instead of holding an ad-hoc collection of fields mirroring those that would be present in the corresponding `Attr` subclass. This aims to simplify and unify the modeling of attributes, both to make tooling simpler and to avoid code duplication for attributes that can be both type and declaration attributes. Repository: rC Clang https://reviews.llvm.org/D50526 Files: include/clang/AST/ASTContext.h include/clang/AST/Attr.h include/clang/AST/Type.h include/clang/AST/TypeLoc.h include/clang/Basic/Attr.td include/clang/Sema/Sema.h include/clang/Serialization/ASTReader.h include/clang/Serialization/ASTWriter.h lib/ARCMigrate/TransGCAttrs.cpp lib/ARCMigrate/Transforms.cpp lib/AST/ASTContext.cpp lib/AST/Type.cpp lib/AST/TypeLoc.cpp lib/AST/TypePrinter.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaInit.cpp lib/Sema/SemaObjCProperty.cpp lib/Sema/SemaType.cpp lib/Sema/TreeTransform.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriter.cpp lib/StaticAnalyzer/Core/CheckerHelpers.cpp utils/TableGen/ClangAttrEmitter.cpp Index: utils/TableGen/ClangAttrEmitter.cpp === --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -2470,8 +2470,10 @@ static const AttrClassDescriptor AttrClassDescriptors[] = { { "ATTR", "Attr" }, + { "TYPE_ATTR", "TypeAttr" }, { "STMT_ATTR", "StmtAttr" }, { "INHERITABLE_ATTR", "InheritableAttr" }, + { "DECL_OR_TYPE_ATTR", "DeclOrTypeAttr" }, { "INHERITABLE_PARAM_ATTR", "InheritableParamAttr" }, { "PARAMETER_ABI_ATTR", "ParameterABIAttr" } }; Index: lib/StaticAnalyzer/Core/CheckerHelpers.cpp === --- lib/StaticAnalyzer/Core/CheckerHelpers.cpp +++ lib/StaticAnalyzer/Core/CheckerHelpers.cpp @@ -103,9 +103,9 @@ const auto *AttrType = Type->getAs(); if (!AttrType) return Nullability::Unspecified; - if (AttrType->getAttrKind() == AttributedType::attr_nullable) + if (AttrType->getAttrKind() == attr::TypeNullable) return Nullability::Nullable; - else if (AttrType->getAttrKind() == AttributedType::attr_nonnull) + else if (AttrType->getAttrKind() == attr::TypeNonNull) return Nullability::Nonnull; return Nullability::Unspecified; } Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -770,19 +770,7 @@ } void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) { - Record.AddSourceLocation(TL.getAttrNameLoc()); - if (TL.hasAttrOperand()) { -SourceRange range = TL.getAttrOperandParensRange(); -Record.AddSourceLocation(range.getBegin()); -Record.AddSourceLocation(range.getEnd()); - } - if (TL.hasAttrExprOperand()) { -Expr *operand = TL.getAttrExprOperand(); -Record.push_back(operand ? 1 : 0); -if (operand) Record.AddStmt(operand); - } else if (TL.hasAttrEnumOperand()) { -Record.AddSourceLocation(TL.getAttrEnumOperandLoc()); - } + Record.AddAttr(TL.getAttr()); } void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) { @@ -4481,16 +4469,21 @@ // General Serialization Routines //===--===// -/// Emit the list of attributes to the specified record. -void ASTRecordWriter::AddAttributes(ArrayRef Attrs) { +void ASTRecordWriter::AddAttr(const Attr *A) { auto &Record = *this; - Record.push_back(Attrs.size()); - for (const auto *A : Attrs) { -Record.push_back(A->getKind()); // FIXME: stable encoding, target attrs -Record.AddSourceRange(A->getRange()); + if (!A) +return Record.push_back(0); + Record.push_back(A->getKind() + 1); // FIXME: stable encoding, target attrs + Record.AddSourceRange(A->getRange()); #include "clang/Serialization/AttrPCHWrite.inc" - } +} + +/// Emit the list of attributes to the specified record. +void ASTRecordWriter::AddAttributes(ArrayRef Attrs) { + push_back(Attrs.size()); + for (const auto *A : Attrs) +AddAttr(A); } void ASTWriter::AddToken(const Token &Tok, RecordDataImpl &Record) { Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -2642,19 +2642,70 @@ // Attribute Reading //===--===// +namespace { +class AttrReader { + ModuleFile *F; + ASTReader *Reader; + const ASTReader::RecordData &Record; +
[PATCH] D33029: [clang-format] add option for dangling parenthesis
dannygr664 added a comment. Are there any updates on this revision? The team at my company is interested in using this linting rule in C++ code. 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] D50418: [Sema] Support for P0961R1: Relaxing the structured bindings customization point finding rules
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. LGTM with a small bugfix. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1122 +for (Decl *D : MemberGet) { + if (FunctionTemplateDecl *FTD = dyn_cast(D)) { +TemplateParameterList *TPL = FTD->getTemplateParameters(); You should use `D->getUnderlyingDecl()` rather than just `D` here, otherwise you'll reject this: ``` struct A { template void get(); }; struct B : A { using A::get; }; ``` ... because `D` will be a `UsingShadowDecl` not a `FunctionTemplateDecl`. (Please also add a corresponding testcase.) https://reviews.llvm.org/D50418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50527: [Parser] Support alternative operator token keyword args in Objective-C++
erik.pilkington created this revision. erik.pilkington added reviewers: rjmccall, arphaman. Herald added a subscriber: dexonsmith. This fixes rdar://30741878 Thanks! Erik Repository: rC Clang https://reviews.llvm.org/D50527 Files: clang/lib/Parse/ParseExpr.cpp clang/test/Parser/message-expr-alt-op.mm Index: clang/test/Parser/message-expr-alt-op.mm === --- /dev/null +++ clang/test/Parser/message-expr-alt-op.mm @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@interface WeirdInterface +-(void)allOfThem:(int)a + and:(int)b + and_eq:(int)c + bitand:(int)d + bitor:(int)e + compl:(int)f + not:(int)g + not_eq:(int)h + or:(int)i + or_eq:(int)j + xor:(int)k + xor_eq:(int)l; + +-(void)justAnd:(int)x and:(int)y; +-(void)and; +-(void)and:(int)x; +@end + +void call_it(WeirdInterface *x) { + [x allOfThem:0 + and:0 +and_eq:0 +bitand:0 + bitor:0 + compl:0 + not:0 +not_eq:0 +or:0 + or_eq:0 + xor:0 +xor_eq:0]; + + [x and]; + [x and:0]; + [x &&:0]; // expected-error{{expected expression}}; + [x justAnd:0 and:1]; + [x and: 0 ? : 1]; +} Index: clang/lib/Parse/ParseExpr.cpp === --- clang/lib/Parse/ParseExpr.cpp +++ clang/lib/Parse/ParseExpr.cpp @@ -263,6 +263,24 @@ return isFoldOperator(getBinOpPrecedence(Kind, GreaterThanIsOperator, true)); } +static bool isBinaryCXXAlternativeOperatorToken(Preprocessor &PP, +const Token &Tok) { + switch (Tok.getKind()) { + case tok::ampamp: + case tok::ampequal: + case tok::amp: + case tok::pipe: + case tok::exclaimequal: + case tok::pipepipe: + case tok::pipeequal: + case tok::caret: + case tok::caretequal: +return isLetter(PP.getSpelling(Tok).front()); + default: +return false; + } +} + /// Parse a binary expression that starts with \p LHS and has a /// precedence of at least \p MinPrec. ExprResult @@ -315,6 +333,19 @@ return LHS; } +// In Objective-C++, alternative operator tokens can be used as keyword args +// in message expressions. Unconsume the token so that it can reinterpreted +// as an identifier in ParseObjCMessageExpressionBody. i.e., we support: +// [foo meth:0 and:0]; +// [foo not_eq]; +if (getLangOpts().ObjC1 && getLangOpts().CPlusPlus && +Tok.isOneOf(tok::colon, tok::r_square) && +isBinaryCXXAlternativeOperatorToken(PP, OpToken)) { + PP.EnterToken(Tok); + Tok = OpToken; + return LHS; +} + // Special case handling for the ternary operator. ExprResult TernaryMiddle(true); if (NextTokPrec == prec::Conditional) { Index: clang/test/Parser/message-expr-alt-op.mm === --- /dev/null +++ clang/test/Parser/message-expr-alt-op.mm @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@interface WeirdInterface +-(void)allOfThem:(int)a + and:(int)b + and_eq:(int)c + bitand:(int)d + bitor:(int)e + compl:(int)f + not:(int)g + not_eq:(int)h + or:(int)i + or_eq:(int)j + xor:(int)k + xor_eq:(int)l; + +-(void)justAnd:(int)x and:(int)y; +-(void)and; +-(void)and:(int)x; +@end + +void call_it(WeirdInterface *x) { + [x allOfThem:0 + and:0 +and_eq:0 +bitand:0 + bitor:0 + compl:0 + not:0 +not_eq:0 +or:0 + or_eq:0 + xor:0 +xor_eq:0]; + + [x and]; + [x and:0]; + [x &&:0]; // expected-error{{expected expression}}; + [x justAnd:0 and:1]; + [x and: 0 ? : 1]; +} Index: clang/lib/Parse/ParseExpr.cpp === --- clang/lib/Parse/ParseExpr.cpp +++ clang/lib/Parse/ParseExpr.cpp @@ -263,6 +263,24 @@ return isFoldOperator(getBinOpPrecedence(Kind, GreaterThanIsOperator, true)); } +static bool isBinaryCXXAlternativeOperatorToken(Preprocessor &PP, +const Token &Tok) { + switch (Tok.getKind()) { + case tok::ampamp: + case tok::ampequal: + case tok::amp: + case tok::pipe: + case tok::exclaimequal: + case tok::pipepipe: + case tok::pipeequal: + case tok::caret: + case tok::caretequal: +return isLetter(PP.getSpelling(Tok).front()); + default: +return false; + } +} + /// Parse a binary expression that starts with \p LHS and has a /// precedence of at least \p MinPrec. ExprResult @@ -315,6 +333,19 @@ return LHS; } +// In Objective-C++, alternative operator tokens can be used as keyword args +// in message expressions. Unconsume the token so
[PATCH] D50530: Added LLVM metadata to generated IR to increase vectorization width
emmettneyman created this revision. emmettneyman added reviewers: morehouse, kcc. Herald added a subscriber: cfe-commits. Edited `loop_proto_to_llvm` to emit metadata at the end of the generated IR. This metadata will increase the vector width when the IR is optimized. Repository: rC Clang https://reviews.llvm.org/D50530 Files: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h === --- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h +++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h @@ -15,6 +15,8 @@ #include #include +#include "../handle-llvm/input_arrays.h" + namespace clang_fuzzer { class LoopFunction; Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp === --- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp +++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp @@ -135,7 +135,11 @@ << x.statements() << "%ctnew = add i64 %ct, 1\n" << "%j = icmp eq i64 %ctnew, %s\n" -<< "br i1 %j, label %end, label %loop\n}\n"; +<< "br i1 %j, label %end, label %loop, !llvm.loop !0\n}\n" +<< "!0 = distinct !{!0, !1, !2}\n" +<< "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n" +<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize +<< "}\n"; } // - Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h === --- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h +++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h @@ -15,6 +15,8 @@ #include #include +#include "../handle-llvm/input_arrays.h" + namespace clang_fuzzer { class LoopFunction; Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp === --- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp +++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp @@ -135,7 +135,11 @@ << x.statements() << "%ctnew = add i64 %ct, 1\n" << "%j = icmp eq i64 %ctnew, %s\n" -<< "br i1 %j, label %end, label %loop\n}\n"; +<< "br i1 %j, label %end, label %loop, !llvm.loop !0\n}\n" +<< "!0 = distinct !{!0, !1, !2}\n" +<< "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n" +<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize +<< "}\n"; } // - ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50179: [AArch64][ARM] Context sensitive meaning of option "crypto"
SjoerdMeijer updated this revision to Diff 159979. SjoerdMeijer added a comment. fixed typo https://reviews.llvm.org/D50179 Files: lib/Driver/ToolChains/Arch/AArch64.cpp lib/Driver/ToolChains/Arch/ARM.cpp test/Driver/arm-features.c test/Preprocessor/aarch64-target-features.c Index: test/Preprocessor/aarch64-target-features.c === --- test/Preprocessor/aarch64-target-features.c +++ test/Preprocessor/aarch64-target-features.c @@ -143,6 +143,101 @@ // CHECK-MARCH-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-fp-armv8" "-target-feature" "-neon" "-target-feature" "-crc" "-target-feature" "-crypto" // CHECK-MARCH-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-neon" +// Check +sm4: +// +// RUN: %clang -target aarch64 -march=armv8.2a+sm4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SM4 %s +// CHECK-SM4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+sm4" +// +// Check +sha3: +// +// RUN: %clang -target aarch64 -march=armv8.2a+sha3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SHA3 %s +// CHECK-SHA3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+sha3" +// +// Check +sha2: +// +// RUN: %clang -target aarch64 -march=armv8.3a+sha2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SHA2 %s +// CHECK-SHA2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.{{.}}a" "-target-feature" "+sha2" +// +// Check +aes: +// +// RUN: %clang -target aarch64 -march=armv8.3a+aes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-AES %s +// CHECK-AES: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.{{.}}a" "-target-feature" "+aes" +// +// Check -sm4: +// +// RUN: %clang -target aarch64 -march=armv8.2a+noSM4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SM4 %s +// CHECK-NO-SM4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sm4" +// +// Check -sha3: +// +// RUN: %clang -target aarch64 -march=armv8.2a+noSHA3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SHA3 %s +// CHECK-NO-SHA3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sha3" +// +// Check -sha2: +// +// RUN: %clang -target aarch64 -march=armv8.2a+noSHA2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SHA2 %s +// CHECK-NO-SHA2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sha2" +// +// Check -aes: +// +// RUN: %clang -target aarch64 -march=armv8.2a+noAES -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AES %s +// CHECK-NO-AES: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-aes" +// +// +// Arch <= ARMv8.3: crypto = sha2 + aes +// - +// +// Check +crypto: +// +// RUN: %clang -target aarch64 -march=armv8a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s +// RUN: %clang -target aarch64 -march=armv8.1a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s +// RUN: %clang -target aarch64 -march=armv8.2a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s +// RUN: %clang -target aarch64 -march=armv8.3a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s +// RUN: %clang -target aarch64 -march=armv8a+crypto+nocrypto+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s +// CHECK-CRYPTO83: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+crypto" "-target-feature" "+sha2" "-target-feature" "+aes" +// +// Check -crypto: +// +// RUN: %clang -target aarch64 -march=armv8a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO8A %s +// RUN: %clang -target aarch64 -march=armv8.1a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO81 %s +// RUN: %clang -target aarch64 -march=armv8.2a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s +// RUN: %clang -target aarch64 -march=armv8.3a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s +// RUN: %clang -target aarch64 -march=armv8.3a+nocrypto+crypto+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s + +// CHECK-NOCRYPTO8A: "-target-feature" "+neon" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-abi" "aapcs" +// CHECK-NOCRYPTO81: "-target-feature" "+neon" "-target-feature" "+v8.1a" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-abi" "aapcs" +// CHECK-NOCRYPTO82: "-target-feature" "+neon" "-target-feature" "+v8.{{.}}a" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-feature" "-sm4" "-target-feature" "-sha3" "-target-abi" "aapcs" +// +// Check +crypto -sha2 -aes: +// +// RUN: %clang -target aarch64 -march=armv8.1a+crypto+nosha2+noaes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83-NOSHA2-NOAES %s +// CHECK-CRYPTO83-NOSHA2-NOAES-NOT: "-target-fea
[PATCH] D50527: [Parser] Support alternative operator token keyword args in Objective-C++
rsmith added a comment. One comment, but otherwise the code change looks mechanically correct. Not accepting only because I don't know whether this is the intended language rule for Objective-C++ or not (please get someone else to sign off on that). Comment at: clang/lib/Parse/ParseExpr.cpp:278 + case tok::caretequal: +return isLetter(PP.getSpelling(Tok).front()); + default: Just check `Tok.getIdentifierInfo()`. That will be null for a punctuation token and non-null for a token spelled as an identifier. (I don't think you even need the `switch`, because we already only get here for operators.) Repository: rC Clang https://reviews.llvm.org/D50527 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50531: [NFC] Convert ParsedAttr to use llvm::TrailingObjects
erichkeane created this revision. erichkeane added reviewers: rjmccall, riccibruno, aaron.ballman. ParsedAttr is using a hand-rolled trailing-objects implementation that gets cleaned up quite a bit by just using llvm::TrailingObjects. This is a large TrailingObjects list, but most things are length '0'. https://reviews.llvm.org/D50531 Files: include/clang/Sema/ParsedAttr.h lib/Sema/ParsedAttr.cpp lib/Sema/SemaDeclCXX.cpp Index: lib/Sema/ParsedAttr.cpp === --- lib/Sema/ParsedAttr.cpp +++ lib/Sema/ParsedAttr.cpp @@ -41,8 +41,12 @@ else if (IsProperty) return AttributeFactory::PropertyAllocSize; else if (HasParsedType) -return sizeof(ParsedAttr) + sizeof(void *); - return (sizeof(ParsedAttr) + NumArgs * sizeof(ArgsUnion)); +return totalSizeToAlloc(0, 0, 0, 1, 0); + return totalSizeToAlloc(NumArgs, 0, 0, 0, 0); } AttributeFactory::AttributeFactory() { Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -15463,9 +15463,10 @@ PrevDecl = nullptr; SourceLocation TSSL = D.getLocStart(); - const ParsedAttr::PropertyData &Data = MSPropertyAttr.getPropertyData(); - MSPropertyDecl *NewPD = MSPropertyDecl::Create( - Context, Record, Loc, II, T, TInfo, TSSL, Data.GetterId, Data.SetterId); + MSPropertyDecl *NewPD = + MSPropertyDecl::Create(Context, Record, Loc, II, T, TInfo, TSSL, + MSPropertyAttr.getPropertyDataGetter(), + MSPropertyAttr.getPropertyDataSetter()); ProcessDeclAttributes(TUScope, NewPD, D); NewPD->setAccess(AS); Index: include/clang/Sema/ParsedAttr.h === --- include/clang/Sema/ParsedAttr.h +++ include/clang/Sema/ParsedAttr.h @@ -55,8 +55,7 @@ bool isValid() const { return !Version.empty(); } }; -namespace { - +namespace detail { enum AvailabilitySlot { IntroducedSlot, DeprecatedSlot, ObsoletedSlot, NumAvailabilitySlots }; @@ -78,6 +77,18 @@ } }; +struct TypeTagForDatatypeData { + ParsedType *MatchingCType; + unsigned LayoutCompatible : 1; + unsigned MustBeNull : 1; +}; +struct PropertyData { + IdentifierInfo *GetterId, *SetterId; + + PropertyData(IdentifierInfo *getterId, IdentifierInfo *setterId) + : GetterId(getterId), SetterId(setterId) {} +}; + } // namespace /// Wraps an identifier and optional source location for the identifier. @@ -103,7 +114,29 @@ /// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used. /// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used. /// -class ParsedAttr { +class ParsedAttr final +: private llvm::TrailingObjects< + ParsedAttr, ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> { + friend class llvm::TrailingObjects< + ParsedAttr, ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData>; + + size_t numTrailingObjects(OverloadToken) const { return NumArgs; } + size_t numTrailingObjects(OverloadToken) const { +return IsAvailability; + } + size_t + numTrailingObjects(OverloadToken) const { +return IsTypeTagForDatatype; + } + size_t numTrailingObjects(OverloadToken) const { +return HasParsedType; + } + size_t numTrailingObjects(OverloadToken) const { +return IsProperty; + } + public: /// The style used to specify an attribute. enum Syntax { @@ -183,34 +216,18 @@ const Expr *MessageExpr; - /// Arguments, if any, are stored immediately following the object. - ArgsUnion *getArgsBuffer() { return reinterpret_cast(this + 1); } + ArgsUnion *getArgsBuffer() { return getTrailingObjects(); } ArgsUnion const *getArgsBuffer() const { -return reinterpret_cast(this + 1); +return getTrailingObjects(); } - /// Availability information is stored immediately following the arguments, - /// if any, at the end of the object. - AvailabilityData *getAvailabilityData() { -return reinterpret_cast(getArgsBuffer() + NumArgs); + detail::AvailabilityData *getAvailabilityData() { +return getTrailingObjects(); } - const AvailabilityData *getAvailabilityData() const { -return reinterpret_cast(getArgsBuffer() + NumArgs); + const detail::AvailabilityData *getAvailabilityData() const { +return getTrailingObjects(); } -public: - struct TypeTagForDatatypeData { -ParsedType *MatchingCType; -unsigned LayoutCompatible : 1; -unsigned MustBeNull : 1; - }; - struct PropertyData { -IdentifierInfo *GetterId, *SetterId; - -PropertyData(IdentifierInfo *getterId, IdentifierInfo *setterId) -: GetterId(getterId), SetterId(setterId) {} - }; - private: friend class AttributeFactory; friend class AttributePool; @@ -245,7 +262,7 @@
[PATCH] D50530: Added LLVM metadata to generated IR to increase vectorization width
morehouse added inline comments. Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:141 +<< "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n" +<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize +<< "}\n"; I'm not sure `kArraySize` is what you want here. Does "width" refer to array size or the SIMD width? Any problem with letting the vectorizer determine this automatically? Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:142 +<< "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize +<< "}\n"; } Does this metadata change coverage in the vectorizer? Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h:18 +#include "../handle-llvm/input_arrays.h" + This include should be in the cpp file. Repository: rC Clang https://reviews.llvm.org/D50530 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339372 - Add getBeginLoc API to replace getLocStart
Author: steveire Date: Thu Aug 9 13:05:03 2018 New Revision: 339372 URL: http://llvm.org/viewvc/llvm-project?rev=339372&view=rev Log: Add getBeginLoc API to replace getLocStart Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50346 Modified: cfe/trunk/include/clang/AST/Comment.h cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/AST/DeclBase.h cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/include/clang/AST/DeclObjC.h cfe/trunk/include/clang/AST/DeclarationName.h cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/AST/ExprObjC.h cfe/trunk/include/clang/AST/ExprOpenMP.h cfe/trunk/include/clang/AST/OpenMPClause.h cfe/trunk/include/clang/AST/RawCommentList.h cfe/trunk/include/clang/AST/Stmt.h cfe/trunk/include/clang/AST/StmtCXX.h cfe/trunk/include/clang/AST/StmtObjC.h cfe/trunk/include/clang/AST/StmtOpenMP.h cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprCXX.cpp cfe/trunk/lib/AST/Stmt.cpp cfe/trunk/lib/Sema/SemaChecking.cpp Modified: cfe/trunk/include/clang/AST/Comment.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=339372&r1=339371&r2=339372&view=diff == --- cfe/trunk/include/clang/AST/Comment.h (original) +++ cfe/trunk/include/clang/AST/Comment.h Thu Aug 9 13:05:03 2018 @@ -215,9 +215,8 @@ public: SourceRange getSourceRange() const LLVM_READONLY { return Range; } - SourceLocation getLocStart() const LLVM_READONLY { -return Range.getBegin(); - } + SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); } SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=339372&r1=339371&r2=339372&view=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Thu Aug 9 13:05:03 2018 @@ -614,7 +614,8 @@ public: return SourceRange(LocStart, RBraceLoc); } - SourceLocation getLocStart() const LLVM_READONLY { return LocStart; } + SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const LLVM_READONLY { return LocStart; } SourceLocation getRBraceLoc() const { return RBraceLoc; } void setLocStart(SourceLocation L) { LocStart = L; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } @@ -735,7 +736,8 @@ public: SourceRange getSourceRange() const override LLVM_READONLY; - SourceLocation getLocStart() const LLVM_READONLY { + SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const LLVM_READONLY { return getOuterLocStart(); } @@ -2865,7 +2867,8 @@ public: const Type *getTypeForDecl() const { return TypeForDecl; } void setTypeForDecl(const Type *TD) { TypeForDecl = TD; } - SourceLocation getLocStart() const LLVM_READONLY { return LocStart; } + SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const LLVM_READONLY { return LocStart; } void setLocStart(SourceLocation L) { LocStart = L; } SourceRange getSourceRange() const override LLVM_READONLY { if (LocStart.isValid()) Modified: cfe/trunk/include/clang/AST/DeclBase.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=339372&r1=339371&r2=339372&view=diff == --- cfe/trunk/include/clang/AST/DeclBase.h (original) +++ cfe/trunk/include/clang/AST/DeclBase.h Thu Aug 9 13:05:03 2018 @@ -406,7 +406,8 @@ public: return SourceRange(getLocation(), getLocation()); } - SourceLocation getLocStart() const LLVM_READONLY { + SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const LLVM_READONLY { return getSourceRange().getBegin(); } Modified: cfe/trunk/include/clang/AST/DeclCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=339372&r1=339371&r2=339372&view=diff == --- cfe/trunk/include/clang/AST/DeclCXX.h (original) +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Aug 9 13:05:03 2018 @@ -233,7 +233,8 @@ public: /// Retrieves the source range that contains the entire base specifier. SourceRange getSourceRange() const LLVM_READONLY { return Range; } - SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } + SourceLocation getLocStart() const LLVM_READO
r339373 - Add getBeginLoc API to replace getStartLoc
Author: steveire Date: Thu Aug 9 13:05:18 2018 New Revision: 339373 URL: http://llvm.org/viewvc/llvm-project?rev=339373&view=rev Log: Add getBeginLoc API to replace getStartLoc Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50347 Modified: cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/AST/Stmt.h cfe/trunk/include/clang/Analysis/CloneDetection.h cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Modified: cfe/trunk/include/clang/AST/ExprCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=339373&r1=339372&r2=339373&view=diff == --- cfe/trunk/include/clang/AST/ExprCXX.h (original) +++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Aug 9 13:05:18 2018 @@ -2094,7 +2094,8 @@ public: return SubExprs + Array + hasInitializer() + getNumPlacementArgs(); } - SourceLocation getStartLoc() const { return Range.getBegin(); } + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const { return Range.getBegin(); } SourceLocation getEndLoc() const { return Range.getEnd(); } SourceRange getDirectInitRange() const { return DirectInitRange; } @@ -2104,7 +2105,6 @@ public: } SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } - SourceLocation getBeginLoc() const LLVM_READONLY { return getStartLoc(); } SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } static bool classof(const Stmt *T) { Modified: cfe/trunk/include/clang/AST/Stmt.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=339373&r1=339372&r2=339373&view=diff == --- cfe/trunk/include/clang/AST/Stmt.h (original) +++ cfe/trunk/include/clang/AST/Stmt.h Thu Aug 9 13:05:18 2018 @@ -523,7 +523,7 @@ public: DeclGroupRef getDeclGroup() { return DG; } void setDeclGroup(DeclGroupRef DGR) { DG = DGR; } - SourceLocation getStartLoc() const { return StartLoc; } + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } void setStartLoc(SourceLocation L) { StartLoc = L; } SourceLocation getEndLoc() const { return EndLoc; } void setEndLoc(SourceLocation L) { EndLoc = L; } Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=339373&r1=339372&r2=339373&view=diff == --- cfe/trunk/include/clang/Analysis/CloneDetection.h (original) +++ cfe/trunk/include/clang/Analysis/CloneDetection.h Thu Aug 9 13:05:18 2018 @@ -122,7 +122,8 @@ public: /// Returns the start sourcelocation of the first statement in this sequence. /// /// This method should only be called on a non-empty StmtSequence object. - SourceLocation getStartLoc() const; + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const; /// Returns the end sourcelocation of the last statement in this sequence. /// Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=339373&r1=339372&r2=339373&view=diff == --- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original) +++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu Aug 9 13:05:18 2018 @@ -67,7 +67,8 @@ public: void setStartLoc(SourceLocation Loc) { LocStart = Loc; } - SourceLocation getStartLoc() const { + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const { assert(LocStart && "Region has no start location"); return *LocStart; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50346: Add getBeginLoc API to replace getLocStart
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rL339372: Add getBeginLoc API to replace getLocStart (authored by steveire, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50346?vs=159357&id=159983#toc Repository: rL LLVM https://reviews.llvm.org/D50346 Files: cfe/trunk/include/clang/AST/Comment.h cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/AST/DeclBase.h cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/include/clang/AST/DeclObjC.h cfe/trunk/include/clang/AST/DeclarationName.h cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/AST/ExprObjC.h cfe/trunk/include/clang/AST/ExprOpenMP.h cfe/trunk/include/clang/AST/OpenMPClause.h cfe/trunk/include/clang/AST/RawCommentList.h cfe/trunk/include/clang/AST/Stmt.h cfe/trunk/include/clang/AST/StmtCXX.h cfe/trunk/include/clang/AST/StmtObjC.h cfe/trunk/include/clang/AST/StmtOpenMP.h cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprCXX.cpp cfe/trunk/lib/AST/Stmt.cpp cfe/trunk/lib/Sema/SemaChecking.cpp Index: cfe/trunk/lib/AST/Stmt.cpp === --- cfe/trunk/lib/AST/Stmt.cpp +++ cfe/trunk/lib/AST/Stmt.cpp @@ -275,8 +275,8 @@ llvm_unreachable("unknown statement kind!"); } -SourceLocation Stmt::getLocStart() const { -// llvm::errs() << "getLocStart() for " << getStmtClassName() << "\n"; +SourceLocation Stmt::getBeginLoc() const { + // llvm::errs() << "getBeginLoc() for " << getStmtClassName() << "\n"; switch (getStmtClass()) { case Stmt::NoStmtClass: llvm_unreachable("statement without class"); #define ABSTRACT_STMT(type) Index: cfe/trunk/lib/AST/ExprCXX.cpp === --- cfe/trunk/lib/AST/ExprCXX.cpp +++ cfe/trunk/lib/AST/ExprCXX.cpp @@ -89,7 +89,7 @@ } // CXXScalarValueInitExpr -SourceLocation CXXScalarValueInitExpr::getLocStart() const { +SourceLocation CXXScalarValueInitExpr::getBeginLoc() const { return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc; } @@ -450,7 +450,7 @@ return E; } -SourceLocation CXXConstructExpr::getLocStart() const { +SourceLocation CXXConstructExpr::getBeginLoc() const { if (isa(this)) return cast(this)->getLocStart(); return Loc; @@ -707,7 +707,7 @@ return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize); } -SourceLocation CXXFunctionalCastExpr::getLocStart() const { +SourceLocation CXXFunctionalCastExpr::getBeginLoc() const { return getTypeInfoAsWritten()->getTypeLoc().getLocStart(); } @@ -792,7 +792,7 @@ CXXConstructExpr::CK_Complete, ParenOrBraceRange), Type(TSI) {} -SourceLocation CXXTemporaryObjectExpr::getLocStart() const { +SourceLocation CXXTemporaryObjectExpr::getBeginLoc() const { return Type->getTypeLoc().getBeginLoc(); } @@ -1120,7 +1120,7 @@ return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs); } -SourceLocation CXXUnresolvedConstructExpr::getLocStart() const { +SourceLocation CXXUnresolvedConstructExpr::getBeginLoc() const { return Type->getTypeLoc().getBeginLoc(); } Index: cfe/trunk/lib/AST/Expr.cpp === --- cfe/trunk/lib/AST/Expr.cpp +++ cfe/trunk/lib/AST/Expr.cpp @@ -447,7 +447,7 @@ return new (Mem) DeclRefExpr(EmptyShell()); } -SourceLocation DeclRefExpr::getLocStart() const { +SourceLocation DeclRefExpr::getBeginLoc() const { if (hasQualifier()) return getQualifierLoc().getBeginLoc(); return getNameInfo().getLocStart(); @@ -1358,7 +1358,7 @@ return FnType->getReturnType(); } -SourceLocation CallExpr::getLocStart() const { +SourceLocation CallExpr::getBeginLoc() const { if (isa(this)) return cast(this)->getLocStart(); @@ -1529,7 +1529,7 @@ return E; } -SourceLocation MemberExpr::getLocStart() const { +SourceLocation MemberExpr::getBeginLoc() const { if (isImplicitAccess()) { if (hasQualifier()) return getQualifierLoc().getBeginLoc(); @@ -2039,7 +2039,7 @@ return Lit && Lit->getValue() == 0; } -SourceLocation InitListExpr::getLocStart() const { +SourceLocation InitListExpr::getBeginLoc() const { if (InitListExpr *SyntacticForm = getSyntacticForm()) return SyntacticForm->getLocStart(); SourceLocation Beg = LBraceLoc; @@ -3870,7 +3870,7 @@ DIE->getDesignator(size()-1)->getLocEnd()); } -SourceLocation DesignatedInitExpr::getLocStart() const { +SourceLocation DesignatedInitExpr::getBeginLoc() const { SourceLocation StartLoc; auto *DIE = const_cast(this); Designator &First = *DIE->getDesignator(0); @@ -3944,7 +3944,7 @@ BaseAndUpdaterExprs[1] = ILE; } -SourceLocation DesignatedInitUpd
[PATCH] D50346: Add getBeginLoc API to replace getLocStart
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rC339372: Add getBeginLoc API to replace getLocStart (authored by steveire, committed by ). Changed prior to commit: https://reviews.llvm.org/D50346?vs=159357&id=159984#toc Repository: rC Clang https://reviews.llvm.org/D50346 Files: include/clang/AST/Comment.h include/clang/AST/Decl.h include/clang/AST/DeclBase.h include/clang/AST/DeclCXX.h include/clang/AST/DeclObjC.h include/clang/AST/DeclarationName.h include/clang/AST/Expr.h include/clang/AST/ExprCXX.h include/clang/AST/ExprObjC.h include/clang/AST/ExprOpenMP.h include/clang/AST/OpenMPClause.h include/clang/AST/RawCommentList.h include/clang/AST/Stmt.h include/clang/AST/StmtCXX.h include/clang/AST/StmtObjC.h include/clang/AST/StmtOpenMP.h include/clang/Sema/DeclSpec.h lib/AST/Expr.cpp lib/AST/ExprCXX.cpp lib/AST/Stmt.cpp lib/Sema/SemaChecking.cpp Index: lib/AST/Expr.cpp === --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -447,7 +447,7 @@ return new (Mem) DeclRefExpr(EmptyShell()); } -SourceLocation DeclRefExpr::getLocStart() const { +SourceLocation DeclRefExpr::getBeginLoc() const { if (hasQualifier()) return getQualifierLoc().getBeginLoc(); return getNameInfo().getLocStart(); @@ -1358,7 +1358,7 @@ return FnType->getReturnType(); } -SourceLocation CallExpr::getLocStart() const { +SourceLocation CallExpr::getBeginLoc() const { if (isa(this)) return cast(this)->getLocStart(); @@ -1529,7 +1529,7 @@ return E; } -SourceLocation MemberExpr::getLocStart() const { +SourceLocation MemberExpr::getBeginLoc() const { if (isImplicitAccess()) { if (hasQualifier()) return getQualifierLoc().getBeginLoc(); @@ -2039,7 +2039,7 @@ return Lit && Lit->getValue() == 0; } -SourceLocation InitListExpr::getLocStart() const { +SourceLocation InitListExpr::getBeginLoc() const { if (InitListExpr *SyntacticForm = getSyntacticForm()) return SyntacticForm->getLocStart(); SourceLocation Beg = LBraceLoc; @@ -3870,7 +3870,7 @@ DIE->getDesignator(size()-1)->getLocEnd()); } -SourceLocation DesignatedInitExpr::getLocStart() const { +SourceLocation DesignatedInitExpr::getBeginLoc() const { SourceLocation StartLoc; auto *DIE = const_cast(this); Designator &First = *DIE->getDesignator(0); @@ -3944,7 +3944,7 @@ BaseAndUpdaterExprs[1] = ILE; } -SourceLocation DesignatedInitUpdateExpr::getLocStart() const { +SourceLocation DesignatedInitUpdateExpr::getBeginLoc() const { return getBase()->getLocStart(); } Index: lib/AST/Stmt.cpp === --- lib/AST/Stmt.cpp +++ lib/AST/Stmt.cpp @@ -275,8 +275,8 @@ llvm_unreachable("unknown statement kind!"); } -SourceLocation Stmt::getLocStart() const { -// llvm::errs() << "getLocStart() for " << getStmtClassName() << "\n"; +SourceLocation Stmt::getBeginLoc() const { + // llvm::errs() << "getBeginLoc() for " << getStmtClassName() << "\n"; switch (getStmtClass()) { case Stmt::NoStmtClass: llvm_unreachable("statement without class"); #define ABSTRACT_STMT(type) Index: lib/AST/ExprCXX.cpp === --- lib/AST/ExprCXX.cpp +++ lib/AST/ExprCXX.cpp @@ -89,7 +89,7 @@ } // CXXScalarValueInitExpr -SourceLocation CXXScalarValueInitExpr::getLocStart() const { +SourceLocation CXXScalarValueInitExpr::getBeginLoc() const { return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc; } @@ -450,7 +450,7 @@ return E; } -SourceLocation CXXConstructExpr::getLocStart() const { +SourceLocation CXXConstructExpr::getBeginLoc() const { if (isa(this)) return cast(this)->getLocStart(); return Loc; @@ -707,7 +707,7 @@ return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize); } -SourceLocation CXXFunctionalCastExpr::getLocStart() const { +SourceLocation CXXFunctionalCastExpr::getBeginLoc() const { return getTypeInfoAsWritten()->getTypeLoc().getLocStart(); } @@ -792,7 +792,7 @@ CXXConstructExpr::CK_Complete, ParenOrBraceRange), Type(TSI) {} -SourceLocation CXXTemporaryObjectExpr::getLocStart() const { +SourceLocation CXXTemporaryObjectExpr::getBeginLoc() const { return Type->getTypeLoc().getBeginLoc(); } @@ -1120,7 +1120,7 @@ return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs); } -SourceLocation CXXUnresolvedConstructExpr::getLocStart() const { +SourceLocation CXXUnresolvedConstructExpr::getBeginLoc() const { return Type->getTypeLoc().getBeginLoc(); } Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -6121,7 +6121,8 @@
[PATCH] D50347: Add getBeginLoc API to replace getStartLoc
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rC339373: Add getBeginLoc API to replace getStartLoc (authored by steveire, committed by ). Changed prior to commit: https://reviews.llvm.org/D50347?vs=159358&id=159986#toc Repository: rC Clang https://reviews.llvm.org/D50347 Files: include/clang/AST/ExprCXX.h include/clang/AST/Stmt.h include/clang/Analysis/CloneDetection.h lib/CodeGen/CoverageMappingGen.cpp Index: lib/CodeGen/CoverageMappingGen.cpp === --- lib/CodeGen/CoverageMappingGen.cpp +++ lib/CodeGen/CoverageMappingGen.cpp @@ -67,7 +67,8 @@ void setStartLoc(SourceLocation Loc) { LocStart = Loc; } - SourceLocation getStartLoc() const { + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const { assert(LocStart && "Region has no start location"); return *LocStart; } Index: include/clang/AST/ExprCXX.h === --- include/clang/AST/ExprCXX.h +++ include/clang/AST/ExprCXX.h @@ -2094,7 +2094,8 @@ return SubExprs + Array + hasInitializer() + getNumPlacementArgs(); } - SourceLocation getStartLoc() const { return Range.getBegin(); } + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const { return Range.getBegin(); } SourceLocation getEndLoc() const { return Range.getEnd(); } SourceRange getDirectInitRange() const { return DirectInitRange; } @@ -2104,7 +2105,6 @@ } SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } - SourceLocation getBeginLoc() const LLVM_READONLY { return getStartLoc(); } SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } static bool classof(const Stmt *T) { Index: include/clang/AST/Stmt.h === --- include/clang/AST/Stmt.h +++ include/clang/AST/Stmt.h @@ -523,7 +523,7 @@ DeclGroupRef getDeclGroup() { return DG; } void setDeclGroup(DeclGroupRef DGR) { DG = DGR; } - SourceLocation getStartLoc() const { return StartLoc; } + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } void setStartLoc(SourceLocation L) { StartLoc = L; } SourceLocation getEndLoc() const { return EndLoc; } void setEndLoc(SourceLocation L) { EndLoc = L; } Index: include/clang/Analysis/CloneDetection.h === --- include/clang/Analysis/CloneDetection.h +++ include/clang/Analysis/CloneDetection.h @@ -122,7 +122,8 @@ /// Returns the start sourcelocation of the first statement in this sequence. /// /// This method should only be called on a non-empty StmtSequence object. - SourceLocation getStartLoc() const; + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const; /// Returns the end sourcelocation of the last statement in this sequence. /// Index: lib/CodeGen/CoverageMappingGen.cpp === --- lib/CodeGen/CoverageMappingGen.cpp +++ lib/CodeGen/CoverageMappingGen.cpp @@ -67,7 +67,8 @@ void setStartLoc(SourceLocation Loc) { LocStart = Loc; } - SourceLocation getStartLoc() const { + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const { assert(LocStart && "Region has no start location"); return *LocStart; } Index: include/clang/AST/ExprCXX.h === --- include/clang/AST/ExprCXX.h +++ include/clang/AST/ExprCXX.h @@ -2094,7 +2094,8 @@ return SubExprs + Array + hasInitializer() + getNumPlacementArgs(); } - SourceLocation getStartLoc() const { return Range.getBegin(); } + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const { return Range.getBegin(); } SourceLocation getEndLoc() const { return Range.getEnd(); } SourceRange getDirectInitRange() const { return DirectInitRange; } @@ -2104,7 +2105,6 @@ } SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } - SourceLocation getBeginLoc() const LLVM_READONLY { return getStartLoc(); } SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } static bool classof(const Stmt *T) { Index: include/clang/AST/Stmt.h === --- include/clang/AST/Stmt.h +++ include/clang/AST/Stmt.h @@ -523,7 +523,7 @@ DeclGroupRef getDeclGroup() { return DG; } void setDeclGroup(DeclGroupRef DGR) { DG = DGR; } - SourceLocation getStartLoc() const { return StartLoc; } + SourceLocation getStartLoc() con
[PATCH] D50347: Add getBeginLoc API to replace getStartLoc
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rL339373: Add getBeginLoc API to replace getStartLoc (authored by steveire, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50347?vs=159358&id=159985#toc Repository: rL LLVM https://reviews.llvm.org/D50347 Files: cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/AST/Stmt.h cfe/trunk/include/clang/Analysis/CloneDetection.h cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp === --- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp +++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp @@ -67,7 +67,8 @@ void setStartLoc(SourceLocation Loc) { LocStart = Loc; } - SourceLocation getStartLoc() const { + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const { assert(LocStart && "Region has no start location"); return *LocStart; } Index: cfe/trunk/include/clang/AST/Stmt.h === --- cfe/trunk/include/clang/AST/Stmt.h +++ cfe/trunk/include/clang/AST/Stmt.h @@ -523,7 +523,7 @@ DeclGroupRef getDeclGroup() { return DG; } void setDeclGroup(DeclGroupRef DGR) { DG = DGR; } - SourceLocation getStartLoc() const { return StartLoc; } + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } void setStartLoc(SourceLocation L) { StartLoc = L; } SourceLocation getEndLoc() const { return EndLoc; } void setEndLoc(SourceLocation L) { EndLoc = L; } Index: cfe/trunk/include/clang/AST/ExprCXX.h === --- cfe/trunk/include/clang/AST/ExprCXX.h +++ cfe/trunk/include/clang/AST/ExprCXX.h @@ -2094,7 +2094,8 @@ return SubExprs + Array + hasInitializer() + getNumPlacementArgs(); } - SourceLocation getStartLoc() const { return Range.getBegin(); } + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const { return Range.getBegin(); } SourceLocation getEndLoc() const { return Range.getEnd(); } SourceRange getDirectInitRange() const { return DirectInitRange; } @@ -2104,7 +2105,6 @@ } SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } - SourceLocation getBeginLoc() const LLVM_READONLY { return getStartLoc(); } SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } static bool classof(const Stmt *T) { Index: cfe/trunk/include/clang/Analysis/CloneDetection.h === --- cfe/trunk/include/clang/Analysis/CloneDetection.h +++ cfe/trunk/include/clang/Analysis/CloneDetection.h @@ -122,7 +122,8 @@ /// Returns the start sourcelocation of the first statement in this sequence. /// /// This method should only be called on a non-empty StmtSequence object. - SourceLocation getStartLoc() const; + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const; /// Returns the end sourcelocation of the last statement in this sequence. /// Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp === --- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp +++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp @@ -67,7 +67,8 @@ void setStartLoc(SourceLocation Loc) { LocStart = Loc; } - SourceLocation getStartLoc() const { + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getBeginLoc() const { assert(LocStart && "Region has no start location"); return *LocStart; } Index: cfe/trunk/include/clang/AST/Stmt.h === --- cfe/trunk/include/clang/AST/Stmt.h +++ cfe/trunk/include/clang/AST/Stmt.h @@ -523,7 +523,7 @@ DeclGroupRef getDeclGroup() { return DG; } void setDeclGroup(DeclGroupRef DGR) { DG = DGR; } - SourceLocation getStartLoc() const { return StartLoc; } + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } void setStartLoc(SourceLocation L) { StartLoc = L; } SourceLocation getEndLoc() const { return EndLoc; } void setEndLoc(SourceLocation L) { EndLoc = L; } Index: cfe/trunk/include/clang/AST/ExprCXX.h === --- cfe/trunk/include/clang/AST/ExprCXX.h +++ cfe/trunk/include/clang/AST/ExprCXX.h @@ -2094,7 +2094,8 @@ return SubExprs + Array + hasInitializer() + getNumPlacementArgs(); } - SourceLocation getStartLoc() const { return Range.getBegin(); } + SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); } + Sour
r339374 - Add getEndLoc API to replace getLocEnd
Author: steveire Date: Thu Aug 9 13:05:47 2018 New Revision: 339374 URL: http://llvm.org/viewvc/llvm-project?rev=339374&view=rev Log: Add getEndLoc API to replace getLocEnd Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50348 Modified: cfe/trunk/include/clang/AST/Comment.h cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/AST/DeclBase.h cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/include/clang/AST/DeclObjC.h cfe/trunk/include/clang/AST/DeclarationName.h cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/AST/ExprObjC.h cfe/trunk/include/clang/AST/ExprOpenMP.h cfe/trunk/include/clang/AST/OpenMPClause.h cfe/trunk/include/clang/AST/RawCommentList.h cfe/trunk/include/clang/AST/Stmt.h cfe/trunk/include/clang/AST/StmtCXX.h cfe/trunk/include/clang/AST/StmtObjC.h cfe/trunk/include/clang/AST/StmtOpenMP.h cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/lib/AST/DeclObjC.cpp cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprCXX.cpp cfe/trunk/lib/AST/Stmt.cpp cfe/trunk/lib/AST/StmtObjC.cpp cfe/trunk/lib/Sema/SemaChecking.cpp Modified: cfe/trunk/include/clang/AST/Comment.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Comment.h?rev=339374&r1=339373&r2=339374&view=diff == --- cfe/trunk/include/clang/AST/Comment.h (original) +++ cfe/trunk/include/clang/AST/Comment.h Thu Aug 9 13:05:47 2018 @@ -218,9 +218,8 @@ public: SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); } - SourceLocation getLocEnd() const LLVM_READONLY { -return Range.getEnd(); - } + SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } + SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); } SourceLocation getLocation() const LLVM_READONLY { return Loc; } Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=339374&r1=339373&r2=339374&view=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Thu Aug 9 13:05:47 2018 @@ -4195,7 +4195,8 @@ public: SourceLocation getRBraceLoc() const { return RBraceLoc; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } - SourceLocation getLocEnd() const LLVM_READONLY { + SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } + SourceLocation getEndLoc() const LLVM_READONLY { if (RBraceLoc.isValid()) return RBraceLoc; // No braces: get the end location of the (only) declaration in context Modified: cfe/trunk/include/clang/AST/DeclBase.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=339374&r1=339373&r2=339374&view=diff == --- cfe/trunk/include/clang/AST/DeclBase.h (original) +++ cfe/trunk/include/clang/AST/DeclBase.h Thu Aug 9 13:05:47 2018 @@ -411,7 +411,8 @@ public: return getSourceRange().getBegin(); } - SourceLocation getLocEnd() const LLVM_READONLY { + SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } + SourceLocation getEndLoc() const LLVM_READONLY { return getSourceRange().getEnd(); } Modified: cfe/trunk/include/clang/AST/DeclCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=339374&r1=339373&r2=339374&view=diff == --- cfe/trunk/include/clang/AST/DeclCXX.h (original) +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Aug 9 13:05:47 2018 @@ -235,7 +235,8 @@ public: SourceRange getSourceRange() const LLVM_READONLY { return Range; } SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); } - SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } + SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } + SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); } /// Get the location at which the base class type was written. SourceLocation getBaseTypeLoc() const LLVM_READONLY { @@ -2871,7 +2872,8 @@ public: LinkageSpecDeclBits.HasBraces = RBraceLoc.isValid(); } - SourceLocation getLocEnd() const LLVM_READONLY { + SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } + SourceLocation getEndLoc() const LLVM_READONLY { if (hasBraces()) return getRBraceLoc(); // No braces: get the end location of the (only) declaration in context Modified: cfe/trunk/include/clang/AST/DeclObjC.h
[PATCH] D50531: [NFC] Convert ParsedAttr to use llvm::TrailingObjects
erichkeane added inline comments. Comment at: include/clang/Sema/ParsedAttr.h:80 +struct TypeTagForDatatypeData { + ParsedType *MatchingCType; Because all of these became part of the TYPE of ParsedAttr now, they need to be defined outside of ParsedAttr. Additionally, they are now required to be in a non-anonymous namespace. Comment at: include/clang/Sema/ParsedAttr.h:525 - const PropertyData &getPropertyData() const { -assert(isDeclspecPropertyAttribute() && "Not a __delcspec(property) attribute"); -return getPropertyDataBuffer(); + IdentifierInfo *getPropertyDataGetter() const { +assert(isDeclspecPropertyAttribute() && Unfortunately, these need to return a non-const param, since the only user of these takes a const ParsedAttr and requires the IdentifierInfo* to be a non-const ptr. Comment at: include/clang/Sema/ParsedAttr.h:578 AvailabilityAllocSize = -sizeof(ParsedAttr) + -((sizeof(AvailabilityData) + sizeof(void *) + sizeof(ArgsUnion) - 1) / - sizeof(void *) * sizeof(void *)), -TypeTagForDatatypeAllocSize = sizeof(ParsedAttr) + - (sizeof(ParsedAttr::TypeTagForDatatypeData) + - sizeof(void *) + sizeof(ArgsUnion) - 1) / - sizeof(void *) * sizeof(void *), +ParsedAttr::totalSizeToAllochttps://reviews.llvm.org/D50531 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits