[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. LG. Thanks! Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45392 ___ 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 updated this revision to Diff 143243. HsiangKai added a comment. - Update test cases. - Checked with clang-format. Repository: rC Clang https://reviews.llvm.org/D45045 Files: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/CodeGen/CGStmt.cpp test/CodeGen/backend-unsupported-error.ll test/CodeGen/debug-label-inline.c test/CodeGen/debug-label.c Index: test/CodeGen/debug-label.c === --- /dev/null +++ test/CodeGen/debug-label.c @@ -0,0 +1,16 @@ +// This test will test the correstness of generating DILabel and +// llvm.dbg.label for labels. +// +// RUN: %clang_cc1 -emit-llvm %s -o - -emit-llvm -debug-info-kind=limited | FileCheck %s + +int f1(int a, int b) { + int sum; + +top: + // CHECK: call void @llvm.dbg.label(metadata [[LABEL_METADATA:!.*]]), !dbg [[LABEL_LOCATION:!.*]] + sum = a + b; + return sum; +} + +// CHECK: [[LABEL_METADATA]] = !DILabel({{.*}}, name: "top", {{.*}}, line: 9) +// CHECK: [[LABEL_LOCATION]] = !DILocation(line: 9, Index: test/CodeGen/debug-label-inline.c === --- /dev/null +++ test/CodeGen/debug-label-inline.c @@ -0,0 +1,28 @@ +// This test will test the correctness of generating DILabel and +// llvm.dbg.label when the label is in inlined functions. +// +// RUN: %clang_cc1 -O2 %s -o - -emit-llvm -debug-info-kind=limited | FileCheck %s +inline int f1(int a, int b) { + int sum; + +top: + sum = a + b; + return sum; +} + +extern int ga, gb; + +int f2(void) { + int result; + + result = f1(ga, gb); + // CHECK: call void @llvm.dbg.label(metadata [[LABEL_METADATA:!.*]]), !dbg [[LABEL_LOCATION:!.*]] + + return result; +} + +// CHECK: distinct !DISubprogram(name: "f1", {{.*}}, retainedNodes: [[ELEMENTS:!.*]]) +// CHECK: [[ELEMENTS]] = !{{{.*}}, [[LABEL_METADATA]]} +// CHECK: [[LABEL_METADATA]] = !DILabel({{.*}}, name: "top", {{.*}}, line: 8) +// CHECK: [[INLINEDAT:!.*]] = distinct !DILocation(line: 18, +// CHECK: [[LABEL_LOCATION]] = !DILocation(line: 8, {{.*}}, inlinedAt: [[INLINEDAT]]) Index: test/CodeGen/backend-unsupported-error.ll === --- test/CodeGen/backend-unsupported-error.ll +++ test/CodeGen/backend-unsupported-error.ll @@ -30,11 +30,11 @@ !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2) !1 = !DIFile(filename: "test.c", directory: "") !2 = !{} -!4 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, variables: !2) +!4 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, retainedNodes: !2) !5 = !DISubroutineType(types: !6) !6 = !{!7} !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) +!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) !9 = !{i32 2, !"Dwarf Version", i32 4} !10 = !{i32 2, !"Debug Info Version", i32 3} !11 = !{!"clang version 3.9.0"} Index: lib/CodeGen/CGStmt.cpp === --- lib/CodeGen/CGStmt.cpp +++ lib/CodeGen/CGStmt.cpp @@ -531,6 +531,16 @@ } EmitBlock(Dest.getBlock()); + + // Emit debug info for labels. + if (CGDebugInfo *DI = getDebugInfo()) { +if (CGM.getCodeGenOpts().getDebugInfo() >= +codegenoptions::LimitedDebugInfo) { + DI->setLocation(D->getLocation()); + DI->EmitLabel(D, Builder); +} + } + incrementProfileCounter(D->getStmt()); } Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -395,6 +395,9 @@ llvm::Value *AI, CGBuilderTy &Builder); + /// Emit call to \c llvm.dbg.label for an label. + void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder); + /// Emit call to \c llvm.dbg.declare for an imported variable /// declaration in a block. void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable, Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -3640,6 +3640,32 @@ return EmitDeclare(VD, Storage, llvm::None, Builder); } +void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBu
[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line
djasper added inline comments. Comment at: include/clang/Format/Format.h:154 + /// \brief If a function call, initializer list, or template + /// argument list doesn't fit on a line, allow putting all writing just "initializer list" is confusing, especially next to the constructor initializer list below. Maybe "brace initializer list"? Also, if this influences initializer lists and template argument lists, please add tests for those. If you change this file, please run docs/tools/dump_format_style.py to update the docs. (also, why is this comment so narrow?) Comment at: include/clang/Format/Format.h:171 + + /// \brief If a constructor initializer list doesn't fit on a line, allow + /// putting all initializers onto the next line, if I think this comment is a bit confusing. The "initializer list" does fit on one line. Comment at: lib/Format/ContinuationIndenter.cpp:757 +Previous.is(TT_DictLiteral) || +(!Style.AllowAllArgumentsOnNextLine && !State.Line->MustBeDeclaration)) State.Stack.back().BreakBeforeParameter = true; nitpick: move this up one line so it's next to the case for AllowAllParametersOfDeclarationOnNextLine. Comment at: unittests/Format/FormatTest.cpp:3438 + FormatStyle Style = getLLVMStyle(); + Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma; + Style.ColumnLimit = 60; Only testing this for BCIS_BeforeComma seems a bit bad to me. Is there a reason for it? Also, I think we should have a test where the constructor declaration itself does not fit on one line, e.g. what's the behavior for: Constructor(int param1, ... int paramN) { : aa(a), b(b) { .. } https://reviews.llvm.org/D40988 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name
SimeonEhrig updated this revision to Diff 143246. SimeonEhrig added a comment. Add full context with -U99 to diff. https://reviews.llvm.org/D44435 Files: lib/CodeGen/CGCUDANV.cpp unittests/CodeGen/IncrementalProcessingTest.cpp Index: unittests/CodeGen/IncrementalProcessingTest.cpp === --- unittests/CodeGen/IncrementalProcessingTest.cpp +++ unittests/CodeGen/IncrementalProcessingTest.cpp @@ -21,9 +21,11 @@ #include "llvm/IR/Module.h" #include "llvm/Support/Host.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Target/TargetOptions.h" #include "gtest/gtest.h" #include +#include using namespace llvm; using namespace clang; @@ -171,4 +173,122 @@ } + +// In CUDA incremental processing, a CUDA ctor or dtor will be generated for +// every statement if a fatbinary file exists. +const char CUDATestProgram1[] = +"void cudaFunc1(){}\n"; + +const char CUDATestProgram2[] = +"void cudaFunc2(){}\n"; + +const Function* getCUDActor(llvm::Module& M) { + for (const auto& Func: M) +if (Func.hasName() && Func.getName().startswith("__cuda_module_ctor_")) + return &Func; + + return nullptr; +} + +const Function* getCUDAdtor(llvm::Module& M) { + for (const auto& Func: M) +if (Func.hasName() && Func.getName().startswith("__cuda_module_dtor_")) + return &Func; + + return nullptr; +} + +TEST(IncrementalProcessing, EmitCUDAGlobalInitFunc) { +LLVMContext Context; +CompilerInstance compiler; + +compiler.createDiagnostics(); +compiler.getLangOpts().CPlusPlus = 1; +compiler.getLangOpts().CPlusPlus11 = 1; +compiler.getLangOpts().CUDA = 1; + +compiler.getTargetOpts().Triple = llvm::Triple::normalize( +llvm::sys::getProcessTriple()); +compiler.setTarget(clang::TargetInfo::CreateTargetInfo( + compiler.getDiagnostics(), + std::make_shared( +compiler.getTargetOpts(; + +// To enable the generating of cuda host code, it's needs to set up the +// auxTriple. +llvm::Triple hostTriple(llvm::sys::getProcessTriple()); +compiler.getFrontendOpts().AuxTriple = +hostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda"; +auto targetOptions = std::make_shared(); +targetOptions->Triple = compiler.getFrontendOpts().AuxTriple; +targetOptions->HostTriple = compiler.getTarget().getTriple().str(); +compiler.setAuxTarget(clang::TargetInfo::CreateTargetInfo( +compiler.getDiagnostics(), targetOptions)); + +// A fatbinary file is necessary, that the code generator generates the ctor +// and dtor. +auto tmpFatbinFileOrError = llvm::sys::fs::TempFile::create("dummy.fatbin"); +ASSERT_TRUE((bool)tmpFatbinFileOrError); +auto tmpFatbinFile = std::move(*tmpFatbinFileOrError); +compiler.getCodeGenOpts().CudaGpuBinaryFileName = tmpFatbinFile.TmpName; + +compiler.createFileManager(); +compiler.createSourceManager(compiler.getFileManager()); +compiler.createPreprocessor(clang::TU_Prefix); +compiler.getPreprocessor().enableIncrementalProcessing(); + +compiler.createASTContext(); + +CodeGenerator* CG = +CreateLLVMCodeGen( +compiler.getDiagnostics(), +"main-module", +compiler.getHeaderSearchOpts(), +compiler.getPreprocessorOpts(), +compiler.getCodeGenOpts(), +Context); + +compiler.setASTConsumer(std::unique_ptr(CG)); +compiler.createSema(clang::TU_Prefix, nullptr); +Sema& S = compiler.getSema(); + +std::unique_ptr ParseOP(new Parser(S.getPreprocessor(), S, + /*SkipFunctionBodies*/ false)); +Parser &P = *ParseOP.get(); + +std::array, 3> M; +M[0] = IncrementalParseAST(compiler, P, *CG, nullptr); +ASSERT_TRUE(M[0]); + +M[1] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram1); +ASSERT_TRUE(M[1]); +ASSERT_TRUE(M[1]->getFunction("_Z9cudaFunc1v")); + +M[2] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram2); +ASSERT_TRUE(M[2]); +ASSERT_TRUE(M[2]->getFunction("_Z9cudaFunc2v")); +// First code should not end up in second module: +ASSERT_FALSE(M[2]->getFunction("_Z9cudaFunc1v")); + +// Make sure, that cuda ctor's and dtor's exist: +const Function* CUDActor1 = getCUDActor(*M[1]); +ASSERT_TRUE(CUDActor1); + +const Function* CUDActor2 = getCUDActor(*M[2]); +ASSERT_TRUE(CUDActor2); + +const Function* CUDAdtor1 = getCUDAdtor(*M[1]); +ASSERT_TRUE(CUDAdtor1); + +const Function* CUDAdtor2 = getCUDAdtor(*M[2]); +ASSERT_TRUE(CUDAdtor2); + +// Compare the names of both ctor's and dtor's to check, that they are +// unique. +ASSERT_FALSE(CUDActor1->getName() == CUDActor2->getName()); +ASSERT_FALSE(CUDAdtor1->getName() == CUDAdtor2->getName()); + +ASSERT_FALSE((bool)tmpFatbinFile.discard()); +} + } // end anonymous namespace Index: lib/CodeGen/CGCUDAN
[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros
klimek added inline comments. Comment at: lib/Format/WhitespaceManager.cpp:438 + + AlignTokens(Style, + [&](const Change &C) { I'm not sure whether we should use AlignTokens here, given that we pass in a parameter to basically skip all its interesting logic. What I'd personally do is try to implement the alignment of macros on their own merit from scratch, which should be significantly simpler, and then look for whether we can pull out common functions between AlignTokens and that implementation to further reduce duplication. Repository: rL LLVM https://reviews.llvm.org/D28462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45808: [OpenCL] Add 'denorms-are-zero' function attribute
This revision was automatically updated to reflect the committed changes. Closed by commit rL330404: [OpenCL] Add 'denorms-are-zero' function attribute (authored by AlexeySotkin, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D45808 Files: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl Index: cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl === --- cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl +++ cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl @@ -1,19 +1,25 @@ -// RUN: %clang_cc1 -S -cl-denorms-are-zero -o - %s 2>&1 -// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s -// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=CHECK-DENORM -// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck --check-prefix=CHECK-FEATURE %s +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - %s | FileCheck %s --check-prefix=DENORM-ZERO +// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=AMDGCN +// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=AMDGCN-DENORM +// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck --check-prefix=AMDGCN-FEATURE %s -// For non-amdgcn targets, this test just checks that the -cl-denorms-are-zero argument is accepted -// by clang. This option is currently a no-op, which is allowed by the -// OpenCL specification. +// For all targets 'denorms-are-zero' attribute is set to 'true' +// if '-cl-denorms-are-zero' was specified and to 'false' otherwise. + +// CHECK-LABEL: define void @f() +// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="false" +// +// DENORM-ZERO-LABEL: define void @f() +// DENORM-ZERO: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" // For amdgcn target cpu fiji, fp32 should be flushed since fiji does not support fp32 denormals, unless +fp32-denormals is // explicitly set. amdgcn target always do not flush fp64 denormals. The control for fp64 and fp16 denormals is the same. -// CHECK-DENORM-LABEL: define void @f() -// CHECK-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}" -// CHECK-LABEL: define void @f() -// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}" -// CHECK-FEATURE-LABEL: define void @f() -// CHECK-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-denormals{{[^"]*}}" +// AMDGCN-LABEL: define void @f() +// AMDGCN: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" {{.*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}" +// AMDGCN-DENORM-LABEL: define void @f() +// AMDGCN-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="false" {{.*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}" +// AMDGCN-FEATURE-LABEL: define void @f() +// AMDGCN-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" {{.*}} "target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-denormals{{[^"]*}}" void f() {} Index: cfe/trunk/lib/CodeGen/CGCall.cpp === --- cfe/trunk/lib/CodeGen/CGCall.cpp +++ cfe/trunk/lib/CodeGen/CGCall.cpp @@ -1745,6 +1745,10 @@ "correctly-rounded-divide-sqrt-fp-math", llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt)); +if (getLangOpts().OpenCL) + FuncAttrs.addAttribute("denorms-are-zero", + llvm::toStringRef(CodeGenOpts.FlushDenorm)); + // TODO: Reciprocal estimate codegen options should apply to instructions? const std::vector &Recips = CodeGenOpts.Reciprocals; if (!Recips.empty()) Index: cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl === --- cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl +++ cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl @@ -1,19 +1,25 @@ -// RUN: %clang_cc1 -S -cl-denorms-are-zero -o - %s 2>&1 -// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s -// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=CHECK-DENORM -// RUN: %clang_cc1 -e
[PATCH] D45254: [X86] WaitPKG intrinsics
GBuella updated this revision to Diff 143249. GBuella retitled this revision from "[X86][WAITPKG] WaitPKG intrinsics" to "[X86] WaitPKG intrinsics". https://reviews.llvm.org/D45254 Files: include/clang/Basic/BuiltinsX86.def include/clang/Driver/Options.td lib/Basic/Targets/X86.cpp lib/Basic/Targets/X86.h lib/Headers/CMakeLists.txt lib/Headers/cpuid.h lib/Headers/waitpkgintrin.h lib/Headers/x86intrin.h test/CodeGen/waitpkg.c test/Driver/x86-target-features.c test/Preprocessor/predefined-arch-macros.c Index: test/Preprocessor/predefined-arch-macros.c === --- test/Preprocessor/predefined-arch-macros.c +++ test/Preprocessor/predefined-arch-macros.c @@ -1482,6 +1482,7 @@ // CHECK_TRM_M32: #define __SSE_MATH__ 1 // CHECK_TRM_M32: #define __SSE__ 1 // CHECK_TRM_M32: #define __SSSE3__ 1 +// CHECK_TRM_M32: #define __WAITPKG__ 1 // CHECK_TRM_M32: #define __XSAVEC__ 1 // CHECK_TRM_M32: #define __XSAVEOPT__ 1 // CHECK_TRM_M32: #define __XSAVES__ 1 @@ -1518,6 +1519,7 @@ // CHECK_TRM_M64: #define __SSE4_2__ 1 // CHECK_TRM_M64: #define __SSE__ 1 // CHECK_TRM_M64: #define __SSSE3__ 1 +// CHECK_TRM_M64: #define __WAITPKG__ 1 // CHECK_TRM_M64: #define __XSAVEC__ 1 // CHECK_TRM_M64: #define __XSAVEOPT__ 1 // CHECK_TRM_M64: #define __XSAVES__ 1 Index: test/Driver/x86-target-features.c === --- test/Driver/x86-target-features.c +++ test/Driver/x86-target-features.c @@ -144,3 +144,8 @@ // RUN: %clang -target i386-linux-gnu -mretpoline -mno-retpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-RETPOLINE-EXTERNAL-THUNK %s // RETPOLINE-EXTERNAL-THUNK: "-target-feature" "+retpoline-external-thunk" // NO-RETPOLINE-EXTERNAL-THUNK: "-target-feature" "-retpoline-external-thunk" + +// RUN: %clang -target i386-linux-gnu -mwaitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=WAITPKG %s +// RUN: %clang -target i386-linux-gnu -mno-waitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-WAITPKG %s +// WAITPKG: "-target-feature" "+waitpkg" +// NO-WAITPKG: "-target-feature" "-waitpkg" Index: test/CodeGen/waitpkg.c === --- /dev/null +++ test/CodeGen/waitpkg.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -target-feature +waitpkg -Wall -pedantic -o - | FileCheck %s +// RUN: %clang_cc1 %s -ffreestanding -triple i386-unknown-unknown -emit-llvm -target-feature +waitpkg -Wall -pedantic -o - | FileCheck %s + +#include + +#include +#include + +void test_umonitor(void *address) { + //CHECK-LABEL: @test_umonitor + //CHECK: call void @llvm.x86.umonitor(i8* %{{.*}}) + return _umonitor(address); +} + +uint8_t test_umwait(uint32_t control, uint64_t counter) { + //CHECK-LABEL: @test_umwait + //CHECK: call i8 @llvm.x86.umwait(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _umwait(control, counter); +} + +uint8_t test_tpause(uint32_t control, uint64_t counter) { + //CHECK-LABEL: @test_tpause + //CHECK: call i8 @llvm.x86.tpause(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _tpause(control, counter); +} Index: lib/Headers/x86intrin.h === --- lib/Headers/x86intrin.h +++ lib/Headers/x86intrin.h @@ -96,4 +96,8 @@ #include #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__WAITPKG__) +#include +#endif + #endif /* __X86INTRIN_H */ Index: lib/Headers/waitpkgintrin.h === --- /dev/null +++ lib/Headers/waitpkgintrin.h @@ -0,0 +1,56 @@ +/*===--- waitpkgintrin.h - WAITPKG === + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===---=== + */ +#ifndef __X86INTRIN_H +#error
[PATCH] D45865: [Sema] Emit -Warray-bounds for multiple levels of subscript expressions.
ebevhan created this revision. ebevhan added reviewers: danielmarjamaki, aaron.ballman. Herald added a subscriber: cfe-commits. This patch has CheckArrayBounds recurse into ArraySubscriptExprs and MemberExprs, giving warnings for invalid indices for every level of subscript instead of just the topmost one. Repository: rC Clang https://reviews.llvm.org/D45865 Files: lib/Sema/SemaChecking.cpp test/SemaCXX/array-bounds.cpp test/SemaCXX/constant-expression-cxx11.cpp Index: test/SemaCXX/constant-expression-cxx11.cpp === --- test/SemaCXX/constant-expression-cxx11.cpp +++ test/SemaCXX/constant-expression-cxx11.cpp @@ -528,15 +528,18 @@ constexpr int xs0 = p[-3]; // ok constexpr int xs_1 = p[-4]; // expected-error {{constant expression}} expected-note {{cannot refer to element -1}} -constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; +constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; // expected-note {{array 'zs' declared here}} static_assert(zs[0][0][0][0] == 1, ""); static_assert(zs[1][1][1][1] == 16, ""); static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}} static_assert((&zs[0][0][0][2])[-1] == 2, ""); static_assert(**(**(zs + 1) + 1) == 11, ""); static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][-1] + 1) == 11, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1 of array of 2 elements in a constant expression}} static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2) == 11, ""); -constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // expected-error {{constant expression}} expected-note {{cannot access array element of pointer past the end}} +constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // \ +expected-error {{constant expression}} \ +expected-note {{cannot access array element of pointer past the end}} \ +expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} constexpr int fail(const int &p) { return (&p)[64]; // expected-note {{cannot refer to element 64 of array of 2 elements}} Index: test/SemaCXX/array-bounds.cpp === --- test/SemaCXX/array-bounds.cpp +++ test/SemaCXX/array-bounds.cpp @@ -269,3 +269,16 @@ struct P x[10] = {0}; // expected-note {{array 'x' declared here}} return x[1] + x[11]; // expected-warning {{array index 11 is past the end of the array (which contains 10 elements)}} } + +int multi[2][2][2]; // expected-note {{array 'multi' declared here}} +int test_multiarray() { + return multi[2][0][0]; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}} +} + +struct multi_s { + int arr[4]; +}; +struct multi_s multi2[4]; // expected-note {{array 'multi2' declared here}} +int test_struct_multiarray() { + return multi2[4].arr[0]; // expected-warning {{array index 4 is past the end of the array (which contains 4 elements)}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -11277,7 +11277,13 @@ const ArraySubscriptExpr *ASE = cast(expr); CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE, AllowOnePastEnd > 0); -return; +expr = ASE->getBase(); +break; + } + case Stmt::MemberExprClass: { +const MemberExpr *ME = cast(expr); +expr = ME->getBase(); +break; } case Stmt::OMPArraySectionExprClass: { const OMPArraySectionExpr *ASE = cast(expr); Index: test/SemaCXX/constant-expression-cxx11.cpp === --- test/SemaCXX/constant-expression-cxx11.cpp +++ test/SemaCXX/constant-expression-cxx11.cpp @@ -528,15 +528,18 @@ constexpr int xs0 = p[-3]; // ok constexpr int xs_1 = p[-4]; // expected-error {{constant expression}} expected-note {{cannot refer to element -1}} -constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; +constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; // expected-note {{array 'zs' declared here}} static_assert(zs[0][0][0][0] == 1, ""); static_assert(zs[1][1][1][1] == 16, ""); static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}} static_assert((&zs[0][0][0][2])[-1] == 2, ""); static_assert(**(**(zs + 1) + 1) == 11, ""); static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][-1] + 1) == 11, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1 of array of 2 elements in a constant expression}} static_assert(*(&(&(*(*
[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name
SimeonEhrig added inline comments. Comment at: lib/CodeGen/CGCUDANV.cpp:287 +CtorSuffix.append("_"); +CtorSuffix.append(ModuleName); + } tra wrote: > There is a general problem with this approach. File name can contain the > characters that PTX does not allow. > We currently only deal with '.' and '@', but that's not enough here. > You may want to either mangle the name somehow to avoid/convert illegal > characters or use some other way to provide unique suffix. Hex-encoded hash > of the file name would avoid this problem, for example. > > > Maybe I'm wrong but I think, that should be no problem, because the generating of a cuda ctor/dtor have nothing to do with the PTX generation. The function 'makeModuleCtorFunction' should just generate llvm ir code for the host (e.g. x86_64). If I'm wrong, could you tell me please, where in the source code the 'makeModuleCtorFunction' affect the PTX generation. https://reviews.llvm.org/D44435 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45726: Format closing braces when reformatting the line containing theopening brace.
klimek added a comment. In https://reviews.llvm.org/D45726#1071925, @krasimir wrote: > Another point: for the example in the summary about bailing-out early, is > there a test for this already? If not, we should add one. Yep, there already is one - I regressed that with my change at first ;) Repository: rC Clang https://reviews.llvm.org/D45726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45726: Format closing braces when reformatting the line containing theopening brace.
klimek updated this revision to Diff 143274. klimek marked 2 inline comments as done. klimek added a comment. Address comments. Repository: rC Clang https://reviews.llvm.org/D45726 Files: lib/Format/AffectedRangeManager.cpp lib/Format/AffectedRangeManager.h lib/Format/Format.cpp lib/Format/NamespaceEndCommentsFixer.cpp lib/Format/SortJavaScriptImports.cpp lib/Format/TokenAnnotator.h lib/Format/UnwrappedLineFormatter.cpp lib/Format/UnwrappedLineParser.cpp lib/Format/UnwrappedLineParser.h lib/Format/UsingDeclarationsSorter.cpp unittests/Format/FormatTestSelective.cpp Index: unittests/Format/FormatTestSelective.cpp === --- unittests/Format/FormatTestSelective.cpp +++ unittests/Format/FormatTestSelective.cpp @@ -177,6 +177,72 @@ 0, 0)); } +TEST_F(FormatTestSelective, ContinueReindenting) { + // When we change an indent, we continue formatting as long as following + // lines are not indented correctly. + EXPECT_EQ("int i;\n" +"int b;\n" +"int c;\n" +"int d;\n" +"int e;\n" +" int f;\n", +format("int i;\n" + " int b;\n" + " int c;\n" + " int d;\n" + "int e;\n" + " int f;\n", + 11, 0)); +} + +TEST_F(FormatTestSelective, ReindentClosingBrace) { + EXPECT_EQ("int i;\n" +"int f() {\n" +" int a;\n" +" int b;\n" +"}\n" +" int c;\n", +format("int i;\n" + " int f(){\n" + "int a;\n" + "int b;\n" + " }\n" + " int c;\n", + 11, 0)); + EXPECT_EQ("void f() {\n" +" if (foo) {\n" +"b();\n" +" } else {\n" +"c();\n" +" }\n" +"int d;\n" +"}\n", +format("void f() {\n" + " if (foo) {\n" + "b();\n" + "}else{\n" + "c();\n" + "}\n" + "int d;\n" + "}\n", + 13, 0)); + EXPECT_EQ("int i = []() {\n" +" class C {\n" +"int a;\n" +"int b;\n" +" };\n" +" int c;\n" +"};\n", +format("int i = []() {\n" + " class C{\n" + "int a;\n" + "int b;\n" + "};\n" + "int c;\n" + " };\n", + 17, 0)); +} + TEST_F(FormatTestSelective, IndividualStatementsOfNestedBlocks) { EXPECT_EQ("DEBUG({\n" " int i;\n" @@ -503,7 +569,7 @@ " if (a) {\n" "g();\n" "h();\n" - "}\n" + " }\n" "\n" "void g() {\n" "}", Index: lib/Format/UsingDeclarationsSorter.cpp === --- lib/Format/UsingDeclarationsSorter.cpp +++ lib/Format/UsingDeclarationsSorter.cpp @@ -187,8 +187,7 @@ TokenAnnotator &Annotator, SmallVectorImpl &AnnotatedLines, FormatTokenLexer &Tokens) { const SourceManager &SourceMgr = Env.getSourceManager(); - AffectedRangeMgr.computeAffectedLines(AnnotatedLines.begin(), -AnnotatedLines.end()); + AffectedRangeMgr.computeAffectedLines(AnnotatedLines); tooling::Replacements Fixes; SmallVector UsingDeclarations; for (size_t I = 0, E = AnnotatedLines.size(); I != E; ++I) { Index: lib/Format/UnwrappedLineParser.h === --- lib/Format/UnwrappedLineParser.h +++ lib/Format/UnwrappedLineParser.h @@ -53,7 +53,11 @@ /// \c MatchingOpeningBlockLineIndex stores the index of the corresponding /// opening line. Otherwise, \c MatchingOpeningBlockLineIndex must be /// \c kInvalidIndex. - size_t MatchingOpeningBlockLineIndex; + size_t MatchingOpeningBlockLineIndex = kInvalidIndex; + + /// \brief If this \c UnwrappedLine opens a block, stores the index of the + /// line with the corresponding closing brace. + size_t MatchingClosingBlockLineIndex = kInvalidIndex; static const size_t kInvalidIndex = -1; Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -570,7 +570,7 @@ Line->MatchingOpeningBlockLineIndex = OpeningLineIndex; if (OpeningLineIndex != UnwrappedLine::kInvalidIndex) { // Update the opening line to add the forward reference as well - (*CurrentLines)[OpeningLineIndex].MatchingOpeningBlockLineIndex = + (*CurrentLines)[OpeningLineIndex].MatchingClosingBlockLineIndex = CurrentL
[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.
JonasToth added a comment. I like your refactoring very much and i think we have a state that is close to commit. My clang-tidy check is already based on top of your functionality, but i can not work on it this weekend and next week is already busy for me. I decided to analysis values and references only for now, and work on pointer semantics later, because of some uncertainty how to handle different things. Right now, nothing comes to my mind that might be missing. Maybe you could add small helpers and utilities, that take a `varDecl` and run the analysis (implemented in my check). That would move the last piece into this section :) Comment at: clang-tidy/utils/ASTUtils.cpp:125 + const auto AsNonConstRefArg = + anyOf(callExpr(NonConstRefParam), cxxConstructExpr(NonConstRefParam)); + shuaiwang wrote: > JonasToth wrote: > > I am suprised that `callExpr` does not cover constructor calls. Or is there > > more? > Added test cases for this. > cxxConstructExpr is the only one I can think of that happens to not be > covered by callExpr. Are move and copy constructor covered by this? Comment at: clang-tidy/utils/ASTUtils.cpp:149 + Stm, *Context); + if (const auto *S = selectFirst("mod", ModOrEsc)) { +if (Chain != nullptr) shuaiwang wrote: > JonasToth wrote: > > Having the history for the trivial modifications would be nice, too. > > > > I think treating all kinds of modifications is best. > Could you elaborate what do you mean here? I think i was mostly irritated and it is irrelevant with the new semantics (which i think are good for now!). Comment at: clang-tidy/utils/ASTUtils.cpp:222 + return Kind; +if (Chain != nullptr) + Chain->pop_back(); shuaiwang wrote: > JonasToth wrote: > > The pop is not clear to me > Removed. > > In case you wonder, I was intended to put a bit more information into Chain > and here we're basically trying each element of LoopVars and see whether it's > modified or not, because each recursive call appends to Chain we need to push > the LoopVarStmt first before doing the recursive call, but if the recursive > call concluded that the var is not modified, we need to pop the LoopVarStmt > back out. > Anyway this is not removed. Ok. Comment at: clang-tidy/utils/ASTUtils.cpp:233 + conditionalOperator(anyOf( + hasTrueExpression(equalsNode(&Exp)), + hasFalseExpression(equalsNode(&Exp)), shuaiwang wrote: > JonasToth wrote: > > If the `Exp` is an array, that will not match array subscript? > > > > Are there other similar cases? > If `Exp` is an array, we should first follow the array subscript expression > and do a recursive call. > > i.e.: > int x[2]; > int& y = x[0]; > y = 10; > isModified(x) -> isModified(x[0]) -> isModified(y) { return true /* because y > = 10 */ } > I was wondering about the ternaryOperator and if some suprises might arise from it. Thats something i will investigate next week within the clang-tidy check. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.
JonasToth added a comment. Something came to my mind: conversion operators. Do they behave as normal overloaded operators? The tests should reflect both a const conversion and a modifying one. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".
george.karpenkov added inline comments. Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:144 +// includes the full path. +if (SM.getFilename(IL).contains("UnifiedSource")) { + StringRef Name = SM.getFilename(SL); Is this `if` really necessary? This logic has too much overfitting, and it seems that if someone decides to include `.cc` files, we should analyze them in any case, right? We also would prefer to not stop working if webkit decides on using a different naming for those. Comment at: lib/StaticAnalyzer/Core/CallEvent.cpp:975 + ->getAnalysisManager() + .isInCodeFile(D->getLocation())) return true; You would shave off a bit of redundancy and verbosity by saving `AnalysisManager` in a local variable. Comment at: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:837 return false; // Conditionally control the inlining of the destructor of C++ shared_ptr. baloghadamsoftware wrote: > Maybe we should include a test for container methods as well. +1 Comment at: lib/StaticAnalyzer/Core/PathDiagnostic.cpp:153 + assert(AnalysisManager::isInCodeFile(CallLoc, SMgr) && "The call piece should be in the main file."); Assert error message is not quite technically correct now Comment at: test/Analysis/unified-sources/source1.cpp:8 + if (x) {} + return 1 / x; // expected-warning{{}} +} Wow, expected-* directives work across multiple files?? This is really cool! https://reviews.llvm.org/D45839 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45774: [analyzer] cover more cases where a Loc can be bound to constants
george.karpenkov added inline comments. Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1720 +// Either the record variable or the field has to be const qualified. +if (RecordVarTy.isConstQualified() || Ty.isConstQualified()) { + if (const Expr *Init = VD->getInit()) { style note -- by LLVM coding standards `{`'s are usually omitted when there's only a single statement inside the guard. Would help to avoid giant towers of `}`'s Repository: rC Clang https://reviews.llvm.org/D45774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45517: [analyzer] WIP: False positive refutation with Z3
rnkovacs updated this revision to Diff 143287. rnkovacs edited the summary of this revision. rnkovacs added a comment. Fixed logical operator in the `Z3ConstraintManager::checkRangedStateConstraints()` function. https://reviews.llvm.org/D45517 Files: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Core/BugReporter.cpp lib/StaticAnalyzer/Core/BugReporterVisitors.cpp lib/StaticAnalyzer/Core/ProgramState.cpp lib/StaticAnalyzer/Core/RangeConstraintManager.cpp lib/StaticAnalyzer/Core/RangedConstraintManager.h lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp === --- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp +++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp @@ -7,6 +7,7 @@ // //===--===// +#include "RangedConstraintManager.h" #include "clang/Basic/TargetInfo.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" @@ -915,6 +916,8 @@ void print(ProgramStateRef St, raw_ostream &Out, const char *nl, const char *sep) override; + bool checkRangedStateConstraints(ProgramStateRef State) override; + //===--===// // Implementation for interface from SimpleConstraintManager. //===--===// @@ -1235,6 +1238,47 @@ return State->set(CZ); } +bool Z3ConstraintManager::checkRangedStateConstraints(ProgramStateRef State) { + Solver.reset(); + ConstraintRangeTy CR = State->get(); + + for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) { +SymbolRef Sym = I.getKey(); + +for (const auto &Range : I.getData()) { + const llvm::APSInt &From = Range.From(); + const llvm::APSInt &To = Range.To(); + + assert((getAPSIntType(From) == getAPSIntType(To)) && + "Range values have different types!"); + QualType RangeTy = getAPSIntType(From); + // Skip ranges whose endpoints cannot be converted to APSInts with + // a valid APSIntType. + if (RangeTy.isNull()) +continue; + + QualType SymTy; + Z3Expr Exp = getZ3Expr(Sym, &SymTy); + bool isSignedTy = SymTy->isSignedIntegerOrEnumerationType(); + + Z3Expr FromExp = Z3Expr::fromAPSInt(From); + Z3Expr ToExp = Z3Expr::fromAPSInt(To); + + if (From == To) { +Z3Expr Eq = getZ3BinExpr(Exp, SymTy, BO_EQ, FromExp, RangeTy, nullptr); +Solver.addConstraint(Eq); + } else { +Z3Expr LHS = getZ3BinExpr(Exp, SymTy, BO_GE, FromExp, RangeTy, nullptr); +Z3Expr RHS = getZ3BinExpr(Exp, SymTy, BO_LE, ToExp, RangeTy, nullptr); +Solver.addConstraint(Z3Expr::fromBinOp(LHS, BO_LOr, RHS, isSignedTy)); + } +} + } + // If Z3 timeouts, Z3_L_UNDEF is returned, and we assume that the state + // is feasible. + return Solver.check() != Z3_L_FALSE; +} + //===--===// // Internal implementation. //===--===// Index: lib/StaticAnalyzer/Core/RangedConstraintManager.h === --- lib/StaticAnalyzer/Core/RangedConstraintManager.h +++ lib/StaticAnalyzer/Core/RangedConstraintManager.h @@ -15,12 +15,124 @@ #define LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h" namespace clang { namespace ento { +/// A Range represents the closed range [from, to]. The caller must +/// guarantee that from <= to. Note that Range is immutable, so as not +/// to subvert RangeSet's immutability. +class Range : public std::pair { +public: + Range(const llvm::APSInt &from, const llvm::APSInt &to) + : std::pair(&from, &to) { +assert(from <= to); + } + bool Includes(const llvm::APSInt &v) const { +return *first <= v && v <= *second; + } + const llvm::APSInt &From() const { return *first; } + const llvm::APSInt &To() const { return *second; } + const llvm::APSInt *getConcreteValue() const { +return &From() == &To() ? &From() : nullptr; + } + + void Profile(llvm::FoldingSetNodeID &ID) const { +ID.AddPointer(&From()); +ID.AddPointer(&To()); + } +}; + +class RangeTrait : public llvm::ImutContainerInfo { +public: + // When co
[clang-tools-extra] r330418 - Parse .h files as objective-c++ if we don't have a compile command.
Author: sammccall Date: Fri Apr 20 04:35:17 2018 New Revision: 330418 URL: http://llvm.org/viewvc/llvm-project?rev=330418&view=rev Log: Parse .h files as objective-c++ if we don't have a compile command. Summary: This makes C++/objC not totally broken, without hurting C files too much. Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D45442 Added: clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt clang-tools-extra/trunk/unittests/clangd/TestFS.cpp Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=330418&r1=330417&r2=330418&view=diff == --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original) +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Fri Apr 20 04:35:17 2018 @@ -18,9 +18,15 @@ namespace clangd { tooling::CompileCommand GlobalCompilationDatabase::getFallbackCommand(PathRef File) const { + std::vector Argv = {"clang"}; + // Clang treats .h files as C by default, resulting in unhelpful diagnostics. + // Parsing as Objective C++ is friendly to more cases. + if (llvm::sys::path::extension(File) == ".h") +Argv.push_back("-xobjective-c++-header"); + Argv.push_back(File); return tooling::CompileCommand(llvm::sys::path::parent_path(File), llvm::sys::path::filename(File), - {"clang", File.str()}, + std::move(Argv), /*Output=*/""); } @@ -29,6 +35,9 @@ DirectoryBasedGlobalCompilationDatabase: llvm::Optional CompileCommandsDir) : CompileCommandsDir(std::move(CompileCommandsDir)) {} +DirectoryBasedGlobalCompilationDatabase:: +~DirectoryBasedGlobalCompilationDatabase() = default; + llvm::Optional DirectoryBasedGlobalCompilationDatabase::getCompileCommand(PathRef File) const { if (auto CDB = getCDBForFile(File)) { Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h?rev=330418&r1=330417&r2=330418&view=diff == --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h (original) +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h Fri Apr 20 04:35:17 2018 @@ -52,6 +52,7 @@ class DirectoryBasedGlobalCompilationDat public: DirectoryBasedGlobalCompilationDatabase( llvm::Optional CompileCommandsDir); + ~DirectoryBasedGlobalCompilationDatabase() override; /// Scans File's parents looking for compilation databases. /// Any extra flags will be added. Modified: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt?rev=330418&r1=330417&r2=330418&view=diff == --- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt (original) +++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Fri Apr 20 04:35:17 2018 @@ -18,6 +18,7 @@ add_extra_unittest(ClangdTests DraftStoreTests.cpp FileIndexTests.cpp FuzzyMatchTests.cpp + GlobalCompilationDatabaseTests.cpp HeadersTests.cpp IndexTests.cpp JSONExprTests.cpp Added: clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp?rev=330418&view=auto == --- clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp (added) +++ clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp Fri Apr 20 04:35:17 2018 @@ -0,0 +1,37 @@ +//===-- GlobalCompilationDatabaseTests.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "GlobalCompilationDatabase.h" + +#include "TestFS.h" +#include "llvm/ADT/StringExtras.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +namespace clang { +namespace clangd { +namespace { +using ::testing::ElementsAre; + +TEST(GlobalCompilationDatabaseTest, FallbackCommand) { + DirectoryBasedGlobalCompilationDatabase DB
[PATCH] D45442: Parse .h files as objective-c++ if we don't have a compile command.
This revision was automatically updated to reflect the committed changes. Closed by commit rL330418: Parse .h files as objective-c++ if we don't have a compile command. (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D45442 Files: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp clang-tools-extra/trunk/unittests/clangd/TestFS.cpp Index: clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp === --- clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp +++ clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp @@ -0,0 +1,37 @@ +//===-- GlobalCompilationDatabaseTests.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "GlobalCompilationDatabase.h" + +#include "TestFS.h" +#include "llvm/ADT/StringExtras.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +namespace clang { +namespace clangd { +namespace { +using ::testing::ElementsAre; + +TEST(GlobalCompilationDatabaseTest, FallbackCommand) { + DirectoryBasedGlobalCompilationDatabase DB(llvm::None); + auto Cmd = DB.getFallbackCommand(testPath("foo/bar.cc")); + EXPECT_EQ(Cmd.Directory, testPath("foo")); + EXPECT_THAT(Cmd.CommandLine, ElementsAre("clang", testPath("foo/bar.cc"))); + EXPECT_EQ(Cmd.Output, ""); + + // .h files have unknown language, so they are parsed liberally as obj-c++. + Cmd = DB.getFallbackCommand(testPath("foo/bar.h")); + EXPECT_THAT(Cmd.CommandLine, ElementsAre("clang", "-xobjective-c++-header", + testPath("foo/bar.h"))); +} + +} // namespace +} // namespace clangd +} // namespace clang Index: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt === --- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt +++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt @@ -18,6 +18,7 @@ DraftStoreTests.cpp FileIndexTests.cpp FuzzyMatchTests.cpp + GlobalCompilationDatabaseTests.cpp HeadersTests.cpp IndexTests.cpp JSONExprTests.cpp Index: clang-tools-extra/trunk/unittests/clangd/TestFS.cpp === --- clang-tools-extra/trunk/unittests/clangd/TestFS.cpp +++ clang-tools-extra/trunk/unittests/clangd/TestFS.cpp @@ -55,8 +55,10 @@ std::string testPath(PathRef File) { assert(sys::path::is_relative(File) && "FileName should be relative"); + SmallString<32> NativeFile = File; + sys::path::native(NativeFile); SmallString<32> Path; - sys::path::append(Path, testRoot(), File); + sys::path::append(Path, testRoot(), NativeFile); return Path.str(); } Index: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h === --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h @@ -52,6 +52,7 @@ public: DirectoryBasedGlobalCompilationDatabase( llvm::Optional CompileCommandsDir); + ~DirectoryBasedGlobalCompilationDatabase() override; /// Scans File's parents looking for compilation databases. /// Any extra flags will be added. Index: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp === --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp @@ -18,17 +18,26 @@ tooling::CompileCommand GlobalCompilationDatabase::getFallbackCommand(PathRef File) const { + std::vector Argv = {"clang"}; + // Clang treats .h files as C by default, resulting in unhelpful diagnostics. + // Parsing as Objective C++ is friendly to more cases. + if (llvm::sys::path::extension(File) == ".h") +Argv.push_back("-xobjective-c++-header"); + Argv.push_back(File); return tooling::CompileCommand(llvm::sys::path::parent_path(File), llvm::sys::path::filename(File), - {"clang", File.str()}, + std::move(Argv), /*Output=*/""); } DirectoryBasedGlobalCompilationDatabase:: DirectoryBasedGlobalCompilationDatabase( llvm::Optional CompileCommandsDir) : CompileCommandsDir(std::move(CompileCommandsDir)) {} +DirectoryBasedGlobalCompilationDatabase
[PATCH] D45873: [OpenCL] Reject virtual functions for OpenCL C++
svenvh created this revision. svenvh added reviewers: yaxunl, bader. Herald added a subscriber: cfe-commits. The OpenCL C++ specification doesn't mention restricting virtual inheritance, so leaving that unaffected for now. Repository: rC Clang https://reviews.llvm.org/D45873 Files: include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/LangOptions.def lib/Frontend/CompilerInvocation.cpp lib/Parse/ParseDecl.cpp test/Parser/opencl-cxx-virtual.cl Index: test/Parser/opencl-cxx-virtual.cl === --- /dev/null +++ test/Parser/opencl-cxx-virtual.cl @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -fsyntax-only -verify + +// Test that virtual functions and abstract classes are rejected. +class virtual_functions { + virtual void bad1() {} + //expected-error@-1 {{virtual functions are not supported in OpenCL C++}} + + virtual void bad2() =0; + //expected-error@-1 {{virtual functions are not supported in OpenCL C++}} + //expected-error@-2 {{'bad2' is not virtual and cannot be declared pure}} +}; + +// Test that virtual base classes are allowed. +struct A { + int a; + void foo(); +}; + +struct B : virtual A { + int b; +}; + +struct C : public virtual A { + int c; +}; + +struct D : B, C { + int d; +}; + +kernel void virtual_inheritance() { + D d; + + d.foo(); + d.a = 11; + d.b = 22; + d.c = 33; + d.d = 44; +} Index: lib/Parse/ParseDecl.cpp === --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -3466,7 +3466,15 @@ isInvalid = DS.setFunctionSpecInline(Loc, PrevSpec, DiagID); break; case tok::kw_virtual: - isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID); + // OpenCL C++ v1.0 s2.9: the virtual function qualifier is not supported. + if (getLangOpts().OpenCLCPlusPlus) { +DiagID = diag::err_openclcxx_virtual_function; +PrevSpec = Tok.getIdentifierInfo()->getNameStart(); +isInvalid = true; + } + else { +isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID); + } break; case tok::kw_explicit: isInvalid = DS.setFunctionSpecExplicit(Loc, PrevSpec, DiagID); Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -1925,6 +1925,7 @@ Opts.setDefaultFPContractMode(LangOptions::FPC_On); Opts.NativeHalfType = 1; Opts.NativeHalfArgsAndReturns = 1; +Opts.OpenCLCPlusPlus = Opts.CPlusPlus; // Include default header file for OpenCL. if (Opts.IncludeDefaultHeader) { PPOpts.Includes.push_back("opencl-c.h"); Index: include/clang/Basic/LangOptions.def === --- include/clang/Basic/LangOptions.def +++ include/clang/Basic/LangOptions.def @@ -189,6 +189,7 @@ LANGOPT(OpenCL, 1, 0, "OpenCL") LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version") +LANGOPT(OpenCLCPlusPlus , 1, 0, "OpenCL C++") LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "OpenCL C++ version") LANGOPT(NativeHalfType, 1, 0, "Native half type support") LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns") Index: include/clang/Basic/DiagnosticParseKinds.td === --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -1073,6 +1073,10 @@ def err_opencl_logical_exclusive_or : Error< "^^ is a reserved operator in OpenCL">; +// OpenCL C++. +def err_openclcxx_virtual_function : Error< + "virtual functions are not supported in OpenCL C++">; + // OpenMP support. def warn_pragma_omp_ignored : Warning< "unexpected '#pragma omp ...' in program">, InGroup, DefaultIgnore; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45815: [libclang] Add options to limit skipping of function bodies
ilya-biryukov added a comment. In https://reviews.llvm.org/D45815#1072094, @nik wrote: > @ilya: Using SkipFunctionBodies_AllExceptTemplates for the preamble might be > also useful for clangd. Unfortunately, that's also the biggest performance win you get when skipping the function bodies. I.e. most codebases do not have function bodies in headers unless the function is template. Have you measured the performance gain of skipping only non-template functions, but not skipping the template ones? Would that really make a significant difference for any real codebase? Comment at: include/clang/Frontend/SkipFunctionBodies.h:18 +enum SkipFunctionBodiesKind { + SkipFunctionBodies_None, + SkipFunctionBodies_All, Maybe make it `enum class` and remove the name prefix from enumerators? I.e. `enum class SkipFunctionBodiesKind { None, ` Repository: rC Clang https://reviews.llvm.org/D45815 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45771: [Driver] Support for -save-stats in AddGoldPlugin.
fhahn updated this revision to Diff 143292. fhahn marked 2 inline comments as done. fhahn added a comment. Thank you very much for the review and the excellent suggestions. I simplified getStatsFileName, added a doxygen comment and changed the arguments of AddGoldPlugin as suggested https://reviews.llvm.org/D45771 Files: lib/Driver/ToolChains/Ananas.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/CloudABI.cpp lib/Driver/ToolChains/CommonArgs.cpp lib/Driver/ToolChains/CommonArgs.h lib/Driver/ToolChains/FreeBSD.cpp lib/Driver/ToolChains/Gnu.cpp test/Driver/save-stats.c Index: test/Driver/save-stats.c === --- test/Driver/save-stats.c +++ test/Driver/save-stats.c @@ -18,3 +18,11 @@ // RUN: %clang -target x86_64-apple-darwin -save-stats=bla -c %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID // CHECK-INVALID: invalid value 'bla' in '-save-stats=bla' + +// RUN: %clang -target x86_64-linux-unknown -save-stats -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO +// CHECK-LTO: "-stats-file=save-stats.stats" +// CHECK-LTO: "-o" "obj/dir{{/|}}save-stats.exe" +// CHECK-LTO: "-plugin-opt=stats-file=save-stats.stats" + +// RUN: %clang -target x86_64-linux-unknown -save-stats=obj -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO-OBJ +// CHECK-LTO-OBJ: "-plugin-opt=stats-file=obj/dir/save-stats.stats" Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -435,8 +435,11 @@ ToolChain.AddFilePathLibArgs(Args, CmdArgs); - if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); + if (D.isUsingLTO()) { +assert(!Inputs.empty() && "Must have at least one input."); +AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0], + D.getLTOMode() == LTOK_Thin); + } if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle)) CmdArgs.push_back("--no-demangle"); Index: lib/Driver/ToolChains/FreeBSD.cpp === --- lib/Driver/ToolChains/FreeBSD.cpp +++ lib/Driver/ToolChains/FreeBSD.cpp @@ -231,8 +231,11 @@ Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag); Args.AddAllArgs(CmdArgs, options::OPT_r); - if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); + if (D.isUsingLTO()) { +assert(!Inputs.empty() && "Must have at least one input."); +AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0], + D.getLTOMode() == LTOK_Thin); + } bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); Index: lib/Driver/ToolChains/CommonArgs.h === --- lib/Driver/ToolChains/CommonArgs.h +++ lib/Driver/ToolChains/CommonArgs.h @@ -60,8 +60,8 @@ const InputInfo &Output, const char *OutFile); void AddGoldPlugin(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, - llvm::opt::ArgStringList &CmdArgs, bool IsThinLTO, - const Driver &D); + llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output, + const InputInfo &Input, bool IsThinLTO); std::tuple ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args); @@ -107,6 +107,11 @@ std::vector &Features, llvm::opt::OptSpecifier Group); +/// Handles the -save-stats option and returns the filename to save statistics +/// to. +SmallString<128> getStatsFileName(const llvm::opt::ArgList &Args, + const InputInfo &Output, + const InputInfo &Input, const Driver &D); } // end namespace tools } // end namespace driver } // end namespace clang Index: lib/Driver/ToolChains/CommonArgs.cpp === --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -8,14 +8,14 @@ //===--===// #include "CommonArgs.h" -#include "InputInfo.h" -#include "Hexagon.h" #include "Arch/AArch64.h" #include "Arch/ARM.h" #include "Arch/Mips.h" #include "Arch/PPC.h" #include "Arch/SystemZ.h" #include "Arch/X86.h" +#include "Hexagon.h" +#include "InputInfo.h" #include "clang/Basic/CharInfo.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/ObjCRuntime.h" @@ -42,6 +42,7 @@ #include "llvm/Option/Option.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/Compression.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support
r330420 - [NEON] Add a comment explaining the situation with vget_high_f16() and vget_low_f16() intrinsics
Author: kosarev Date: Fri Apr 20 05:09:25 2018 New Revision: 330420 URL: http://llvm.org/viewvc/llvm-project?rev=330420&view=rev Log: [NEON] Add a comment explaining the situation with vget_high_f16() and vget_low_f16() intrinsics Related differential revision: https://reviews.llvm.org/D45668 Modified: cfe/trunk/include/clang/Basic/arm_neon.td Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330420&r1=330419&r2=330420&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Fri Apr 20 05:09:25 2018 @@ -397,6 +397,10 @@ def VCOMBINE : NoTestOpInst<"vcombine", // E.3.21 Splitting vectors +// Note that the ARM NEON Reference 2.0 mistakenly document the vget_high_f16() +// and vget_low_f16() intrinsics as AArch64-only. We (and GCC) support all +// versions of these intrinsics in both AArch32 and AArch64 architectures. See +// D45668 for more details. let InstName = "vmov" in { def VGET_HIGH : NoTestOpInst<"vget_high", "dk", "csilhfUcUsUiUlPcPs", OP_HI>; def VGET_LOW : NoTestOpInst<"vget_low", "dk", "csilhfUcUsUiUlPcPs", OP_LO>; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45668: [NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only
kosarev added a comment. Thanks Sjoerd and James. Just added a comment referring to this revision in https://reviews.llvm.org/rL330420. Repository: rL LLVM https://reviews.llvm.org/D45668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330404 - [OpenCL] Add 'denorms-are-zero' function attribute
Author: AlexeySotkin Date: Fri Apr 20 01:08:04 2018 New Revision: 330404 URL: http://llvm.org/viewvc/llvm-project?rev=330404&view=rev Log: [OpenCL] Add 'denorms-are-zero' function attribute Summary: Generate attribute 'denorms-are-zero'='true' if '-cl-denorms-are-zero' compile option was specified and 'denorms-are-zero'='false' otherwise. Patch by krisb Reviewers: Anastasia, yaxunl Reviewed By: yaxunl Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45808 Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=330404&r1=330403&r2=330404&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Apr 20 01:08:04 2018 @@ -1745,6 +1745,10 @@ void CodeGenModule::ConstructDefaultFnAt "correctly-rounded-divide-sqrt-fp-math", llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt)); +if (getLangOpts().OpenCL) + FuncAttrs.addAttribute("denorms-are-zero", + llvm::toStringRef(CodeGenOpts.FlushDenorm)); + // TODO: Reciprocal estimate codegen options should apply to instructions? const std::vector &Recips = CodeGenOpts.Reciprocals; if (!Recips.empty()) Modified: cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl?rev=330404&r1=330403&r2=330404&view=diff == --- cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl Fri Apr 20 01:08:04 2018 @@ -1,19 +1,25 @@ -// RUN: %clang_cc1 -S -cl-denorms-are-zero -o - %s 2>&1 -// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s -// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=CHECK-DENORM -// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck --check-prefix=CHECK-FEATURE %s +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - %s | FileCheck %s --check-prefix=DENORM-ZERO +// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=AMDGCN +// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=AMDGCN-DENORM +// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck --check-prefix=AMDGCN-FEATURE %s -// For non-amdgcn targets, this test just checks that the -cl-denorms-are-zero argument is accepted -// by clang. This option is currently a no-op, which is allowed by the -// OpenCL specification. +// For all targets 'denorms-are-zero' attribute is set to 'true' +// if '-cl-denorms-are-zero' was specified and to 'false' otherwise. + +// CHECK-LABEL: define void @f() +// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="false" +// +// DENORM-ZERO-LABEL: define void @f() +// DENORM-ZERO: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" // For amdgcn target cpu fiji, fp32 should be flushed since fiji does not support fp32 denormals, unless +fp32-denormals is // explicitly set. amdgcn target always do not flush fp64 denormals. The control for fp64 and fp16 denormals is the same. -// CHECK-DENORM-LABEL: define void @f() -// CHECK-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}" -// CHECK-LABEL: define void @f() -// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}" -// CHECK-FEATURE-LABEL: define void @f() -// CHECK-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} "target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-denormals{{[^"]*}}" +// AMDGCN-LABEL: define void @f() +// AMDGCN: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" {{.*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}" +// AMDGCN-DENORM-LABEL: define void @f() +// AMDGCN-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="false" {{.*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}" +// AMDGCN-FEATURE-LABEL: define void @f() +// AMDGCN-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" {{.*}} "target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-d
r330408 - Fix -Wunused-variable warnings after r330377.
Author: adibiagio Date: Fri Apr 20 02:47:03 2018 New Revision: 330408 URL: http://llvm.org/viewvc/llvm-project?rev=330408&view=rev Log: Fix -Wunused-variable warnings after r330377. Modified: cfe/trunk/lib/Analysis/ConstructionContext.cpp Modified: cfe/trunk/lib/Analysis/ConstructionContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ConstructionContext.cpp?rev=330408&r1=330407&r2=330408&view=diff == --- cfe/trunk/lib/Analysis/ConstructionContext.cpp (original) +++ cfe/trunk/lib/Analysis/ConstructionContext.cpp Fri Apr 20 02:47:03 2018 @@ -80,7 +80,7 @@ const ConstructionContext *ConstructionC return create(C, BTE, MTE); } // This is a constructor into a function argument. Not implemented yet. -if (auto *CE = dyn_cast(ParentLayer->getTriggerStmt())) +if (isa(ParentLayer->getTriggerStmt())) return nullptr; // This is C++17 copy-elided construction into return statement. if (auto *RS = dyn_cast(ParentLayer->getTriggerStmt())) { @@ -118,7 +118,7 @@ const ConstructionContext *ConstructionC return create(C, RS); } // This is a constructor into a function argument. Not implemented yet. -if (auto *CE = dyn_cast(TopLayer->getTriggerStmt())) +if (isa(TopLayer->getTriggerStmt())) return nullptr; llvm_unreachable("Unexpected construction context with statement!"); } else if (const CXXCtorInitializer *I = TopLayer->getTriggerInit()) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45771: [Driver] Support for -save-stats in AddGoldPlugin.
This revision was automatically updated to reflect the committed changes. Closed by commit rC330422: [Driver] Support for -save-stats in AddGoldPlugin. (authored by fhahn, committed by ). Changed prior to commit: https://reviews.llvm.org/D45771?vs=143292&id=143299#toc Repository: rC Clang https://reviews.llvm.org/D45771 Files: lib/Driver/ToolChains/Ananas.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/CloudABI.cpp lib/Driver/ToolChains/CommonArgs.cpp lib/Driver/ToolChains/CommonArgs.h lib/Driver/ToolChains/FreeBSD.cpp lib/Driver/ToolChains/Gnu.cpp test/Driver/save-stats.c Index: test/Driver/save-stats.c === --- test/Driver/save-stats.c +++ test/Driver/save-stats.c @@ -18,3 +18,11 @@ // RUN: %clang -target x86_64-apple-darwin -save-stats=bla -c %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID // CHECK-INVALID: invalid value 'bla' in '-save-stats=bla' + +// RUN: %clang -target x86_64-linux-unknown -save-stats -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO +// CHECK-LTO: "-stats-file=save-stats.stats" +// CHECK-LTO: "-o" "obj/dir{{/|}}save-stats.exe" +// CHECK-LTO: "-plugin-opt=stats-file=save-stats.stats" + +// RUN: %clang -target x86_64-linux-unknown -save-stats=obj -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO-OBJ +// CHECK-LTO-OBJ: "-plugin-opt=stats-file=obj/dir/save-stats.stats" Index: lib/Driver/ToolChains/CommonArgs.cpp === --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -8,14 +8,14 @@ //===--===// #include "CommonArgs.h" -#include "InputInfo.h" -#include "Hexagon.h" #include "Arch/AArch64.h" #include "Arch/ARM.h" #include "Arch/Mips.h" #include "Arch/PPC.h" #include "Arch/SystemZ.h" #include "Arch/X86.h" +#include "Hexagon.h" +#include "InputInfo.h" #include "clang/Basic/CharInfo.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/ObjCRuntime.h" @@ -42,6 +42,7 @@ #include "llvm/Option/Option.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/Compression.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" @@ -370,8 +371,8 @@ } void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args, - ArgStringList &CmdArgs, bool IsThinLTO, - const Driver &D) { + ArgStringList &CmdArgs, const InputInfo &Output, + const InputInfo &Input, bool IsThinLTO) { // Tell the linker to load the plugin. This has to come before AddLinkerInputs // as gold requires -plugin to come before any -plugin-opt that -Wl might // forward. @@ -416,7 +417,7 @@ if (IsThinLTO) CmdArgs.push_back("-plugin-opt=thinlto"); - if (unsigned Parallelism = getLTOParallelism(Args, D)) + if (unsigned Parallelism = getLTOParallelism(Args, ToolChain.getDriver())) CmdArgs.push_back( Args.MakeArgString("-plugin-opt=jobs=" + Twine(Parallelism))); @@ -447,7 +448,7 @@ if (Arg *A = getLastProfileSampleUseArg(Args)) { StringRef FName = A->getValue(); if (!llvm::sys::fs::exists(FName)) - D.Diag(diag::err_drv_no_such_file) << FName; + ToolChain.getDriver().Diag(diag::err_drv_no_such_file) << FName; else CmdArgs.push_back( Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + FName)); @@ -460,6 +461,12 @@ CmdArgs.push_back("-plugin-opt=new-pass-manager"); } + // Setup statistics file output. + SmallString<128> StatsFile = + getStatsFileName(Args, Output, Input, ToolChain.getDriver()); + if (!StatsFile.empty()) +CmdArgs.push_back( +Args.MakeArgString(Twine("-plugin-opt=stats-file=") + StatsFile)); } void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args, @@ -1267,3 +1274,27 @@ Lksf << LksBuffer; } + +SmallString<128> tools::getStatsFileName(const llvm::opt::ArgList &Args, + const InputInfo &Output, + const InputInfo &Input, + const Driver &D) { + const Arg *A = Args.getLastArg(options::OPT_save_stats_EQ); + if (!A) +return {}; + + StringRef SaveStats = A->getValue(); + SmallString<128> StatsFile; + if (SaveStats == "obj" && Output.isFilename()) { +StatsFile.assign(Output.getFilename()); +llvm::sys::path::remove_filename(StatsFile); + } else if (SaveStats != "cwd") { +D.Diag(diag::err_drv_invalid_value) << A->getAsString(Args) << SaveStats; +return {}; + } + + StringRef BaseName = llvm::sys::path::filename(Input.getBaseInput()); + llvm::sys::path::append(StatsFile, BaseName); + l
r330422 - [Driver] Support for -save-stats in AddGoldPlugin.
Author: fhahn Date: Fri Apr 20 05:50:10 2018 New Revision: 330422 URL: http://llvm.org/viewvc/llvm-project?rev=330422&view=rev Log: [Driver] Support for -save-stats in AddGoldPlugin. This patch updates AddGoldPlugin to pass stats-file to the Gold plugin, if -save-stats is passed. It also moves the save-stats option handling to a helper function tools::getStatsFileName. Reviewers: tejohnson, mehdi_amini, compnerd Reviewed By: tejohnson, compnerd Differential Revision: https://reviews.llvm.org/D45771 Modified: cfe/trunk/lib/Driver/ToolChains/Ananas.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/lib/Driver/ToolChains/CommonArgs.h cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/test/Driver/save-stats.c Modified: cfe/trunk/lib/Driver/ToolChains/Ananas.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Ananas.cpp?rev=330422&r1=330421&r2=330422&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Ananas.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Ananas.cpp Fri Apr 20 05:50:10 2018 @@ -103,8 +103,11 @@ void ananas::Linker::ConstructJob(Compil {options::OPT_T_Group, options::OPT_e, options::OPT_s, options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); - if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); + if (D.isUsingLTO()) { +assert(!Inputs.empty() && "Must have at least one input."); +AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0], + D.getLTOMode() == LTOK_Thin); + } AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=330422&r1=330421&r2=330422&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Apr 20 05:50:10 2018 @@ -4589,31 +4589,9 @@ void Clang::ConstructJob(Compilation &C, } // Setup statistics file output. - if (const Arg *A = Args.getLastArg(options::OPT_save_stats_EQ)) { -StringRef SaveStats = A->getValue(); - -SmallString<128> StatsFile; -bool DoSaveStats = false; -if (SaveStats == "obj") { - if (Output.isFilename()) { -StatsFile.assign(Output.getFilename()); -llvm::sys::path::remove_filename(StatsFile); - } - DoSaveStats = true; -} else if (SaveStats == "cwd") { - DoSaveStats = true; -} else { - D.Diag(diag::err_drv_invalid_value) << A->getAsString(Args) << SaveStats; -} - -if (DoSaveStats) { - StringRef BaseName = llvm::sys::path::filename(Input.getBaseInput()); - llvm::sys::path::append(StatsFile, BaseName); - llvm::sys::path::replace_extension(StatsFile, "stats"); - CmdArgs.push_back(Args.MakeArgString(Twine("-stats-file=") + - StatsFile)); -} - } + SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D); + if (!StatsFile.empty()) +CmdArgs.push_back(Args.MakeArgString(Twine("-stats-file=") + StatsFile)); // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option // parser. Modified: cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp?rev=330422&r1=330421&r2=330422&view=diff == --- cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp Fri Apr 20 05:50:10 2018 @@ -75,8 +75,11 @@ void cloudabi::Linker::ConstructJob(Comp {options::OPT_T_Group, options::OPT_e, options::OPT_s, options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); - if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); + if (D.isUsingLTO()) { +assert(!Inputs.empty() && "Must have at least one input."); +AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0], + D.getLTOMode() == LTOK_Thin); + } AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=330422&r1=330421&r2=330422&view=diff == --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Fri Apr 20 05:50:10 2018 @@ -8,14 +8,14 @@ //===---
[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu
yaxunl updated this revision to Diff 143298. yaxunl edited the summary of this revision. yaxunl added a comment. sync to ToT. https://reviews.llvm.org/D45212 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Action.h include/clang/Driver/Options.td include/clang/Driver/ToolChain.h lib/Driver/Action.cpp lib/Driver/Compilation.cpp lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/Cuda.cpp lib/Driver/ToolChains/Cuda.h test/Driver/cuda-bad-arch.cu test/Driver/cuda-phases.cu Index: test/Driver/cuda-phases.cu === --- test/Driver/cuda-phases.cu +++ test/Driver/cuda-phases.cu @@ -7,195 +7,233 @@ // REQUIRES: clang-driver // REQUIRES: powerpc-registered-target // REQUIRES: nvptx-registered-target - +// REQUIRES: amdgpu-registered-target // // Test single gpu architecture with complete compilation. // // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s 2>&1 \ -// RUN: | FileCheck -check-prefix=BIN %s -// BIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda) -// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (host-cuda) -// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-cuda) -// BIN-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30) -// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, sm_30) -// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, sm_30) -// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, sm_30) -// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, sm_30) -// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P7]]}, object -// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P6]]}, assembler -// BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-cuda) -// BIN-DAG: [[P11:[0-9]+]]: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-cuda (nvptx64-nvidia-cuda)" {[[P10]]}, ir -// BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-cuda) -// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-cuda) -// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-cuda) +// RUN: | FileCheck -check-prefixes=BIN,BIN_NV %s +// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN,BIN_AMD %s +// BIN_NV-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:cuda]], (host-[[T]]) +// BIN_AMD-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:hip]], (host-[[T]]) +// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (host-[[T]]) +// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-[[T]]) +// BIN_NV-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:sm_30]]) +// BIN_AMD-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:gfx803]]) +// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]]) +// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-[[T]], [[ARCH]]) +// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-[[T]], [[ARCH]]) +// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-[[T]], [[ARCH]]) +// BIN_NV-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE:nvptx64-nvidia-cuda]]:[[ARCH]])" {[[P7]]}, object +// BIN_AMD-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P7]]}, object +// BIN-DAG: [[P9:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE]]:[[ARCH]])" {[[P6]]}, assembler +// BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-[[T]]) +// BIN-DAG: [[P11:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-[[T]] ([[TRIPLE]])" {[[P10]]}, ir +// BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]]) +// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]]) +// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]]) // // Test single gpu architecture up to the assemble phase. // // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s -S 2>&1 \ -// RUN: | FileCheck -check-prefix=ASM %s -// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30) -// ASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (device-cuda, sm_30) -// ASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-cuda, sm_30) -// ASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-cuda, sm_30) -// ASM-DAG: [[P4:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P3]]}, assembler -// ASM-DAG: [[P5:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda) -// ASM-DAG: [[P6:[0-9]+]]: preprocessor, {[[P5]]}, cuda-cpp-output, (host-cuda) -// ASM
r330426 - [CUDA] Document recent changes
Author: hahnfeld Date: Fri Apr 20 06:04:54 2018 New Revision: 330426 URL: http://llvm.org/viewvc/llvm-project?rev=330426&view=rev Log: [CUDA] Document recent changes * Finding installations via ptxas binary * Relocatable device code Differential Revision: https://reviews.llvm.org/D45449 Modified: cfe/trunk/docs/ReleaseNotes.rst cfe/trunk/include/clang/Driver/Options.td Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=330426&r1=330425&r2=330426&view=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Fri Apr 20 06:04:54 2018 @@ -163,6 +163,18 @@ OpenMP Support in Clang - ... +CUDA Support in Clang +- + +- Clang will now try to locate the CUDA installation next to :program:`ptxas` + in the `PATH` environment variable. This behavior can be turned off by passing + the new flag `--cuda-path-ignore-env`. + +- Clang now supports generating object files with relocatable device code. This + feature needs to be enabled with `-fcuda-rdc` and my result in performance + penalties compared to whole program compilation. Please note that NVIDIA's + :program:`nvcc` must be used for linking. + Internal API Changes Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=330426&r1=330425&r2=330426&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 20 06:04:54 2018 @@ -573,7 +573,7 @@ def fno_cuda_flush_denormals_to_zero : F def fcuda_approx_transcendentals : Flag<["-"], "fcuda-approx-transcendentals">, Flags<[CC1Option]>, HelpText<"Use approximate transcendental functions">; def fno_cuda_approx_transcendentals : Flag<["-"], "fno-cuda-approx-transcendentals">; -def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option, HelpHidden]>, +def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option]>, HelpText<"Generate relocatable device code, also known as separate compilation mode.">; def fno_cuda_rdc : Flag<["-"], "fno-cuda-rdc">; def dA : Flag<["-"], "dA">, Group; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42922: [CUDA] Register relocatable GPU binaries
This revision was automatically updated to reflect the committed changes. Closed by commit rC330425: [CUDA] Register relocatable GPU binaries (authored by Hahnfeld, committed by ). Repository: rC Clang https://reviews.llvm.org/D42922 Files: lib/CodeGen/CGCUDANV.cpp test/CodeGenCUDA/device-stub.cu Index: test/CodeGenCUDA/device-stub.cu === --- test/CodeGenCUDA/device-stub.cu +++ test/CodeGenCUDA/device-stub.cu @@ -1,33 +1,40 @@ // RUN: echo "GPU binary would be here" > %t -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - \ +// RUN: | FileCheck %s --check-prefixes=ALL,NORDC +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ // RUN: | FileCheck %s -check-prefix=NOGLOBALS -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - \ +// RUN: | FileCheck %s --check-prefixes=ALL,RDC +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \ +// RUN: | FileCheck %s -check-prefix=NOGPUBIN #include "Inputs/cuda.h" #ifndef NOGLOBALS -// CHECK-DAG: @device_var = internal global i32 +// ALL-DAG: @device_var = internal global i32 __device__ int device_var; -// CHECK-DAG: @constant_var = internal global i32 +// ALL-DAG: @constant_var = internal global i32 __constant__ int constant_var; -// CHECK-DAG: @shared_var = internal global i32 +// ALL-DAG: @shared_var = internal global i32 __shared__ int shared_var; // Make sure host globals don't get internalized... -// CHECK-DAG: @host_var = global i32 +// ALL-DAG: @host_var = global i32 int host_var; // ... and that extern vars remain external. -// CHECK-DAG: @ext_host_var = external global i32 +// ALL-DAG: @ext_host_var = external global i32 extern int ext_host_var; // Shadows for external device-side variables are *definitions* of // those variables. -// CHECK-DAG: @ext_device_var = internal global i32 +// ALL-DAG: @ext_device_var = internal global i32 extern __device__ int ext_device_var; -// CHECK-DAG: @ext_device_var = internal global i32 +// ALL-DAG: @ext_device_var = internal global i32 extern __constant__ int ext_constant_var; void use_pointers() { @@ -43,59 +50,73 @@ // Make sure that all parts of GPU code init/cleanup are there: // * constant unnamed string with the kernel name -// CHECK: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00" +// ALL: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00" // * constant unnamed string with GPU binary -// CHECK: private unnamed_addr constant{{.*GPU binary would be here.*}}\00" -// CHECK-SAME: section ".nv_fatbin", align 8 +// ALL: private unnamed_addr constant{{.*GPU binary would be here.*}}\00" +// NORDC-SAME: section ".nv_fatbin", align 8 +// RDC-SAME: section "__nv_relfatbin", align 8 // * constant struct that wraps GPU binary -// CHECK: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } -// CHECK-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null } -// CHECK-SAME: section ".nvFatBinSegment" +// ALL: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } +// ALL-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null } +// ALL-SAME: section ".nvFatBinSegment" // * variable to save GPU binary handle after initialization -// CHECK: @__cuda_gpubin_handle = internal global i8** null -// * Make sure our constructor/destructor was added to global ctor/dtor list. -// CHECK: @llvm.global_ctors = appending global {{.*}}@__cuda_module_ctor -// CHECK: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor +// NORDC: @__cuda_gpubin_handle = internal global i8** null +// * constant unnamed string with NVModuleID +// RDC: [[MODULE_ID_GLOBAL:@.*]] = private unnamed_addr constant +// RDC-SAME: c"[[MODULE_ID:.+]]\00", section "__nv_module_id", align 32 +// * Make sure our constructor was added to global ctor list. +// ALL: @llvm.global_ctors = appending global {{.*}}@__cuda_module_ctor +// * In separate mode we also register a destructor. +// NORDC: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor +// * Alias to global symbol containing the NVModuleID. +// RDC: @__fatbinwrap[[MODULE_ID]] = alias { i32, i32, i8*, i8* } +// RDC-SAME: { i32, i32, i8*, i8* }* @__cuda_fatbin_wrapper // Test that we build the correct number of calls to cudaSetupArgument followed // by a call to cudaLaunch. -// CHECK: define{{.*}}kernelfunc -// CHECK: call{{.*}}cudaSetupArgument -// CHECK: call{{.*}}cudaSetupArgument -// CHECK: call{{.*}}cudaSetupArgument -// CHECK: call{{.*}}cudaLaunch +//
r330425 - [CUDA] Register relocatable GPU binaries
Author: hahnfeld Date: Fri Apr 20 06:04:45 2018 New Revision: 330425 URL: http://llvm.org/viewvc/llvm-project?rev=330425&view=rev Log: [CUDA] Register relocatable GPU binaries nvcc generates a unique registration function for each object file that contains relocatable device code. Unique names are achieved with a module id that is also reflected in the function's name. Differential Revision: https://reviews.llvm.org/D42922 Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp cfe/trunk/test/CodeGenCUDA/device-stub.cu Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=330425&r1=330424&r2=330425&view=diff == --- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Fri Apr 20 06:04:45 2018 @@ -15,12 +15,13 @@ #include "CGCUDARuntime.h" #include "CodeGenFunction.h" #include "CodeGenModule.h" -#include "clang/CodeGen/ConstantInitBuilder.h" #include "clang/AST/Decl.h" +#include "clang/CodeGen/ConstantInitBuilder.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CallSite.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" +#include "llvm/Support/Format.h" using namespace clang; using namespace CodeGen; @@ -45,10 +46,16 @@ private: /// ModuleCtorFunction() and used to create corresponding cleanup calls in /// ModuleDtorFunction() llvm::GlobalVariable *GpuBinaryHandle = nullptr; + /// Whether we generate relocatable device code. + bool RelocatableDeviceCode; llvm::Constant *getSetupArgumentFn() const; llvm::Constant *getLaunchFn() const; + llvm::FunctionType *getRegisterGlobalsFnTy() const; + llvm::FunctionType *getCallbackFnTy() const; + llvm::FunctionType *getRegisterLinkedBinaryFnTy() const; + /// Creates a function to register all kernel stubs generated in this module. llvm::Function *makeRegisterGlobalsFn(); @@ -71,7 +78,23 @@ private: return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(), ConstStr.getPointer(), Zeros); - } + } + + /// Helper function that generates an empty dummy function returning void. + llvm::Function *makeDummyFunction(llvm::FunctionType *FnTy) { +assert(FnTy->getReturnType()->isVoidTy() && + "Can only generate dummy functions returning void!"); +llvm::Function *DummyFunc = llvm::Function::Create( +FnTy, llvm::GlobalValue::InternalLinkage, "dummy", &TheModule); + +llvm::BasicBlock *DummyBlock = +llvm::BasicBlock::Create(Context, "", DummyFunc); +CGBuilderTy FuncBuilder(CGM, Context); +FuncBuilder.SetInsertPoint(DummyBlock); +FuncBuilder.CreateRetVoid(); + +return DummyFunc; + } void emitDeviceStubBody(CodeGenFunction &CGF, FunctionArgList &Args); @@ -93,7 +116,8 @@ public: CGNVCUDARuntime::CGNVCUDARuntime(CodeGenModule &CGM) : CGCUDARuntime(CGM), Context(CGM.getLLVMContext()), - TheModule(CGM.getModule()) { + TheModule(CGM.getModule()), + RelocatableDeviceCode(CGM.getLangOpts().CUDARelocatableDeviceCode) { CodeGen::CodeGenTypes &Types = CGM.getTypes(); ASTContext &Ctx = CGM.getContext(); @@ -120,6 +144,22 @@ llvm::Constant *CGNVCUDARuntime::getLaun llvm::FunctionType::get(IntTy, CharPtrTy, false), "cudaLaunch"); } +llvm::FunctionType *CGNVCUDARuntime::getRegisterGlobalsFnTy() const { + return llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false); +} + +llvm::FunctionType *CGNVCUDARuntime::getCallbackFnTy() const { + return llvm::FunctionType::get(VoidTy, VoidPtrTy, false); +} + +llvm::FunctionType *CGNVCUDARuntime::getRegisterLinkedBinaryFnTy() const { + auto CallbackFnTy = getCallbackFnTy(); + auto RegisterGlobalsFnTy = getRegisterGlobalsFnTy(); + llvm::Type *Params[] = {RegisterGlobalsFnTy->getPointerTo(), VoidPtrTy, + VoidPtrTy, CallbackFnTy->getPointerTo()}; + return llvm::FunctionType::get(VoidTy, Params, false); +} + void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) { EmittedKernels.push_back(CGF.CurFn); @@ -181,8 +221,8 @@ llvm::Function *CGNVCUDARuntime::makeReg return nullptr; llvm::Function *RegisterKernelsFunc = llvm::Function::Create( - llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false), - llvm::GlobalValue::InternalLinkage, "__cuda_register_globals", &TheModule); + getRegisterGlobalsFnTy(), llvm::GlobalValue::InternalLinkage, + "__cuda_register_globals", &TheModule); llvm::BasicBlock *EntryBB = llvm::BasicBlock::Create(Context, "entry", RegisterKernelsFunc); CGBuilderTy Builder(CGM, Context); @@ -257,6 +297,11 @@ llvm::Function *CGNVCUDARuntime::makeMod // void __cuda_register_globals(void* handle); llvm::Function *RegisterGlobalsFunc = makeRegisterGlobalsFn(); + // We always need a function to pass
[PATCH] D45449: [CUDA] Document recent changes
This revision was automatically updated to reflect the committed changes. Closed by commit rC330426: [CUDA] Document recent changes (authored by Hahnfeld, committed by ). Repository: rC Clang https://reviews.llvm.org/D45449 Files: docs/ReleaseNotes.rst include/clang/Driver/Options.td Index: docs/ReleaseNotes.rst === --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -163,6 +163,18 @@ - ... +CUDA Support in Clang +- + +- Clang will now try to locate the CUDA installation next to :program:`ptxas` + in the `PATH` environment variable. This behavior can be turned off by passing + the new flag `--cuda-path-ignore-env`. + +- Clang now supports generating object files with relocatable device code. This + feature needs to be enabled with `-fcuda-rdc` and my result in performance + penalties compared to whole program compilation. Please note that NVIDIA's + :program:`nvcc` must be used for linking. + Internal API Changes Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -573,7 +573,7 @@ def fcuda_approx_transcendentals : Flag<["-"], "fcuda-approx-transcendentals">, Flags<[CC1Option]>, HelpText<"Use approximate transcendental functions">; def fno_cuda_approx_transcendentals : Flag<["-"], "fno-cuda-approx-transcendentals">; -def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option, HelpHidden]>, +def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option]>, HelpText<"Generate relocatable device code, also known as separate compilation mode.">; def fno_cuda_rdc : Flag<["-"], "fno-cuda-rdc">; def dA : Flag<["-"], "dA">, Group; Index: docs/ReleaseNotes.rst === --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -163,6 +163,18 @@ - ... +CUDA Support in Clang +- + +- Clang will now try to locate the CUDA installation next to :program:`ptxas` + in the `PATH` environment variable. This behavior can be turned off by passing + the new flag `--cuda-path-ignore-env`. + +- Clang now supports generating object files with relocatable device code. This + feature needs to be enabled with `-fcuda-rdc` and my result in performance + penalties compared to whole program compilation. Please note that NVIDIA's + :program:`nvcc` must be used for linking. + Internal API Changes Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -573,7 +573,7 @@ def fcuda_approx_transcendentals : Flag<["-"], "fcuda-approx-transcendentals">, Flags<[CC1Option]>, HelpText<"Use approximate transcendental functions">; def fno_cuda_approx_transcendentals : Flag<["-"], "fno-cuda-approx-transcendentals">; -def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option, HelpHidden]>, +def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option]>, HelpText<"Generate relocatable device code, also known as separate compilation mode.">; def fno_cuda_rdc : Flag<["-"], "fno-cuda-rdc">; def dA : Flag<["-"], "dA">, Group; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45877: clang-cl: Accept (and ignore) /Zc:__cplusplus.
thakis closed this revision. thakis added a comment. r330427, thanks! https://reviews.llvm.org/D45877 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45877: clang-cl: Accept (and ignore) /Zc:__cplusplus.
thakis created this revision. thakis added a reviewer: hans. thakis edited the summary of this revision. hans accepted this revision. hans added a comment. This revision is now accepted and ready to land. lgtm, thanks! See https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/ clang-cl already sets __cplusplus to the correct value, so we can just ignore this flag. Also add test coverage for a few more accepted-but-ignored flags. https://reviews.llvm.org/D45877 Files: include/clang/Driver/CLCompatOptions.td test/Driver/cl-options.c Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -346,6 +346,7 @@ // RUN:/GS- \ // RUN:/kernel- \ // RUN:/nologo \ +// RUN:/Og \ // RUN:/openmp- \ // RUN:/permissive- \ // RUN:/RTC1 \ @@ -357,6 +358,14 @@ // RUN:/volatile:iso \ // RUN:/w12345 \ // RUN:/wd1234 \ +// RUN:/Zc:__cplusplus \ +// RUN:/Zc:auto \ +// RUN:/Zc:forScope \ +// RUN:/Zc:inline \ +// RUN:/Zc:rvalueCast \ +// RUN:/Zc:ternary \ +// RUN:/Zc:wchar_t \ +// RUN:/Zm \ // RUN:/Zo \ // RUN:/Zo- \ // RUN:-### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s Index: include/clang/Driver/CLCompatOptions.td === --- include/clang/Driver/CLCompatOptions.td +++ include/clang/Driver/CLCompatOptions.td @@ -338,12 +338,13 @@ def _SLASH_utf8 : CLIgnoredFlag<"utf-8">, HelpText<"Set source and runtime encoding to UTF-8 (default)">; def _SLASH_w : CLIgnoredJoined<"w">; +def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">; def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">; def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">; def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">; def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">; -def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; def _SLASH_Zc_ternary : CLIgnoredFlag<"Zc:ternary">; +def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; def _SLASH_Zm : CLIgnoredJoined<"Zm">; def _SLASH_Zo : CLIgnoredFlag<"Zo">; def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">; Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -346,6 +346,7 @@ // RUN:/GS- \ // RUN:/kernel- \ // RUN:/nologo \ +// RUN:/Og \ // RUN:/openmp- \ // RUN:/permissive- \ // RUN:/RTC1 \ @@ -357,6 +358,14 @@ // RUN:/volatile:iso \ // RUN:/w12345 \ // RUN:/wd1234 \ +// RUN:/Zc:__cplusplus \ +// RUN:/Zc:auto \ +// RUN:/Zc:forScope \ +// RUN:/Zc:inline \ +// RUN:/Zc:rvalueCast \ +// RUN:/Zc:ternary \ +// RUN:/Zc:wchar_t \ +// RUN:/Zm \ // RUN:/Zo \ // RUN:/Zo- \ // RUN:-### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s Index: include/clang/Driver/CLCompatOptions.td === --- include/clang/Driver/CLCompatOptions.td +++ include/clang/Driver/CLCompatOptions.td @@ -338,12 +338,13 @@ def _SLASH_utf8 : CLIgnoredFlag<"utf-8">, HelpText<"Set source and runtime encoding to UTF-8 (default)">; def _SLASH_w : CLIgnoredJoined<"w">; +def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">; def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">; def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">; def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">; def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">; -def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; def _SLASH_Zc_ternary : CLIgnoredFlag<"Zc:ternary">; +def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; def _SLASH_Zm : CLIgnoredJoined<"Zm">; def _SLASH_Zo : CLIgnoredFlag<"Zo">; def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45877: clang-cl: Accept (and ignore) /Zc:__cplusplus.
hans accepted this revision. hans added a comment. This revision is now accepted and ready to land. lgtm, thanks! https://reviews.llvm.org/D45877 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330427 - clang-cl: Accept (and ignore) /Zc:__cplusplus.
Author: nico Date: Fri Apr 20 06:10:44 2018 New Revision: 330427 URL: http://llvm.org/viewvc/llvm-project?rev=330427&view=rev Log: clang-cl: Accept (and ignore) /Zc:__cplusplus. See https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/ clang-cl already sets __cplusplus to the correct value, so we can just ignore this flag. Also add test coverage for a few more accepted-but-ignored flags. https://reviews.llvm.org/D45877 Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=330427&r1=330426&r2=330427&view=diff == --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original) +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Fri Apr 20 06:10:44 2018 @@ -338,12 +338,13 @@ def _SLASH_sdl_ : CLIgnoredFlag<"sdl-">; def _SLASH_utf8 : CLIgnoredFlag<"utf-8">, HelpText<"Set source and runtime encoding to UTF-8 (default)">; def _SLASH_w : CLIgnoredJoined<"w">; +def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">; def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">; def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">; def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">; def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">; -def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; def _SLASH_Zc_ternary : CLIgnoredFlag<"Zc:ternary">; +def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; def _SLASH_Zm : CLIgnoredJoined<"Zm">; def _SLASH_Zo : CLIgnoredFlag<"Zo">; def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">; Modified: cfe/trunk/test/Driver/cl-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=330427&r1=330426&r2=330427&view=diff == --- cfe/trunk/test/Driver/cl-options.c (original) +++ cfe/trunk/test/Driver/cl-options.c Fri Apr 20 06:10:44 2018 @@ -346,6 +346,7 @@ // RUN:/GS- \ // RUN:/kernel- \ // RUN:/nologo \ +// RUN:/Og \ // RUN:/openmp- \ // RUN:/permissive- \ // RUN:/RTC1 \ @@ -357,6 +358,14 @@ // RUN:/volatile:iso \ // RUN:/w12345 \ // RUN:/wd1234 \ +// RUN:/Zc:__cplusplus \ +// RUN:/Zc:auto \ +// RUN:/Zc:forScope \ +// RUN:/Zc:inline \ +// RUN:/Zc:rvalueCast \ +// RUN:/Zc:ternary \ +// RUN:/Zc:wchar_t \ +// RUN:/Zm \ // RUN:/Zo \ // RUN:/Zo- \ // RUN:-### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330430 - [docs] Regenerate command line reference
Author: hahnfeld Date: Fri Apr 20 06:26:03 2018 New Revision: 330430 URL: http://llvm.org/viewvc/llvm-project?rev=330430&view=rev Log: [docs] Regenerate command line reference This will correctly sort some manually added entries which should generally be avoided! Modified: cfe/trunk/docs/ClangCommandLineReference.rst Modified: cfe/trunk/docs/ClangCommandLineReference.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=330430&r1=330429&r2=330430&view=diff == --- cfe/trunk/docs/ClangCommandLineReference.rst (original) +++ cfe/trunk/docs/ClangCommandLineReference.rst Fri Apr 20 06:26:03 2018 @@ -144,14 +144,14 @@ Compile CUDA code for device only CUDA GPU architecture (e.g. sm\_35). May be specified more than once. -.. option:: --cuda-include-ptx=, --no-cuda-include-ptx= - -Include (or not) PTX along with CUDA GPU binary for the given architecture (e.g. sm\_35). Argument may be 'all'. The option may be specified more than once. Default: --cuda-include-ptx=all - .. option:: --cuda-host-only Compile CUDA code for host only. Has no effect on non-CUDA compilations. +.. option:: --cuda-include-ptx=, --no-cuda-include-ptx= + +Include PTX for the follwing GPU architecture (e.g. sm\_35) or 'all'. May be specified more than once. + .. option:: --cuda-noopt-device-debug, --no-cuda-noopt-device-debug Enable device-side debug info generation. Disables ptxas optimizations. @@ -202,6 +202,10 @@ Use approximate transcendental functions Flush denormal floating point values to zero in CUDA device mode. +.. option:: -ffixed-r19 + +Reserve the r19 register (Hexagon only) + .. option:: -fheinous-gnu-extensions .. option:: -flat\_namespace @@ -242,6 +246,8 @@ Display available options .. option:: --help-hidden +Display help for hidden options + .. option:: -image\_base .. option:: -index-header-map @@ -940,7 +946,7 @@ Specify the module user build path Don't verify input files for the modules if the module has been successfully validated or loaded during this build session -.. option:: -fmodules-validate-system-headers +.. option:: -fmodules-validate-system-headers, -fno-modules-validate-system-headers Validate the system headers that a module depends on when loading the module @@ -948,8 +954,6 @@ Validate the system headers that a modul Specify the prebuilt module path -.. option:: -i - .. option:: -idirafter, --include-directory-after , --include-directory-after= Add directory to AFTER include search path @@ -1135,6 +1139,12 @@ Target-independent compilation options .. option:: -faccess-control, -fno-access-control +.. option:: -falign-functions, -fno-align-functions + +.. program:: clang1 +.. option:: -falign-functions= +.. program:: clang + .. program:: clang1 .. option:: -faligned-allocation, -faligned-new, -fno-aligned-allocation .. program:: clang @@ -1337,6 +1347,8 @@ Use emutls functions to access thread\_l .. option:: -ferror-limit= +.. option:: -fescaping-block-tail-calls, -fno-escaping-block-tail-calls + .. option:: -fexceptions, -fno-exceptions Enable support for exception handling @@ -1353,6 +1365,10 @@ Allow aggressive, lossy floating-point o .. option:: -ffor-scope, -fno-for-scope +.. option:: -fforce-enable-int128, -fno-force-enable-int128 + +Enable support for int128\_t type + .. option:: -ffp-contract= Form fused FP ops (e.g. FMAs): fast (everywhere) \| on (according to FP\_CONTRACT pragma, default) \| off (never fuse) @@ -1441,6 +1457,8 @@ Specify the maximum alignment to enforce .. option:: -fmerge-all-constants, -fno-merge-all-constants +Allow merging of constants + .. option:: -fmessage-length= .. option:: -fmodule-file-deps, -fno-module-file-deps @@ -1523,10 +1541,16 @@ Do not elide types when printing diagnos Do not treat C++ operator name keywords as synonyms for operators +.. option:: -fno-rtti-data + +Control emission of RTTI data + .. option:: -fno-strict-modules-decluse .. option:: -fno-working-directory +.. option:: -fnoxray-link-deps + .. option:: -fobjc-abi-version= .. option:: -fobjc-arc, -fno-objc-arc @@ -1680,6 +1704,10 @@ Allow division operations to be reassoci Override the default ABI to return small structs in registers +.. option:: -fregister-global-dtors-with-atexit, -fno-register-global-dtors-with-atexit + +Use atexit or \_\_cxa\_atexit to register global destructors + .. option:: -frelaxed-template-template-args, -fno-relaxed-template-template-args Enable C++17 relaxed template template argument matching @@ -1906,9 +1934,17 @@ Store string literals as writable data Determine whether to always emit \_\_xray\_customevent(...) calls even if the function it appears in is not always instrumented. +.. option:: -fxray-always-emit-typedevents, -fno-xray-always-emit-typedevents + +Determine whether to always emit \_\_xray\_typedevent(...) calls
r330429 - [OpenMP] Hide -fopenmp-cuda-mode
Author: hahnfeld Date: Fri Apr 20 06:25:59 2018 New Revision: 330429 URL: http://llvm.org/viewvc/llvm-project?rev=330429&view=rev Log: [OpenMP] Hide -fopenmp-cuda-mode This is an advanced flag that should show up neither in clang --help nor in the ClangCommandLineReference. Modified: cfe/trunk/include/clang/Driver/Options.td Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=330429&r1=330428&r2=330429&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 20 06:25:59 2018 @@ -1463,8 +1463,10 @@ def fnoopenmp_relocatable_target : Flag< def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, Flags<[CC1Option, NoArgumentUnused]>, HelpText<"Emit OpenMP code only for SIMD-based constructs.">; def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, Flags<[CC1Option, NoArgumentUnused]>; -def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group, Flags<[CC1Option, NoArgumentUnused]>; -def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, Group, Flags<[NoArgumentUnused]>; +def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group, + Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; +def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, Group, + Flags<[NoArgumentUnused, HelpHidden]>; def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Group; def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, Group; def fno_escaping_block_tail_calls : Flag<["-"], "fno-escaping-block-tail-calls">, Group, Flags<[CC1Option]>; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu
yaxunl updated this revision to Diff 143307. yaxunl added a comment. minor bug fix: do not add CUDA specific link options for HIP. https://reviews.llvm.org/D45212 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Action.h include/clang/Driver/Options.td include/clang/Driver/ToolChain.h lib/Driver/Action.cpp lib/Driver/Compilation.cpp lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/Cuda.cpp lib/Driver/ToolChains/Cuda.h test/Driver/cuda-bad-arch.cu test/Driver/cuda-phases.cu Index: test/Driver/cuda-phases.cu === --- test/Driver/cuda-phases.cu +++ test/Driver/cuda-phases.cu @@ -7,195 +7,233 @@ // REQUIRES: clang-driver // REQUIRES: powerpc-registered-target // REQUIRES: nvptx-registered-target - +// REQUIRES: amdgpu-registered-target // // Test single gpu architecture with complete compilation. // // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s 2>&1 \ -// RUN: | FileCheck -check-prefix=BIN %s -// BIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda) -// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (host-cuda) -// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-cuda) -// BIN-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30) -// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, sm_30) -// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, sm_30) -// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, sm_30) -// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, sm_30) -// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P7]]}, object -// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P6]]}, assembler -// BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-cuda) -// BIN-DAG: [[P11:[0-9]+]]: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-cuda (nvptx64-nvidia-cuda)" {[[P10]]}, ir -// BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-cuda) -// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-cuda) -// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-cuda) +// RUN: | FileCheck -check-prefixes=BIN,BIN_NV %s +// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN,BIN_AMD %s +// BIN_NV-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:cuda]], (host-[[T]]) +// BIN_AMD-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:hip]], (host-[[T]]) +// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (host-[[T]]) +// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-[[T]]) +// BIN_NV-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:sm_30]]) +// BIN_AMD-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:gfx803]]) +// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]]) +// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-[[T]], [[ARCH]]) +// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-[[T]], [[ARCH]]) +// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-[[T]], [[ARCH]]) +// BIN_NV-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE:nvptx64-nvidia-cuda]]:[[ARCH]])" {[[P7]]}, object +// BIN_AMD-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P7]]}, object +// BIN-DAG: [[P9:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE]]:[[ARCH]])" {[[P6]]}, assembler +// BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-[[T]]) +// BIN-DAG: [[P11:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-[[T]] ([[TRIPLE]])" {[[P10]]}, ir +// BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]]) +// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]]) +// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]]) // // Test single gpu architecture up to the assemble phase. // // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s -S 2>&1 \ -// RUN: | FileCheck -check-prefix=ASM %s -// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30) -// ASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (device-cuda, sm_30) -// ASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-cuda, sm_30) -// ASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-cuda, sm_30) -// ASM-DAG: [[P4:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P3]]}, assembler -// ASM-DAG: [[P5:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda) -// ASM-DAG: [[P6:[0-9]+]]: preprocessor, {[[P5]]}, cuda-cpp-output, (host-cuda) -/
[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature
avt77 added inline comments. Comment at: test/Frontend/ftime-report-template-decl.cpp:2 +// RUN: %clang %s -S -o - -ftime-report 2>&1 | FileCheck %s +// RUN: %clang %s -S -o - -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING -ftime-report 2>&1 | FileCheck %s + efriedma wrote: > What is this test supposed to be testing? If you're just checking that we > output the timers, this doesn't need to be so complicated. > > We generally prefer to use %clang_cc1 for tests like this. > > Please use -emit-llvm instead of -S if you don't actually need assembly. You wrote "What is this test supposed to be testing? If you're just checking that we output the timers, this doesn't need to be so complicated." I'm going to use this test to show new timers soon that's why it looks so complicated at the first glance. At the moment it simply checking the output of the existing counter but later it will show the new counters. 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] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature
avt77 updated this revision to Diff 143311. avt77 added a comment. I fixed issues raised by efriedma. https://reviews.llvm.org/D45619 Files: include/clang/Frontend/Utils.h lib/CodeGen/BackendUtil.cpp lib/CodeGen/CodeGenAction.cpp lib/Frontend/CMakeLists.txt lib/Frontend/FrontendTiming.cpp test/Frontend/ftime-report-template-decl.cpp Index: test/Frontend/ftime-report-template-decl.cpp === --- test/Frontend/ftime-report-template-decl.cpp +++ test/Frontend/ftime-report-template-decl.cpp @@ -0,0 +1,159 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -ftime-report 2>&1 | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING -ftime-report 2>&1 | FileCheck %s + +// Template function declarations +template +void foo(); +template +void foo(); + +// Template function definitions. +template +void foo() {} + +// Template class (forward) declarations +template +struct A; +template +struct b; +template +struct C; +template +struct D; + +// Forward declarations with default parameters? +template +class X1; +template +class X2; + +// Forward declarations w/template template parameters +template class T> +class TTP1; +template class> +class TTP2; +template class T> +class TTP5; + +// Forward declarations with non-type params +template +class NTP0; +template +class NTP1; +template +class NTP2; +template +class NTP3; +template +class NTP4; +template +class NTP5; +template +class NTP6; +template +class NTP7; + +// Template class declarations +template +struct A {}; +template +struct B {}; + +namespace PR6184 { +namespace N { +template +void bar(typename T::x); +} + +template +void N::bar(typename T::x) {} +} + +// This PR occurred only in template parsing mode. +namespace PR17637 { +template +struct L { + template + struct O { +template +static void Fun(U); + }; +}; + +template +template +template +void L::O::Fun(U) {} + +void Instantiate() { L<0>::O::Fun(0); } +} + +namespace explicit_partial_specializations { +typedef char (&oneT)[1]; +typedef char (&twoT)[2]; +typedef char (&threeT)[3]; +typedef char (&fourT)[4]; +typedef char (&fiveT)[5]; +typedef char (&sixT)[6]; + +char one[1]; +char two[2]; +char three[3]; +char four[4]; +char five[5]; +char six[6]; + +template +struct bool_ { typedef int type; }; +template <> +struct bool_ {}; + +#define XCAT(x, y) x##y +#define CAT(x, y) XCAT(x, y) +#define sassert(_b_) bool_<(_b_)>::type CAT(var, __LINE__); + +template +struct L { + template + struct O { +template +static oneT Fun(U); + }; +}; +template +template +template +oneT L::O::Fun(U) { return one; } + +template <> +template <> +template +oneT L<0>::O::Fun(U) { return one; } + +void Instantiate() { + sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one)); + sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one)); +} +} + +template +struct Foo { + template + using rebind_alloc = _Other; +}; +template +struct _Wrap_alloc { + template + using rebind_alloc = typename Foo<_Alloc>::template rebind_alloc<_Other>; + template + using rebind = _Wrap_alloc; +}; +_Wrap_alloc::rebind w; + +// CHECK: Miscellaneous Ungrouped Timers +// CHECK: LLVM IR Generation Time +// CHECK: Code Generation Time +// CHECK: Total +// CHECK: Clang front-end time report +// CHECK: Clang front-end timer +// CHECK: Total Index: lib/Frontend/FrontendTiming.cpp === --- lib/Frontend/FrontendTiming.cpp +++ lib/Frontend/FrontendTiming.cpp @@ -0,0 +1,20 @@ +//===- FronendTiming.cpp - Implements Frontend timing utils --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// This file keps implementation of frontend timing utils. +// +//===--===// + +#include "clang/Frontend/Utils.h" + +namespace clang { + +bool FrontendTimesIsEnabled = false; + +} Index: lib/Frontend/CMakeLists.txt === --- lib/Frontend/CMakeLists.txt +++ lib/Frontend/CMakeLists.txt @@ -29,6 +29,7 @@ FrontendAction.cpp FrontendActions.cpp FrontendOptions.cpp + FrontendTiming.cpp HeaderIncludeGen.cpp InitHeaderSearch.cpp InitPreprocessor.cpp Index: lib/CodeGen/CodeGenAction.cpp === --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -126,7 +126,7 @@ Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts, CodeGenOpts, C, CoverageInfo)), LinkModules(std::move(LinkModules)) { - llvm::TimePassesIsEnabled = TimePasses; + Fronte
[PATCH] D45815: [libclang] Add options to limit skipping of function bodies
nik added a comment. In https://reviews.llvm.org/D45815#1073418, @ilya-biryukov wrote: > In https://reviews.llvm.org/D45815#1072094, @nik wrote: > > > @ilya: Using SkipFunctionBodies_AllExceptTemplates for the preamble might > > be also useful for clangd. > > > Unfortunately, that's also the biggest performance win you get when skipping > the function bodies. > I.e. most codebases do not have function bodies in headers unless the > function is template. > > Have you measured the performance gain of skipping only non-template > functions, but not skipping the template ones? > Would that really make a significant difference for any real codebase? Here are some rough numbers, based on LIBCLANG_TIMING=1 output: https://dpaste.de/os39/raw Reparses of Qt Creator's texteditor.cpp Without any skipping of function bodies in the preamble: 1.9s Skipping all function bodies in the preamble: 1.0s Skipping all function bodies in the preamble except function template bodies: 1.2s Reparses of Clang's SemaDecl.cpp Without any skipping of function bodies in the preamble: 1.7s Skipping all function bodies in the preamble: 0.59s Skipping all function bodies in the preamble except function template bodies: 0.64s Hmm, that indicates that template function bodies are actually not that dominant, which I also haven't thought. Now I'm doubting the correctness of my patch/tests. I'll recheck this on Tuesday. Until then, you/someone might want to give this also a shot. Comment at: include/clang/Frontend/SkipFunctionBodies.h:18 +enum SkipFunctionBodiesKind { + SkipFunctionBodies_None, + SkipFunctionBodies_All, ilya-biryukov wrote: > Maybe make it `enum class` and remove the name prefix from enumerators? > I.e. `enum class SkipFunctionBodiesKind { None, ` Will do. Repository: rC Clang https://reviews.llvm.org/D45815 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45873: [OpenCL] Reject virtual functions for OpenCL C++
yaxunl added inline comments. Comment at: test/Parser/opencl-cxx-virtual.cl:1 +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -fsyntax-only -verify + can you add a test for template class with virtual member? Repository: rC Clang https://reviews.llvm.org/D45873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45884: [Sema] Fix parsing of anonymous union in language linkage specification
jkorous created this revision. jkorous added reviewers: vsapsai, arphaman, rsmith. jkorous added a project: clang. Herald added a subscriber: cfe-commits. C++17 [dcl.link]p4: A linkage specification does not establish a scope. C++17 [class.union.anon]p2: Namespace level anonymous unions shall be declared static. The test produces a crash on master. Repository: rC Clang https://reviews.llvm.org/D45884 Files: Sema/SemaDecl.cpp SemaCXX/anonymous-union.cpp Index: SemaCXX/anonymous-union.cpp === --- SemaCXX/anonymous-union.cpp +++ SemaCXX/anonymous-union.cpp @@ -80,6 +80,10 @@ float float_val; }; +extern "C++" { +union { }; // expected-error{{anonymous unions at namespace or global scope must be declared 'static'}} +} + static union { int int_val2; // expected-note{{previous definition is here}} float float_val2; Index: Sema/SemaDecl.cpp === --- Sema/SemaDecl.cpp +++ Sema/SemaDecl.cpp @@ -4645,12 +4645,20 @@ unsigned DiagID; if (Record->isUnion()) { // C++ [class.union]p6: + // C++17 [class.union.anon]p2: // Anonymous unions declared in a named namespace or in the // global namespace shall be declared static. + + // We need to get to the parent scope (extern {} is not a scope). + DeclContext *OwnerScope = Owner; + while (OwnerScope->getDeclKind() == Decl::LinkageSpec) { +OwnerScope = OwnerScope->getParent(); + } + if (DS.getStorageClassSpec() != DeclSpec::SCS_static && - (isa(Owner) || - (isa(Owner) && -cast(Owner)->getDeclName( { + (isa(OwnerScope) || + (isa(OwnerScope) && +cast(OwnerScope)->getDeclName( { Diag(Record->getLocation(), diag::err_anonymous_union_not_static) << FixItHint::CreateInsertion(Record->getLocation(), "static "); Index: SemaCXX/anonymous-union.cpp === --- SemaCXX/anonymous-union.cpp +++ SemaCXX/anonymous-union.cpp @@ -80,6 +80,10 @@ float float_val; }; +extern "C++" { +union { }; // expected-error{{anonymous unions at namespace or global scope must be declared 'static'}} +} + static union { int int_val2; // expected-note{{previous definition is here}} float float_val2; Index: Sema/SemaDecl.cpp === --- Sema/SemaDecl.cpp +++ Sema/SemaDecl.cpp @@ -4645,12 +4645,20 @@ unsigned DiagID; if (Record->isUnion()) { // C++ [class.union]p6: + // C++17 [class.union.anon]p2: // Anonymous unions declared in a named namespace or in the // global namespace shall be declared static. + + // We need to get to the parent scope (extern {} is not a scope). + DeclContext *OwnerScope = Owner; + while (OwnerScope->getDeclKind() == Decl::LinkageSpec) { +OwnerScope = OwnerScope->getParent(); + } + if (DS.getStorageClassSpec() != DeclSpec::SCS_static && - (isa(Owner) || - (isa(Owner) && -cast(Owner)->getDeclName( { + (isa(OwnerScope) || + (isa(OwnerScope) && +cast(OwnerScope)->getDeclName( { Diag(Record->getLocation(), diag::err_anonymous_union_not_static) << FixItHint::CreateInsertion(Record->getLocation(), "static "); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu
yaxunl marked an inline comment as done. yaxunl added inline comments. Comment at: lib/Driver/ToolChains/Cuda.cpp:498-501 +OptArgs.push_back(mcpustr); +OptArgs.push_back("-dce"); +OptArgs.push_back("-sroa"); +OptArgs.push_back("-globaldce"); yaxunl wrote: > tra wrote: > > This does not look like the right place to disable particular passes. > > Shouldn't it be done somewhere in LLVM? > These are not disabling the passes but adding these passes. They are some > optimizations which are usually improving performance for amdgcn. Since opt is now able to adjust passes based on -mtriple and -mcpu, will remove these manually added passes and add -mtriple and -mcpu instead. https://reviews.llvm.org/D45212 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu
yaxunl updated this revision to Diff 143320. yaxunl marked an inline comment as done. yaxunl added a comment. Remove manually added passes from opt and add -mtriple. https://reviews.llvm.org/D45212 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Action.h include/clang/Driver/Options.td include/clang/Driver/ToolChain.h lib/Driver/Action.cpp lib/Driver/Compilation.cpp lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/Cuda.cpp lib/Driver/ToolChains/Cuda.h test/Driver/cuda-bad-arch.cu test/Driver/cuda-phases.cu Index: test/Driver/cuda-phases.cu === --- test/Driver/cuda-phases.cu +++ test/Driver/cuda-phases.cu @@ -7,195 +7,233 @@ // REQUIRES: clang-driver // REQUIRES: powerpc-registered-target // REQUIRES: nvptx-registered-target - +// REQUIRES: amdgpu-registered-target // // Test single gpu architecture with complete compilation. // // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s 2>&1 \ -// RUN: | FileCheck -check-prefix=BIN %s -// BIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda) -// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (host-cuda) -// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-cuda) -// BIN-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30) -// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, sm_30) -// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, sm_30) -// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, sm_30) -// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, sm_30) -// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P7]]}, object -// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P6]]}, assembler -// BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-cuda) -// BIN-DAG: [[P11:[0-9]+]]: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-cuda (nvptx64-nvidia-cuda)" {[[P10]]}, ir -// BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-cuda) -// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-cuda) -// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-cuda) +// RUN: | FileCheck -check-prefixes=BIN,BIN_NV %s +// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=BIN,BIN_AMD %s +// BIN_NV-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:cuda]], (host-[[T]]) +// BIN_AMD-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:hip]], (host-[[T]]) +// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (host-[[T]]) +// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-[[T]]) +// BIN_NV-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:sm_30]]) +// BIN_AMD-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:gfx803]]) +// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]]) +// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-[[T]], [[ARCH]]) +// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-[[T]], [[ARCH]]) +// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-[[T]], [[ARCH]]) +// BIN_NV-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE:nvptx64-nvidia-cuda]]:[[ARCH]])" {[[P7]]}, object +// BIN_AMD-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P7]]}, object +// BIN-DAG: [[P9:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE]]:[[ARCH]])" {[[P6]]}, assembler +// BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-[[T]]) +// BIN-DAG: [[P11:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-[[T]] ([[TRIPLE]])" {[[P10]]}, ir +// BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]]) +// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]]) +// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]]) // // Test single gpu architecture up to the assemble phase. // // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s -S 2>&1 \ -// RUN: | FileCheck -check-prefix=ASM %s -// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30) -// ASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (device-cuda, sm_30) -// ASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-cuda, sm_30) -// ASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-cuda, sm_30) -// ASM-DAG: [[P4:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P3]]}, assembler -// ASM-DAG: [[P5:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda) -// ASM-DAG: [[P6:[0-9]+]]: preprocessor, {[[P5]
[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)
zahiraam marked 3 inline comments as done. zahiraam added inline comments. Comment at: lib/Sema/SemaDeclAttr.cpp:4937-4938 - return nullptr; -Diag(UA->getLocation(), diag::err_mismatched_uuid); -Diag(Range.getBegin(), diag::note_previous_uuid); -D->dropAttr(); zahiraam wrote: > rsmith wrote: > > Do we still diagnose UUID mismatches somewhere else? > Not as far as I know. I guess I should put this diag somewhere? Fixed the initial code. https://reviews.llvm.org/D43576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)
zahiraam updated this revision to Diff 143321. https://reviews.llvm.org/D43576 Files: include/clang/AST/Decl.h include/clang/Basic/Attr.td include/clang/Sema/AttributeList.h include/clang/Sema/Sema.h lib/AST/Decl.cpp lib/AST/DeclCXX.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CodeGenModule.cpp lib/Parse/ParseDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Serialization/ASTCommon.cpp utils/TableGen/ClangAttrEmitter.cpp Index: utils/TableGen/ClangAttrEmitter.cpp === --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -330,7 +330,7 @@ void writeDump(raw_ostream &OS) const override { if (type == "FunctionDecl *" || type == "NamedDecl *" || - (type == "DeclSpecUuidDecl *")) { + type == "DeclSpecUuidDecl *") { OS << "OS << \" \";\n"; OS << "dumpBareDeclRef(SA->get" << getUpperName() << "());\n"; } else if (type == "IdentifierInfo *") { Index: lib/Serialization/ASTCommon.cpp === --- lib/Serialization/ASTCommon.cpp +++ lib/Serialization/ASTCommon.cpp @@ -269,6 +269,7 @@ case Decl::ObjCProtocol: case Decl::ObjCInterface: case Decl::Empty: + case Decl::DeclSpecUuid: return true; // Never redeclarable. Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -4932,8 +4932,13 @@ UuidAttr *Sema::mergeUuidAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex, DeclSpecUuidDecl *Uuid) { - if (D->getAttr()) -return nullptr; + if (const auto *UA = D->getAttr()) { +if (UA->getDeclSpecUuidDecl()->getStrUuid().equals_lower(Uuid->getStrUuid())) + return nullptr; +Diag(UA->getLocation(), diag::err_mismatched_uuid); +Diag(Range.getBegin(), diag::note_previous_uuid); +D->dropAttr(); + } return ::new (Context) UuidAttr(Range, Context, Uuid, AttrSpellingListIndex); } @@ -4945,7 +4950,7 @@ return; } - StringRef StrRef = AL.getUuidDecl()->getStrUuid(); + StringRef StrRef = AL.getUuidStr(); SourceLocation LiteralLoc = AL.getLoc(); if (StrRef.empty()) return; @@ -4982,12 +4987,28 @@ if (AL.isMicrosoftAttribute()) // Check for [uuid(...)] spelling. S.Diag(AL.getLoc(), diag::warn_atl_uuid_deprecated); + DeclSpecUuidDecl *ArgDecl, *PreviousArgDecl; + ArgDecl = DeclSpecUuidDecl::Create(S.getASTContext(), + S.getFunctionLevelDeclContext(), + SourceLocation(), + StrRef); + + // Do a lookup of the declspec. + auto DSU = S.UuidDeclSpecMap.find(StrRef); + if (DSU != S.UuidDeclSpecMap.end()) { +PreviousArgDecl = DSU->second; +PreviousArgDecl->setNext(ArgDecl); +ArgDecl->setPrevious(PreviousArgDecl); + } + S.UuidDeclSpecMap[StrRef] = ArgDecl; + UuidAttr *UA = S.mergeUuidAttr(D, AL.getRange(), AL.getAttributeSpellingListIndex(), - AL.getUuidDecl()); + ArgDecl); if (UA) D->addAttr(UA); + } static void handleMSInheritanceAttr(Sema &S, Decl *D, const AttributeList &AL) { Index: lib/Parse/ParseDecl.cpp === --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -560,26 +560,20 @@ // Parse the uuid attribute and create a UuidDecl. ConsumeParen(); assert(Tok.is(tok::string_literal) && "uuid not followed by string literal '('"); -int sz = Tok.getLength(); SmallString<8> UuidBuffer; bool Invalid = false; StringRef UuidStr = PP.getSpelling(Tok, UuidBuffer, &Invalid); // Clean up the string from the "\" at begining and at end. StringRef UuidStr1 = UuidStr.ltrim('\"'); StringRef TrimmedUuidStr = UuidStr1.rtrim('\"'); -DeclSpecUuidDecl *ArgDecl = - DeclSpecUuidDecl::Create(Actions.getASTContext(), - Actions.getFunctionLevelDeclContext(), - SourceLocation(), - TrimmedUuidStr); // Advance to next token. Should be a r-paren. PP.Lex(Tok); SourceLocation RParen = Tok.getLocation(); SourceRange attrRange = SourceRange(AttrNameLoc, RParen); if (!ExpectAndConsume(tok::r_paren)) - Attrs.addNew(AttrName, attrRange, nullptr, AttrNameLoc, ArgDecl, AttributeList::AS_Declspec); + Attrs.addNew(AttrName, attrRange, nullptr, AttrNameLoc, TrimmedUuidStr, AttributeList::AS_Declspec); return true; } unsigned NumArgs = @@ -936,7 +930,6 @@ enum { Introduced, Deprecated, Obsoleted, Unknown }; AvailabilityChange Changes[Unknown]; ExprResult MessageExpr, ReplacementExpr; - Decl *DeclSpecUuidDecl = nullptr; // Opening '('. BalancedDelimiterTracker T(*this, tok::l_paren); Index: lib/CodeGen/CodeGenModule.cpp =
[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)
zahiraam added a comment. Richard, Please let me know if I have answered to all the issues you raised. Thanks. https://reviews.llvm.org/D43576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330441 - Fix some tests that were failing on Windows
Author: hans Date: Fri Apr 20 08:33:44 2018 New Revision: 330441 URL: http://llvm.org/viewvc/llvm-project?rev=330441&view=rev Log: Fix some tests that were failing on Windows Modified: cfe/trunk/test/CodeGen/function-alignment.c cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl cfe/trunk/test/Driver/save-stats.c Modified: cfe/trunk/test/CodeGen/function-alignment.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-alignment.c?rev=330441&r1=330440&r2=330441&view=diff == --- cfe/trunk/test/CodeGen/function-alignment.c (original) +++ cfe/trunk/test/CodeGen/function-alignment.c Fri Apr 20 08:33:44 2018 @@ -5,12 +5,12 @@ void f(void) {} void __attribute__((__aligned__(64))) g(void) {} -// CHECK-NONE-NOT: define void @f() #0 align -// CHECK-NONE: define void @g() #0 align 64 +// CHECK-NONE-NOT: define {{(dso_local )?}}void @f() #0 align +// CHECK-NONE: define {{(dso_local )?}}void @g() #0 align 64 -// CHECK-16: define void @f() #0 align 16 -// CHECK-16: define void @g() #0 align 64 +// CHECK-16: define {{(dso_local )?}}void @f() #0 align 16 +// CHECK-16: define {{(dso_local )?}}void @g() #0 align 64 -// CHECK-32: define void @f() #0 align 32 -// CHECK-32: define void @g() #0 align 64 +// CHECK-32: define {{(dso_local )?}}void @f() #0 align 32 +// CHECK-32: define {{(dso_local )?}}void @g() #0 align 64 Modified: cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl?rev=330441&r1=330440&r2=330441&view=diff == --- cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl Fri Apr 20 08:33:44 2018 @@ -7,10 +7,10 @@ // For all targets 'denorms-are-zero' attribute is set to 'true' // if '-cl-denorms-are-zero' was specified and to 'false' otherwise. -// CHECK-LABEL: define void @f() +// CHECK-LABEL: define {{(dso_local )?}}void @f() // CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="false" // -// DENORM-ZERO-LABEL: define void @f() +// DENORM-ZERO-LABEL: define {{(dso_local )?}}void @f() // DENORM-ZERO: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" // For amdgcn target cpu fiji, fp32 should be flushed since fiji does not support fp32 denormals, unless +fp32-denormals is Modified: cfe/trunk/test/Driver/save-stats.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/save-stats.c?rev=330441&r1=330440&r2=330441&view=diff == --- cfe/trunk/test/Driver/save-stats.c (original) +++ cfe/trunk/test/Driver/save-stats.c Fri Apr 20 08:33:44 2018 @@ -25,4 +25,4 @@ // CHECK-LTO: "-plugin-opt=stats-file=save-stats.stats" // RUN: %clang -target x86_64-linux-unknown -save-stats=obj -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO-OBJ -// CHECK-LTO-OBJ: "-plugin-opt=stats-file=obj/dir/save-stats.stats" +// CHECK-LTO-OBJ: "-plugin-opt=stats-file=obj/dir{{/|}}save-stats.stats" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident
miyuki updated this revision to Diff 143327. miyuki added a comment. Updated the test https://reviews.llvm.org/D45255 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CodeGenModule.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/no-ident-version.c Index: test/CodeGen/no-ident-version.c === --- /dev/null +++ test/CodeGen/no-ident-version.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-NONE %s +// RUN: %clang_cc1 -Qn -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QN %s +// RUN: %clang_cc1 -Qy -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QY %s + +// CHECK-NONE: define i32 @main() +// CHECK-NONE: llvm.ident +// CHECK-NONE: producer: + +// CHECK-QN: define i32 @main() +// CHECK-QN-NOT: llvm.ident +// CHECK-QN-NOT: producer: + +// CHECK-QY: define i32 @main() +// CHECK-QY: llvm.ident +// CHECK-QY: producer: +int main(void) {} Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -1112,6 +1112,8 @@ Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue( Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags); + Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true); + return Success; } Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4408,6 +4408,9 @@ } } + if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true)) +CmdArgs.push_back("-Qn"); + // -fcommon is the default unless compiling kernel code or the target says so bool NoCommonDefault = KernelOrKext || isNoCommonDefault(RawTriple); if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common, Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -571,7 +571,8 @@ if (DebugInfo) DebugInfo->finalize(); - EmitVersionIdentMetadata(); + if (getCodeGenOpts().EmitVersionIdentMetadata) +EmitVersionIdentMetadata(); EmitTargetMetadata(); } Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -577,7 +577,8 @@ remapDIPath(getCurrentDirname()), CSInfo, getSource(SM, SM.getMainFileID())), - Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, + CGOpts.EmitVersionIdentMetadata ? Producer : "", + LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind, 0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling, Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -69,6 +69,7 @@ ///< Decl* various IR entities came from. ///< Only useful when running CodeGen as a ///< subroutine. +CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version metadata. CODEGENOPT(EmitGcovArcs , 1, 0) ///< Emit coverage data files, aka. GCDA. CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka GCNO. CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata. Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -396,7 +396,10 @@ def Ofast : Joined<["-"], "Ofast">, Group, Flags<[CC1Option]>; def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group, HelpText<"Disable linemarker output in -E mode">; -def Qn : Flag<["-"], "Qn">, IgnoredGCCCompat; +def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>, + HelpText<"Emit metadata containing compiler name and version">; +def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>, + HelpText<"Do not emit metadata containing compiler name and version">; def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[DriverOption, CoreOption]>, HelpText<"Don't emit warning for unused driver arguments">; def Q : Flag<["-"], "Q">, IgnoredGCCCompat; ___ cfe-commits maili
[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident
This revision was automatically updated to reflect the committed changes. Closed by commit rC330442: [CodeGen] Add an option to suppress output of llvm.ident (authored by miyuki, committed by ). Repository: rC Clang https://reviews.llvm.org/D45255 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CodeGenModule.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/no-ident-version.c Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -577,7 +577,8 @@ remapDIPath(getCurrentDirname()), CSInfo, getSource(SM, SM.getMainFileID())), - Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, + CGOpts.EmitVersionIdentMetadata ? Producer : "", + LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind, 0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling, Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -571,7 +571,8 @@ if (DebugInfo) DebugInfo->finalize(); - EmitVersionIdentMetadata(); + if (getCodeGenOpts().EmitVersionIdentMetadata) +EmitVersionIdentMetadata(); EmitTargetMetadata(); } Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4408,6 +4408,9 @@ } } + if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true)) +CmdArgs.push_back("-Qn"); + // -fcommon is the default unless compiling kernel code or the target says so bool NoCommonDefault = KernelOrKext || isNoCommonDefault(RawTriple); if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common, Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -1112,6 +1112,8 @@ Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue( Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags); + Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true); + return Success; } Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -69,6 +69,7 @@ ///< Decl* various IR entities came from. ///< Only useful when running CodeGen as a ///< subroutine. +CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version metadata. CODEGENOPT(EmitGcovArcs , 1, 0) ///< Emit coverage data files, aka. GCDA. CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka GCNO. CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata. Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -396,7 +396,10 @@ def Ofast : Joined<["-"], "Ofast">, Group, Flags<[CC1Option]>; def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group, HelpText<"Disable linemarker output in -E mode">; -def Qn : Flag<["-"], "Qn">, IgnoredGCCCompat; +def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>, + HelpText<"Emit metadata containing compiler name and version">; +def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>, + HelpText<"Do not emit metadata containing compiler name and version">; def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[DriverOption, CoreOption]>, HelpText<"Don't emit warning for unused driver arguments">; def Q : Flag<["-"], "Q">, IgnoredGCCCompat; Index: test/CodeGen/no-ident-version.c === --- test/CodeGen/no-ident-version.c +++ test/CodeGen/no-ident-version.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-NONE %s +// RUN: %clang_cc1 -Qn -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QN %s +// RUN: %clang_cc1 -Qy -emit-llvm -debug-info-kind=limited -o - %s \ +// RUN: | FileCheck --check-prefix=CHECK-QY %s + +// CHECK-NONE: define i32 @main() +// CHECK-NONE: llvm.ident +// CHECK-NONE: producer: + +// CHECK-QN: define i32 @main() +// CHECK-QN-NOT: llvm.ident +// CHECK-QN-NOT: producer: + +// CHECK-QY
[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident
JDevlieghere added a comment. I’m happy with the test, thanks! In https://reviews.llvm.org/D45255#1072335, @aprantl wrote: > I'm not sure. Compatibility with GCC and getting identical output for > debugging purposes seem to be at odds here. I personally lean slightly > towards stripping it from the debug info as well. If it were the other way around I’d agree with you, but given that -Qn becomes the default, I think we should not strip it from the debug info. https://reviews.llvm.org/D45255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45873: [OpenCL] Reject virtual functions for OpenCL C++
svenvh updated this revision to Diff 143330. svenvh added a comment. Added a template class test as requested. https://reviews.llvm.org/D45873 Files: include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/LangOptions.def lib/Frontend/CompilerInvocation.cpp lib/Parse/ParseDecl.cpp test/Parser/opencl-cxx-virtual.cl Index: test/Parser/opencl-cxx-virtual.cl === --- /dev/null +++ test/Parser/opencl-cxx-virtual.cl @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -fsyntax-only -verify + +// Test that virtual functions and abstract classes are rejected. +class virtual_functions { + virtual void bad1() {} + //expected-error@-1 {{virtual functions are not supported in OpenCL C++}} + + virtual void bad2() =0; + //expected-error@-1 {{virtual functions are not supported in OpenCL C++}} + //expected-error@-2 {{'bad2' is not virtual and cannot be declared pure}} +}; + +template +class X { + virtual T f(); + //expected-error@-1 {{virtual functions are not supported in OpenCL C++}} +}; + +// Test that virtual base classes are allowed. +struct A { + int a; + void foo(); +}; + +struct B : virtual A { + int b; +}; + +struct C : public virtual A { + int c; +}; + +struct D : B, C { + int d; +}; + +kernel void virtual_inheritance() { + D d; + + d.foo(); + d.a = 11; + d.b = 22; + d.c = 33; + d.d = 44; +} Index: lib/Parse/ParseDecl.cpp === --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -3466,7 +3466,15 @@ isInvalid = DS.setFunctionSpecInline(Loc, PrevSpec, DiagID); break; case tok::kw_virtual: - isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID); + // OpenCL C++ v1.0 s2.9: the virtual function qualifier is not supported. + if (getLangOpts().OpenCLCPlusPlus) { +DiagID = diag::err_openclcxx_virtual_function; +PrevSpec = Tok.getIdentifierInfo()->getNameStart(); +isInvalid = true; + } + else { +isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID); + } break; case tok::kw_explicit: isInvalid = DS.setFunctionSpecExplicit(Loc, PrevSpec, DiagID); Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -1925,6 +1925,7 @@ Opts.setDefaultFPContractMode(LangOptions::FPC_On); Opts.NativeHalfType = 1; Opts.NativeHalfArgsAndReturns = 1; +Opts.OpenCLCPlusPlus = Opts.CPlusPlus; // Include default header file for OpenCL. if (Opts.IncludeDefaultHeader) { PPOpts.Includes.push_back("opencl-c.h"); Index: include/clang/Basic/LangOptions.def === --- include/clang/Basic/LangOptions.def +++ include/clang/Basic/LangOptions.def @@ -189,6 +189,7 @@ LANGOPT(OpenCL, 1, 0, "OpenCL") LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version") +LANGOPT(OpenCLCPlusPlus , 1, 0, "OpenCL C++") LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "OpenCL C++ version") LANGOPT(NativeHalfType, 1, 0, "Native half type support") LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns") Index: include/clang/Basic/DiagnosticParseKinds.td === --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -1073,6 +1073,10 @@ def err_opencl_logical_exclusive_or : Error< "^^ is a reserved operator in OpenCL">; +// OpenCL C++. +def err_openclcxx_virtual_function : Error< + "virtual functions are not supported in OpenCL C++">; + // OpenMP support. def warn_pragma_omp_ignored : Warning< "unexpected '#pragma omp ...' in program">, InGroup, DefaultIgnore; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident
miyuki added a comment. In https://reviews.llvm.org/D45255#1073703, @JDevlieghere wrote: > If it were the other way around I’d agree with you, but given that -Qn > becomes the default, I think we should not strip it from the debug info. No, the default is -Qy Repository: rC Clang https://reviews.llvm.org/D45255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45887: [CodeComplete] Fix completion at the end of keywords
ilya-biryukov created this revision. ilya-biryukov added reviewers: sammccall, bkramer, arphaman, aaron.ballman. Make completion behave consistently no matter if it is run at the start, in the middle or at the end of an identifier that happens to be a keyword or a macro name. Since completion is often ran on incomplete identifiers, they may turn into keywords by accident. For example, we should produce same results for all of these completion points: // ^ is completion point. ^class cla^ss class^ Previously clang produced different results for the last case (as if the completion point was after a space: `class ^`). This change also updates some offsets in tests that (unintentionally?) relied on the old behavior. Repository: rC Clang https://reviews.llvm.org/D45887 Files: lib/Lex/Lexer.cpp test/CodeCompletion/end-of-ident-macro.cpp test/CodeCompletion/end-of-ident.cpp test/CodeCompletion/macros.c test/CodeCompletion/namespace.cpp test/CodeCompletion/operator.cpp test/CodeCompletion/tag.c test/CodeCompletion/tag.cpp test/CodeCompletion/using-namespace.cpp test/CodeCompletion/using.cpp test/Index/complete-exprs.c test/Index/complete-preprocessor.m Index: test/Index/complete-preprocessor.m === --- test/Index/complete-preprocessor.m +++ test/Index/complete-preprocessor.m @@ -13,7 +13,7 @@ FOO(in,t) value; -// RUN: c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: c-index-test -code-completion-at=%s:4:3 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro} (40) // CHECK-CC1-NEXT: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro}{LeftParen (}{Placeholder args}{RightParen )} (40) // CHECK-CC1-NEXT: NotImplemented:{TypedText error}{HorizontalSpace }{Placeholder message} (40) @@ -55,8 +55,8 @@ // RUN: c-index-test -code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s // CHECK-CC3: macro definition:{TypedText BAR} (40) // CHECK-CC3: macro definition:{TypedText FOO} (40) -// RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck -check-prefix=CHECK-CC3 %s // RUN: c-index-test -code-completion-at=%s:11:13 %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: c-index-test -code-completion-at=%s:11:14 %s | FileCheck -check-prefix=CHECK-CC3 %s // RUN: c-index-test -code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s // CHECK-CC4: macro definition:{TypedText BAR} (70) // CHECK-CC4: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70) Index: test/Index/complete-exprs.c === --- test/Index/complete-exprs.c +++ test/Index/complete-exprs.c @@ -24,15 +24,15 @@ (type)f; } -// RUN: c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s -// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (65) // CHECK-CC1: macro definition:{TypedText __VERSION__} (70) // CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable) // CHECK-CC1-NOT: NotImplemented:{TypedText float} (65) // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (8) // CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40) -// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s // RUN: c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s // CHECK-CC3: macro definition:{TypedText __VERSION__} (70) Index: test/CodeCompletion/using.cpp === --- test/CodeCompletion/using.cpp +++ test/CodeCompletion/using.cpp @@ -13,8 +13,8 @@ void foo() { int N3; -using -
[PATCH] D45254: [X86] WaitPKG intrinsics
craig.topper accepted this revision. craig.topper added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D45254 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident
JDevlieghere added a comment. In https://reviews.llvm.org/D45255#1073710, @miyuki wrote: > In https://reviews.llvm.org/D45255#1073703, @JDevlieghere wrote: > > > If it were the other way around I’d agree with you, but given that -Qn > > becomes the default, I think we should not strip it from the debug info. > > > No, the default is -Qy Ah, right, I was confused by the CHECK-NONE prefix, I would have merged it with the default case. In that case I agree with Adrian. :-) Repository: rC Clang https://reviews.llvm.org/D45255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330447 - [CUDA] Set LLVM calling convention for CUDA kernel
Author: yaxunl Date: Fri Apr 20 10:01:03 2018 New Revision: 330447 URL: http://llvm.org/viewvc/llvm-project?rev=330447&view=rev Log: [CUDA] Set LLVM calling convention for CUDA kernel Some targets need special LLVM calling convention for CUDA kernel. This patch does that through a TargetCodeGenInfo hook. It only affects amdgcn target. Patch by Greg Rodgers. Revised and lit tests added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D45223 Added: cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/lib/CodeGen/TargetInfo.h Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=330447&r1=330446&r2=330447&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Apr 20 10:01:03 2018 @@ -3627,6 +3627,9 @@ void CodeGenModule::EmitGlobalFunctionDe MaybeHandleStaticInExternC(D, Fn); + if (D->hasAttr()) +getTargetCodeGenInfo().setCUDAKernelCallingConvention(Fn); + maybeSetTrivialComdat(*D, *Fn); CodeGenFunction(*this).GenerateCode(D, Fn, FI); Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=330447&r1=330446&r2=330447&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Apr 20 10:01:03 2018 @@ -7637,6 +7637,7 @@ public: llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const override; bool shouldEmitStaticExternCAliases() const override; + void setCUDAKernelCallingConvention(llvm::Function *F) const override; }; } @@ -7772,6 +7773,11 @@ bool AMDGPUTargetCodeGenInfo::shouldEmit return false; } +void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention( +llvm::Function *F) const { + F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL); +} + //===--===// // SPARC v8 ABI Implementation. // Based on the SPARC Compliance Definition version 2.4.1. Modified: cfe/trunk/lib/CodeGen/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.h?rev=330447&r1=330446&r2=330447&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.h (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.h Fri Apr 20 10:01:03 2018 @@ -301,6 +301,8 @@ public: /// mangled name of functions declared within an extern "C" region and marked /// as 'used', and having internal linkage. virtual bool shouldEmitStaticExternCAliases() const { return true; } + + virtual void setCUDAKernelCallingConvention(llvm::Function *F) const {} }; } // namespace CodeGen Added: cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu?rev=330447&view=auto == --- cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu (added) +++ cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu Fri Apr 20 10:01:03 2018 @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s +#include "Inputs/cuda.h" + +// CHECK: define amdgpu_kernel void @_ZN1A6kernelEv +class A { +public: + static __global__ void kernel(){} +}; + +// CHECK: define void @_Z10non_kernelv +__device__ void non_kernel(){} + +// CHECK: define amdgpu_kernel void @_Z6kerneli +__global__ void kernel(int x) { + non_kernel(); +} + +// CHECK: define amdgpu_kernel void @_Z11EmptyKernelIvEvv +template +__global__ void EmptyKernel(void) {} + +struct Dummy { + /// Type definition of the EmptyKernel kernel entry point + typedef void (*EmptyKernelPtr)(); + EmptyKernelPtr Empty() { return EmptyKernel; } +}; + +// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_ +template +__global__ void template_kernel(T x) {} + +void launch(void *f); + +int main() { + Dummy D; + launch((void*)A::kernel); + launch((void*)kernel); + launch((void*)template_kernel); + launch((void*)D.Empty()); + return 0; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45223: [CUDA] Set LLVM calling convention for CUDA kernel
This revision was automatically updated to reflect the committed changes. Closed by commit rC330447: [CUDA] Set LLVM calling convention for CUDA kernel (authored by yaxunl, committed by ). Repository: rL LLVM https://reviews.llvm.org/D45223 Files: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/TargetInfo.cpp lib/CodeGen/TargetInfo.h test/CodeGenCUDA/kernel-amdgcn.cu Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -3627,6 +3627,9 @@ MaybeHandleStaticInExternC(D, Fn); + if (D->hasAttr()) +getTargetCodeGenInfo().setCUDAKernelCallingConvention(Fn); + maybeSetTrivialComdat(*D, *Fn); CodeGenFunction(*this).GenerateCode(D, Fn, FI); Index: lib/CodeGen/TargetInfo.h === --- lib/CodeGen/TargetInfo.h +++ lib/CodeGen/TargetInfo.h @@ -301,6 +301,8 @@ /// mangled name of functions declared within an extern "C" region and marked /// as 'used', and having internal linkage. virtual bool shouldEmitStaticExternCAliases() const { return true; } + + virtual void setCUDAKernelCallingConvention(llvm::Function *F) const {} }; } // namespace CodeGen Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -7637,6 +7637,7 @@ llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const override; bool shouldEmitStaticExternCAliases() const override; + void setCUDAKernelCallingConvention(llvm::Function *F) const override; }; } @@ -7772,6 +7773,11 @@ return false; } +void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention( +llvm::Function *F) const { + F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL); +} + //===--===// // SPARC v8 ABI Implementation. // Based on the SPARC Compliance Definition version 2.4.1. Index: test/CodeGenCUDA/kernel-amdgcn.cu === --- test/CodeGenCUDA/kernel-amdgcn.cu +++ test/CodeGenCUDA/kernel-amdgcn.cu @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s +#include "Inputs/cuda.h" + +// CHECK: define amdgpu_kernel void @_ZN1A6kernelEv +class A { +public: + static __global__ void kernel(){} +}; + +// CHECK: define void @_Z10non_kernelv +__device__ void non_kernel(){} + +// CHECK: define amdgpu_kernel void @_Z6kerneli +__global__ void kernel(int x) { + non_kernel(); +} + +// CHECK: define amdgpu_kernel void @_Z11EmptyKernelIvEvv +template +__global__ void EmptyKernel(void) {} + +struct Dummy { + /// Type definition of the EmptyKernel kernel entry point + typedef void (*EmptyKernelPtr)(); + EmptyKernelPtr Empty() { return EmptyKernel; } +}; + +// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_ +template +__global__ void template_kernel(T x) {} + +void launch(void *f); + +int main() { + Dummy D; + launch((void*)A::kernel); + launch((void*)kernel); + launch((void*)template_kernel); + launch((void*)D.Empty()); + return 0; +} Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -3627,6 +3627,9 @@ MaybeHandleStaticInExternC(D, Fn); + if (D->hasAttr()) +getTargetCodeGenInfo().setCUDAKernelCallingConvention(Fn); + maybeSetTrivialComdat(*D, *Fn); CodeGenFunction(*this).GenerateCode(D, Fn, FI); Index: lib/CodeGen/TargetInfo.h === --- lib/CodeGen/TargetInfo.h +++ lib/CodeGen/TargetInfo.h @@ -301,6 +301,8 @@ /// mangled name of functions declared within an extern "C" region and marked /// as 'used', and having internal linkage. virtual bool shouldEmitStaticExternCAliases() const { return true; } + + virtual void setCUDAKernelCallingConvention(llvm::Function *F) const {} }; } // namespace CodeGen Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -7637,6 +7637,7 @@ llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const override; bool shouldEmitStaticExternCAliases() const override; + void setCUDAKernelCallingConvention(llvm::Function *F) const override; }; } @@ -7772,6 +7773,11 @@ return false; } +void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention( +llvm::Function *F) const { + F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL); +} + //===--===// // SPARC v8 ABI Implementation. // Based on t
[PATCH] D45873: [OpenCL] Reject virtual functions for OpenCL C++
yaxunl accepted this revision. yaxunl added a comment. This revision is now accepted and ready to land. LGTM. Thanks! https://reviews.llvm.org/D45873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45223: [CUDA] Set LLVM calling convention for CUDA kernel
This revision was automatically updated to reflect the committed changes. Closed by commit rL330447: [CUDA] Set LLVM calling convention for CUDA kernel (authored by yaxunl, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D45223?vs=143001&id=143340#toc Repository: rL LLVM https://reviews.llvm.org/D45223 Files: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/lib/CodeGen/TargetInfo.h cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu Index: cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu === --- cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu +++ cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s +#include "Inputs/cuda.h" + +// CHECK: define amdgpu_kernel void @_ZN1A6kernelEv +class A { +public: + static __global__ void kernel(){} +}; + +// CHECK: define void @_Z10non_kernelv +__device__ void non_kernel(){} + +// CHECK: define amdgpu_kernel void @_Z6kerneli +__global__ void kernel(int x) { + non_kernel(); +} + +// CHECK: define amdgpu_kernel void @_Z11EmptyKernelIvEvv +template +__global__ void EmptyKernel(void) {} + +struct Dummy { + /// Type definition of the EmptyKernel kernel entry point + typedef void (*EmptyKernelPtr)(); + EmptyKernelPtr Empty() { return EmptyKernel; } +}; + +// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_ +template +__global__ void template_kernel(T x) {} + +void launch(void *f); + +int main() { + Dummy D; + launch((void*)A::kernel); + launch((void*)kernel); + launch((void*)template_kernel); + launch((void*)D.Empty()); + return 0; +} Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp === --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -7637,6 +7637,7 @@ llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const override; bool shouldEmitStaticExternCAliases() const override; + void setCUDAKernelCallingConvention(llvm::Function *F) const override; }; } @@ -7772,6 +7773,11 @@ return false; } +void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention( +llvm::Function *F) const { + F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL); +} + //===--===// // SPARC v8 ABI Implementation. // Based on the SPARC Compliance Definition version 2.4.1. Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -3627,6 +3627,9 @@ MaybeHandleStaticInExternC(D, Fn); + if (D->hasAttr()) +getTargetCodeGenInfo().setCUDAKernelCallingConvention(Fn); + maybeSetTrivialComdat(*D, *Fn); CodeGenFunction(*this).GenerateCode(D, Fn, FI); Index: cfe/trunk/lib/CodeGen/TargetInfo.h === --- cfe/trunk/lib/CodeGen/TargetInfo.h +++ cfe/trunk/lib/CodeGen/TargetInfo.h @@ -301,6 +301,8 @@ /// mangled name of functions declared within an extern "C" region and marked /// as 'used', and having internal linkage. virtual bool shouldEmitStaticExternCAliases() const { return true; } + + virtual void setCUDAKernelCallingConvention(llvm::Function *F) const {} }; } // namespace CodeGen Index: cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu === --- cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu +++ cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s +#include "Inputs/cuda.h" + +// CHECK: define amdgpu_kernel void @_ZN1A6kernelEv +class A { +public: + static __global__ void kernel(){} +}; + +// CHECK: define void @_Z10non_kernelv +__device__ void non_kernel(){} + +// CHECK: define amdgpu_kernel void @_Z6kerneli +__global__ void kernel(int x) { + non_kernel(); +} + +// CHECK: define amdgpu_kernel void @_Z11EmptyKernelIvEvv +template +__global__ void EmptyKernel(void) {} + +struct Dummy { + /// Type definition of the EmptyKernel kernel entry point + typedef void (*EmptyKernelPtr)(); + EmptyKernelPtr Empty() { return EmptyKernel; } +}; + +// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_ +template +__global__ void template_kernel(T x) {} + +void launch(void *f); + +int main() { + Dummy D; + launch((void*)A::kernel); + launch((void*)kernel); + launch((void*)template_kernel); + launch((void*)D.Empty()); + return 0; +} Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp === --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGe
r330452 - Record whether a module came from a private module map
Author: jrose Date: Fri Apr 20 10:16:04 2018 New Revision: 330452 URL: http://llvm.org/viewvc/llvm-project?rev=330452&view=rev Log: Record whether a module came from a private module map Right now we only use this information in one place, immediately after we calculate it, but it's still nice information to have. The Swift project is going to use this to tidy up its "API notes" feature (see past discussion on cfe-dev that never quite converged). Reviewed by Bruno Cardoso Lopes. Modified: cfe/trunk/include/clang/Basic/Module.h cfe/trunk/lib/Basic/Module.cpp cfe/trunk/lib/Lex/ModuleMap.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Modified: cfe/trunk/include/clang/Basic/Module.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=330452&r1=330451&r2=330452&view=diff == --- cfe/trunk/include/clang/Basic/Module.h (original) +++ cfe/trunk/include/clang/Basic/Module.h Fri Apr 20 10:16:04 2018 @@ -258,6 +258,10 @@ public: /// and headers from used modules. unsigned NoUndeclaredIncludes : 1; + /// \brief Whether this module came from a "private" module map, found next + /// to a regular (public) module map. + unsigned ModuleMapIsPrivate : 1; + /// \brief Describes the visibility of the various names within a /// particular module. enum NameVisibilityKind { Modified: cfe/trunk/lib/Basic/Module.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=330452&r1=330451&r2=330452&view=diff == --- cfe/trunk/lib/Basic/Module.cpp (original) +++ cfe/trunk/lib/Basic/Module.cpp Fri Apr 20 10:16:04 2018 @@ -44,7 +44,8 @@ Module::Module(StringRef Name, SourceLoc IsSystem(false), IsExternC(false), IsInferred(false), InferSubmodules(false), InferExplicitSubmodules(false), InferExportWildcard(false), ConfigMacrosExhaustive(false), - NoUndeclaredIncludes(false), NameVisibility(Hidden) { + NoUndeclaredIncludes(false), ModuleMapIsPrivate(false), + NameVisibility(Hidden) { if (Parent) { if (!Parent->isAvailable()) IsAvailable = false; @@ -54,6 +55,8 @@ Module::Module(StringRef Name, SourceLoc IsExternC = true; if (Parent->NoUndeclaredIncludes) NoUndeclaredIncludes = true; +if (Parent->ModuleMapIsPrivate) + ModuleMapIsPrivate = true; IsMissingRequirement = Parent->IsMissingRequirement; Parent->SubModuleIndex[Name] = Parent->SubModules.size(); Modified: cfe/trunk/lib/Lex/ModuleMap.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=330452&r1=330451&r2=330452&view=diff == --- cfe/trunk/lib/Lex/ModuleMap.cpp (original) +++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Apr 20 10:16:04 2018 @@ -1891,20 +1891,23 @@ void ModuleMapParser::parseModuleDecl() ActiveModule->NoUndeclaredIncludes = true; ActiveModule->Directory = Directory; + StringRef MapFileName(ModuleMapFile->getName()); + if (MapFileName.endswith("module.private.modulemap") || + MapFileName.endswith("module_private.map")) { +ActiveModule->ModuleMapIsPrivate = true; + } // Private modules named as FooPrivate, Foo.Private or similar are likely a // user error; provide warnings, notes and fixits to direct users to use // Foo_Private instead. SourceLocation StartLoc = SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID()); - StringRef MapFileName(ModuleMapFile->getName()); if (Map.HeaderInfo.getHeaderSearchOpts().ImplicitModuleMaps && !Diags.isIgnored(diag::warn_mmap_mismatched_private_submodule, StartLoc) && !Diags.isIgnored(diag::warn_mmap_mismatched_private_module_name, StartLoc) && - (MapFileName.endswith("module.private.modulemap") || - MapFileName.endswith("module_private.map"))) + ActiveModule->ModuleMapIsPrivate) diagnosePrivateModules(Map, Diags, ActiveModule, LastInlineParentLoc); bool Done = false; Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=330452&r1=330451&r2=330452&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Apr 20 10:16:04 2018 @@ -4980,7 +4980,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile break; case SUBMODULE_DEFINITION: { - if (Record.size() < 8) { + if (Record.size() < 12) { Error("malformed module definition"); return Failure; } @@ -4998,6 +4998,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile bool InferExplicitSubmodules = Record[Idx++]; bool
[PATCH] D45891: [clang-tidy] Improve bugprone-unused-return-value check
khuttun created this revision. khuttun added a reviewer: alexfh. Herald added subscribers: cfe-commits, xazax.hun. Add support for checking class template member functions. Also add the following functions to be checked by default: - std::unique_ptr::release - std::basic_string::empty - std::vector::empty Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45891 Files: clang-tidy/bugprone/UnusedReturnValueCheck.cpp docs/clang-tidy/checks/bugprone-unused-return-value.rst test/clang-tidy/bugprone-unused-return-value-custom.cpp test/clang-tidy/bugprone-unused-return-value.cpp Index: test/clang-tidy/bugprone-unused-return-value.cpp === --- test/clang-tidy/bugprone-unused-return-value.cpp +++ test/clang-tidy/bugprone-unused-return-value.cpp @@ -24,6 +24,34 @@ template ForwardIt unique(ForwardIt, ForwardIt); +template +struct default_delete; + +template > +struct unique_ptr { + T *release() noexcept; +}; + +template +struct char_traits; + +template +struct allocator; + +template , + typename Allocator = allocator> +struct basic_string { + bool empty() const; +}; + +typedef basic_string string; + +template > +struct vector { + bool empty() const noexcept; +}; + // the check should be able to match std lib calls even if the functions are // declared inside inline namespaces inline namespace v1 { @@ -64,6 +92,18 @@ std::unique(nullptr, nullptr); // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + std::unique_ptr UPtr; + UPtr.release(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + + std::string Str; + Str.empty(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + + std::vector Vec; + Vec.empty(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + // test discarding return values inside different kinds of statements auto Lambda = [] { std::remove(nullptr, nullptr, 1); }; @@ -137,6 +177,15 @@ auto UniqueRetval = std::unique(nullptr, nullptr); + std::unique_ptr UPtrNoWarning; + auto ReleaseRetval = UPtrNoWarning.release(); + + std::string StrNoWarning; + auto StrEmptyRetval = StrNoWarning.empty(); + + std::vector VecNoWarning; + auto VecEmptyRetval = VecNoWarning.empty(); + // test using the return value in different kinds of expressions useFuture(std::async(increment, 42)); std::launder(&FNoWarning)->f(); Index: test/clang-tidy/bugprone-unused-return-value-custom.cpp === --- test/clang-tidy/bugprone-unused-return-value-custom.cpp +++ test/clang-tidy/bugprone-unused-return-value-custom.cpp @@ -1,7 +1,7 @@ // RUN: %check_clang_tidy %s bugprone-unused-return-value %t \ // RUN: -config='{CheckOptions: \ // RUN: [{key: bugprone-unused-return-value.CheckedFunctions, \ -// RUN:value: "::fun;::ns::Outer::Inner::memFun;::ns::Type::staticFun"}]}' \ +// RUN:value: "::fun;::ns::Outer::Inner::memFun;::ns::Type::staticFun;::ns::ClassTemplate::memFun;::ns::ClassTemplate::staticFun"}]}' \ // RUN: -- namespace std { @@ -34,6 +34,12 @@ static Retval staticFun(); }; +template +struct ClassTemplate { + Retval memFun(); + static Retval staticFun(); +}; + } // namespace ns int fun(); @@ -60,6 +66,13 @@ ns::Type::staticFun(); // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + + ns::ClassTemplate ObjA4; + ObjA4.memFun(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] + + ns::ClassTemplate::staticFun(); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value] } void noWarning() { @@ -70,13 +83,18 @@ auto R3 = ns::Type::staticFun(); + ns::ClassTemplate ObjB2; + auto R4 = ObjB2.memFun(); + + auto R5 = ns::ClassTemplate::staticFun(); + // test calling a void overload of a checked function fun(5); // test discarding return value of functions that are not configured to be checked int I = 1; std::launder(&I); - ns::Type ObjB2; - ObjB2.memFun(); + ns::Type ObjB3; + ObjB3.memFun(); } Index: docs/clang-tidy/checks/bugprone-unused-return-value.rst === --- docs/clang-tidy/checks/bugprone-unused-return-value.rst +++ docs/clang-tidy/checks/bugprone-unused-return-value.rst @@ -11,7 +11,7 @@ .. option:: CheckedFunctions Semicolon-separated list of functions to check. Defaults to - ``::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique`
[PATCH] D45835: Add new driver mode for dumping compiler options
efriedma added a comment. > If any of those options we care about wind up being changed, there's a good > chance we may need to change something on our end anyway, so breaking us is > actually useful. I'm not sure I follow. The language options have specific consequences you could check some other way, so they're "stable" in the sense that the same flags will produce the same result (e.g. LangOpts.FastMath represents whether __FAST_MATH__ is defined). So it should be possible to provide the data somehow; I'm more concerned about taking names and enum values from LangOptions.def itself. https://reviews.llvm.org/D45835 ___ 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
efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. LGTM 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] D45254: [X86] WaitPKG intrinsics
This revision was automatically updated to reflect the committed changes. Closed by commit rL330463: [X86] WaitPKG intrinsics (authored by GBuella, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D45254?vs=143249&id=143355#toc Repository: rL LLVM https://reviews.llvm.org/D45254 Files: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/Targets/X86.cpp cfe/trunk/lib/Basic/Targets/X86.h cfe/trunk/lib/Headers/CMakeLists.txt cfe/trunk/lib/Headers/cpuid.h cfe/trunk/lib/Headers/waitpkgintrin.h cfe/trunk/lib/Headers/x86intrin.h cfe/trunk/test/CodeGen/waitpkg.c cfe/trunk/test/Driver/x86-target-features.c cfe/trunk/test/Preprocessor/predefined-arch-macros.c Index: cfe/trunk/test/CodeGen/waitpkg.c === --- cfe/trunk/test/CodeGen/waitpkg.c +++ cfe/trunk/test/CodeGen/waitpkg.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -target-feature +waitpkg -Wall -pedantic -o - | FileCheck %s +// RUN: %clang_cc1 %s -ffreestanding -triple i386-unknown-unknown -emit-llvm -target-feature +waitpkg -Wall -pedantic -o - | FileCheck %s + +#include + +#include +#include + +void test_umonitor(void *address) { + //CHECK-LABEL: @test_umonitor + //CHECK: call void @llvm.x86.umonitor(i8* %{{.*}}) + return _umonitor(address); +} + +uint8_t test_umwait(uint32_t control, uint64_t counter) { + //CHECK-LABEL: @test_umwait + //CHECK: call i8 @llvm.x86.umwait(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _umwait(control, counter); +} + +uint8_t test_tpause(uint32_t control, uint64_t counter) { + //CHECK-LABEL: @test_tpause + //CHECK: call i8 @llvm.x86.tpause(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _tpause(control, counter); +} Index: cfe/trunk/test/Preprocessor/predefined-arch-macros.c === --- cfe/trunk/test/Preprocessor/predefined-arch-macros.c +++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c @@ -1482,6 +1482,7 @@ // CHECK_TRM_M32: #define __SSE_MATH__ 1 // CHECK_TRM_M32: #define __SSE__ 1 // CHECK_TRM_M32: #define __SSSE3__ 1 +// CHECK_TRM_M32: #define __WAITPKG__ 1 // CHECK_TRM_M32: #define __XSAVEC__ 1 // CHECK_TRM_M32: #define __XSAVEOPT__ 1 // CHECK_TRM_M32: #define __XSAVES__ 1 @@ -1518,6 +1519,7 @@ // CHECK_TRM_M64: #define __SSE4_2__ 1 // CHECK_TRM_M64: #define __SSE__ 1 // CHECK_TRM_M64: #define __SSSE3__ 1 +// CHECK_TRM_M64: #define __WAITPKG__ 1 // CHECK_TRM_M64: #define __XSAVEC__ 1 // CHECK_TRM_M64: #define __XSAVEOPT__ 1 // CHECK_TRM_M64: #define __XSAVES__ 1 Index: cfe/trunk/test/Driver/x86-target-features.c === --- cfe/trunk/test/Driver/x86-target-features.c +++ cfe/trunk/test/Driver/x86-target-features.c @@ -144,3 +144,8 @@ // RUN: %clang -target i386-linux-gnu -mretpoline -mno-retpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-RETPOLINE-EXTERNAL-THUNK %s // RETPOLINE-EXTERNAL-THUNK: "-target-feature" "+retpoline-external-thunk" // NO-RETPOLINE-EXTERNAL-THUNK: "-target-feature" "-retpoline-external-thunk" + +// RUN: %clang -target i386-linux-gnu -mwaitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=WAITPKG %s +// RUN: %clang -target i386-linux-gnu -mno-waitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-WAITPKG %s +// WAITPKG: "-target-feature" "+waitpkg" +// NO-WAITPKG: "-target-feature" "-waitpkg" Index: cfe/trunk/lib/Headers/CMakeLists.txt === --- cfe/trunk/lib/Headers/CMakeLists.txt +++ cfe/trunk/lib/Headers/CMakeLists.txt @@ -96,6 +96,7 @@ varargs.h vecintrin.h vpclmulqdqintrin.h + waitpkgintrin.h wbnoinvdintrin.h wmmintrin.h __wmmintrin_aes.h Index: cfe/trunk/lib/Headers/x86intrin.h === --- cfe/trunk/lib/Headers/x86intrin.h +++ cfe/trunk/lib/Headers/x86intrin.h @@ -96,4 +96,8 @@ #include #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__WAITPKG__) +#include +#endif + #endif /* __X86INTRIN_H */ Index: cfe/trunk/lib/Headers/cpuid.h === --- cfe/trunk/lib/Headers/cpuid.h +++ cfe/trunk/lib/Headers/cpuid.h @@ -177,6 +177,7 @@ #define bit_AVX512VBMI 0x0002 #define bit_PKU 0x0004 #define bit_OSPKE0x0010 +#define bit_WAITPKG 0x0020 #define bit_AVX512VBMI2 0x0040 #define bit_SHSTK0x0080 #define bit_GFNI 0x0100 Index: cfe/trunk/lib/Headers/waitpkgintrin.h === --- cfe/trunk/lib/Headers/waitpkgintrin.h +++ cfe/trunk/lib/Headers/waitpkgintrin.h @@ -0,0 +1,56 @@ +/*===
[PATCH] D39053: [Bitfield] Add more cases to making the bitfield a separate location
mgrang added a comment. Here is a test case which improves with this patch (for RISCV target). It is able to detect load/store halfword for size 16 bitfields. struct st { int a:1; int b:8; int c:11; int d:12; int e:16; int f:16; int g:16; } S; void foo(int x) { S.e = x; } GCC: : 0: 07b7lui x15,0x0 4: 00a79223sh x10,4(x15) # 4 8: 8067jalrx0,0(x1) LLVM without this patch: : 0: 000105b7lui x11,0x10 4: fff58593addix11,x11,-1 # 8: 00b57533and x10,x10,x11 c: 05b7lui x11,0x0 10: 00058593addix11,x11,0 # 0 14: 0045a603lw x12,4(x11) 18: 06b7lui x13,0x0 1c: 00d67633and x12,x12,x13 20: 00a66533or x10,x12,x10 24: 00a5a223sw x10,4(x11) 28: 8067jalrx0,0(x1) LLVM with this patch: : 0: 05b7lui x11,0x0 4: 00058593addix11,x11,0 # 0 8: 00a59223sh x10,4(x11) c: 8067jalrx0,0(x1) https://reviews.llvm.org/D39053 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45897: Convert clang-interpreter to ORC JIT API
sas created this revision. sas added reviewers: ddunbar, lhames. Herald added a subscriber: mgorny. This mostly re-uses code from the KaleidoscopeJIT example. Repository: rC Clang https://reviews.llvm.org/D45897 Files: examples/clang-interpreter/CMakeLists.txt examples/clang-interpreter/Invoke.cpp examples/clang-interpreter/Invoke.h examples/clang-interpreter/Manager.cpp examples/clang-interpreter/Manager.h examples/clang-interpreter/main.cpp Index: examples/clang-interpreter/main.cpp === --- examples/clang-interpreter/main.cpp +++ examples/clang-interpreter/main.cpp @@ -7,11 +7,8 @@ // //===--===// -#include "Invoke.h" -#include "Manager.h" - -#include "clang/CodeGen/CodeGenAction.h" #include "clang/Basic/DiagnosticOptions.h" +#include "clang/CodeGen/CodeGenAction.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" #include "clang/Driver/Tool.h" @@ -21,37 +18,24 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" #include "llvm/ADT/SmallString.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" -#include "llvm/ExecutionEngine/MCJIT.h" +#include "llvm/ExecutionEngine/Orc/CompileUtils.h" +#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" +#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" +#include "llvm/ExecutionEngine/SectionMemoryManager.h" +#include "llvm/IR/DataLayout.h" +#include "llvm/IR/Mangler.h" #include "llvm/IR/Module.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetMachine.h" using namespace clang; using namespace clang::driver; -namespace interpreter { - -static llvm::ExecutionEngine * -createExecutionEngine(std::unique_ptr M, std::string *ErrorStr) { - llvm::EngineBuilder EB(std::move(M)); - EB.setErrorStr(ErrorStr); - EB.setMemoryManager(llvm::make_unique()); - llvm::ExecutionEngine *EE = EB.create(); - EE->finalizeObject(); - return EE; -} - -// Invoked from a try/catch block in invoke.cpp. -// -static int Invoke(llvm::ExecutionEngine *EE, llvm::Function *EntryFn, - const std::vector &Args, char *const *EnvP) { - return EE->runFunctionAsMain(EntryFn, Args, EnvP); -} - // This function isn't referenced outside its translation unit, but it // can't use the "static" keyword because its address is used for // GetMainExecutable (since some platforms don't support taking the @@ -61,13 +45,75 @@ return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } -} // namespace interpreter +namespace llvm { +namespace orc { + +class SimpleJIT { +private: + ExecutionSession ES; + std::shared_ptr Resolver; + std::unique_ptr TM; + const DataLayout DL; + RTDyldObjectLinkingLayer ObjectLayer; + IRCompileLayer CompileLayer; + +public: + SimpleJIT() + : Resolver(createLegacyLookupResolver( +[this](const std::string &Name) -> JITSymbol { + if (auto Sym = CompileLayer.findSymbol(Name, false)) +return Sym; + else if (auto Err = Sym.takeError()) +return std::move(Err); + if (auto SymAddr = + RTDyldMemoryManager::getSymbolAddressInProcess(Name)) +return JITSymbol(SymAddr, JITSymbolFlags::Exported); + return nullptr; +}, +[](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })), +TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), +ObjectLayer(ES, +[this](VModuleKey) { + return RTDyldObjectLinkingLayer::Resources{ + std::make_shared(), Resolver}; +}), +CompileLayer(ObjectLayer, SimpleCompiler(*TM)) { +llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr); + } + + TargetMachine &getTargetMachine() { return *TM; } -int main(int argc, const char **argv, char * const *envp) { + VModuleKey addModule(std::unique_ptr M) { +// Add the module to the JIT with a new VModuleKey. +auto K = ES.allocateVModule(); +cantFail(CompileLayer.addModule(K, std::move(M))); +return K; + } + + JITSymbol findSymbol(const std::string Name) { +std::string MangledName; +raw_string_ostream MangledNameStream(MangledName); +Mangler::getNameWithPrefix(MangledNameStream, Name, DL); +return CompileLayer.findSymbol(MangledNameStream.str(), true); + } + + JITTargetAddress getSymbolAddress(const std::string Name) { +return cantFail(findSymbol(Name).getAddress()); + } + + void removeModule(VModuleKey K) { +cantFail(CompileLayer.removeModule(K)); + } +}; + +} // end namespace orc +} // end namespace llvm + +int main(int argc, const char **argv) { // This just needs to
[PATCH] D45898: [SemaCXX] Mark destructor as referenced
ahatanak created this revision. ahatanak added reviewers: rsmith, rjmccall. If an initializer in a braced-init-list is a C++ class that has a non-trivial destructor, mark the destructor as referenced. This fixes a crash in CodeGenFunction::destroyCXXObject that occurs when it tries to emit a call to the destructor on the stack unwinding path but the CXXRecordDecl of the class doesn't have a CXXDestructorDecl for the destructor. Repository: rC Clang https://reviews.llvm.org/D45898 Files: lib/Sema/SemaInit.cpp test/CodeGenObjCXX/arc-list-init-destruct.mm Index: test/CodeGenObjCXX/arc-list-init-destruct.mm === --- /dev/null +++ test/CodeGenObjCXX/arc-list-init-destruct.mm @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -std=c++1z -fobjc-arc -fobjc-exceptions -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s + +// CHECK: %[[V0:.*]] = type opaque +// CHECK: %[[STRUCT_CLASS1:.*]] = type { %[[V0]]* } + +@interface Class0; +@end + +struct Class1 { + Class0 *f; +}; + +struct Container { + Class1 a; + bool b; +}; + +bool getBool() { + return false; +} + +Class0 *g; + +// CHECK: define {{.*}} @_Z4testv() +// CHECK: invoke zeroext i1 @_Z7getBoolv() +// CHECK: landingpad { i8*, i32 } +// CHECK: call void @_ZN6Class1D1Ev(%[[STRUCT_CLASS1]]* %{{.*}}) +// CHECK: br label + +// CHECK: define linkonce_odr void @_ZN6Class1D1Ev( + +Container test() { + return {{g}, getBool()}; +} Index: lib/Sema/SemaInit.cpp === --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -7065,6 +7065,14 @@ *ResultType = Ty; } + for (Expr *E : InitList->inits()) +// If this initializer's type is a C++ class that has a non-trivial +// destructor, mark the destructor as referenced. The destructor can be +// invoked during stack unwinding. +if (auto *RD = E->getType()->getAsCXXRecordDecl()) + if (RD->hasDefinition() && RD->hasNonTrivialDestructor()) +S.MarkFunctionReferenced(E->getExprLoc(), S.LookupDestructor(RD)); + InitListExpr *StructuredInitList = PerformInitList.getFullyStructuredList(); CurInit.get(); Index: test/CodeGenObjCXX/arc-list-init-destruct.mm === --- /dev/null +++ test/CodeGenObjCXX/arc-list-init-destruct.mm @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -std=c++1z -fobjc-arc -fobjc-exceptions -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s + +// CHECK: %[[V0:.*]] = type opaque +// CHECK: %[[STRUCT_CLASS1:.*]] = type { %[[V0]]* } + +@interface Class0; +@end + +struct Class1 { + Class0 *f; +}; + +struct Container { + Class1 a; + bool b; +}; + +bool getBool() { + return false; +} + +Class0 *g; + +// CHECK: define {{.*}} @_Z4testv() +// CHECK: invoke zeroext i1 @_Z7getBoolv() +// CHECK: landingpad { i8*, i32 } +// CHECK: call void @_ZN6Class1D1Ev(%[[STRUCT_CLASS1]]* %{{.*}}) +// CHECK: br label + +// CHECK: define linkonce_odr void @_ZN6Class1D1Ev( + +Container test() { + return {{g}, getBool()}; +} Index: lib/Sema/SemaInit.cpp === --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -7065,6 +7065,14 @@ *ResultType = Ty; } + for (Expr *E : InitList->inits()) +// If this initializer's type is a C++ class that has a non-trivial +// destructor, mark the destructor as referenced. The destructor can be +// invoked during stack unwinding. +if (auto *RD = E->getType()->getAsCXXRecordDecl()) + if (RD->hasDefinition() && RD->hasNonTrivialDestructor()) +S.MarkFunctionReferenced(E->getExprLoc(), S.LookupDestructor(RD)); + InitListExpr *StructuredInitList = PerformInitList.getFullyStructuredList(); CurInit.get(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45900: CodeGen: Fix invalid bitcast for lifetime.start/end
yaxunl created this revision. yaxunl added a reviewer: rjmccall. lifetime.start/end expects pointer argument in alloca address space. However in C++ a temporary variable is in default address space. This patch casts the pointer argument of lifetime.start/end to alloca address space if necessary. It only affects targets with non-zero alloca address space. https://reviews.llvm.org/D45900 Files: lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenCXX/amdgcn_declspec_get.cpp Index: test/CodeGenCXX/amdgcn_declspec_get.cpp === --- /dev/null +++ test/CodeGenCXX/amdgcn_declspec_get.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -O3 -fdeclspec \ +// RUN: -disable-llvm-passes -o - %s | FileCheck %s + +int get_x(); + +struct A { + __declspec(property(get = _get_x)) int x; + static int _get_x(void) { + return get_x(); + }; +}; + +extern const A a; + +// CHECK-LABEL: define void @_Z4testv() +// CHECK: %i = alloca i32, align 4, addrspace(5) +// CHECK: %[[ii:.*]] = addrspacecast i32 addrspace(5)* %i to i32* +// CHECK: %[[cast1:.*]] = addrspacecast i32* %[[ii]] to i8 addrspace(5)* +// CHECK: call void @llvm.lifetime.start.p5i8(i64 4, i8 addrspace(5)* %[[cast1]]) +// CHECK: %call = call i32 @_ZN1A6_get_xEv() +// CHECK: store i32 %call, i32* %[[ii]] +// CHECK: %[[cast2:.*]] = addrspacecast i32* %[[ii]] to i8 addrspace(5)* +// CHECK: call void @llvm.lifetime.end.p5i8(i64 4, i8 addrspace(5)* %[[cast2]]) +void test() +{ + int i = a.x; +} Index: lib/CodeGen/CodeGenFunction.h === --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -2072,6 +2072,9 @@ /// Emit a cast to void* in the appropriate address space. llvm::Value *EmitCastToVoidPtr(llvm::Value *value); + /// Emit a cast to void* in alloca address space. + llvm::Value *EmitCastToVoidPtrInAllocaAddrSpace(llvm::Value *V); + /// EvaluateExprAsBool - Perform the usual unary conversions on the specified /// expression and compare the result against zero, returning an Int1Ty value. llvm::Value *EvaluateExprAsBool(const Expr *E); Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -59,6 +59,18 @@ return Builder.CreateBitCast(value, destType); } +llvm::Value * +CodeGenFunction::EmitCastToVoidPtrInAllocaAddrSpace(llvm::Value *V) { + if (V->getType()->getPointerAddressSpace() != + CGM.getDataLayout().getAllocaAddrSpace()) { +return getTargetHooks().performAddrSpaceCast( +*this, V, getASTAllocaAddressSpace(), LangAS::Default, AllocaInt8PtrTy, +/*non-null*/ true); + } else { +return Builder.CreateBitCast(V, AllocaInt8PtrTy); + } +} + /// CreateTempAlloca - This creates a alloca and inserts it into the entry /// block. Address CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align, Index: lib/CodeGen/CGDecl.cpp === --- lib/CodeGen/CGDecl.cpp +++ lib/CodeGen/CGDecl.cpp @@ -966,15 +966,15 @@ return nullptr; llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size); - Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy); + Addr = EmitCastToVoidPtrInAllocaAddrSpace(Addr); llvm::CallInst *C = Builder.CreateCall(CGM.getLLVMLifetimeStartFn(), {SizeV, Addr}); C->setDoesNotThrow(); return SizeV; } void CodeGenFunction::EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr) { - Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy); + Addr = EmitCastToVoidPtrInAllocaAddrSpace(Addr); llvm::CallInst *C = Builder.CreateCall(CGM.getLLVMLifetimeEndFn(), {Size, Addr}); C->setDoesNotThrow(); Index: test/CodeGenCXX/amdgcn_declspec_get.cpp === --- /dev/null +++ test/CodeGenCXX/amdgcn_declspec_get.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -O3 -fdeclspec \ +// RUN: -disable-llvm-passes -o - %s | FileCheck %s + +int get_x(); + +struct A { + __declspec(property(get = _get_x)) int x; + static int _get_x(void) { + return get_x(); + }; +}; + +extern const A a; + +// CHECK-LABEL: define void @_Z4testv() +// CHECK: %i = alloca i32, align 4, addrspace(5) +// CHECK: %[[ii:.*]] = addrspacecast i32 addrspace(5)* %i to i32* +// CHECK: %[[cast1:.*]] = addrspacecast i32* %[[ii]] to i8 addrspace(5)* +// CHECK: call void @llvm.lifetime.start.p5i8(i64 4, i8 addrspace(5)* %[[cast1]]) +// CHECK: %call = call i32 @_ZN1A6_get_xEv() +// CHECK: store i32 %call, i32* %[[ii]] +// CHECK: %[[cast2:.*]] = addrspacecast i32* %[[ii]] to i8 addrspace(5)* +// CHECK: call void @llvm.lifetime.end.p5i8(i64 4, i8 addrspace(5)* %[[cast2]]) +void test() +{ + int i = a.x; +} Index: lib/CodeGen/
[PATCH] D45897: Convert clang-interpreter to ORC JIT API
alexshap added inline comments. Comment at: examples/clang-interpreter/main.cpp:52 +class SimpleJIT { +private: + ExecutionSession ES; not needed Comment at: examples/clang-interpreter/main.cpp:84 + + TargetMachine &getTargetMachine() { return *TM; } const TargetMachine & ? Comment at: examples/clang-interpreter/main.cpp:93 + + JITSymbol findSymbol(const std::string Name) { +std::string MangledName; const string & or maybe even StringRef and the same below Repository: rC Clang https://reviews.llvm.org/D45897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45897: Convert clang-interpreter to ORC JIT API
sas added inline comments. Comment at: examples/clang-interpreter/main.cpp:52 +class SimpleJIT { +private: + ExecutionSession ES; alexshap wrote: > not needed Seems cleaner to me to have these explicit, and avoids potentiel code churn if there are changes above. Is there something in the llvm coding style that recommends skipping these? Repository: rC Clang https://reviews.llvm.org/D45897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45897: Convert clang-interpreter to ORC JIT API
sas updated this revision to Diff 143376. sas added a comment. Review comments from @alexshap. Repository: rC Clang https://reviews.llvm.org/D45897 Files: examples/clang-interpreter/CMakeLists.txt examples/clang-interpreter/Invoke.cpp examples/clang-interpreter/Invoke.h examples/clang-interpreter/Manager.cpp examples/clang-interpreter/Manager.h examples/clang-interpreter/main.cpp Index: examples/clang-interpreter/main.cpp === --- examples/clang-interpreter/main.cpp +++ examples/clang-interpreter/main.cpp @@ -7,11 +7,8 @@ // //===--===// -#include "Invoke.h" -#include "Manager.h" - -#include "clang/CodeGen/CodeGenAction.h" #include "clang/Basic/DiagnosticOptions.h" +#include "clang/CodeGen/CodeGenAction.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" #include "clang/Driver/Tool.h" @@ -21,37 +18,24 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" #include "llvm/ADT/SmallString.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" -#include "llvm/ExecutionEngine/MCJIT.h" +#include "llvm/ExecutionEngine/Orc/CompileUtils.h" +#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" +#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" +#include "llvm/ExecutionEngine/SectionMemoryManager.h" +#include "llvm/IR/DataLayout.h" +#include "llvm/IR/Mangler.h" #include "llvm/IR/Module.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetMachine.h" using namespace clang; using namespace clang::driver; -namespace interpreter { - -static llvm::ExecutionEngine * -createExecutionEngine(std::unique_ptr M, std::string *ErrorStr) { - llvm::EngineBuilder EB(std::move(M)); - EB.setErrorStr(ErrorStr); - EB.setMemoryManager(llvm::make_unique()); - llvm::ExecutionEngine *EE = EB.create(); - EE->finalizeObject(); - return EE; -} - -// Invoked from a try/catch block in invoke.cpp. -// -static int Invoke(llvm::ExecutionEngine *EE, llvm::Function *EntryFn, - const std::vector &Args, char *const *EnvP) { - return EE->runFunctionAsMain(EntryFn, Args, EnvP); -} - // This function isn't referenced outside its translation unit, but it // can't use the "static" keyword because its address is used for // GetMainExecutable (since some platforms don't support taking the @@ -61,13 +45,75 @@ return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } -} // namespace interpreter +namespace llvm { +namespace orc { + +class SimpleJIT { +private: + ExecutionSession ES; + std::shared_ptr Resolver; + std::unique_ptr TM; + const DataLayout DL; + RTDyldObjectLinkingLayer ObjectLayer; + IRCompileLayer CompileLayer; + +public: + SimpleJIT() + : Resolver(createLegacyLookupResolver( +[this](const std::string &Name) -> JITSymbol { + if (auto Sym = CompileLayer.findSymbol(Name, false)) +return Sym; + else if (auto Err = Sym.takeError()) +return std::move(Err); + if (auto SymAddr = + RTDyldMemoryManager::getSymbolAddressInProcess(Name)) +return JITSymbol(SymAddr, JITSymbolFlags::Exported); + return nullptr; +}, +[](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })), +TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), +ObjectLayer(ES, +[this](VModuleKey) { + return RTDyldObjectLinkingLayer::Resources{ + std::make_shared(), Resolver}; +}), +CompileLayer(ObjectLayer, SimpleCompiler(*TM)) { +llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr); + } + + const TargetMachine &getTargetMachine() const { return *TM; } -int main(int argc, const char **argv, char * const *envp) { + VModuleKey addModule(std::unique_ptr M) { +// Add the module to the JIT with a new VModuleKey. +auto K = ES.allocateVModule(); +cantFail(CompileLayer.addModule(K, std::move(M))); +return K; + } + + JITSymbol findSymbol(const StringRef &Name) { +std::string MangledName; +raw_string_ostream MangledNameStream(MangledName); +Mangler::getNameWithPrefix(MangledNameStream, Name, DL); +return CompileLayer.findSymbol(MangledNameStream.str(), true); + } + + JITTargetAddress getSymbolAddress(const StringRef &Name) { +return cantFail(findSymbol(Name).getAddress()); + } + + void removeModule(VModuleKey K) { +cantFail(CompileLayer.removeModule(K)); + } +}; + +} // end namespace orc +} // end namespace llvm + +int main(int argc, const char **argv) { // This just needs to be some symbol in the binary; C++ doesn't // allow
[PATCH] D45517: [analyzer] WIP: False positive refutation with Z3
NoQ added a comment. > The visitor currently checks states appearing as block edges in the exploded > graph. The first idea was to filter states based on the shape of the exploded > graph, by checking the number of successors of the parent node, but > surprisingly, both `succ_size()` and `pred_size()` seemed to return 1 for > each node in the graph (except for the root), even if there clearly were > branchings in the code (and on the `.dot` picture). To my understanding, the > exploded graph is fully constructed at the stage where visitors are run, so I > must be missing something. Aha, yep, that's probably because visitors are operating on the "trimmed" exploded graph. You can paint it via the `-trim-egraph` flag or by calling `ViewGraph(1)` in the debugger. So, yeah, that's a good optimization that we're not invoking the solver on every node. But i don't think we should focus on improving this optimization further; instead, i think the next obvious step here is to implement it in such a way that we only needed to call the solver //once// for every report. We could simply collect all constraints from all states along the path and put them into the solver all together. This will work because symbols are not mutable and they don't reincarnate. Apart from that, the patch seems to be going in the right direction. It should be possible to split up the `RangeSet` refactoring into a different review, for easier reviewing and better commit history. https://reviews.llvm.org/D45517 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py
zinovy.nis updated this revision to Diff 143384. zinovy.nis edited the summary of this revision. zinovy.nis added a comment. - Minor cosmetic fixes. https://reviews.llvm.org/D45776 Files: docs/clang-tidy/index.rst test/clang-tidy/check_clang_tidy.cpp test/clang-tidy/check_clang_tidy.py Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -18,6 +18,7 @@ Usage: check_clang_tidy.py [-resource-dir ] \ [-assume-filename ] \ +[-check-suffix ] \ \ -- [optional clang-tidy arguments] @@ -42,6 +43,7 @@ parser.add_argument('-expect-clang-tidy-error', action='store_true') parser.add_argument('-resource-dir') parser.add_argument('-assume-filename') + parser.add_argument('-check-suffix', default='') parser.add_argument('input_file_name') parser.add_argument('check_name') parser.add_argument('temp_file_name') @@ -70,6 +72,13 @@ clang_tidy_extra_args.extend( ['-fobjc-abi-version=2', '-fobjc-arc']) + if args.check_suffix and not re.match('^[A-Z0-9\-]+$', args.check_suffix): +sys.exit('Only A..Z, 0..9 and "-" are allowed in check suffix, but "%s" was given' % (args.check_suffix)) + + file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else '' + check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix + check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix + # Tests should not rely on STL being available, and instead provide mock # implementations of relevant APIs. clang_tidy_extra_args.append('-nostdinc++') @@ -80,17 +89,17 @@ with open(input_file_name, 'r') as input_file: input_text = input_file.read() - has_check_fixes = input_text.find('CHECK-FIXES') >= 0 - has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_fixes = check_fixes_prefix in input_text + has_check_messages = check_messages_prefix in input_text if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') +sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) ) # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while # avoiding empty lines which could potentially trigger formatting-related # checks. - cleaned_test = re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text) + cleaned_test = re.sub('// *CHECK-[A-Z0-9\-]*:[^\r\n]*', '//', input_text) write_file(temp_file_name, cleaned_test) @@ -128,7 +137,7 @@ try: subprocess.check_output( ['FileCheck', '-input-file=' + temp_file_name, input_file_name, - '-check-prefix=CHECK-FIXES', '-strict-whitespace'], + '-check-prefix=' + check_fixes_prefix, '-strict-whitespace'], stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print('FileCheck failed:\n' + e.output.decode()) @@ -140,7 +149,7 @@ try: subprocess.check_output( ['FileCheck', '-input-file=' + messages_file, input_file_name, - '-check-prefix=CHECK-MESSAGES', + '-check-prefix=' + check_messages_prefix, '-implicit-check-not={{warning|error}}:'], stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: Index: test/clang-tidy/check_clang_tidy.cpp === --- test/clang-tidy/check_clang_tidy.cpp +++ test/clang-tidy/check_clang_tidy.cpp @@ -0,0 +1,21 @@ +// RUN: %check_clang_tidy -check-suffix USING-A %s misc-unused-using-decls %t -- -- -DUSING_A +// RUN: %check_clang_tidy -check-suffix USING-B %s misc-unused-using-decls %t -- -- -DUSING_B +// RUN: %check_clang_tidy %s misc-unused-using-decls %t + +namespace a {class A {}; class B {}; class C {}; } +namespace b { +#if defined(USING_A) +using a::A; +#elif defined(USING_B) +using a::B; +#else +using a::C; +#endif +} +namespace c {} +// CHECK-MESSAGES-USING-A: :[[@LINE-8]]:10: warning: using decl 'A' {{.*}} +// CHECK-MESSAGES-USING-B: :[[@LINE-7]]:10: warning: using decl 'B' {{.*}} +// CHECK-MESSAGES: :[[@LINE-6]]:10: warning: using decl 'C' {{.*}} +// CHECK-FIXES-USING-A-NOT: using a::A;$ +// CHECK-FIXES-USING-B-NOT: using a::B;$ +// CHECK-FIXES-NOT: using a::C;$ Index: docs/clang-tidy/index.rst === --- docs/clang-tidy/index.rst +++ docs/clang-tidy/index.rst @@ -673,6 +673,27 @@ // CHECK-FIXES: int b = a; } +To check more than one scenario in the same test file use +``-check-suffix=SUFFIX_NAME`` on ``check_clang_tidy.py`` command line. +With ``-check-suffix=SUFFIX_NAME`` you need to replace your ``CHECK-*`` +directives with ``CHECK-MESSAGES-SUFFIX-NAME`` and ``CHECK-FIXES-SUFFIX-NAME``. + +Here's an example: + +.. code-
[PATCH] D45407: [StaticAnalyzer] Added notes to the plist output
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Checked this out, seems to be safely ignored for now. The `.plist` format is pretty resistant to this sort of stuff because most APIs to handle it are almost treating it as native arrays/dictionaries, so i guess it should be fine. In https://reviews.llvm.org/D45407#1068724, @whisperity wrote: > @NoQ The problem with emitting notes as events is that we lose the > information that the node was a `note`. How does Xcode behave with these > notes? Does it ignore them, or can read them from the command-line output of > the analyser? Yep, precisely: notes are completely different from path pieces - they shouldn't be connected to the rest of the path via arrows or necessarily have a certain ordering with respect to the path. For now notes are ignored by Xcode; there's no good UI for them implemented. They are also not used by many on-by-default checkers, so they're mostly an experiment for now. Repository: rC Clang https://reviews.llvm.org/D45407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".
NoQ added inline comments. Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:144 +// includes the full path. +if (SM.getFilename(IL).contains("UnifiedSource")) { + StringRef Name = SM.getFilename(SL); george.karpenkov wrote: > Is this `if` really necessary? This logic has too much overfitting, and it > seems that if someone decides to include `.cc` files, we should analyze them > in any case, right? We also would prefer to not stop working if webkit > decides on using a different naming for those. This is indeed an act of overfitting. But also there are very few reasons to include a non-header file, and all of them are pretty exotic. I'm not sure we want to analyze these files in all cases. So i want to play safe until we gather more data. Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:148 + Name.endswith_lower(".cc") || Name.endswith_lower(".m") || + Name.endswith_lower(".mm")) { +return true; baloghadamsoftware wrote: > Although not very common, but .cxx is also a possibly extension for C++ > source files. Yup, thanks! Comment at: test/Analysis/unified-sources/source1.cpp:8 + if (x) {} + return 1 / x; // expected-warning{{}} +} george.karpenkov wrote: > Wow, expected-* directives work across multiple files?? This is really cool! `-verify` works over preprocessed files, so yeah, these directives respect `#if`s (which we regularly abuse) and `#include`s (which we rarely abuse). This test also acts as a normal test, but the `UnifiedSource-1.cpp` test is the one that'll fail if we break the newly added functionality. https://reviews.llvm.org/D45839 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".
NoQ updated this revision to Diff 143396. NoQ marked 3 inline comments as done. NoQ added a comment. Address most comments. https://reviews.llvm.org/D45839 Files: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h lib/StaticAnalyzer/Core/CallEvent.cpp lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp lib/StaticAnalyzer/Core/PathDiagnostic.cpp lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp test/Analysis/unified-sources/UnifiedSource-1.cpp test/Analysis/unified-sources/container.h test/Analysis/unified-sources/source1.cpp test/Analysis/unified-sources/source2.cpp Index: test/Analysis/unified-sources/source2.cpp === --- /dev/null +++ test/Analysis/unified-sources/source2.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s + +// This test tests that the warning is here when it is included from +// the unified sources file. The run-line in this file is there +// only to suppress LIT warning for the complete lack of run-line. +int testNullDereference() { + int *x = 0; + return *x; // expected-warning{{}} +} + +// Let's see if the container inlining heuristic still works. +class ContainerInCodeFile { + class Iterator { + }; + +public: + Iterator begin() const; + Iterator end() const; + + int method() { return 0; } +}; + +int testContainerMethodInCodeFile(ContainerInCodeFile Cont) { + return 1 / Cont.method(); // expected-warning{{}} +} Index: test/Analysis/unified-sources/source1.cpp === --- /dev/null +++ test/Analysis/unified-sources/source1.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s + +// This test tests that the warning is here when it is included from +// the unified sources file. The run-line in this file is there +// only to suppress LIT warning for the complete lack of run-line. +int foo(int x) { + if (x) {} + return 1 / x; // expected-warning{{}} +} + +// Let's see if the container inlining heuristic still works. +#include "container.h" +int testContainerMethodInHeaderFile(ContainerInHeaderFile Cont) { + return 1 / Cont.method(); // no-warning +} Index: test/Analysis/unified-sources/container.h === --- /dev/null +++ test/Analysis/unified-sources/container.h @@ -0,0 +1,10 @@ +class ContainerInHeaderFile { + class Iterator { + }; + +public: + Iterator begin() const; + Iterator end() const; + + int method() { return 0; } +}; Index: test/Analysis/unified-sources/UnifiedSource-1.cpp === --- /dev/null +++ test/Analysis/unified-sources/UnifiedSource-1.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s + +// There should still be diagnostics within included files. +#include "source1.cpp" +#include "source2.cpp" Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp === --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -678,7 +678,7 @@ SourceLocation SL = Body ? Body->getLocStart() : D->getLocation(); SL = SM.getExpansionLoc(SL); - if (!Opts->AnalyzeAll && !SM.isWrittenInMainFile(SL)) { + if (!Opts->AnalyzeAll && !Mgr->isInCodeFile(SL)) { if (SL.isInvalid() || SM.isInSystemHeader(SL)) return AM_None; return Mode & ~AM_Path; Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp === --- lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -29,6 +29,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "llvm/ADT/ArrayRef.h" @@ -148,11 +149,11 @@ if (CallLoc.isMacroID()) return nullptr; - assert(SMgr.isInMainFile(CallLoc) && - "The call piece should be in the main file."); + assert(AnalysisManager::isInCodeFile(CallLoc, SMgr) && + "The call piece should not be in a header file."); // Check if CP represents a path through a function outside of the main file. - if (!SMgr.isInMainFile(CP->callEnterWithin.asLocation())) + if (!AnalysisManager::isInCodeFile(CP->callEnterWithin.asLocation(), SMgr)) return CP; const PathPieces &Path = CP->path; Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp === --- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -806,8 +806,9 @@ /// This checks static properties of the function, such as its
[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".
majnemer added inline comments. Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:145-147 + if (Name.endswith_lower(".c") || Name.endswith_lower(".cpp") || + Name.endswith_lower(".cc") || Name.endswith_lower(".cxx") || + Name.endswith_lower(".m") || Name.endswith_lower(".mm")) { C++ source code is also found in files which end in .C, this code will match against strange file endings like .cXx and .mM I think the above logic should be changed to match https://github.com/llvm-mirror/clang/blob/master/lib/Frontend/FrontendOptions.cpp#L27 https://reviews.llvm.org/D45839 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE330492: [clang-tidy] add new check to find out objc ivars which do not have prefix '_' (authored by Wizard, committed by ). Changed prior to commit: https://reviews.llvm.org/D45392?vs=142057&id=143408#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45392 Files: clang-tidy/readability/IdentifierNamingCheck.cpp test/clang-tidy/readability-identifier-naming-objc.m Index: test/clang-tidy/readability-identifier-naming-objc.m === --- test/clang-tidy/readability-identifier-naming-objc.m +++ test/clang-tidy/readability-identifier-naming-objc.m @@ -0,0 +1,15 @@ +// RUN: %check_clang_tidy %s readability-identifier-naming %t \ +// RUN: -config='{CheckOptions: \ +// RUN: [{key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}]}' \ +// RUN: -- + +@interface Foo +@end + +@interface Foo () { +int _bar; +int barWithoutPrefix; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc ivar 'barWithoutPrefix' [readability-identifier-naming] +// CHECK-FIXES: int _barWithoutPrefix; +} +@end Index: clang-tidy/readability/IdentifierNamingCheck.cpp === --- clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tidy/readability/IdentifierNamingCheck.cpp @@ -109,6 +109,7 @@ m(TemplateParameter) \ m(TypeAlias) \ m(MacroDefinition) \ +m(ObjcIvar) \ enum StyleKind { #define ENUMERATE(v) SK_ ## v, @@ -384,6 +385,9 @@ const NamedDecl *D, const std::vector> &NamingStyles) { + if (isa(D) && NamingStyles[SK_ObjcIvar]) +return SK_ObjcIvar; + if (isa(D) && NamingStyles[SK_Typedef]) return SK_Typedef; Index: test/clang-tidy/readability-identifier-naming-objc.m === --- test/clang-tidy/readability-identifier-naming-objc.m +++ test/clang-tidy/readability-identifier-naming-objc.m @@ -0,0 +1,15 @@ +// RUN: %check_clang_tidy %s readability-identifier-naming %t \ +// RUN: -config='{CheckOptions: \ +// RUN: [{key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}]}' \ +// RUN: -- + +@interface Foo +@end + +@interface Foo () { +int _bar; +int barWithoutPrefix; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc ivar 'barWithoutPrefix' [readability-identifier-naming] +// CHECK-FIXES: int _barWithoutPrefix; +} +@end Index: clang-tidy/readability/IdentifierNamingCheck.cpp === --- clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tidy/readability/IdentifierNamingCheck.cpp @@ -109,6 +109,7 @@ m(TemplateParameter) \ m(TypeAlias) \ m(MacroDefinition) \ +m(ObjcIvar) \ enum StyleKind { #define ENUMERATE(v) SK_ ## v, @@ -384,6 +385,9 @@ const NamedDecl *D, const std::vector> &NamingStyles) { + if (isa(D) && NamingStyles[SK_ObjcIvar]) +return SK_ObjcIvar; + if (isa(D) && NamingStyles[SK_Typedef]) return SK_Typedef; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45160: [clang-apply-replacements] Make clang-apply-replacements installable
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. LG Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330442 - [CodeGen] Add an option to suppress output of llvm.ident
Author: miyuki Date: Fri Apr 20 09:29:03 2018 New Revision: 330442 URL: http://llvm.org/viewvc/llvm-project?rev=330442&view=rev Log: [CodeGen] Add an option to suppress output of llvm.ident Summary: By default Clang outputs its version (including git commit hash, in case of trunk builds) into object and assembly files. It might be useful to have an option to disable this, especially for debugging purposes. This patch implements new command line flags -Qn and -Qy (the names are chosen for compatibility with GCC). -Qn disables output of the 'llvm.ident' metadata string and the 'producer' debug info. -Qy (enabled by default) does the opposite. Reviewers: faisalv, echristo, aprantl Reviewed By: aprantl Subscribers: aprantl, cfe-commits, JDevlieghere, rogfer01 Differential Revision: https://reviews.llvm.org/D45255 Added: cfe/trunk/test/CodeGen/no-ident-version.c Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=330442&r1=330441&r2=330442&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 20 09:29:03 2018 @@ -396,7 +396,10 @@ def O_flag : Flag<["-"], "O">, Flags<[CC def Ofast : Joined<["-"], "Ofast">, Group, Flags<[CC1Option]>; def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group, HelpText<"Disable linemarker output in -E mode">; -def Qn : Flag<["-"], "Qn">, IgnoredGCCCompat; +def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>, + HelpText<"Emit metadata containing compiler name and version">; +def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>, + HelpText<"Do not emit metadata containing compiler name and version">; def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[DriverOption, CoreOption]>, HelpText<"Don't emit warning for unused driver arguments">; def Q : Flag<["-"], "Q">, IgnoredGCCCompat; Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=330442&r1=330441&r2=330442&view=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Apr 20 09:29:03 2018 @@ -69,6 +69,7 @@ CODEGENOPT(EmitDeclMetadata , 1, 0) /// ///< Decl* various IR entities came from. ///< Only useful when running CodeGen as a ///< subroutine. +CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version metadata. CODEGENOPT(EmitGcovArcs , 1, 0) ///< Emit coverage data files, aka. GCDA. CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka GCNO. CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=330442&r1=330441&r2=330442&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 20 09:29:03 2018 @@ -577,7 +577,8 @@ void CGDebugInfo::CreateCompileUnit() { remapDIPath(getCurrentDirname()), CSInfo, getSource(SM, SM.getMainFileID())), - Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, + CGOpts.EmitVersionIdentMetadata ? Producer : "", + LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind, 0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling, Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=330442&r1=330441&r2=330442&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Apr 20 09:29:03 2018 @@ -571,7 +571,8 @@ void CodeGenModule::Release() { if (DebugInfo) DebugInfo->finalize(); - EmitVersionIdentMetadata(); + if (getCodeGenOpts().EmitVersionIdentMetadata) +EmitVersionIdentMetadata(); EmitTargetMetadata(); } Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/v
r330451 - Revert r330442, CodeGen/no-ident-version.c is failing on PPC
Author: miyuki Date: Fri Apr 20 10:14:39 2018 New Revision: 330451 URL: http://llvm.org/viewvc/llvm-project?rev=330451&view=rev Log: Revert r330442, CodeGen/no-ident-version.c is failing on PPC Removed: cfe/trunk/test/CodeGen/no-ident-version.c Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=330451&r1=330450&r2=330451&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 20 10:14:39 2018 @@ -396,10 +396,7 @@ def O_flag : Flag<["-"], "O">, Flags<[CC def Ofast : Joined<["-"], "Ofast">, Group, Flags<[CC1Option]>; def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group, HelpText<"Disable linemarker output in -E mode">; -def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>, - HelpText<"Emit metadata containing compiler name and version">; -def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>, - HelpText<"Do not emit metadata containing compiler name and version">; +def Qn : Flag<["-"], "Qn">, IgnoredGCCCompat; def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[DriverOption, CoreOption]>, HelpText<"Don't emit warning for unused driver arguments">; def Q : Flag<["-"], "Q">, IgnoredGCCCompat; Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=330451&r1=330450&r2=330451&view=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Apr 20 10:14:39 2018 @@ -69,7 +69,6 @@ CODEGENOPT(EmitDeclMetadata , 1, 0) /// ///< Decl* various IR entities came from. ///< Only useful when running CodeGen as a ///< subroutine. -CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version metadata. CODEGENOPT(EmitGcovArcs , 1, 0) ///< Emit coverage data files, aka. GCDA. CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka GCNO. CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=330451&r1=330450&r2=330451&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 20 10:14:39 2018 @@ -577,8 +577,7 @@ void CGDebugInfo::CreateCompileUnit() { remapDIPath(getCurrentDirname()), CSInfo, getSource(SM, SM.getMainFileID())), - CGOpts.EmitVersionIdentMetadata ? Producer : "", - LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, + Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind, 0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling, Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=330451&r1=330450&r2=330451&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Apr 20 10:14:39 2018 @@ -571,8 +571,7 @@ void CodeGenModule::Release() { if (DebugInfo) DebugInfo->finalize(); - if (getCodeGenOpts().EmitVersionIdentMetadata) -EmitVersionIdentMetadata(); + EmitVersionIdentMetadata(); EmitTargetMetadata(); } Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=330451&r1=330450&r2=330451&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Apr 20 10:14:39 2018 @@ -4408,9 +4408,6 @@ void Clang::ConstructJob(Compilation &C, } } - if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true)) -CmdArgs.push_back("-Qn"); - // -fcommon is the default unless compiling kernel code or the target says so bool NoCommonDefault = KernelOrKext || isNoCommonDefault(RawTripl
r330463 - [X86] WaitPKG intrinsics
Author: gbuella Date: Fri Apr 20 11:44:33 2018 New Revision: 330463 URL: http://llvm.org/viewvc/llvm-project?rev=330463&view=rev Log: [X86] WaitPKG intrinsics Reviewers: craig.topper, zvi Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D45254 Added: cfe/trunk/lib/Headers/waitpkgintrin.h (with props) cfe/trunk/test/CodeGen/waitpkg.c (with props) Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/Targets/X86.cpp cfe/trunk/lib/Basic/Targets/X86.h cfe/trunk/lib/Headers/CMakeLists.txt cfe/trunk/lib/Headers/cpuid.h cfe/trunk/lib/Headers/x86intrin.h cfe/trunk/test/Driver/x86-target-features.c cfe/trunk/test/Preprocessor/predefined-arch-macros.c Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=330463&r1=330462&r2=330463&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Apr 20 11:44:33 2018 @@ -1880,6 +1880,11 @@ TARGET_BUILTIN(__builtin_ia32_selectpd_5 TARGET_BUILTIN(__builtin_ia32_monitorx, "vv*UiUi", "", "mwaitx") TARGET_BUILTIN(__builtin_ia32_mwaitx, "vUiUiUi", "", "mwaitx") +// WAITPKG +TARGET_BUILTIN(__builtin_ia32_umonitor, "vv*", "", "waitpkg") +TARGET_BUILTIN(__builtin_ia32_umwait, "UcUiUiUi", "", "waitpkg") +TARGET_BUILTIN(__builtin_ia32_tpause, "UcUiUiUi", "", "waitpkg") + // CLZERO TARGET_BUILTIN(__builtin_ia32_clzero, "vv*", "", "clzero") Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=330463&r1=330462&r2=330463&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 20 11:44:33 2018 @@ -2680,6 +2680,8 @@ def mvaes : Flag<["-"], "mvaes">, Group< def mno_vaes : Flag<["-"], "mno-vaes">, Group; def mvpclmulqdq : Flag<["-"], "mvpclmulqdq">, Group; def mno_vpclmulqdq : Flag<["-"], "mno-vpclmulqdq">, Group; +def mwaitpkg : Flag<["-"], "mwaitpkg">, Group; +def mno_waitpkg : Flag<["-"], "mno-waitpkg">, Group; def mxop : Flag<["-"], "mxop">, Group; def mno_xop : Flag<["-"], "mno-xop">, Group; def mxsave : Flag<["-"], "mxsave">, Group; Modified: cfe/trunk/lib/Basic/Targets/X86.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=330463&r1=330462&r2=330463&view=diff == --- cfe/trunk/lib/Basic/Targets/X86.cpp (original) +++ cfe/trunk/lib/Basic/Targets/X86.cpp Fri Apr 20 11:44:33 2018 @@ -247,6 +247,7 @@ bool X86TargetInfo::initFeatureMap( case CK_Tremont: setFeatureEnabledImpl(Features, "cldemote", true); setFeatureEnabledImpl(Features, "gfni", true); +setFeatureEnabledImpl(Features, "waitpkg", true); LLVM_FALLTHROUGH; case CK_GoldmontPlus: setFeatureEnabledImpl(Features, "rdpid", true); @@ -818,6 +819,8 @@ bool X86TargetInfo::handleTargetFeatures HasRetpolineExternalThunk = true; } else if (Feature == "+sahf") { HasLAHFSAHF = true; +} else if (Feature == "+waitpkg") { + HasWAITPKG = true; } X86SSEEnum Level = llvm::StringSwitch(Feature) @@ -1172,6 +1175,8 @@ void X86TargetInfo::getTargetDefines(con Builder.defineMacro("__RDPID__"); if (HasCLDEMOTE) Builder.defineMacro("__CLDEMOTE__"); + if (HasWAITPKG) +Builder.defineMacro("__WAITPKG__"); // Each case falls through to the previous one here. switch (SSELevel) { @@ -1323,6 +1328,7 @@ bool X86TargetInfo::isValidFeatureName(S .Case("vaes", true) .Case("vpclmulqdq", true) .Case("wbnoinvd", true) + .Case("waitpkg", true) .Case("x87", true) .Case("xop", true) .Case("xsave", true) @@ -1399,6 +1405,7 @@ bool X86TargetInfo::hasFeature(StringRef .Case("vaes", HasVAES) .Case("vpclmulqdq", HasVPCLMULQDQ) .Case("wbnoinvd", HasWBNOINVD) + .Case("waitpkg", HasWAITPKG) .Case("x86", true) .Case("x86_32", getTriple().getArch() == llvm::Triple::x86) .Case("x86_64", getTriple().getArch() == llvm::Triple::x86_64) Modified: cfe/trunk/lib/Basic/Targets/X86.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=330463&r1=330462&r2=330463&view=diff == --- cfe/trunk/lib/Basic/Targets/X86.h (original) +++ cfe/trunk/lib/Basic/Targets/X86.h Fri Apr 20 11:44:33 2018 @@ -102,6 +102,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetI bool HasRetpolineExternalThunk = false; bool HasLAHFSAHF = false; bool HasWBNOINVD = false; + bool HasWAITPKG = false; pr
[clang-tools-extra] r330492 - [clang-tidy] add new check to find out objc ivars which do not have prefix '_'
Author: wizard Date: Fri Apr 20 16:18:09 2018 New Revision: 330492 URL: http://llvm.org/viewvc/llvm-project?rev=330492&view=rev Log: [clang-tidy] add new check to find out objc ivars which do not have prefix '_' Summary: For code of ivar declaration: int barWithoutPrefix; The fix will be: int _barWithoutPrefix; Reviewers: benhamilton, hokein, alexfh, aaron.ballman, ilya-biryukov Reviewed By: alexfh Subscribers: Eugene.Zelenko, xazax.hun, klimek, mgorny, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D45392 Added: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m Modified: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=330492&r1=330491&r2=330492&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp Fri Apr 20 16:18:09 2018 @@ -109,6 +109,7 @@ namespace readability { m(TemplateParameter) \ m(TypeAlias) \ m(MacroDefinition) \ +m(ObjcIvar) \ enum StyleKind { #define ENUMERATE(v) SK_ ## v, @@ -384,6 +385,9 @@ static StyleKind findStyleKind( const NamedDecl *D, const std::vector> &NamingStyles) { + if (isa(D) && NamingStyles[SK_ObjcIvar]) +return SK_ObjcIvar; + if (isa(D) && NamingStyles[SK_Typedef]) return SK_Typedef; Added: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m?rev=330492&view=auto == --- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m (added) +++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m Fri Apr 20 16:18:09 2018 @@ -0,0 +1,15 @@ +// RUN: %check_clang_tidy %s readability-identifier-naming %t \ +// RUN: -config='{CheckOptions: \ +// RUN: [{key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}]}' \ +// RUN: -- + +@interface Foo +@end + +@interface Foo () { +int _bar; +int barWithoutPrefix; +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc ivar 'barWithoutPrefix' [readability-identifier-naming] +// CHECK-FIXES: int _barWithoutPrefix; +} +@end ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py
alexfh added a comment. A few style-related comments. Comment at: docs/clang-tidy/index.rst:677 +To check more than one scenario in the same test file use +``-check-suffix=SUFFIX_NAME`` on ``check_clang_tidy.py`` command line. +With ``-check-suffix=SUFFIX_NAME`` you need to replace your ``CHECK-*`` s/SUFFIX_NAME/SUFFIX-NAME/ Same below. Comment at: docs/clang-tidy/index.rst:685 + + // RUN: %check_clang_tidy -check-suffix USING-A %s misc-unused-using-decls %t -- -- -DUSING_A + // RUN: %check_clang_tidy -check-suffix USING-B %s misc-unused-using-decls %t -- -- -DUSING_B I'd use the ``-check-suffix=...`` format (with the equals sign) for consistency with the documentation. Comment at: test/clang-tidy/check_clang_tidy.py:21 [-assume-filename ] \ +[-check-suffix ] \ \ ``-check-suffix=`` and maybe the same for -assume-filename https://reviews.llvm.org/D45776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".
NoQ added inline comments. Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:145-147 + if (Name.endswith_lower(".c") || Name.endswith_lower(".cpp") || + Name.endswith_lower(".cc") || Name.endswith_lower(".cxx") || + Name.endswith_lower(".m") || Name.endswith_lower(".mm")) { majnemer wrote: > C++ source code is also found in files which end in .C, this code will match > against strange file endings like .cXx and .mM > > I think the above logic should be changed to match > https://github.com/llvm-mirror/clang/blob/master/lib/Frontend/FrontendOptions.cpp#L27 Aha, yeah, thanks, that's the place i was looking for. https://reviews.llvm.org/D45839 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".
NoQ updated this revision to Diff 143416. NoQ marked an inline comment as done. NoQ added a comment. A more accurate extension check. https://reviews.llvm.org/D45839 Files: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h lib/StaticAnalyzer/Core/CallEvent.cpp lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp lib/StaticAnalyzer/Core/PathDiagnostic.cpp lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp test/Analysis/unified-sources/UnifiedSource-1.cpp test/Analysis/unified-sources/container.h test/Analysis/unified-sources/source1.cpp test/Analysis/unified-sources/source2.cpp Index: test/Analysis/unified-sources/source2.cpp === --- /dev/null +++ test/Analysis/unified-sources/source2.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s + +// This test tests that the warning is here when it is included from +// the unified sources file. The run-line in this file is there +// only to suppress LIT warning for the complete lack of run-line. +int testNullDereference() { + int *x = 0; + return *x; // expected-warning{{}} +} + +// Let's see if the container inlining heuristic still works. +class ContainerInCodeFile { + class Iterator { + }; + +public: + Iterator begin() const; + Iterator end() const; + + int method() { return 0; } +}; + +int testContainerMethodInCodeFile(ContainerInCodeFile Cont) { + return 1 / Cont.method(); // expected-warning{{}} +} Index: test/Analysis/unified-sources/source1.cpp === --- /dev/null +++ test/Analysis/unified-sources/source1.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s + +// This test tests that the warning is here when it is included from +// the unified sources file. The run-line in this file is there +// only to suppress LIT warning for the complete lack of run-line. +int foo(int x) { + if (x) {} + return 1 / x; // expected-warning{{}} +} + +// Let's see if the container inlining heuristic still works. +#include "container.h" +int testContainerMethodInHeaderFile(ContainerInHeaderFile Cont) { + return 1 / Cont.method(); // no-warning +} Index: test/Analysis/unified-sources/container.h === --- /dev/null +++ test/Analysis/unified-sources/container.h @@ -0,0 +1,10 @@ +class ContainerInHeaderFile { + class Iterator { + }; + +public: + Iterator begin() const; + Iterator end() const; + + int method() { return 0; } +}; Index: test/Analysis/unified-sources/UnifiedSource-1.cpp === --- /dev/null +++ test/Analysis/unified-sources/UnifiedSource-1.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s + +// There should still be diagnostics within included files. +#include "source1.cpp" +#include "source2.cpp" Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp === --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -678,7 +678,7 @@ SourceLocation SL = Body ? Body->getLocStart() : D->getLocation(); SL = SM.getExpansionLoc(SL); - if (!Opts->AnalyzeAll && !SM.isWrittenInMainFile(SL)) { + if (!Opts->AnalyzeAll && !Mgr->isInCodeFile(SL)) { if (SL.isInvalid() || SM.isInSystemHeader(SL)) return AM_None; return Mode & ~AM_Path; Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp === --- lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -29,6 +29,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "llvm/ADT/ArrayRef.h" @@ -148,11 +149,11 @@ if (CallLoc.isMacroID()) return nullptr; - assert(SMgr.isInMainFile(CallLoc) && - "The call piece should be in the main file."); + assert(AnalysisManager::isInCodeFile(CallLoc, SMgr) && + "The call piece should not be in a header file."); // Check if CP represents a path through a function outside of the main file. - if (!SMgr.isInMainFile(CP->callEnterWithin.asLocation())) + if (!AnalysisManager::isInCodeFile(CP->callEnterWithin.asLocation(), SMgr)) return CP; const PathPieces &Path = CP->path; Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp === --- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -806,8 +806,9 @@ /// This checks static properties of the function, s
[PATCH] D45912: update test to use ivar in implementation instead of class extension
Wizard created this revision. Herald added subscribers: cfe-commits, klimek. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45912 Files: test/clang-tidy/readability-identifier-naming-objc.m Index: test/clang-tidy/readability-identifier-naming-objc.m === --- test/clang-tidy/readability-identifier-naming-objc.m +++ test/clang-tidy/readability-identifier-naming-objc.m @@ -6,7 +6,7 @@ @interface Foo @end -@interface Foo () { +@implementation Foo { int _bar; int barWithoutPrefix; // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc ivar 'barWithoutPrefix' [readability-identifier-naming] Index: test/clang-tidy/readability-identifier-naming-objc.m === --- test/clang-tidy/readability-identifier-naming-objc.m +++ test/clang-tidy/readability-identifier-naming-objc.m @@ -6,7 +6,7 @@ @interface Foo @end -@interface Foo () { +@implementation Foo { int _bar; int barWithoutPrefix; // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc ivar 'barWithoutPrefix' [readability-identifier-naming] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45284: [RISCV] More validations on the input value of -march=
apazos added a comment. Hi Alex, it seems the table expects these extensions in a canonical order too: all x extensions, followed by all s extensions, and then all sx extensions. I can make the change, no problem. I have also coded other error situations described below. But f I cannot push a test we can enable, because we error out when we find the first non-supported extension in the string with unsupported extension message, and stop parsing the string. Any suggestion? Examples: clang -target riscv32-unknown-elf -march=rv32ixabc_ -### extension name missing after separator '_' clang -target riscv32-unknown-elf -march=rv32ixabc_a -### invalid extension prefix 'a' clang -target riscv32-unknown-elf -march=rv32isabc_xdef -### non-standard user-level extension not given in canonical order 'xdef' clang -target riscv32-unknown-elf -march=rv32isxabc_sdef -### standard supervisor-level extension not given in canonical order 'sdef' clang -target riscv32-unknown-elf -march=rv32ixabc_xabc -### duplicated non-standard user-level extension 'xabc' clang -target riscv32-unknown-elf -march=rv32ixabc_xdef -### no parsing error, should be accepted if xabc and xdef are valid extensions clang -target riscv32-unknown-elf -march=rv32ixabc_sdef_sxghi -### no parsing error, should be accepted if xabc sdef sxghi are valid extensions https://reviews.llvm.org/D45284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r330492 - [clang-tidy] add new check to find out objc ivars which do not have prefix '_'
This has broken most of the build bots. Are you working on a fix or revert? Might be useful to get on the IRC channel to help coordinate this kind of thing. On Fri, Apr 20, 2018 at 4:45 PM Yan Zhang via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: wizard > Date: Fri Apr 20 16:18:09 2018 > New Revision: 330492 > > URL: http://llvm.org/viewvc/llvm-project?rev=330492&view=rev > Log: > [clang-tidy] add new check to find out objc ivars which do not have prefix > '_' > > Summary: > For code of ivar declaration: > >int barWithoutPrefix; > > The fix will be: > >int _barWithoutPrefix; > > Reviewers: benhamilton, hokein, alexfh, aaron.ballman, ilya-biryukov > > Reviewed By: alexfh > > Subscribers: Eugene.Zelenko, xazax.hun, klimek, mgorny, cfe-commits > > Tags: #clang-tools-extra > > Differential Revision: https://reviews.llvm.org/D45392 > > Added: > > clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m > Modified: > > clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp > > Modified: > clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=330492&r1=330491&r2=330492&view=diff > > == > --- > clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp > (original) > +++ > clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp > Fri Apr 20 16:18:09 2018 > @@ -109,6 +109,7 @@ namespace readability { > m(TemplateParameter) \ > m(TypeAlias) \ > m(MacroDefinition) \ > +m(ObjcIvar) \ > > enum StyleKind { > #define ENUMERATE(v) SK_ ## v, > @@ -384,6 +385,9 @@ static StyleKind findStyleKind( > const NamedDecl *D, > const std::vector> > &NamingStyles) { > + if (isa(D) && NamingStyles[SK_ObjcIvar]) > +return SK_ObjcIvar; > + >if (isa(D) && NamingStyles[SK_Typedef]) > return SK_Typedef; > > > Added: > clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m?rev=330492&view=auto > > == > --- > clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m > (added) > +++ > clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m > Fri Apr 20 16:18:09 2018 > @@ -0,0 +1,15 @@ > +// RUN: %check_clang_tidy %s readability-identifier-naming %t \ > +// RUN: -config='{CheckOptions: \ > +// RUN: [{key: readability-identifier-naming.ObjcIvarPrefix, value: > '_'}]}' \ > +// RUN: -- > + > +@interface Foo > +@end > + > +@interface Foo () { > +int _bar; > +int barWithoutPrefix; > +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for > objc ivar 'barWithoutPrefix' [readability-identifier-naming] > +// CHECK-FIXES: int _barWithoutPrefix; > +} > +@end > > > ___ > 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
Re: [clang-tools-extra] r330492 - [clang-tidy] add new check to find out objc ivars which do not have prefix '_'
https://reviews.llvm.org/D45912 need someone to accept Best regards Yan Zhang > On Apr 20, 2018, at 19:08, Chandler Carruth wrote: > > This has broken most of the build bots. Are you working on a fix or revert? > > Might be useful to get on the IRC channel to help coordinate this kind of > thing. > >> On Fri, Apr 20, 2018 at 4:45 PM Yan Zhang via cfe-commits >> wrote: >> Author: wizard >> Date: Fri Apr 20 16:18:09 2018 >> New Revision: 330492 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=330492&view=rev >> Log: >> [clang-tidy] add new check to find out objc ivars which do not have prefix >> '_' >> >> Summary: >> For code of ivar declaration: >> >>int barWithoutPrefix; >> >> The fix will be: >> >>int _barWithoutPrefix; >> >> Reviewers: benhamilton, hokein, alexfh, aaron.ballman, ilya-biryukov >> >> Reviewed By: alexfh >> >> Subscribers: Eugene.Zelenko, xazax.hun, klimek, mgorny, cfe-commits >> >> Tags: #clang-tools-extra >> >> Differential Revision: https://reviews.llvm.org/D45392 >> >> Added: >> >> clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m >> Modified: >> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp >> >> Modified: >> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=330492&r1=330491&r2=330492&view=diff >> == >> --- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp >> (original) >> +++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp >> Fri Apr 20 16:18:09 2018 >> @@ -109,6 +109,7 @@ namespace readability { >> m(TemplateParameter) \ >> m(TypeAlias) \ >> m(MacroDefinition) \ >> +m(ObjcIvar) \ >> >> enum StyleKind { >> #define ENUMERATE(v) SK_ ## v, >> @@ -384,6 +385,9 @@ static StyleKind findStyleKind( >> const NamedDecl *D, >> const std::vector> >> &NamingStyles) { >> + if (isa(D) && NamingStyles[SK_ObjcIvar]) >> +return SK_ObjcIvar; >> + >>if (isa(D) && NamingStyles[SK_Typedef]) >> return SK_Typedef; >> >> >> Added: >> clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m?rev=330492&view=auto >> == >> --- >> clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m >> (added) >> +++ >> clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m >> Fri Apr 20 16:18:09 2018 >> @@ -0,0 +1,15 @@ >> +// RUN: %check_clang_tidy %s readability-identifier-naming %t \ >> +// RUN: -config='{CheckOptions: \ >> +// RUN: [{key: readability-identifier-naming.ObjcIvarPrefix, value: >> '_'}]}' \ >> +// RUN: -- >> + >> +@interface Foo >> +@end >> + >> +@interface Foo () { >> +int _bar; >> +int barWithoutPrefix; >> +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc >> ivar 'barWithoutPrefix' [readability-identifier-naming] >> +// CHECK-FIXES: int _barWithoutPrefix; >> +} >> +@end >> >> >> ___ >> 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] D45912: update test to use ivar in implementation instead of class extension
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. LG Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r330492 - [clang-tidy] add new check to find out objc ivars which do not have prefix '_'
I see Alex already got it, but in the future, that kind of trivial test fix for a failing test is fine to just land, and it is more important to get the bots healthy. =] On Fri, Apr 20, 2018, 22:14 Yan Zhang via cfe-commits < cfe-commits@lists.llvm.org> wrote: > https://reviews.llvm.org/D45912 need someone to accept > > Best regards > Yan Zhang > > On Apr 20, 2018, at 19:08, Chandler Carruth wrote: > > This has broken most of the build bots. Are you working on a fix or revert? > > Might be useful to get on the IRC channel to help coordinate this kind of > thing. > > On Fri, Apr 20, 2018 at 4:45 PM Yan Zhang via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: wizard >> Date: Fri Apr 20 16:18:09 2018 >> New Revision: 330492 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=330492&view=rev >> Log: >> [clang-tidy] add new check to find out objc ivars which do not have >> prefix '_' >> >> Summary: >> For code of ivar declaration: >> >>int barWithoutPrefix; >> >> The fix will be: >> >>int _barWithoutPrefix; >> >> Reviewers: benhamilton, hokein, alexfh, aaron.ballman, ilya-biryukov >> >> Reviewed By: alexfh >> >> Subscribers: Eugene.Zelenko, xazax.hun, klimek, mgorny, cfe-commits >> >> Tags: #clang-tools-extra >> >> Differential Revision: https://reviews.llvm.org/D45392 >> >> Added: >> >> clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m >> Modified: >> >> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp >> >> Modified: >> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=330492&r1=330491&r2=330492&view=diff >> >> == >> --- >> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp >> (original) >> +++ >> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp >> Fri Apr 20 16:18:09 2018 >> @@ -109,6 +109,7 @@ namespace readability { >> m(TemplateParameter) \ >> m(TypeAlias) \ >> m(MacroDefinition) \ >> +m(ObjcIvar) \ >> >> enum StyleKind { >> #define ENUMERATE(v) SK_ ## v, >> @@ -384,6 +385,9 @@ static StyleKind findStyleKind( >> const NamedDecl *D, >> const std::vector> >> &NamingStyles) { >> + if (isa(D) && NamingStyles[SK_ObjcIvar]) >> +return SK_ObjcIvar; >> + >>if (isa(D) && NamingStyles[SK_Typedef]) >> return SK_Typedef; >> >> >> Added: >> clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m?rev=330492&view=auto >> >> == >> --- >> clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m >> (added) >> +++ >> clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-objc.m >> Fri Apr 20 16:18:09 2018 >> @@ -0,0 +1,15 @@ >> +// RUN: %check_clang_tidy %s readability-identifier-naming %t \ >> +// RUN: -config='{CheckOptions: \ >> +// RUN: [{key: readability-identifier-naming.ObjcIvarPrefix, value: >> '_'}]}' \ >> +// RUN: -- >> + >> +@interface Foo >> +@end >> + >> +@interface Foo () { >> +int _bar; >> +int barWithoutPrefix; >> +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for >> objc ivar 'barWithoutPrefix' [readability-identifier-naming] >> +// CHECK-FIXES: int _barWithoutPrefix; >> +} >> +@end >> >> >> ___ >> 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 > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits