[PATCH] D46383: implementing Cursor.get_included_file in python bindings
jbcoe added a comment. I will try to commit this today. Repository: rC Clang https://reviews.llvm.org/D46383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode
hans added a comment. In https://reviews.llvm.org/D46520#1092233, @rnk wrote: > Please don't do this, this is actually really problematic, since `#line` > directives lose information about what's a system header. That means the > result of -E usually won't compile, since Windows headers are typically full > of warnings and default-error warnings. Sorry, I didn't realize this was the case :-/ Repository: rL LLVM https://reviews.llvm.org/D46520 ___ 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 added a comment. Okay, I will close the request and thank you very much for your help and your hints. 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] D45177: CStringChecker, check strlcpy/strlcat
devnexen added a comment. ping https://reviews.llvm.org/D45177 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45177: CStringChecker, check strlcpy/strlcat
rja accepted this revision. rja added a comment. LG https://reviews.llvm.org/D45177 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46541: [CodeGen] Improve diagnostics related to target attributes
GBuella updated this revision to Diff 145876. https://reviews.llvm.org/D46541 Files: lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h test/CodeGen/target-features-error-2.c test/CodeGen/target-features-error.c Index: test/CodeGen/target-features-error.c === --- test/CodeGen/target-features-error.c +++ test/CodeGen/target-features-error.c @@ -3,6 +3,5 @@ return a + 4; } int bar() { - return foo(4); // expected-error {{always_inline function 'foo' requires target feature 'sse4.2', but would be inlined into function 'bar' that is compiled without support for 'sse4.2'}} + return foo(4); // expected-error {{always_inline function 'foo' requires target feature 'avx', but would be inlined into function 'bar' that is compiled without support for 'avx'}} } - Index: test/CodeGen/target-features-error-2.c === --- test/CodeGen/target-features-error-2.c +++ test/CodeGen/target-features-error-2.c @@ -3,13 +3,14 @@ // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_4 +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX512f #define __MM_MALLOC_H #include #if NEED_SSE42 int baz(__m256i a) { - return _mm256_extract_epi32(a, 3); // expected-error {{always_inline function '_mm256_extract_epi32' requires target feature 'sse4.2', but would be inlined into function 'baz' that is compiled without support for 'sse4.2'}} + return _mm256_extract_epi32(a, 3); // expected-error {{always_inline function '_mm256_extract_epi32' requires target feature 'avx', but would be inlined into function 'baz' that is compiled without support for 'avx'}} } #endif @@ -36,3 +37,9 @@ return _mm_cmp_sd(a, b, 0); // expected-error {{'__builtin_ia32_cmpsd' needs target feature avx}} } #endif + +#if NEED_AVX512f +unsigned short need_avx512f(unsigned short a, unsigned short b) { + return __builtin_ia32_korhi(a, b); // expected-error {{'__builtin_ia32_korhi' needs target feature avx512f}} +} +#endif Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1082,6 +1082,8 @@ /// It's up to you to ensure that this is safe. void AddDefaultFnAttrs(llvm::Function &F); + TargetAttr::ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD); + // Fills in the supplied string map with the set of target features for the // passed in function. void getFunctionFeatureMap(llvm::StringMap &FeatureMap, Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -4995,22 +4995,28 @@ } } +TargetAttr::ParsedTargetAttr CodeGenModule::filterFunctionTargetAttrs(const TargetAttr *TD) { + assert(TD != nullptr); + TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse(); + + ParsedAttr.Features.erase( + llvm::remove_if(ParsedAttr.Features, + [&](const std::string &Feat) { +return !Target.isValidFeatureName( +StringRef{Feat}.substr(1)); + }), + ParsedAttr.Features.end()); + return ParsedAttr; +} + + // Fills in the supplied string map with the set of target features for the // passed in function. void CodeGenModule::getFunctionFeatureMap(llvm::StringMap &FeatureMap, const FunctionDecl *FD) { StringRef TargetCPU = Target.getTargetOpts().CPU; if (const auto *TD = FD->getAttr()) { -// If we have a TargetAttr build up the feature map based on that. -TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse(); - -ParsedAttr.Features.erase( -llvm::remove_if(ParsedAttr.Features, -[&](const std::string &Feat) { - return !Target.isValidFeatureName( - StringRef{Feat}.substr(1)); -}), -ParsedAttr.Features.end()); +TargetAttr::ParsedTargetAttr ParsedAttr = filterFunctionTargetAttrs(TD); // Make a copy of the features as passed on the command line into the // beginning of the additional features from the function to override. Index: lib/CodeGen/CodeGenFunction.cpp === --- lib/CodeGen/CodeGenFunction.cpp +++ lib/CodeGen/CodeGenFunction.cpp @@ -2330,9 +2330,19 @@ } else if (TargetDecl->hasAttr()) { // Get the required features for the callee. + +const TargetAttr *TD = TargetDecl->getAttr(); +TargetAttr::ParsedTargetAttr ParsedAttr = CGM.filterFunctionTargetAttrs(
[PATCH] D46540: [X86] ptwrite intrinsic
GBuella added a comment. In https://reviews.llvm.org/D46540#1091625, @Hahnfeld wrote: > Could you maybe add some short summaries to your patches? It's hard for > non-Intel employees to guess what all these instructions do... Well, I was thinking I could copy-paste this from https://software.intel.com/en-us/articles/intel-sdm : "This instruction reads data in the source operand and sends it to the Intel Processor Trace hardware to be encoded in a PTW packet if TriggerEn, ContextEn, FilterEn, and PTWEn are all set to 1. For more details on these values, see Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3C, Section 35.2.2, “Software Trace Instrumentation with PTWRITE”." Do you think this would really help anyone? It appears to be just meaningless without larger context. Those who ever need this, need to read a lot of these manuals anyways, I think noone in practice is going to be enlightened by such a short description. That of course makes a lot more sense with simpler instructions, e.g. movdir64b - I can just describe that as something like "atomically moving 64 bytes". https://reviews.llvm.org/D46540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46522: [clang] cmake: resolve symlinks in ClangConfig.cmake
Lekensteyn abandoned this revision. Lekensteyn added a comment. Per discussion in https://reviews.llvm.org/D46521, resolving symlinks might introduce issues that are are worse than the issue that was solved here. It seems better to carry this patch downstream (in Debian) since the problem only exists there due to its use of symlinks (which is apparently not fully supported/recommended in LLVM upstream). Repository: rC Clang https://reviews.llvm.org/D46522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331856 - [driver] Add mips_Features_Group to Options to improve documentation sorting
Author: atanasyan Date: Wed May 9 01:42:30 2018 New Revision: 331856 URL: http://llvm.org/viewvc/llvm-project?rev=331856&view=rev Log: [driver] Add mips_Features_Group to Options to improve documentation sorting Move all of the MIPS-only options into a new m_mips_Features_Group. Nearly all other targets have most target-specific options grouped, but MIPS does not. The primary benefits are that the options will be listed together (and thus identifiable as MIPS-specific even if they have no help string) in the ClangCommandLineReference, and that Options.td is a bit more organized. A secondary benefit is that a custom version of clang can more easily hide/disable groups of options for unsupported targets. Patch by Vince Del Vecchio Differential Revision: https://reviews.llvm.org/D46450 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=331856&r1=331855&r2=331856&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Wed May 9 01:42:30 2018 @@ -143,6 +143,8 @@ def m_hexagon_Features_Group : OptionGro // These are explicitly handled. def m_hexagon_Features_HVX_Group : OptionGroup<"">, Group, DocName<"Hexagon">; +def m_mips_Features_Group : OptionGroup<"">, +Group, DocName<"MIPS">; def m_ppc_Features_Group : OptionGroup<"">, Group, DocName<"PowerPC">; def m_wasm_Features_Group : OptionGroup<"">, @@ -150,7 +152,7 @@ def m_wasm_Features_Group : OptionGroup< def m_x86_Features_Group : OptionGroup<"">, Group, Flags<[CoreOption]>, DocName<"X86">; -def m_libc_Group : OptionGroup<"">, Group, +def m_libc_Group : OptionGroup<"">, Group, Flags<[HelpHidden]>; def O_Group : OptionGroup<"">, Group, @@ -2094,127 +2096,135 @@ def mpie_copy_relocations : Flag<["-"], def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group; def mfentry : Flag<["-"], "mfentry">, HelpText<"Insert calls to fentry at function entry (x86 only)">, Flags<[CC1Option]>, Group; -def mips16 : Flag<["-"], "mips16">, Group; -def mno_mips16 : Flag<["-"], "mno-mips16">, Group; -def mmicromips : Flag<["-"], "mmicromips">, Group; -def mno_micromips : Flag<["-"], "mno-micromips">, Group; -def mxgot : Flag<["-"], "mxgot">, Group; -def mno_xgot : Flag<["-"], "mno-xgot">, Group; -def mldc1_sdc1 : Flag<["-"], "mldc1-sdc1">, Group; -def mno_ldc1_sdc1 : Flag<["-"], "mno-ldc1-sdc1">, Group; -def mcheck_zero_division : Flag<["-"], "mcheck-zero-division">, Group; +def mips16 : Flag<["-"], "mips16">, Group; +def mno_mips16 : Flag<["-"], "mno-mips16">, Group; +def mmicromips : Flag<["-"], "mmicromips">, Group; +def mno_micromips : Flag<["-"], "mno-micromips">, Group; +def mxgot : Flag<["-"], "mxgot">, Group; +def mno_xgot : Flag<["-"], "mno-xgot">, Group; +def mldc1_sdc1 : Flag<["-"], "mldc1-sdc1">, Group; +def mno_ldc1_sdc1 : Flag<["-"], "mno-ldc1-sdc1">, Group; +def mcheck_zero_division : Flag<["-"], "mcheck-zero-division">, + Group; def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">, - Group; -def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group; + Group; +def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, + Group; def mbranch_likely : Flag<["-"], "mbranch-likely">, Group, IgnoredGCCCompat; def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group, IgnoredGCCCompat; def mindirect_jump_EQ : Joined<["-"], "mindirect-jump=">, - Group, + Group, HelpText<"Change indirect jump instructions to inhibit speculation">; -def mdsp : Flag<["-"], "mdsp">, Group; -def mno_dsp : Flag<["-"], "mno-dsp">, Group; -def mdspr2 : Flag<["-"], "mdspr2">, Group; -def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group; -def msingle_float : Flag<["-"], "msingle-float">, Group; -def mdouble_float : Flag<["-"], "mdouble-float">, Group; -def mmadd4 : Flag<["-"], "mmadd4">, Group, +def mdsp : Flag<["-"], "mdsp">, Group; +def mno_dsp : Flag<["-"], "mno-dsp">, Group; +def mdspr2 : Flag<["-"], "mdspr2">, Group; +def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group; +def msingle_float : Flag<["-"], "msingle-float">, Group; +def mdouble_float : Flag<["-"], "mdouble-float">, Group; +def mmadd4 : Flag<["-"], "mmadd4">, Group, HelpText<"Enable the generation of 4-operand madd.s, madd.d and related instructions.">; -def mno_madd4 : Flag<["-"], "mno-madd4">, Group, +def mno_madd4 : Flag<["-"], "mno-madd4">, Group, HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">; -def mmsa : Flag<["-"], "mmsa">, Group, +def mmsa : Flag<["-"], "mmsa">, Group
[PATCH] D46450: [Driver] Add mips_Features_Group to Options to improve documentation sorting
This revision was automatically updated to reflect the committed changes. Closed by commit rL331856: [driver] Add mips_Features_Group to Options to improve documentation sorting (authored by atanasyan, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D46450?vs=145256&id=145879#toc Repository: rL LLVM https://reviews.llvm.org/D46450 Files: cfe/trunk/include/clang/Driver/Options.td Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -143,14 +143,16 @@ // These are explicitly handled. def m_hexagon_Features_HVX_Group : OptionGroup<"">, Group, DocName<"Hexagon">; +def m_mips_Features_Group : OptionGroup<"">, +Group, DocName<"MIPS">; def m_ppc_Features_Group : OptionGroup<"">, Group, DocName<"PowerPC">; def m_wasm_Features_Group : OptionGroup<"">, Group, DocName<"WebAssembly">; def m_x86_Features_Group : OptionGroup<"">, Group, Flags<[CoreOption]>, DocName<"X86">; -def m_libc_Group : OptionGroup<"">, Group, +def m_libc_Group : OptionGroup<"">, Group, Flags<[HelpHidden]>; def O_Group : OptionGroup<"">, Group, @@ -2094,127 +2096,135 @@ def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group; def mfentry : Flag<["-"], "mfentry">, HelpText<"Insert calls to fentry at function entry (x86 only)">, Flags<[CC1Option]>, Group; -def mips16 : Flag<["-"], "mips16">, Group; -def mno_mips16 : Flag<["-"], "mno-mips16">, Group; -def mmicromips : Flag<["-"], "mmicromips">, Group; -def mno_micromips : Flag<["-"], "mno-micromips">, Group; -def mxgot : Flag<["-"], "mxgot">, Group; -def mno_xgot : Flag<["-"], "mno-xgot">, Group; -def mldc1_sdc1 : Flag<["-"], "mldc1-sdc1">, Group; -def mno_ldc1_sdc1 : Flag<["-"], "mno-ldc1-sdc1">, Group; -def mcheck_zero_division : Flag<["-"], "mcheck-zero-division">, Group; +def mips16 : Flag<["-"], "mips16">, Group; +def mno_mips16 : Flag<["-"], "mno-mips16">, Group; +def mmicromips : Flag<["-"], "mmicromips">, Group; +def mno_micromips : Flag<["-"], "mno-micromips">, Group; +def mxgot : Flag<["-"], "mxgot">, Group; +def mno_xgot : Flag<["-"], "mno-xgot">, Group; +def mldc1_sdc1 : Flag<["-"], "mldc1-sdc1">, Group; +def mno_ldc1_sdc1 : Flag<["-"], "mno-ldc1-sdc1">, Group; +def mcheck_zero_division : Flag<["-"], "mcheck-zero-division">, + Group; def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">, - Group; -def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group; + Group; +def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, + Group; def mbranch_likely : Flag<["-"], "mbranch-likely">, Group, IgnoredGCCCompat; def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group, IgnoredGCCCompat; def mindirect_jump_EQ : Joined<["-"], "mindirect-jump=">, - Group, + Group, HelpText<"Change indirect jump instructions to inhibit speculation">; -def mdsp : Flag<["-"], "mdsp">, Group; -def mno_dsp : Flag<["-"], "mno-dsp">, Group; -def mdspr2 : Flag<["-"], "mdspr2">, Group; -def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group; -def msingle_float : Flag<["-"], "msingle-float">, Group; -def mdouble_float : Flag<["-"], "mdouble-float">, Group; -def mmadd4 : Flag<["-"], "mmadd4">, Group, +def mdsp : Flag<["-"], "mdsp">, Group; +def mno_dsp : Flag<["-"], "mno-dsp">, Group; +def mdspr2 : Flag<["-"], "mdspr2">, Group; +def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group; +def msingle_float : Flag<["-"], "msingle-float">, Group; +def mdouble_float : Flag<["-"], "mdouble-float">, Group; +def mmadd4 : Flag<["-"], "mmadd4">, Group, HelpText<"Enable the generation of 4-operand madd.s, madd.d and related instructions.">; -def mno_madd4 : Flag<["-"], "mno-madd4">, Group, +def mno_madd4 : Flag<["-"], "mno-madd4">, Group, HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">; -def mmsa : Flag<["-"], "mmsa">, Group, +def mmsa : Flag<["-"], "mmsa">, Group, HelpText<"Enable MSA ASE (MIPS only)">; -def mno_msa : Flag<["-"], "mno-msa">, Group, +def mno_msa : Flag<["-"], "mno-msa">, Group, HelpText<"Disable MSA ASE (MIPS only)">; -def mmt : Flag<["-"], "mmt">, Group, +def mmt : Flag<["-"], "mmt">, Group, HelpText<"Enable MT ASE (MIPS only)">; -def mno_mt : Flag<["-"], "mno-mt">, Group, +def mno_mt : Flag<["-"], "mno-mt">, Group, HelpText<"Disable MT ASE (MIPS only)">; -def mfp64 : Flag<["-"], "mfp64">, Group, +def mfp64 : Flag<["-"], "mfp64">, Group, HelpText<"Use 64-bit floating point registers (MIPS only)">; -def mfp32 : Flag<["-"], "mfp32">, Group, +def mfp32 : Flag<["-"], "mfp32">, Group,
[PATCH] D46450: [Driver] Add mips_Features_Group to Options to improve documentation sorting
atanasyan added a comment. Committed at https://reviews.llvm.org/rL331856. Thanks for the patch. Repository: rL LLVM https://reviews.llvm.org/D46450 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331857 - [clang-format] Respect BreakBeforeClosingBrace while calculating length
Author: krasimir Date: Wed May 9 02:02:11 2018 New Revision: 331857 URL: http://llvm.org/viewvc/llvm-project?rev=331857&view=rev Log: [clang-format] Respect BreakBeforeClosingBrace while calculating length Summary: This patch makes `getLengthToMatchingParen` respect the `BreakBeforeClosingBrace` ParenState for matching scope closers. In order to distinguish between paren states introduced by real vs. fake parens, I've added the token opening the ParensState to that struct. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D46519 Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/lib/Format/ContinuationIndenter.h cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp cfe/trunk/unittests/Format/FormatTestProto.cpp cfe/trunk/unittests/Format/FormatTestRawStrings.cpp cfe/trunk/unittests/Format/FormatTestTextProto.cpp Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=331857&r1=331856&r2=331857&view=diff == --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Wed May 9 02:02:11 2018 @@ -35,12 +35,70 @@ static bool shouldIndentWrappedSelectorN // Returns the length of everything up to the first possible line break after // the ), ], } or > matching \c Tok. -static unsigned getLengthToMatchingParen(const FormatToken &Tok) { +static unsigned getLengthToMatchingParen(const FormatToken &Tok, + const std::vector &Stack) { + // Normally whether or not a break before T is possible is calculated and + // stored in T.CanBreakBefore. Braces, array initializers and text proto + // messages like `key: < ... >` are an exception: a break is possible + // before a closing brace R if a break was inserted after the corresponding + // opening brace. The information about whether or not a break is needed + // before a closing brace R is stored in the ParenState field + // S.BreakBeforeClosingBrace where S is the state that R closes. + // + // In order to decide whether there can be a break before encountered right + // braces, this implementation iterates over the sequence of tokens and over + // the paren stack in lockstep, keeping track of the stack level which visited + // right braces correspond to in MatchingStackIndex. + // + // For example, consider: + // L. <- line number + // 1. { + // 2. {1}, + // 3. {2}, + // 4. {{3}}} + // ^ where we call this method with this token. + // The paren stack at this point contains 3 brace levels: + // 0. { at line 1, BreakBeforeClosingBrace: true + // 1. first { at line 4, BreakBeforeClosingBrace: false + // 2. second { at line 4, BreakBeforeClosingBrace: false, + // where there might be fake parens levels in-between these levels. + // The algorithm will start at the first } on line 4, which is the matching + // brace of the initial left brace and at level 2 of the stack. Then, + // examining BreakBeforeClosingBrace: false at level 2, it will continue to + // the second } on line 4, and will traverse the stack downwards until it + // finds the matching { on level 1. Then, examining BreakBeforeClosingBrace: + // false at level 1, it will continue to the third } on line 4 and will + // traverse the stack downwards until it finds the matching { on level 0. + // Then, examining BreakBeforeClosingBrace: true at level 0, the algorithm + // will stop and will use the second } on line 4 to determine the length to + // return, as in this example the range will include the tokens: {3}} + // + // The algorithm will only traverse the stack if it encounters braces, array + // initializer squares or text proto angle brackets. if (!Tok.MatchingParen) return 0; FormatToken *End = Tok.MatchingParen; - while (End->Next && !End->Next->CanBreakBefore) { -End = End->Next; + // Maintains a stack level corresponding to the current End token. + int MatchingStackIndex = Stack.size() - 1; + // Traverses the stack downwards, looking for the level to which LBrace + // corresponds. Returns either a pointer to the matching level or nullptr if + // LParen is not found in the initial portion of the stack up to + // MatchingStackIndex. + auto FindParenState = [&](const FormatToken *LBrace) -> const ParenState * { +while (MatchingStackIndex >= 0 && Stack[MatchingStackIndex].Tok != LBrace) + --MatchingStackIndex; +return MatchingStackIndex >= 0 ? &Stack[MatchingStackIndex] : nullptr; + }; + for (; End->Next; End = End->Next) { +if (End->Next->CanBreakBefore || !End->Next->closesScope()) + break; +if (End->Next->MatchingParen->isOneOf(tok::l_brace, + TT_ArrayInitializerLSquare, +
[PATCH] D46519: [clang-format] Respect BreakBeforeClosingBrace while calculating length
This revision was automatically updated to reflect the committed changes. Closed by commit rC331857: [clang-format] Respect BreakBeforeClosingBrace while calculating length (authored by krasimir, committed by ). Changed prior to commit: https://reviews.llvm.org/D46519?vs=145677&id=145881#toc Repository: rC Clang https://reviews.llvm.org/D46519 Files: lib/Format/ContinuationIndenter.cpp lib/Format/ContinuationIndenter.h lib/Format/UnwrappedLineFormatter.cpp unittests/Format/FormatTestProto.cpp unittests/Format/FormatTestRawStrings.cpp unittests/Format/FormatTestTextProto.cpp Index: lib/Format/UnwrappedLineFormatter.cpp === --- lib/Format/UnwrappedLineFormatter.cpp +++ lib/Format/UnwrappedLineFormatter.cpp @@ -659,8 +659,8 @@ static void printLineState(const LineState &State) { llvm::dbgs() << "State: "; for (const ParenState &P : State.Stack) { -llvm::dbgs() << P.Indent << "|" << P.LastSpace << "|" << P.NestedBlockIndent - << " "; +llvm::dbgs() << (P.Tok ? P.Tok->TokenText : "F") << "|" << P.Indent << "|" + << P.LastSpace << "|" << P.NestedBlockIndent << " "; } llvm::dbgs() << State.NextToken->TokenText << "\n"; } Index: lib/Format/ContinuationIndenter.h === --- lib/Format/ContinuationIndenter.h +++ lib/Format/ContinuationIndenter.h @@ -200,16 +200,23 @@ }; struct ParenState { - ParenState(unsigned Indent, unsigned LastSpace, bool AvoidBinPacking, - bool NoLineBreak) - : Indent(Indent), LastSpace(LastSpace), NestedBlockIndent(Indent), -BreakBeforeClosingBrace(false), AvoidBinPacking(AvoidBinPacking), -BreakBeforeParameter(false), NoLineBreak(NoLineBreak), -NoLineBreakInOperand(false), LastOperatorWrapped(true), -ContainsLineBreak(false), ContainsUnwrappedBuilder(false), -AlignColons(true), ObjCSelectorNameFound(false), -HasMultipleNestedBlocks(false), NestedBlockInlined(false), -IsInsideObjCArrayLiteral(false) {} + ParenState(const FormatToken *Tok, unsigned Indent, unsigned LastSpace, + bool AvoidBinPacking, bool NoLineBreak) + : Tok(Tok), Indent(Indent), LastSpace(LastSpace), +NestedBlockIndent(Indent), BreakBeforeClosingBrace(false), +AvoidBinPacking(AvoidBinPacking), BreakBeforeParameter(false), +NoLineBreak(NoLineBreak), NoLineBreakInOperand(false), +LastOperatorWrapped(true), ContainsLineBreak(false), +ContainsUnwrappedBuilder(false), AlignColons(true), +ObjCSelectorNameFound(false), HasMultipleNestedBlocks(false), +NestedBlockInlined(false), IsInsideObjCArrayLiteral(false) {} + + /// \brief The token opening this parenthesis level, or nullptr if this level + /// is opened by fake parenthesis. + /// + /// Not considered for memoization as it will always have the same value at + /// the same token. + const FormatToken *Tok; /// The position to which a specific parenthesis level needs to be /// indented. Index: lib/Format/ContinuationIndenter.cpp === --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -35,12 +35,70 @@ // Returns the length of everything up to the first possible line break after // the ), ], } or > matching \c Tok. -static unsigned getLengthToMatchingParen(const FormatToken &Tok) { +static unsigned getLengthToMatchingParen(const FormatToken &Tok, + const std::vector &Stack) { + // Normally whether or not a break before T is possible is calculated and + // stored in T.CanBreakBefore. Braces, array initializers and text proto + // messages like `key: < ... >` are an exception: a break is possible + // before a closing brace R if a break was inserted after the corresponding + // opening brace. The information about whether or not a break is needed + // before a closing brace R is stored in the ParenState field + // S.BreakBeforeClosingBrace where S is the state that R closes. + // + // In order to decide whether there can be a break before encountered right + // braces, this implementation iterates over the sequence of tokens and over + // the paren stack in lockstep, keeping track of the stack level which visited + // right braces correspond to in MatchingStackIndex. + // + // For example, consider: + // L. <- line number + // 1. { + // 2. {1}, + // 3. {2}, + // 4. {{3}}} + // ^ where we call this method with this token. + // The paren stack at this point contains 3 brace levels: + // 0. { at line 1, BreakBeforeClosingBrace: true + // 1. first { at line 4, BreakBeforeClosingBrace: false + // 2. second { at line 4, BreakBeforeClosingBrace: false, + // where there might be fake parens levels in-between these levels. + // The algorithm will start at the first
[PATCH] D46633: [analyzer] add range check for InitList lookup
r.stahl created this revision. r.stahl added reviewers: alexfh, NoQ, george.karpenkov. Herald added subscribers: cfe-commits, a.sidorin, szepet, xazax.hun. Fixes issue introduced by https://reviews.llvm.org/rC331556. Closes bug: https://bugs.llvm.org/show_bug.cgi?id=37357 Repository: rC Clang https://reviews.llvm.org/D46633 Files: lib/StaticAnalyzer/Core/RegionStore.cpp test/Analysis/initialization.c Index: test/Analysis/initialization.c === --- test/Analysis/initialization.c +++ test/Analysis/initialization.c @@ -0,0 +1,8 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s +// expected-no-diagnostics + +void initbug() { + const union { float a; } u = {}; + (void)u.a; // no-crash +} + Index: lib/StaticAnalyzer/Core/RegionStore.cpp === --- lib/StaticAnalyzer/Core/RegionStore.cpp +++ lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1711,13 +1711,15 @@ if (const auto *VR = dyn_cast(superR)) { const VarDecl *VD = VR->getDecl(); QualType RecordVarTy = VD->getType(); +unsigned Index = FD->getFieldIndex(); // Either the record variable or the field has to be const qualified. if (RecordVarTy.isConstQualified() || Ty.isConstQualified()) if (const Expr *Init = VD->getInit()) if (const auto *InitList = dyn_cast(Init)) - if (const Expr *FieldInit = InitList->getInit(FD->getFieldIndex())) -if (Optional V = svalBuilder.getConstantVal(FieldInit)) - return *V; + if (Index < InitList->getNumInits()) +if (const Expr *FieldInit = InitList->getInit(Index)) + if (Optional V = svalBuilder.getConstantVal(FieldInit)) +return *V; } return getBindingForFieldOrElementCommon(B, R, Ty); Index: test/Analysis/initialization.c === --- test/Analysis/initialization.c +++ test/Analysis/initialization.c @@ -0,0 +1,8 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s +// expected-no-diagnostics + +void initbug() { + const union { float a; } u = {}; + (void)u.a; // no-crash +} + Index: lib/StaticAnalyzer/Core/RegionStore.cpp === --- lib/StaticAnalyzer/Core/RegionStore.cpp +++ lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1711,13 +1711,15 @@ if (const auto *VR = dyn_cast(superR)) { const VarDecl *VD = VR->getDecl(); QualType RecordVarTy = VD->getType(); +unsigned Index = FD->getFieldIndex(); // Either the record variable or the field has to be const qualified. if (RecordVarTy.isConstQualified() || Ty.isConstQualified()) if (const Expr *Init = VD->getInit()) if (const auto *InitList = dyn_cast(Init)) - if (const Expr *FieldInit = InitList->getInit(FD->getFieldIndex())) -if (Optional V = svalBuilder.getConstantVal(FieldInit)) - return *V; + if (Index < InitList->getNumInits()) +if (const Expr *FieldInit = InitList->getInit(Index)) + if (Optional V = svalBuilder.getConstantVal(FieldInit)) +return *V; } return getBindingForFieldOrElementCommon(B, R, Ty); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331858 - Revert "[Driver] Use -fuse-line-directives by default in MSVC mode"
Author: mstorsjo Date: Wed May 9 02:11:01 2018 New Revision: 331858 URL: http://llvm.org/viewvc/llvm-project?rev=331858&view=rev Log: Revert "[Driver] Use -fuse-line-directives by default in MSVC mode" This reverts commit SVN r331666. It was afterwards pointed out in https://reviews.llvm.org/D46520 that #line directives lose information about what parts come from a system header. That means the result of -E usually won't compile, since Windows headers are typically full of warnings and default-error warnings. Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=331858&r1=331857&r2=331858&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed May 9 02:11:01 2018 @@ -4224,9 +4224,9 @@ void Clang::ConstructJob(Compilation &C, IsWindowsMSVC)) CmdArgs.push_back("-fms-extensions"); - // -fno-use-line-directives is default, except for MSVC targets. + // -fno-use-line-directives is default. if (Args.hasFlag(options::OPT_fuse_line_directives, - options::OPT_fno_use_line_directives, IsWindowsMSVC)) + options::OPT_fno_use_line_directives, false)) CmdArgs.push_back("-fuse-line-directives"); // -fms-compatibility=0 is default. Modified: cfe/trunk/test/Driver/cl-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=331858&r1=331857&r2=331858&view=diff == --- cfe/trunk/test/Driver/cl-options.c (original) +++ cfe/trunk/test/Driver/cl-options.c Wed May 9 02:11:01 2018 @@ -28,7 +28,6 @@ // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s // E: "-E" -// E: "-fuse-line-directives" // E: "-o" "-" // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45999: [clangd] Retrieve minimally formatted comment text in completion.
ilya-biryukov updated this revision to Diff 145883. ilya-biryukov marked 4 inline comments as done. ilya-biryukov added a comment. - Renames and other comments - Don't include brief comments in signature help either, comments there are also handled by the code completion code now. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45999 Files: clangd/CodeComplete.cpp clangd/CodeComplete.h clangd/CodeCompletionStrings.cpp clangd/CodeCompletionStrings.h clangd/index/SymbolCollector.cpp unittests/clangd/CodeCompleteTests.cpp unittests/clangd/CodeCompletionStringsTests.cpp unittests/clangd/SymbolCollectorTests.cpp Index: unittests/clangd/SymbolCollectorTests.cpp === --- unittests/clangd/SymbolCollectorTests.cpp +++ unittests/clangd/SymbolCollectorTests.cpp @@ -490,11 +490,11 @@ } )"; runSymbolCollector(Header, /*Main=*/""); - EXPECT_THAT(Symbols, - UnorderedElementsAre(QName("nx"), - AllOf(QName("nx::ff"), - Labeled("ff(int x, double y)"), - Detail("int"), Doc("Foo comment."; + EXPECT_THAT( + Symbols, + UnorderedElementsAre( + QName("nx"), AllOf(QName("nx::ff"), Labeled("ff(int x, double y)"), + Detail("int"), Doc("Foo comment."; } TEST_F(SymbolCollectorTest, PlainAndSnippet) { Index: unittests/clangd/CodeCompletionStringsTests.cpp === --- unittests/clangd/CodeCompletionStringsTests.cpp +++ unittests/clangd/CodeCompletionStringsTests.cpp @@ -51,23 +51,24 @@ } TEST_F(CompletionStringTest, Documentation) { - Builder.addBriefComment("Is this brief?"); - EXPECT_EQ(getDocumentation(*Builder.TakeString()), "Is this brief?"); + Builder.addBriefComment("This is ignored"); + EXPECT_EQ(formatDocumentation(*Builder.TakeString(), "Is this brief?"), +"Is this brief?"); } TEST_F(CompletionStringTest, DocumentationWithAnnotation) { - Builder.addBriefComment("Is this brief?"); + Builder.addBriefComment("This is ignored"); Builder.AddAnnotation("Ano"); - EXPECT_EQ(getDocumentation(*Builder.TakeString()), + EXPECT_EQ(formatDocumentation(*Builder.TakeString(), "Is this brief?"), "Annotation: Ano\n\nIs this brief?"); } TEST_F(CompletionStringTest, MultipleAnnotations) { Builder.AddAnnotation("Ano1"); Builder.AddAnnotation("Ano2"); Builder.AddAnnotation("Ano3"); - EXPECT_EQ(getDocumentation(*Builder.TakeString()), + EXPECT_EQ(formatDocumentation(*Builder.TakeString(), ""), "Annotations: Ano1 Ano2 Ano3\n"); } @@ -97,7 +98,7 @@ TEST_F(CompletionStringTest, FunctionSnippet) { Builder.AddResultTypeChunk("result no no"); - Builder.addBriefComment("Foo's comment"); + Builder.addBriefComment("This comment is ignored"); Builder.AddTypedTextChunk("Foo"); Builder.AddChunk(CodeCompletionString::CK_LeftParen); Builder.AddPlaceholderChunk("p1"); @@ -113,7 +114,7 @@ labelAndInsertText(*CCS, /*EnableSnippets=*/true); EXPECT_EQ(Label, "Foo(p1, p2)"); EXPECT_EQ(InsertText, "Foo(${1:p1}, ${2:p2})"); - EXPECT_EQ(getDocumentation(*CCS), "Foo's comment"); + EXPECT_EQ(formatDocumentation(*CCS, "Foo's comment"), "Foo's comment"); EXPECT_EQ(getFilterText(*CCS), "Foo"); } Index: unittests/clangd/CodeCompleteTests.cpp === --- unittests/clangd/CodeCompleteTests.cpp +++ unittests/clangd/CodeCompleteTests.cpp @@ -243,8 +243,7 @@ // completion. At least there aren't any we're aware of. EXPECT_THAT(Results.items, Not(Contains(Kind(CompletionItemKind::Snippet; // Check documentation. - EXPECT_IFF(Opts.IncludeBriefComments, Results.items, - Contains(IsDocumented())); + EXPECT_IFF(Opts.IncludeComments, Results.items, Contains(IsDocumented())); } void TestGlobalScopeCompletion(clangd::CodeCompleteOptions Opts) { @@ -289,8 +288,7 @@ AllOf(Has("local_var"), Has("LocalClass"), Contains(Kind(CompletionItemKind::Snippet; // Check documentation. - EXPECT_IFF(Opts.IncludeBriefComments, Results.items, - Contains(IsDocumented())); + EXPECT_IFF(Opts.IncludeComments, Results.items, Contains(IsDocumented())); } TEST(CompletionTest, CompletionOptions) { @@ -301,7 +299,7 @@ // We used to test every combination of options, but that got too slow (2^N). auto Flags = { &clangd::CodeCompleteOptions::IncludeMacros, - &clangd::CodeCompleteOptions::IncludeBriefComments, + &clangd::CodeCompleteOptions::IncludeComments, &clangd::CodeCompleteOptions::EnableSnippets, &clangd::CodeCompleteOptions::IncludeCodePatterns, &clangd::CodeCompleteOptions::IncludeIneligibleResults, Index: clangd/index/SymbolCollector.cpp ===
[PATCH] D45999: [clangd] Retrieve minimally formatted comment text in completion.
ilya-biryukov added inline comments. Comment at: clangd/CodeCompletionStrings.h:24 +/// Gets a raw documentation comment of \p Result. +/// Returns empty string when no comment is available. sammccall wrote: > What does raw mean - range of the file? indentation stripped? Added more details and a reference to `RawComment::getFormattedString`, which is used to get the comment text and has a more descriptive doc. Comment at: clangd/CodeCompletionStrings.h:29 + +/// Gets a raw documentation comment of the current active parameter +/// of \p Result. sammccall wrote: > sammccall wrote: > > "active" is a bit confusing - at this level we just care which arg you're > > interested in, right? > Is this typically a substring of getDocComment for the function? If so, > noting that would make this clearer. This refers to the parameter that should be reported as active in `signatureHelp`. Agree that it requires too much context to understand, changed to a more detailed description involving `CurrentArg` parameter. Comment at: clangd/CodeCompletionStrings.h:29 + +/// Gets a raw documentation comment of the current active parameter +/// of \p Result. ilya-biryukov wrote: > sammccall wrote: > > sammccall wrote: > > > "active" is a bit confusing - at this level we just care which arg you're > > > interested in, right? > > Is this typically a substring of getDocComment for the function? If so, > > noting that would make this clearer. > This refers to the parameter that should be reported as active in > `signatureHelp`. > Agree that it requires too much context to understand, changed to a more > detailed description involving `CurrentArg` parameter. > > > Is this typically a substring of getDocComment for the function? If so, > noting that would make this clearer. I mechanically translated the original source code without looking too much on what it does :-) Extracting a substring from the function doc would be the behavior I expect. However, we simply try to get doc comment for parameter in the same way we do for functions (e.g. look for comment doc for parameter decl, without looking at function decl in the first place) It means we'll always get the empty doc currently. At least, I couldn't make the current code produce any docs for the parameter. I would still keep this function, as it seems to be called in the right places. But we definitely need to parse a function comment instead. Comment at: clangd/CodeCompletionStrings.h:49 +/// getDocComment functions declared above. +std::string getDocumentation(const CodeCompletionString &CCS, + llvm::StringRef DocComment); sammccall wrote: > The name here is confusingly similar to getDocComment, and the comment > doesn't really explain how they're different. > > Consider calling this formatDocumentation, with a comment like "Assembles > formatted documentation for a completion result. This includes documentation > comments and other relevant information like annotations." Thanks! That was definitely confusing. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45999 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode
mstorsjo closed this revision. mstorsjo added a comment. Reverted in SVN r331858. Repository: rL LLVM https://reviews.llvm.org/D46520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331861 - Revert r331843 "[DebugInfo] Generate debug information for labels."
Author: hans Date: Wed May 9 02:29:58 2018 New Revision: 331861 URL: http://llvm.org/viewvc/llvm-project?rev=331861&view=rev Log: Revert r331843 "[DebugInfo] Generate debug information for labels." It broke the Chromium build (see reply on the review). > Generate DILabel metadata and call llvm.dbg.label after label > statement to associate the metadata with the label. > > Differential Revision: https://reviews.llvm.org/D45045 > > Patch by Hsiangkai Wang. This doesn't revert the change to backend-unsupported-error.ll that seems to correspond to an llvm-side change. Removed: cfe/trunk/test/CodeGen/debug-label-inline.c cfe/trunk/test/CodeGen/debug-label.c Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGStmt.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=331861&r1=331860&r2=331861&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed May 9 02:29:58 2018 @@ -3647,32 +3647,6 @@ CGDebugInfo::EmitDeclareOfAutoVariable(c return EmitDeclare(VD, Storage, llvm::None, Builder); } -void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) { - assert(DebugKind >= codegenoptions::LimitedDebugInfo); - assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); - - if (D->hasAttr()) -return; - - auto *Scope = cast(LexicalBlockStack.back()); - llvm::DIFile *Unit = getOrCreateFile(D->getLocation()); - - // Get location information. - unsigned Line = getLineNumber(D->getLocation()); - unsigned Column = getColumnNumber(D->getLocation()); - - StringRef Name = D->getName(); - - // Create the descriptor for the label. - auto *L = - DBuilder.createLabel(Scope, Name, Unit, Line, CGM.getLangOpts().Optimize); - - // Insert an llvm.dbg.label into the current block. - DBuilder.insertLabel(L, - llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt), - Builder.GetInsertBlock()); -} - llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy, llvm::DIType *Ty) { llvm::DIType *CachedTy = getTypeOrNull(QualTy); Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=331861&r1=331860&r2=331861&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed May 9 02:29:58 2018 @@ -396,9 +396,6 @@ public: 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, Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=331861&r1=331860&r2=331861&view=diff == --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Wed May 9 02:29:58 2018 @@ -531,16 +531,6 @@ void CodeGenFunction::EmitLabel(const La } 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()); } Removed: cfe/trunk/test/CodeGen/debug-label-inline.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-label-inline.c?rev=331860&view=auto == --- cfe/trunk/test/CodeGen/debug-label-inline.c (original) +++ cfe/trunk/test/CodeGen/debug-label-inline.c (removed) @@ -1,28 +0,0 @@ -// 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]
[PATCH] D45045: [DebugInfo] Generate debug information for labels.
hans added a comment. This broke the Chromium build. I've uploaded a reproducer at https://bugs.chromium.org/p/chromium/issues/detail?id=841170#c1 I'm guessing maybe a Clang bootstrap with debug info might also reproduce the problem, but I haven't tried that. Reverted in r331861. Repository: rL LLVM https://reviews.llvm.org/D45045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46633: [analyzer] add range check for InitList lookup
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. Thank you for the fix! LG The fix looks trivial and I'll commit your patch to unblock our internal release. If there are comments from other reviewers, they can be resolved post-commit. Repository: rC Clang https://reviews.llvm.org/D46633 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46002: [clangd] Parse all comments in Sema and completion.
ilya-biryukov updated this revision to Diff 145890. ilya-biryukov added a comment. - Moved tests to clang Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46002 Files: clangd/ClangdUnit.cpp clangd/CodeComplete.cpp Index: clangd/CodeComplete.cpp === --- clangd/CodeComplete.cpp +++ clangd/CodeComplete.cpp @@ -22,6 +22,7 @@ #include "SourceCode.h" #include "Trace.h" #include "index/Index.h" +#include "clang/Basic/LangOptions.h" #include "clang/Format/Format.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" @@ -706,6 +707,7 @@ return false; } CI->getFrontendOpts().DisableFree = false; + CI->getLangOpts()->CommentOpts.ParseAllComments = true; std::unique_ptr ContentsBuffer = llvm::MemoryBuffer::getMemBufferCopy(Input.Contents, Input.FileName); Index: clangd/ClangdUnit.cpp === --- clangd/ClangdUnit.cpp +++ clangd/ClangdUnit.cpp @@ -25,6 +25,7 @@ #include "clang/Sema/Sema.h" #include "clang/Serialization/ASTWriter.h" #include "clang/Tooling/CompilationDatabase.h" +#include "clang/Basic/LangOptions.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/CrashRecoveryContext.h" @@ -345,6 +346,7 @@ } // createInvocationFromCommandLine sets DisableFree. CI->getFrontendOpts().DisableFree = false; +CI->getLangOpts()->CommentOpts.ParseAllComments = true; } std::unique_ptr ContentsBuffer = Index: clangd/CodeComplete.cpp === --- clangd/CodeComplete.cpp +++ clangd/CodeComplete.cpp @@ -22,6 +22,7 @@ #include "SourceCode.h" #include "Trace.h" #include "index/Index.h" +#include "clang/Basic/LangOptions.h" #include "clang/Format/Format.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" @@ -706,6 +707,7 @@ return false; } CI->getFrontendOpts().DisableFree = false; + CI->getLangOpts()->CommentOpts.ParseAllComments = true; std::unique_ptr ContentsBuffer = llvm::MemoryBuffer::getMemBufferCopy(Input.Contents, Input.FileName); Index: clangd/ClangdUnit.cpp === --- clangd/ClangdUnit.cpp +++ clangd/ClangdUnit.cpp @@ -25,6 +25,7 @@ #include "clang/Sema/Sema.h" #include "clang/Serialization/ASTWriter.h" #include "clang/Tooling/CompilationDatabase.h" +#include "clang/Basic/LangOptions.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/CrashRecoveryContext.h" @@ -345,6 +346,7 @@ } // createInvocationFromCommandLine sets DisableFree. CI->getFrontendOpts().DisableFree = false; +CI->getLangOpts()->CommentOpts.ParseAllComments = true; } std::unique_ptr ContentsBuffer = ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44568: Fix emission of phony dependency targets when adding extra deps
dstenb added a comment. Ping. Repository: rC Clang https://reviews.llvm.org/D44568 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44568: Fix emission of phony dependency targets when adding extra deps
dstenb added reviewers: bruno, vsapsai. dstenb added subscribers: bruno, vsapsai. dstenb added a comment. @bruno, @vsapsai: I added you since you I saw that you recently reviewed, respectively delivered, https://reviews.llvm.org/D30881. That is the only DependencyFile commit since October; although, this feels a bit orthogonal from that, so feel free to remove yourselves as reviewers (and I'm sorry for adding you in that case)! Repository: rC Clang https://reviews.llvm.org/D44568 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.
aaron.ballman added inline comments. Comment at: include/clang/Basic/Attr.td:1494 +def NoStackProtector : InheritableAttr { + let Spellings = [GCC<"no_stack_protector">]; + let Subjects = SubjectList<[Function]>; rnk wrote: > aaron.ballman wrote: > > manojgupta wrote: > > > aaron.ballman wrote: > > > > This is not a GCC attribute, so this should use the Clang spelling. > > > > > > > > However, why spell the attribute this way rather than use the GCC > > > > spelling (`optimize("no-stack-protector")`? > > > Thanks, I have changed it to use Clang spelling. > > > > > > Regarding __attribute__((optimize("..."))), it is a generic facility in > > > GCC that works for many optimizer flags. > > > Clang currently does not support this syntax currently instead preferring > > > its own version for some options e.g. -O0. > > > e.g. > > > ``` > > > __attribute__((optimize("O0"))) // clang version is > > > __attribute__((optnone)) > > > ``` > > > If we want to support the GCC syntax, future expectation would be support > > > more flags under this syntax. Is that the path we want to take (I do not > > > know the history related to previous syntax decisions but better GCC > > > compatibility will be a nice thing to have) > > The history of `optnone` predates my involvement with Clang and I've not > > been able to find the original review thread (I did find the one where I > > gave my LGTM on the original patch, but that was a resubmission after the > > original design was signed off). > > > > I'm not keen on attributes that have the same semantics but differ in > > spelling from attributes supported by GCC unless there's a good reason to > > deviate. Given that we've already deviated, I'd like to understand why > > better -- I don't want to push you to implement something we've already > > decided was a poor design, but I also don't want to accept code if we can > > instead use syntax that is compatible with GCC. > I do not think we want to pursue supporting generic optimization flags with > `__attribute__((optimize("...")))`. > > Part of the reason we only support `optnone` is that LLVM's pass pipeline is > global to the entire module. It's not trivial to enable optimizations for a > single function, but it is much easier to have optimization passes skip > functions marked `optnone`. Thank you, @rnk, that makes sense to me and seems like a solid reason for this approach. Comment at: include/clang/Basic/AttrDocs.td:2746 + let Content = [{ +Clang supports the ``__attribute__((no_stack_protector))`` attribute to disable +stack protector on the specified functions. This attribute is useful for to disable -> which disables the Comment at: include/clang/Basic/AttrDocs.td:2747 +Clang supports the ``__attribute__((no_stack_protector))`` attribute to disable +stack protector on the specified functions. This attribute is useful for +selectively disabling stack protector on some functions when building with functions -> function Comment at: include/clang/Basic/AttrDocs.td:2748 +stack protector on the specified functions. This attribute is useful for +selectively disabling stack protector on some functions when building with +-fstack-protector compiler options. disabling stack -> disabling the stack Comment at: include/clang/Basic/AttrDocs.td:2749 +selectively disabling stack protector on some functions when building with +-fstack-protector compiler options. + options -> option Backticks around the compiler flag. Comment at: include/clang/Basic/AttrDocs.td:2751 + +For example, it disables stack protector for the function foo but function bar +will still be built with stack protector with -fstack-protector option. disables stack -> disables the stack Please put backticks around `foo` and `bar` so they highlight as code. Comment at: include/clang/Basic/AttrDocs.td:2752 +For example, it disables stack protector for the function foo but function bar +will still be built with stack protector with -fstack-protector option. + with stack -> with the stack with -fstack-protector -> with the -fstack-protector Backticks around the compiler flag. Comment at: include/clang/Basic/AttrDocs.td:2757 +int __attribute__((no_stack_protector)) +foo (int); // stack protection will be disabled for foo. + C requires parameters to be named; alternatively, you can use the C++ spelling of the attribute. Comment at: include/clang/Basic/AttrDocs.td:2759 + +int bar(int a); // bar can be built with stack protector. + with stack -> with the stack Comment at: test/Sema/no_stack_protector.c:4 +void __attribute__((no_stack_protector)) foo() {} +int __attribute__((no_stack_protector)
[PATCH] D46614: [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM with a small nit. Comment at: unittests/Lex/PPCallbacksTest.cpp:53 +this->Imported = Imported; +this->FileType = FileType; } Can you add a test that uses this field and checks its has the expected value? https://reviews.llvm.org/D46614 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331870 - Fixes issue introduced by r331556.
Author: alexfh Date: Wed May 9 05:27:21 2018 New Revision: 331870 URL: http://llvm.org/viewvc/llvm-project?rev=331870&view=rev Log: Fixes issue introduced by r331556. Closes bug: https://bugs.llvm.org/show_bug.cgi?id=37357 Patch by Rafael Stahl! Differential revision: https://reviews.llvm.org/D46633 Added: cfe/trunk/test/Analysis/initialization.c Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=331870&r1=331869&r2=331870&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Wed May 9 05:27:21 2018 @@ -1711,13 +1711,15 @@ SVal RegionStoreManager::getBindingForFi if (const auto *VR = dyn_cast(superR)) { const VarDecl *VD = VR->getDecl(); QualType RecordVarTy = VD->getType(); +unsigned Index = FD->getFieldIndex(); // Either the record variable or the field has to be const qualified. if (RecordVarTy.isConstQualified() || Ty.isConstQualified()) if (const Expr *Init = VD->getInit()) if (const auto *InitList = dyn_cast(Init)) - if (const Expr *FieldInit = InitList->getInit(FD->getFieldIndex())) -if (Optional V = svalBuilder.getConstantVal(FieldInit)) - return *V; + if (Index < InitList->getNumInits()) +if (const Expr *FieldInit = InitList->getInit(Index)) + if (Optional V = svalBuilder.getConstantVal(FieldInit)) +return *V; } return getBindingForFieldOrElementCommon(B, R, Ty); Added: cfe/trunk/test/Analysis/initialization.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/initialization.c?rev=331870&view=auto == --- cfe/trunk/test/Analysis/initialization.c (added) +++ cfe/trunk/test/Analysis/initialization.c Wed May 9 05:27:21 2018 @@ -0,0 +1,7 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s +// expected-no-diagnostics + +void initbug() { + const union { float a; } u = {}; + (void)u.a; // no-crash +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46633: [analyzer] add range check for InitList lookup
This revision was automatically updated to reflect the committed changes. Closed by commit rL331870: Fixes issue introduced by r331556. (authored by alexfh, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D46633?vs=145880&id=145899#toc Repository: rL LLVM https://reviews.llvm.org/D46633 Files: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp cfe/trunk/test/Analysis/initialization.c Index: cfe/trunk/test/Analysis/initialization.c === --- cfe/trunk/test/Analysis/initialization.c +++ cfe/trunk/test/Analysis/initialization.c @@ -0,0 +1,7 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s +// expected-no-diagnostics + +void initbug() { + const union { float a; } u = {}; + (void)u.a; // no-crash +} Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1711,13 +1711,15 @@ if (const auto *VR = dyn_cast(superR)) { const VarDecl *VD = VR->getDecl(); QualType RecordVarTy = VD->getType(); +unsigned Index = FD->getFieldIndex(); // Either the record variable or the field has to be const qualified. if (RecordVarTy.isConstQualified() || Ty.isConstQualified()) if (const Expr *Init = VD->getInit()) if (const auto *InitList = dyn_cast(Init)) - if (const Expr *FieldInit = InitList->getInit(FD->getFieldIndex())) -if (Optional V = svalBuilder.getConstantVal(FieldInit)) - return *V; + if (Index < InitList->getNumInits()) +if (const Expr *FieldInit = InitList->getInit(Index)) + if (Optional V = svalBuilder.getConstantVal(FieldInit)) +return *V; } return getBindingForFieldOrElementCommon(B, R, Ty); Index: cfe/trunk/test/Analysis/initialization.c === --- cfe/trunk/test/Analysis/initialization.c +++ cfe/trunk/test/Analysis/initialization.c @@ -0,0 +1,7 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s +// expected-no-diagnostics + +void initbug() { + const union { float a; } u = {}; + (void)u.a; // no-crash +} Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1711,13 +1711,15 @@ if (const auto *VR = dyn_cast(superR)) { const VarDecl *VD = VR->getDecl(); QualType RecordVarTy = VD->getType(); +unsigned Index = FD->getFieldIndex(); // Either the record variable or the field has to be const qualified. if (RecordVarTy.isConstQualified() || Ty.isConstQualified()) if (const Expr *Init = VD->getInit()) if (const auto *InitList = dyn_cast(Init)) - if (const Expr *FieldInit = InitList->getInit(FD->getFieldIndex())) -if (Optional V = svalBuilder.getConstantVal(FieldInit)) - return *V; + if (Index < InitList->getNumInits()) +if (const Expr *FieldInit = InitList->getInit(Index)) + if (Optional V = svalBuilder.getConstantVal(FieldInit)) +return *V; } return getBindingForFieldOrElementCommon(B, R, Ty); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46602: [clang-tidy] Store checks profiling info as CSV files
lebedev.ri planned changes to this revision. lebedev.ri added inline comments. Comment at: docs/clang-tidy/index.rst:762 + +To enable profiling info collection, use ``-enable-check-profile`` argument. +The timings will be outputted to the ``stderr`` as a table. Example output: Eugene.Zelenko wrote: > Please use ` for command line options and other non-C/C++ constructs. `` is used for command line options elsewhere in this document. Is there a reference somewhere? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46603: [Support] TimerGroup changes
lebedev.ri updated this revision to Diff 145900. lebedev.ri retitled this revision from "[Support] Print TimeRecord as CSV" to "[Support] TimerGroup changes". lebedev.ri edited the summary of this revision. lebedev.ri added a reviewer: NoQ. lebedev.ri added subscribers: xazax.hun, szepet, a.sidorin. lebedev.ri added a comment. 1. Drop CSV stuff 2. Add constructor from previously-collected `StringMap` 3. Make `printJSONValues()` public. 4. Dump floating-point values in scientific format with full precision. Repository: rL LLVM https://reviews.llvm.org/D46603 Files: include/llvm/Support/Timer.h lib/Support/Timer.cpp Index: lib/Support/Timer.cpp === --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -22,6 +22,8 @@ #include "llvm/Support/Process.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include + using namespace llvm; // This ugly hack is brought to you courtesy of constructor/destructor ordering @@ -234,6 +236,15 @@ TimerGroupList = this; } +TimerGroup::TimerGroup(StringRef Name, StringRef Description, + const StringMap &Records) +: TimerGroup(Name, Description) { + TimersToPrint.reserve(Records.size()); + for (const auto &P : Records) +TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey()); + assert(TimersToPrint.size() == Records.size() && "Size mismatch"); +} + TimerGroup::~TimerGroup() { // If the timer group is destroyed before the timers it owns, accumulate and // print the timing data. @@ -367,10 +378,12 @@ void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value) { assert(yaml::needsQuotes(Name) == yaml::QuotingType::None && - "TimerGroup name needs no quotes"); + "TimerGroup name should not need quotes"); assert(yaml::needsQuotes(R.Name) == yaml::QuotingType::None && - "Timer name needs no quotes"); - OS << "\t\"time." << Name << '.' << R.Name << suffix << "\": " << Value; + "Timer name should not need quotes"); + constexpr auto max_digits10 = std::numeric_limits::max_digits10; + OS << "\t\"time." << Name << '.' << R.Name << suffix + << "\": " << format("%.*e", max_digits10 - 1, Value); } const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) { Index: include/llvm/Support/Timer.h === --- include/llvm/Support/Timer.h +++ include/llvm/Support/Timer.h @@ -10,6 +10,7 @@ #ifndef LLVM_SUPPORT_TIMER_H #define LLVM_SUPPORT_TIMER_H +#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" #include @@ -194,6 +195,10 @@ public: explicit TimerGroup(StringRef Name, StringRef Description); + + explicit TimerGroup(StringRef Name, StringRef Description, + const StringMap &Records); + ~TimerGroup(); void setName(StringRef NewName, StringRef NewDescription) { @@ -207,6 +212,8 @@ /// This static method prints all timers and clears them all out. static void printAll(raw_ostream &OS); + const char *printJSONValues(raw_ostream &OS, const char *delim); + /// Prints all timers as JSON key/value pairs, and clears them all out. static const char *printAllJSONValues(raw_ostream &OS, const char *delim); @@ -223,7 +230,6 @@ void PrintQueuedTimers(raw_ostream &OS); void printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value); - const char *printJSONValues(raw_ostream &OS, const char *delim); }; } // end namespace llvm Index: lib/Support/Timer.cpp === --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -22,6 +22,8 @@ #include "llvm/Support/Process.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include + using namespace llvm; // This ugly hack is brought to you courtesy of constructor/destructor ordering @@ -234,6 +236,15 @@ TimerGroupList = this; } +TimerGroup::TimerGroup(StringRef Name, StringRef Description, + const StringMap &Records) +: TimerGroup(Name, Description) { + TimersToPrint.reserve(Records.size()); + for (const auto &P : Records) +TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey()); + assert(TimersToPrint.size() == Records.size() && "Size mismatch"); +} + TimerGroup::~TimerGroup() { // If the timer group is destroyed before the timers it owns, accumulate and // print the timing data. @@ -367,10 +378,12 @@ void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value) { assert(yaml::needsQuotes(Name) == yaml::QuotingType::None && - "TimerGroup name needs no quotes"); + "TimerGroup name should not need
[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files
lebedev.ri updated this revision to Diff 145901. lebedev.ri retitled this revision from "[clang-tidy] Store checks profiling info as CSV files" to "[clang-tidy] Store checks profiling info as YAML files". lebedev.ri added reviewers: george.karpenkov, NoQ. lebedev.ri added a comment. - Deduplicate code by switching to already-existing YAML printer infrastructure from `TimerGroup` - Switch to YAML. It's kinda ugly, but maybe better than having to manually construct CSV.. :/ - When the output prefix does not yet exist, still store the profile as YAML, don't fail at `make_real` - When storing profile to file, don't print it to screen. I have tried it, and it is just too noisy for no apparent benefit. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46602 Files: clang-tidy/ClangTidy.cpp clang-tidy/ClangTidy.h clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h clang-tidy/ClangTidyProfiling.cpp clang-tidy/ClangTidyProfiling.h clang-tidy/tool/ClangTidyMain.cpp docs/ReleaseNotes.rst docs/clang-tidy/index.rst test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp Index: test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp === --- /dev/null +++ test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp @@ -0,0 +1,17 @@ +// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T -store-check-profile-elide-prefix=%s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-CONSOLE %s +// RUN: FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -input-file=%T/.yaml -check-prefix=CHECK-FILE %s +// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T/out -store-check-profile-elide-prefix=%s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-CONSOLE %s +// RUN: FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -input-file=%T/out/.yaml -check-prefix=CHECK-FILE %s + +// CHECK-CONSOLE-NOT: ===-=== +// CHECK-CONSOLE-NOT: {{.*}} --- Name --- +// CHECK-CONSOLE-NOT: {{.*}} readability-function-size +// CHECK-CONSOLE-NOT: {{.*}} Total +// CHECK-CONSOLE-NOT: ===-=== + +// CHECK-FILE: "time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, + +class A { + A() {} + ~A() {} +}; Index: test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp === --- test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp +++ test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp @@ -1,22 +1,31 @@ // RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' %s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' %s // CHECK: ===-=== -// CHECK-NEXT: {{.*}} --- Name --- +// CHECK-NEXT: clang-tidy checks profiling +// CHECK-NEXT: ===-=== +// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock) + +// CHECK: {{.*}} --- Name --- // CHECK-NEXT: {{.*}} readability-function-size // CHECK-NEXT: {{.*}} Total -// CHECK-NEXT: ===-=== // CHECK: ===-=== -// CHECK-NEXT: {{.*}} --- Name --- +// CHECK-NEXT: clang-tidy checks profiling +// CHECK-NEXT: ===-=== +// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock) + +// CHECK: {{.*}} --- Name --- // CHECK-NEXT: {{.*}} readability-function-size // CHECK-NEXT: {{.*}} Total -// CHECK-NEXT: ===-=== // CHECK-NOT: ===-=== +// CHECK-NOT: clang-tidy checks profiling +// CHECK-NOT: ===-=== +// CHECK-NOT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock) + // CHECK-NOT: {{.*}} --- Name --- // CHECK-NOT: {{.*}} readability-function-size // CHECK-NOT: {{.*}} Total -// CHECK-NOT: ===-=== class A { A() {} Index: test/clang-tidy/clang-tidy-enable-check-prof
r331871 - Remove unused lit setting, see https://reviews.llvm.org/D46619
Author: nico Date: Wed May 9 05:38:51 2018 New Revision: 331871 URL: http://llvm.org/viewvc/llvm-project?rev=331871&view=rev Log: Remove unused lit setting, see https://reviews.llvm.org/D46619 Modified: cfe/trunk/test/lit.site.cfg.py.in Modified: cfe/trunk/test/lit.site.cfg.py.in URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.site.cfg.py.in?rev=331871&r1=331870&r2=331871&view=diff == --- cfe/trunk/test/lit.site.cfg.py.in (original) +++ cfe/trunk/test/lit.site.cfg.py.in Wed May 9 05:38:51 2018 @@ -25,7 +25,6 @@ config.clang_examples = @CLANG_BUILD_EXA config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ config.host_arch = "@HOST_ARCH@" -config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@" config.python_executable = "@PYTHON_EXECUTABLE@" # Support substitution of the tools and libs dirs with user parameters. This is ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46603: [Support] TimerGroup changes
lebedev.ri updated this revision to Diff 145903. lebedev.ri added a comment. Add lock to now-public `printJSONValues()`. I have no understanding of the `static TimerGroupList`, but this is symmetrical with other [public] `TimerGroup::*print*` methods. Repository: rL LLVM https://reviews.llvm.org/D46603 Files: include/llvm/Support/Timer.h lib/Support/Timer.cpp Index: lib/Support/Timer.cpp === --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -22,6 +22,8 @@ #include "llvm/Support/Process.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include + using namespace llvm; // This ugly hack is brought to you courtesy of constructor/destructor ordering @@ -234,6 +236,15 @@ TimerGroupList = this; } +TimerGroup::TimerGroup(StringRef Name, StringRef Description, + const StringMap &Records) +: TimerGroup(Name, Description) { + TimersToPrint.reserve(Records.size()); + for (const auto &P : Records) +TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey()); + assert(TimersToPrint.size() == Records.size() && "Size mismatch"); +} + TimerGroup::~TimerGroup() { // If the timer group is destroyed before the timers it owns, accumulate and // print the timing data. @@ -367,13 +378,17 @@ void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value) { assert(yaml::needsQuotes(Name) == yaml::QuotingType::None && - "TimerGroup name needs no quotes"); + "TimerGroup name should not need quotes"); assert(yaml::needsQuotes(R.Name) == yaml::QuotingType::None && - "Timer name needs no quotes"); - OS << "\t\"time." << Name << '.' << R.Name << suffix << "\": " << Value; + "Timer name should not need quotes"); + constexpr auto max_digits10 = std::numeric_limits::max_digits10; + OS << "\t\"time." << Name << '.' << R.Name << suffix + << "\": " << format("%.*e", max_digits10 - 1, Value); } const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) { + sys::SmartScopedLock L(*TimerLock); + prepareToPrintList(); for (const PrintRecord &R : TimersToPrint) { OS << delim; Index: include/llvm/Support/Timer.h === --- include/llvm/Support/Timer.h +++ include/llvm/Support/Timer.h @@ -10,6 +10,7 @@ #ifndef LLVM_SUPPORT_TIMER_H #define LLVM_SUPPORT_TIMER_H +#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" #include @@ -194,6 +195,10 @@ public: explicit TimerGroup(StringRef Name, StringRef Description); + + explicit TimerGroup(StringRef Name, StringRef Description, + const StringMap &Records); + ~TimerGroup(); void setName(StringRef NewName, StringRef NewDescription) { @@ -207,6 +212,8 @@ /// This static method prints all timers and clears them all out. static void printAll(raw_ostream &OS); + const char *printJSONValues(raw_ostream &OS, const char *delim); + /// Prints all timers as JSON key/value pairs, and clears them all out. static const char *printAllJSONValues(raw_ostream &OS, const char *delim); @@ -223,7 +230,6 @@ void PrintQueuedTimers(raw_ostream &OS); void printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value); - const char *printJSONValues(raw_ostream &OS, const char *delim); }; } // end namespace llvm Index: lib/Support/Timer.cpp === --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -22,6 +22,8 @@ #include "llvm/Support/Process.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include + using namespace llvm; // This ugly hack is brought to you courtesy of constructor/destructor ordering @@ -234,6 +236,15 @@ TimerGroupList = this; } +TimerGroup::TimerGroup(StringRef Name, StringRef Description, + const StringMap &Records) +: TimerGroup(Name, Description) { + TimersToPrint.reserve(Records.size()); + for (const auto &P : Records) +TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey()); + assert(TimersToPrint.size() == Records.size() && "Size mismatch"); +} + TimerGroup::~TimerGroup() { // If the timer group is destroyed before the timers it owns, accumulate and // print the timing data. @@ -367,13 +378,17 @@ void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value) { assert(yaml::needsQuotes(Name) == yaml::QuotingType::None && - "TimerGroup name needs no quotes"); + "TimerGroup name should not need quotes"); assert(yaml::needsQuotes(R.Name) == yaml::QuotingType::None && - "Timer name needs no quotes"); - OS << "
r331874 - [OpenCL] Restrict various keywords in OpenCL C++ mode
Author: svenvh Date: Wed May 9 06:16:17 2018 New Revision: 331874 URL: http://llvm.org/viewvc/llvm-project?rev=331874&view=rev Log: [OpenCL] Restrict various keywords in OpenCL C++ mode Restrict the following keywords in the OpenCL C++ language mode, according to Sections 2.2 & 2.9 of the OpenCL C++ 1.0 Specification. - dynamic_cast - typeid - register (already restricted in OpenCL C, update the diagnostic) - thread_local - exceptions (try/catch/throw) - access qualifiers read_only, write_only, read_write Support the `__global`, `__local`, `__constant`, `__private`, and `__generic` keywords in OpenCL C++. Leave the unprefixed address space qualifiers such as global available, i.e., do not mark them as reserved keywords in OpenCL C++. libclcxx provides explicit address space pointer classes such as `global_ptr` and `global` that are implemented using the `__`-prefixed qualifiers. Differential Revision: https://reviews.llvm.org/D46022 Added: cfe/trunk/test/Parser/opencl-cxx-keywords.cl cfe/trunk/test/SemaOpenCLCXX/ cfe/trunk/test/SemaOpenCLCXX/restricted.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/lib/Basic/IdentifierTable.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/SemaCast.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/test/Parser/opencl-cl20.cl cfe/trunk/test/Parser/opencl-storage-class.cl cfe/trunk/test/SemaOpenCL/storageclass.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=331874&r1=331873&r2=331874&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed May 9 06:16:17 2018 @@ -232,6 +232,10 @@ def note_mt_message : Note<"[rewriter] % def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">; def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">; +// OpenCL C++. +def err_openclcxx_not_supported : Error< + "'%0' is not supported in OpenCL C++">; + // OpenMP def err_omp_more_one_clause : Error< "directive '#pragma omp %0' cannot contain more than one '%1' clause%select{| with '%3' name modifier| with 'source' dependence}2">; Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=331874&r1=331873&r2=331874&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed May 9 06:16:17 2018 @@ -1078,6 +1078,8 @@ def err_opencl_logical_exclusive_or : Er // OpenCL C++. def err_openclcxx_virtual_function : Error< "virtual functions are not supported in OpenCL C++">; +def err_openclcxx_reserved : Error< + "'%0' is a reserved keyword in OpenCL C++">; // OpenMP support. def warn_pragma_omp_ignored : Warning< Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=331874&r1=331873&r2=331874&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 9 06:16:17 2018 @@ -8609,7 +8609,8 @@ def note_opencl_typedef_access_qualifier // OpenCL Section 6.8.g def err_opencl_unknown_type_specifier : Error< - "OpenCL version %0 does not support the '%1' %select{type qualifier|storage class specifier}2">; + "OpenCL %select{C|C++}0 version %1 does not support the '%2' " + "%select{type qualifier|storage class specifier}3">; // OpenCL v2.0 s6.12.5 Blocks restrictions def err_opencl_block_storage_type : Error< Modified: cfe/trunk/include/clang/Basic/TokenKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=331874&r1=331873&r2=331874&view=diff == --- cfe/trunk/include/clang/Basic/TokenKinds.def (original) +++ cfe/trunk/include/clang/Basic/TokenKinds.def Wed May 9 06:16:17 2018 @@ -249,8 +249,10 @@ PUNCTUATOR(caretcaret,"^^") // KEYMS- This is a keyword if Microsoft extensions are enabled // KEYNOMS18 - This is a keyword th
[PATCH] D46022: [OpenCL] Restrict various keywords in OpenCL C++ mode
This revision was automatically updated to reflect the committed changes. Closed by commit rC331874: [OpenCL] Restrict various keywords in OpenCL C++ mode (authored by svenvh, committed by ). Changed prior to commit: https://reviews.llvm.org/D46022?vs=144745&id=145904#toc Repository: rC Clang https://reviews.llvm.org/D46022 Files: include/clang/Basic/DiagnosticCommonKinds.td include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/TokenKinds.def lib/Basic/IdentifierTable.cpp lib/Frontend/CompilerInvocation.cpp lib/Parse/ParseDecl.cpp lib/Sema/SemaCast.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExprCXX.cpp test/Parser/opencl-cl20.cl test/Parser/opencl-cxx-keywords.cl test/Parser/opencl-storage-class.cl test/SemaOpenCL/storageclass.cl test/SemaOpenCLCXX/restricted.cl Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -8609,7 +8609,8 @@ // OpenCL Section 6.8.g def err_opencl_unknown_type_specifier : Error< - "OpenCL version %0 does not support the '%1' %select{type qualifier|storage class specifier}2">; + "OpenCL %select{C|C++}0 version %1 does not support the '%2' " + "%select{type qualifier|storage class specifier}3">; // OpenCL v2.0 s6.12.5 Blocks restrictions def err_opencl_block_storage_type : Error< Index: include/clang/Basic/DiagnosticParseKinds.td === --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -1078,6 +1078,8 @@ // OpenCL C++. def err_openclcxx_virtual_function : Error< "virtual functions are not supported in OpenCL C++">; +def err_openclcxx_reserved : Error< + "'%0' is a reserved keyword in OpenCL C++">; // OpenMP support. def warn_pragma_omp_ignored : Warning< Index: include/clang/Basic/TokenKinds.def === --- include/clang/Basic/TokenKinds.def +++ include/clang/Basic/TokenKinds.def @@ -249,8 +249,10 @@ // KEYMS- This is a keyword if Microsoft extensions are enabled // KEYNOMS18 - This is a keyword that must never be enabled under // MSVC <= v18. -// KEYOPENCL - This is a keyword in OpenCL -// KEYNOOPENCL - This is a keyword that is not supported in OpenCL +// KEYOPENCLC - This is a keyword in OpenCL C +// KEYOPENCLCXX - This is a keyword in OpenCL C++ +// KEYNOOPENCL - This is a keyword that is not supported in OpenCL C +// nor in OpenCL C++. // KEYALTIVEC - This is a keyword in AltiVec // KEYZVECTOR - This is a keyword for the System z vector extensions, //which are heavily based on AltiVec @@ -525,36 +527,36 @@ KEYWORD(__super , KEYMS) // OpenCL address space qualifiers -KEYWORD(__global, KEYOPENCL) -KEYWORD(__local , KEYOPENCL) -KEYWORD(__constant , KEYOPENCL) -KEYWORD(__private , KEYOPENCL) -KEYWORD(__generic , KEYOPENCL) -ALIAS("global", __global, KEYOPENCL) -ALIAS("local", __local , KEYOPENCL) -ALIAS("constant", __constant, KEYOPENCL) -ALIAS("private", __private , KEYOPENCL) -ALIAS("generic", __generic , KEYOPENCL) +KEYWORD(__global, KEYOPENCLC | KEYOPENCLCXX) +KEYWORD(__local , KEYOPENCLC | KEYOPENCLCXX) +KEYWORD(__constant , KEYOPENCLC | KEYOPENCLCXX) +KEYWORD(__private , KEYOPENCLC | KEYOPENCLCXX) +KEYWORD(__generic , KEYOPENCLC | KEYOPENCLCXX) +ALIAS("global", __global, KEYOPENCLC) +ALIAS("local", __local , KEYOPENCLC) +ALIAS("constant", __constant, KEYOPENCLC) +ALIAS("private", __private , KEYOPENCLC) +ALIAS("generic", __generic , KEYOPENCLC) // OpenCL function qualifiers -KEYWORD(__kernel, KEYOPENCL) -ALIAS("kernel", __kernel, KEYOPENCL) +KEYWORD(__kernel, KEYOPENCLC | KEYOPENCLCXX) +ALIAS("kernel", __kernel, KEYOPENCLC | KEYOPENCLCXX) // OpenCL access qualifiers -KEYWORD(__read_only , KEYOPENCL) -KEYWORD(__write_only, KEYOPENCL) -KEYWORD(__read_write, KEYOPENCL) -ALIAS("read_only", __read_only , KEYOPENCL) -ALIAS("write_only", __write_only, KEYOPENCL) -ALIAS("read_write", __read_write, KEYOPENCL) +KEYWORD(__read_only , KEYOPENCLC | KEYOPENCLCXX) +KEYWORD(__write_only, KEYOPENCLC | KEYOPENCLCXX) +KEYWORD(__read_write, KEYOPENCLC | KEYOPENCLCXX) +ALIAS("read_only", __read_only , KEYOPENCLC | KEYOPENCLCXX) +ALIAS("write_only", __write_only, KEYOPENCLC | KEYOPENCLCXX) +ALIAS("rea
[clang-tools-extra] r331875 - Do not warn on unused parameters for functions with empty bodies.
Author: klimek Date: Wed May 9 06:20:03 2018 New Revision: 331875 URL: http://llvm.org/viewvc/llvm-project?rev=331875&view=rev Log: Do not warn on unused parameters for functions with empty bodies. If a function has an empty body, all parameters are trivially unused. Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp?rev=331875&r1=331874&r2=331875&view=diff == --- clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp Wed May 9 06:20:03 2018 @@ -29,10 +29,11 @@ bool isOverrideMethod(const FunctionDecl } // namespace void UnusedParametersCheck::registerMatchers(MatchFinder *Finder) { - Finder->addMatcher( - functionDecl(isDefinition(), hasBody(stmt()), hasAnyParameter(decl())) - .bind("function"), - this); + Finder->addMatcher(functionDecl(isDefinition(), + hasBody(stmt(hasDescendant(stmt(, + hasAnyParameter(decl())) + .bind("function"), + this); } template Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c?rev=331875&r1=331874&r2=331875&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c (original) +++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c Wed May 9 06:20:03 2018 @@ -2,14 +2,14 @@ // Basic removal // = -void a(int i) {} +void a(int i) {;} // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters] -// CHECK-FIXES: {{^}}void a(int /*i*/) {}{{$}} +// CHECK-FIXES: {{^}}void a(int /*i*/) {;}{{$}} static void b(); // In C, forward declarations can leave out parameters. -static void b(int i) {} +static void b(int i) {;} // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i' is unused [misc-unused-parameters] -// CHECK-FIXES: {{^}}static void b() {}{{$}} +// CHECK-FIXES: {{^}}static void b() {;}{{$}} // Unchanged cases // === Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp?rev=331875&r1=331874&r2=331875&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp Wed May 9 06:20:03 2018 @@ -1,5 +1,5 @@ -// RUN: echo "static void staticFunctionHeader(int i) {}" > %T/header.h -// RUN: echo "static void staticFunctionHeader(int /*i*/) {}" > %T/header-fixed.h +// RUN: echo "static void staticFunctionHeader(int i) {;}" > %T/header.h +// RUN: echo "static void staticFunctionHeader(int /*i*/) {;}" > %T/header-fixed.h // RUN: %check_clang_tidy %s misc-unused-parameters %t -- -header-filter='.*' -- -std=c++11 -fno-delayed-template-parsing // RUN: diff %T/header.h %T/header-fixed.h @@ -8,29 +8,29 @@ // Basic removal // = -void a(int i) {} +void a(int i) {;} // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters] -// CHECK-FIXES: {{^}}void a(int /*i*/) {}{{$}} +// CHECK-FIXES: {{^}}void a(int /*i*/) {;}{{$}} -void b(int i = 1) {} +void b(int i = 1) {;} // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters] -// CHECK-FIXES: {{^}}void b(int /*i*/ = 1) {}{{$}} +// CHECK-FIXES: {{^}}void b(int /*i*/ = 1) {;}{{$}} -void c(int *i) {} +void c(int *i) {;} // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'i' is unused [misc-unused-parameters] -// CHECK-FIXES: {{^}}void c(int * /*i*/) {}{{$}} +// CHECK-FIXES: {{^}}void c(int * /*i*/) {;}{{$}} -void d(int i[]) {} +void d(int i[]) {;} // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters] -// CHECK-FIXES: {{^}}void d(int /*i*/[]) {}{{$}} +// CHECK-FIXES: {{^}}void d(int /*i*/[]) {;}{{$}} -void e(int i[1]) {} +void e(int i[1]) {;} // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters] -// CHECK-FIXES: {{^}}void e(int /*i*/[1]) {}{{$}} +// CHECK-FIXES: {{^}}void e(int /*i*/[1]) {;}{{$}} -void f(void (*fn)()) {} +void f(void (*fn)()) {;} // CHECK-MESSAGES: :[[@LI
r331877 - [OpenCL] Add constant address space to __func__ in AST.
Author: stulova Date: Wed May 9 06:23:26 2018 New Revision: 331877 URL: http://llvm.org/viewvc/llvm-project?rev=331877&view=rev Log: [OpenCL] Add constant address space to __func__ in AST. Added string literal helper function to obtain the type attributed by a constant address space. Also fixed predefind __func__ expr to use the helper to constract the string literal correctly. Differential Revision: https://reviews.llvm.org/D46049 Added: cfe/trunk/test/SemaOpenCL/predefined-expr.cl Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/CodeGenOpenCL/str_literals.cl Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=331877&r1=331876&r2=331877&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 9 06:23:26 2018 @@ -1348,6 +1348,8 @@ public: return getFunctionTypeInternal(ResultTy, Args, EPI, false); } + QualType adjustStringLiteralBaseType(QualType StrLTy) const; + private: /// Return a normal function type with a typed argument list. QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef Args, Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=331877&r1=331876&r2=331877&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Wed May 9 06:23:26 2018 @@ -3621,6 +3621,12 @@ QualType ASTContext::getPipeType(QualTyp return QualType(New, 0); } +QualType ASTContext::adjustStringLiteralBaseType(QualType Ty) const { + // OpenCL v1.1 s6.5.3: a string literal is in the constant address space. + return LangOpts.OpenCL ? getAddrSpaceQualType(Ty, LangAS::opencl_constant) + : Ty; +} + QualType ASTContext::getReadPipeType(QualType T) const { return getPipeType(T, true); } Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=331877&r1=331876&r2=331877&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Wed May 9 06:23:26 2018 @@ -881,7 +881,8 @@ StringLiteral *StringLiteral::CreateEmpt void *Mem = C.Allocate(sizeof(StringLiteral) + sizeof(SourceLocation) * (NumStrs - 1), alignof(StringLiteral)); - StringLiteral *SL = new (Mem) StringLiteral(QualType()); + StringLiteral *SL = + new (Mem) StringLiteral(C.adjustStringLiteralBaseType(QualType())); SL->CharByteWidth = 0; SL->Length = 0; SL->NumConcatenated = NumStrs; Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=331877&r1=331876&r2=331877&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed May 9 06:23:26 2018 @@ -1554,17 +1554,14 @@ Sema::ActOnStringLiteral(ArrayRef if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings) CharTyConst.addConst(); + CharTyConst = Context.adjustStringLiteralBaseType(CharTyConst); + // Get an array type for the string, according to C99 6.4.5. This includes // the nul terminator character as well as the string length for pascal // strings. - QualType StrTy = Context.getConstantArrayType(CharTyConst, - llvm::APInt(32, Literal.GetNumStringChars()+1), - ArrayType::Normal, 0); - - // OpenCL v1.1 s6.5.3: a string literal is in the constant address space. - if (getLangOpts().OpenCL) { -StrTy = Context.getAddrSpaceQualType(StrTy, LangAS::opencl_constant); - } + QualType StrTy = Context.getConstantArrayType( + CharTyConst, llvm::APInt(32, Literal.GetNumStringChars() + 1), + ArrayType::Normal, 0); // Pass &StringTokLocs[0], StringTokLocs.size() to factory! StringLiteral *Lit = StringLiteral::Create(Context, Literal.GetString(), @@ -3046,7 +3043,8 @@ ExprResult Sema::BuildPredefinedExpr(Sou llvm::APInt LengthI(32, Length + 1); if (IT == PredefinedExpr::LFunction) { - ResTy = Context.WideCharTy.withConst(); + ResTy = + Context.adjustStringLiteralBaseType(Context.WideCharTy.withConst()); SmallString<32> RawChars; ConvertUTF8ToWideString(Context.getTypeSizeInChars(ResTy).getQuantity(), Str, RawChars); @@ -3055,7 +3053,7 @@ ExprResult Sema::BuildPredefinedExpr(Sou SL = StringLiteral::Create(Context, RawChars, StringLiteral::Wide,
[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files
lebedev.ri updated this revision to Diff 145906. lebedev.ri edited the summary of this revision. lebedev.ri added a comment. Herald added a subscriber: llvm-commits. - Produce valid-er YAML. Repository: rL LLVM https://reviews.llvm.org/D46602 Files: clang-tidy/ClangTidy.cpp clang-tidy/ClangTidy.h clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h clang-tidy/ClangTidyProfiling.cpp clang-tidy/ClangTidyProfiling.h clang-tidy/tool/ClangTidyMain.cpp docs/ReleaseNotes.rst docs/clang-tidy/index.rst test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp Index: test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp === --- /dev/null +++ test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp @@ -0,0 +1,23 @@ +// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T -store-check-profile-elide-prefix=%s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-CONSOLE %s +// RUN: FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -input-file=%T/.yaml -check-prefix=CHECK-FILE %s +// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T/out -store-check-profile-elide-prefix=%s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-CONSOLE %s +// RUN: FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -input-file=%T/out/.yaml -check-prefix=CHECK-FILE %s + +// CHECK-CONSOLE-NOT: ===-=== +// CHECK-CONSOLE-NOT: {{.*}} --- Name --- +// CHECK-CONSOLE-NOT: {{.*}} readability-function-size +// CHECK-CONSOLE-NOT: {{.*}} Total +// CHECK-CONSOLE-NOT: ===-=== + +// CHECK-FILE: { +// CHECK-FILE-NEXT: "time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, +// CHECK-FILE: } + +// CHECK-NOT: { +// CHECK-NOT: "time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, +// CHECK-NOT: } + +class A { + A() {} + ~A() {} +}; Index: test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp === --- test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp +++ test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp @@ -1,22 +1,31 @@ // RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' %s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' %s // CHECK: ===-=== -// CHECK-NEXT: {{.*}} --- Name --- +// CHECK-NEXT: clang-tidy checks profiling +// CHECK-NEXT: ===-=== +// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock) + +// CHECK: {{.*}} --- Name --- // CHECK-NEXT: {{.*}} readability-function-size // CHECK-NEXT: {{.*}} Total -// CHECK-NEXT: ===-=== // CHECK: ===-=== -// CHECK-NEXT: {{.*}} --- Name --- +// CHECK-NEXT: clang-tidy checks profiling +// CHECK-NEXT: ===-=== +// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock) + +// CHECK: {{.*}} --- Name --- // CHECK-NEXT: {{.*}} readability-function-size // CHECK-NEXT: {{.*}} Total -// CHECK-NEXT: ===-=== // CHECK-NOT: ===-=== +// CHECK-NOT: clang-tidy checks profiling +// CHECK-NOT: ===-=== +// CHECK-NOT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock) + // CHECK-NOT: {{.*}} --- Name --- // CHECK-NOT: {{.*}} readability-function-size // CHECK-NOT: {{.*}} Total -// CHECK-NOT: ===-=== class A { A() {} Index: test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp === --- test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp +++ test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp @@ -1,16 +1,22 @@ // RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' %s 2>&1 | FileCheck --match-fu
[PATCH] D46049: [OpenCL] Add constant address space to __func__ in AST
This revision was automatically updated to reflect the committed changes. Closed by commit rL331877: [OpenCL] Add constant address space to __func__ in AST. (authored by stulova, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D46049?vs=145000&id=145907#toc Repository: rL LLVM https://reviews.llvm.org/D46049 Files: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/CodeGenOpenCL/str_literals.cl cfe/trunk/test/SemaOpenCL/predefined-expr.cl Index: cfe/trunk/include/clang/AST/ASTContext.h === --- cfe/trunk/include/clang/AST/ASTContext.h +++ cfe/trunk/include/clang/AST/ASTContext.h @@ -1348,6 +1348,8 @@ return getFunctionTypeInternal(ResultTy, Args, EPI, false); } + QualType adjustStringLiteralBaseType(QualType StrLTy) const; + private: /// Return a normal function type with a typed argument list. QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef Args, Index: cfe/trunk/test/SemaOpenCL/predefined-expr.cl === --- cfe/trunk/test/SemaOpenCL/predefined-expr.cl +++ cfe/trunk/test/SemaOpenCL/predefined-expr.cl @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 %s -verify +// RUN: %clang_cc1 %s -verify -cl-std=CL2.0 + +void f() { + char *f1 = __func__; //expected-error-re{{initializing '{{__generic char|char}} *' with an expression of type 'const __constant char *' changes address space of pointer}} + constant char *f2 = __func__; //expected-warning{{initializing '__constant char *' with an expression of type 'const __constant char [2]' discards qualifiers}} + constant const char *f3 = __func__; +} Index: cfe/trunk/test/CodeGenOpenCL/str_literals.cl === --- cfe/trunk/test/CodeGenOpenCL/str_literals.cl +++ cfe/trunk/test/CodeGenOpenCL/str_literals.cl @@ -1,9 +1,15 @@ // RUN: %clang_cc1 %s -cl-opt-disable -emit-llvm -o - -ffake-address-space-map | FileCheck %s -__constant char * __constant x = "hello world"; -__constant char * __constant y = "hello world"; +__constant char *__constant x = "hello world"; +__constant char *__constant y = "hello world"; -// CHECK: unnamed_addr addrspace(2) constant +// CHECK: unnamed_addr addrspace(2) constant{{.*}}"hello world\00" // CHECK-NOT: addrspace(2) unnamed_addr constant // CHECK: @x = {{(dso_local )?}}addrspace(2) constant i8 addrspace(2)* // CHECK: @y = {{(dso_local )?}}addrspace(2) constant i8 addrspace(2)* +// CHECK: unnamed_addr addrspace(2) constant{{.*}}"f\00" + +void f() { + //CHECK: store i8 addrspace(2)* {{.*}}, i8 addrspace(2)** + constant const char *f3 = __func__; +} Index: cfe/trunk/lib/AST/ASTContext.cpp === --- cfe/trunk/lib/AST/ASTContext.cpp +++ cfe/trunk/lib/AST/ASTContext.cpp @@ -3621,6 +3621,12 @@ return QualType(New, 0); } +QualType ASTContext::adjustStringLiteralBaseType(QualType Ty) const { + // OpenCL v1.1 s6.5.3: a string literal is in the constant address space. + return LangOpts.OpenCL ? getAddrSpaceQualType(Ty, LangAS::opencl_constant) + : Ty; +} + QualType ASTContext::getReadPipeType(QualType T) const { return getPipeType(T, true); } Index: cfe/trunk/lib/AST/Expr.cpp === --- cfe/trunk/lib/AST/Expr.cpp +++ cfe/trunk/lib/AST/Expr.cpp @@ -881,7 +881,8 @@ void *Mem = C.Allocate(sizeof(StringLiteral) + sizeof(SourceLocation) * (NumStrs - 1), alignof(StringLiteral)); - StringLiteral *SL = new (Mem) StringLiteral(QualType()); + StringLiteral *SL = + new (Mem) StringLiteral(C.adjustStringLiteralBaseType(QualType())); SL->CharByteWidth = 0; SL->Length = 0; SL->NumConcatenated = NumStrs; Index: cfe/trunk/lib/Sema/SemaExpr.cpp === --- cfe/trunk/lib/Sema/SemaExpr.cpp +++ cfe/trunk/lib/Sema/SemaExpr.cpp @@ -1554,17 +1554,14 @@ if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings) CharTyConst.addConst(); + CharTyConst = Context.adjustStringLiteralBaseType(CharTyConst); + // Get an array type for the string, according to C99 6.4.5. This includes // the nul terminator character as well as the string length for pascal // strings. - QualType StrTy = Context.getConstantArrayType(CharTyConst, - llvm::APInt(32, Literal.GetNumStringChars()+1), - ArrayType::Normal, 0); - - // OpenCL v1.1 s6.5.3: a string literal is in the constant address space. - if (getLangOpts().OpenCL) { -StrTy = Context.getAddrSpaceQualType(StrTy, LangAS::opencl_constant); - } + QualType StrTy = Context.getConstantArrayType( + CharTyC
[PATCH] D46601: [OpenCL] Fix typos in emitted enqueue kernel function names
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM! Although I think `vaarg` is common too. :) https://reviews.llvm.org/D46601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files
lebedev.ri added inline comments. Comment at: docs/clang-tidy/index.rst:783 + { +"time.clang-tidy.readability-function-size.wall": 1.0421266555786133e+00, +"time.clang-tidy.readability-function-size.user": 9.208840005421e-01, Hmm, thinking about it a bit more, i think it should also contain the `"file"`, ``` { "file": "/source/example.cpp", "profile": { "time.clang-tidy.readability-function-size.wall": 9.5367431640625000e-05, "time.clang-tidy.readability-function-size.user": 7.20002617e-05, "time.clang-tidy.readability-function-size.sys": 1.8920e-05 } } ``` Repository: rL LLVM https://reviews.llvm.org/D46602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR
GBuella added a comment. In https://reviews.llvm.org/D45616#1067492, @efriedma wrote: > > The fcmp opcode has no defined behavior with NaN operands in the > > comparisions handled in this patch. > > Could you describe the problem here in a bit more detail? As far as I know, > the LLVM IR fcmp should return the same result as the x86 CMPPD, even without > fast-math. So, I'm still looking into this. What I see is, yes, fcmp just so happens to work the same as x86 CMPPD. An example: fcmp olt <2 x double> %x, %y becomes vcmpltpd. But this only holds for condition codes 0 - 7. Where LLVM IR has a condition "olt" <- ordered less-than, x86 cmppd has two corresponding condition codes: 0x01->"less-than (ordered, signaling)", which is "vcmpltpd" and 0x11->"less-than (ordered, nonsignaling)" which is "vcmplt_oqps" Now, if the builtin's CC argument is 1 (which refers to vcmpltps), we lower it to "fcmp olt", which then results in "vcmpltps", we are ok, yes. But in the IR, there is no information about the user expecting "vcmpltps" vs "vcmplt_oqps". Do I understand these tricks right? If we are ok with this (hard to understand) approach, I can just lower these without fast-math as well, as long as CC < 8, by modifying this condition: if (CC < 8 && !UsesNonDefaultRounding && getLangOpts().FastMath) { Although, I'm still looked at what happens with sNaN, and with qNaN constants, once these comparisons are lowered to fcmp. Repository: rC Clang https://reviews.llvm.org/D45616 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41537: Optionally add code completion results for arrow instead of dot
yvvan marked 3 inline comments as done. yvvan added a comment. I have some failing tests... So I will update the diff a bit later (Friday most likely) Comment at: include/clang/Sema/CodeCompleteConsumer.h:564 + + /// \brief For this completion result correction is required. + std::vector Corrections; ilya-biryukov wrote: > yvvan wrote: > > yvvan wrote: > > > ilya-biryukov wrote: > > > > Adding some docs here would be useful. These fix-its could be > > > > interpreted too broadly at this point. > > > > I suggest the following semantics and the comment: > > > > > > > > ``` > > > > /// \brief FixIts that *must* be applied before inserting the text for > > > > the corresponding completion item. > > > > /// Completion items with non-empty fixits will not be returned by > > > > default, they should be explicitly requested by setting > > > > CompletionOptions::IncludeCorrections. > > > > /// For the editors to be able to compute position of the cursor for > > > > the completion item itself, the following conditions are guaranteed to > > > > hold for RemoveRange of the stored fixits: > > > > /// - Ranges in the fixits are guaranteed to never contain the > > > > completion point (or identifier under completion point, if any) inside > > > > them, except at the start or at the end of the range. > > > > /// - If a fixit range starts or ends with completion point (or starts > > > > or ends after the identifier under completion point), it will contain > > > > at least one character. It allows to unambiguously recompute completion > > > > point after applying the fixit. > > > > /// The intuition is that provided fixits change code around the > > > > identifier we complete, but are not allowed to touch the identifier > > > > itself or the completion point. > > > > /// One example of completion items with corrections are the ones > > > > replacing '.' with '->' and vice versa: > > > > /// std::unique_ptr> vec_ptr; > > > > /// vec_ptr.^ // completion returns an item 'push_back', > > > > replacing '.' with '->' > > > > /// vec_ptr->^ // completion returns an item 'release', replacing > > > > '->' with '.'let's put > > > > ``` > > > > > > > > Do those invariants sound reasonable? Could we add asserts that they > > > > hold when constructing the completion results? > > > Thanks! I usually feel the lack of patience when writing descriptions :) > > "Could we add asserts that they hold when constructing the completion > > results" > > > > The current way of creating them actually assures that by default. And to > > check it once again it's required to change many things. > > Starting with the fact that there is no SourceRange contains() methos or > > something similar, > > The current way of creating them actually assures that by default. And to > > check it once again it's required to change many things. > It's still nice to have a sanity check there, mostly for the sake of new > checks that are gonna get added. > But even the current one is tricky, since it may actually contain a range > that ends exactly at the cursor (when completing right after the dot/arrow > `foo->|`). > > > Starting with the fact that there is no SourceRange contains() methos or > > something similar, > Moreover, `SourceRange` doesn't have clear semantics AFAIK. It can either be > a half-open or closed range. > Let's add a FIXME, at least, that we should add those asserts later. > It's removed from CodeCompletionString therefore it's now only above the public declaration. Comment at: include/clang/Sema/CodeCompleteConsumer.h:592 + StringRef ParentName, const char *BriefComment, + std::vector FixIts); ~CodeCompletionString() = default; ilya-biryukov wrote: > We can't store fixits in `CodeCompletionString`, it should not contain source > locatins, which are only valid for the lifetime of SourceManager. > Note that CCS has a lifetime independent of both the SourceManager and the > AST. > Storing them in CodeCompletionResult should be good enough for all our > use-cases. To support that I had to make libclang calls even worse but whatever. Comment at: include/clang/Sema/CodeCompleteConsumer.h:814 + /// \brief FixIts that *must* be applied before inserting the text for the + /// corresponding completion item. Completion items with non-empty fixits will ilya-biryukov wrote: > We shouldn't duplicate such a large comment in too many places, it would be > impossible to keep it in sync. > I would suggest only keeping it in `CodeCompletionResult` and add a reference > to it in other places. > libclang is a bit tricky, though. It is distributed without other LLVM > headers, right? I will keep the comment only here and in libclang https://reviews.llvm.org/D41537 ___ cfe-commits mailing list cfe-commits
r331879 - [OPENMP] Mark global tors/dtors as used.
Author: abataev Date: Wed May 9 07:15:18 2018 New Revision: 331879 URL: http://llvm.org/viewvc/llvm-project?rev=331879&view=rev Log: [OPENMP] Mark global tors/dtors as used. If the global variables are marked as declare target and they need ctors/dtors, these ctors/dtors are emitted and then invoked by the offloading runtime library. They are not explicitly used in the emitted code and thus can be optimized out. Patch marks these functions as used, so the optimizer cannot remove these function during the optimization phase. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/test/OpenMP/declare_target_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=331879&r1=331878&r2=331879&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed May 9 07:15:18 2018 @@ -2686,6 +2686,7 @@ bool CGOpenMPRuntime::emitDeclareTargetV CtorCGF.FinishFunction(); Ctor = Fn; ID = llvm::ConstantExpr::getBitCast(Fn, CGM.Int8PtrTy); + CGM.addUsedGlobal(cast(Ctor)); } else { Ctor = new llvm::GlobalVariable( CGM.getModule(), CGM.Int8Ty, /*isConstant=*/true, @@ -2724,6 +2725,7 @@ bool CGOpenMPRuntime::emitDeclareTargetV DtorCGF.FinishFunction(); Dtor = Fn; ID = llvm::ConstantExpr::getBitCast(Fn, CGM.Int8PtrTy); + CGM.addUsedGlobal(cast(Dtor)); } else { Dtor = new llvm::GlobalVariable( CGM.getModule(), CGM.Int8Ty, /*isConstant=*/true, Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=331879&r1=331878&r2=331879&view=diff == --- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Wed May 9 07:15:18 2018 @@ -17,10 +17,13 @@ // CHECK-DAG: @b = global i32 15, // CHECK-DAG: @d = global i32 0, // CHECK-DAG: @c = external global i32, +// CHECK-DAG: @globals = global %struct.S zeroinitializer, +// CHECK-DAG: @llvm.used = appending global [1 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+41]]_ctor to i8*)], section "llvm.metadata" // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}() // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* %{{.*}}) // CHECK-DAG: define {{.*}}i32 @{{.*}}TemplateClass{{.*}}f_method{{.*}}(%class.TemplateClass* %{{.*}}) +// CHECK-DAG: define {{.*}}void @__omp_offloading__{{.*}}_globals_l[[@LINE+36]]_ctor() #ifndef HEADER #define HEADER @@ -56,6 +59,7 @@ struct S { int foo() { return 0; } int b = 15; int d; +S globals(d); #pragma omp end declare target int c; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files
alexfh added a comment. In https://reviews.llvm.org/D46602#1092111, @rja wrote: > +1 for JSON Could you explain why would you use YAML or JSON for this? How are you going to use/process this data? Repository: rL LLVM https://reviews.llvm.org/D46602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files
alexfh added a comment. Roman, it looks to me that a simpler storage scheme would be sufficient. For example, MMDDhhmmss-InputFileName.cpp.csv. Main things are: 1. include a timestamp, so there's no need to overwrite old results, 2. include just the name of the file without any parent directories, 3. put all outputs into the same directory. This way we wouldn't have to create a directory structure and think about stripping a certain prefix (btw, utilities like patch just specify the number of path components to remove from the start, not the actual substring). WDYT? Repository: rL LLVM https://reviews.llvm.org/D46602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files
lebedev.ri added a comment. In https://reviews.llvm.org/D46602#1092883, @alexfh wrote: > In https://reviews.llvm.org/D46602#1092111, @rja wrote: > > > +1 for JSON > > > Could you explain why would you use YAML or JSON for this? How are you going > to use/process this data? I personally don't have a preference here. The "YAML" may be better because that is what already supported by `TimerGroup`, which allowed to drop the table printer, too. The next step will be a python script: 1. Takes either a file names (these generated `.yaml`), or a prefix, If it is a prefix, it GLOBS all the `.yaml`'s in there. 2. Load all the files from step 1. 3. Print global report from data collected (`reduce(+)` after grouping by check name) from all the files (what https://reviews.llvm.org/D45931 did) 4. Maybe print report about outliers - without "`reduce(+)` after grouping by check name", with percentages to the total time spent on TU. This is where the filename (and YAML) would be helpful. 5. ??? 6. Run on codebases, find performance problems, contribute fixes 7. Profit! Repository: rL LLVM https://reviews.llvm.org/D46602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46603: [Support] TimerGroup changes
alexfh added a comment. I wonder why JSON? What kind of a tool do folks use to process the outputs of printJSONValue? Is there anything existing or is JSON used "just in case"? I personally use either spreadsheets, python or shell when I deal with this kind of data, and all three of them can work reasonably well with CSV (plus the data is pretty simple). Repository: rL LLVM https://reviews.llvm.org/D46603 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files
lebedev.ri added a comment. In https://reviews.llvm.org/D46602#1092890, @alexfh wrote: > Roman, it looks to me that a simpler storage scheme would be sufficient. For > example, MMDDhhmmss-InputFileName.cpp.csv. > Main things are: > > 1. include a timestamp, so there's no need to overwrite old results, Of the input source file? I don't like this, because when working on trying to improve the performance of the check, one wouldn't touch the source file, only the clang-tidy sources. So either you would have to `touch` sources (and if they are not writable?), or remove `.csv` beforehand, or not output to file, but redirect output. Neither of these possibilities sound great to me. > 2. include just the name of the file without any parent directories, That won't work, there are duplicate filenames even in LLVM. $ find -iname Path.cpp ./lib/Support/Path.cpp ./unittests/Support/Path.cpp > 3. put all outputs into the same directory. This way we wouldn't have to > create a directory structure and think about stripping a certain prefix (btw, > utilities like patch just specify the number of path components to remove > from the start, not the actual substring). WDYT? I'm not particularly looking forward to having being forced to have n thousands of reports in a single directory :) Repository: rL LLVM https://reviews.llvm.org/D46602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46639: [CodeComplete] Provide completion in decls even for incomplete types
ilya-biryukov created this revision. ilya-biryukov added reviewers: bkramer, aaron.ballman, sammccall. This change fixes lack of completions in the following case ('^'designates completion points) : void f(^); struct Incomplete; Incomplete g(^); Repository: rC Clang https://reviews.llvm.org/D46639 Files: lib/Sema/SemaCodeComplete.cpp test/CodeCompletion/incomplete-ret-type.cpp Index: test/CodeCompletion/incomplete-ret-type.cpp === --- /dev/null +++ test/CodeCompletion/incomplete-ret-type.cpp @@ -0,0 +1,13 @@ +struct IncompleteType; +int int_value; +typedef int int_typedef; + +void f(in); +IncompleteType g(in); +// Completing should produce results even if types are incomplete. +// Note that clang is expected to return an error code since 'in' does not resolve. +// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:5:9 %s -o - | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:6:19 %s -o - | FileCheck %s +// CHECK: COMPLETION: int{{$}} +// CHECK: COMPLETION: int_typedef +// CHECK: COMPLETION: int_value Index: lib/Sema/SemaCodeComplete.cpp === --- lib/Sema/SemaCodeComplete.cpp +++ lib/Sema/SemaCodeComplete.cpp @@ -4493,10 +4493,8 @@ return; // A complete type is needed to lookup for constructors. - if (!isCompleteType(Loc, Type)) -return; - - CXXRecordDecl *RD = Type->getAsCXXRecordDecl(); + CXXRecordDecl *RD = + isCompleteType(Loc, Type) ? Type->getAsCXXRecordDecl() : nullptr; if (!RD) { CodeCompleteExpression(S, Type); return; Index: test/CodeCompletion/incomplete-ret-type.cpp === --- /dev/null +++ test/CodeCompletion/incomplete-ret-type.cpp @@ -0,0 +1,13 @@ +struct IncompleteType; +int int_value; +typedef int int_typedef; + +void f(in); +IncompleteType g(in); +// Completing should produce results even if types are incomplete. +// Note that clang is expected to return an error code since 'in' does not resolve. +// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:5:9 %s -o - | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:6:19 %s -o - | FileCheck %s +// CHECK: COMPLETION: int{{$}} +// CHECK: COMPLETION: int_typedef +// CHECK: COMPLETION: int_value Index: lib/Sema/SemaCodeComplete.cpp === --- lib/Sema/SemaCodeComplete.cpp +++ lib/Sema/SemaCodeComplete.cpp @@ -4493,10 +4493,8 @@ return; // A complete type is needed to lookup for constructors. - if (!isCompleteType(Loc, Type)) -return; - - CXXRecordDecl *RD = Type->getAsCXXRecordDecl(); + CXXRecordDecl *RD = + isCompleteType(Loc, Type) ? Type->getAsCXXRecordDecl() : nullptr; if (!RD) { CodeCompleteExpression(S, Type); return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files
lebedev.ri added a comment. In https://reviews.llvm.org/D46602#1092902, @lebedev.ri wrote: > In https://reviews.llvm.org/D46602#1092890, @alexfh wrote: > > > Roman, it looks to me that a simpler storage scheme would be sufficient. > > For example, MMDDhhmmss-InputFileName.cpp.csv. > > Main things are: > > > > 1. include a timestamp, so there's no need to overwrite old results, > > > Of the input source file? > > I don't like this, because when working on trying to improve the performance > of the check, > one wouldn't touch the source file, only the clang-tidy sources. So either > you would > have to `touch` sources (and if they are not writable?), or remove `.csv` > beforehand, > or not output to file, but redirect output. ... also, a new report with a new name will be created each time the filetime changes, so not only will it be fun from tooling point of view, but it will also leave old reports in-place.. > Neither of these possibilities sound great to me. > >> 2. include just the name of the file without any parent directories, > > That won't work, there are duplicate filenames even in LLVM. > > $ find -iname Path.cpp > ./lib/Support/Path.cpp > ./unittests/Support/Path.cpp > > > > >> 3. put all outputs into the same directory. This way we wouldn't have to >> create a directory structure and think about stripping a certain prefix >> (btw, utilities like patch just specify the number of path components to >> remove from the start, not the actual substring). WDYT? > > I'm not particularly looking forward to having being forced to have n > thousands of reports in a single directory :) Repository: rL LLVM https://reviews.llvm.org/D46602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45927: [clang-tidy] [modernize-use-auto] Correct way to calculate a type name length for multi-token types
alexfh added inline comments. Comment at: clang-tidy/modernize-use-auto-min-type-name-length.cpp:61-83 +long int li = static_cast(foo()); +// CHECK-FIXES-0-0: auto li = {{.*}} +// CHECK-FIXES-0-5: auto li = {{.*}} +// CHECK-FIXES-1-0: auto li = {{.*}} +// CHECK-FIXES-1-5: auto li = {{.*}} +long int *pli = static_cast(foo()); +// CHECK-FIXES-0-0: auto *pli = {{.*}} zinovy.nis wrote: > zinovy.nis wrote: > > zinovy.nis wrote: > > > alexfh wrote: > > > > These tests could be more useful, if they verified boundary values of > > > > the MinTypeNameLength, e.g. that `long int` is replaced with `auto` > > > > when the option is set to 8 and it stays `long int`with the option set > > > > to 9. > > > > > > > > Please also add tests with template typenames: e.g. the lenght of `T < > > > > int >` should be considered 6 and the length of `T < const int >` is > > > > 12. I guess, the algorithm I proposed will be incorrect for pointer > > > > type arguments of templates (the length of `T` should be 7 > > > > regardless of `RemoveStars`), but this can be fixed by conditionally > > > > (on RemoveStars) trimming `*`s from the right of the type name and then > > > > treating them as punctuation. So instead of > > > > > > > > ``` > > > > for (const unsigned char C : tooling::fixit::getText(SR, Context)) { > > > > const CharType NextChar = > > > > std::isalnum(C) > > > > ? Alpha > > > > : (std::isspace(C) || (!RemoveStars && C == '*')) ? Space > > > > : > > > > Punctuation; > > > > ``` > > > > > > > > you could use something similar to > > > > > > > > ``` > > > > StringRef Text = tooling::fixit::getText(SR, Context); > > > > if (RemoveStars) > > > > Text = Text.rtrim(" \t\v\n\r*"); > > > > for (const unsigned char C : Text) { > > > > const CharType NextChar = > > > > std::isalnum(C) ? Alpha : std::isspace(C) ? Space : Punctuation; > > > > ``` > > > > These tests could be more useful, if they verified boundary values of > > > > the MinTypeNameLength, e.g. that long int is replaced with auto when > > > > the option is set to 8 and it stays long intwith the option set to 9. > > > > > > > > > > `int`-test is just for that :-) > > > > > > ``` > > > int a = static_cast(foo()); // ---> int a = ... > > > ``` > > I measured lengths for template cases: > > > > > > ``` > > S=std::string * len=12 > > S=std::vector * len=25 > > S=std::vector * len=31 > > S=std::string* len=12 > > S=std::vector * len=25 > > S=std::vector* len=31 > > ``` > > > > > RemoveStars==1 here. > S=std::string * len=12 With RemoveStars this should be 11? > S=std::vector * len=25 24? > S=std::vector * len=31 30? The point of my comment was that stars should be treated specially only at the end of the type, not inside template parameters, e.g. `T` should have length 10 regardless of RemoveStars. All your examples are with trailing stars. Comment at: clang-tidy/modernize-use-auto-min-type-name-length.cpp:61-83 +long int li = static_cast(foo()); +// CHECK-FIXES-0-0: auto li = {{.*}} +// CHECK-FIXES-0-5: auto li = {{.*}} +// CHECK-FIXES-1-0: auto li = {{.*}} +// CHECK-FIXES-1-5: auto li = {{.*}} +long int *pli = static_cast(foo()); +// CHECK-FIXES-0-0: auto *pli = {{.*}} alexfh wrote: > zinovy.nis wrote: > > zinovy.nis wrote: > > > zinovy.nis wrote: > > > > alexfh wrote: > > > > > These tests could be more useful, if they verified boundary values of > > > > > the MinTypeNameLength, e.g. that `long int` is replaced with `auto` > > > > > when the option is set to 8 and it stays `long int`with the option > > > > > set to 9. > > > > > > > > > > Please also add tests with template typenames: e.g. the lenght of `T > > > > > < int >` should be considered 6 and the length of `T < const int > > > > > >` is 12. I guess, the algorithm I proposed will be incorrect for > > > > > pointer type arguments of templates (the length of `T` should > > > > > be 7 regardless of `RemoveStars`), but this can be fixed by > > > > > conditionally (on RemoveStars) trimming `*`s from the right of the > > > > > type name and then treating them as punctuation. So instead of > > > > > > > > > > ``` > > > > > for (const unsigned char C : tooling::fixit::getText(SR, Context)) { > > > > > const CharType NextChar = > > > > > std::isalnum(C) > > > > > ? Alpha > > > > > : (std::isspace(C) || (!RemoveStars && C == '*')) ? Space > > > > > : > > > > > Punctuation; > > > > > ``` > > > > > > > > > > you could use something similar to > > > > > > > > > > ``` > > > > > StringRef Text = tooling::fixit::getText(SR, Context); > > > > > if (RemoveStars) > > > > >
r331843 - [DebugInfo] Generate debug information for labels.
Author: shiva Date: Tue May 8 19:41:56 2018 New Revision: 331843 URL: http://llvm.org/viewvc/llvm-project?rev=331843&view=rev Log: [DebugInfo] Generate debug information for labels. Generate DILabel metadata and call llvm.dbg.label after label statement to associate the metadata with the label. Differential Revision: https://reviews.llvm.org/D45045 Patch by Hsiangkai Wang. Added: cfe/trunk/test/CodeGen/debug-label-inline.c cfe/trunk/test/CodeGen/debug-label.c Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/test/CodeGen/backend-unsupported-error.ll Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=331843&r1=331842&r2=331843&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue May 8 19:41:56 2018 @@ -3647,6 +3647,32 @@ CGDebugInfo::EmitDeclareOfAutoVariable(c return EmitDeclare(VD, Storage, llvm::None, Builder); } +void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) { + assert(DebugKind >= codegenoptions::LimitedDebugInfo); + assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); + + if (D->hasAttr()) +return; + + auto *Scope = cast(LexicalBlockStack.back()); + llvm::DIFile *Unit = getOrCreateFile(D->getLocation()); + + // Get location information. + unsigned Line = getLineNumber(D->getLocation()); + unsigned Column = getColumnNumber(D->getLocation()); + + StringRef Name = D->getName(); + + // Create the descriptor for the label. + auto *L = + DBuilder.createLabel(Scope, Name, Unit, Line, CGM.getLangOpts().Optimize); + + // Insert an llvm.dbg.label into the current block. + DBuilder.insertLabel(L, + llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt), + Builder.GetInsertBlock()); +} + llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy, llvm::DIType *Ty) { llvm::DIType *CachedTy = getTypeOrNull(QualTy); Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=331843&r1=331842&r2=331843&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue May 8 19:41:56 2018 @@ -396,6 +396,9 @@ public: 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, Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=331843&r1=331842&r2=331843&view=diff == --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue May 8 19:41:56 2018 @@ -531,6 +531,16 @@ void CodeGenFunction::EmitLabel(const La } 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()); } Modified: cfe/trunk/test/CodeGen/backend-unsupported-error.ll URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/backend-unsupported-error.ll?rev=331843&r1=331842&r2=331843&view=diff == --- cfe/trunk/test/CodeGen/backend-unsupported-error.ll (original) +++ cfe/trunk/test/CodeGen/backend-unsupported-error.ll Tue May 8 19:41:56 2018 @@ -30,11 +30,11 @@ attributes #0 = { nounwind uwtable "disa !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_sign
[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers
pfultz2 updated this revision to Diff 145925. pfultz2 added a comment. Some changes based on feedback. https://reviews.llvm.org/D46159 Files: clang-tidy/ClangTidy.cpp clang-tidy/ClangTidy.h clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h clang-tidy/tool/ClangTidyMain.cpp test/clang-tidy/enable-alpha-checks.cpp Index: test/clang-tidy/enable-alpha-checks.cpp === --- /dev/null +++ test/clang-tidy/enable-alpha-checks.cpp @@ -0,0 +1,6 @@ +// Check if '-allow-enabling-analyzer-alpha-checkers' is visible for users. +// RUN: clang-tidy -help | not grep 'allow-enabling-analyzer-alpha-checkers' + +// Check if '-allow-enabling-analyzer-alpha-checkers' enables alpha checks. +// RUN: clang-tidy -checks=* -list-checks | not grep 'clang-analyzer-alpha' +// RUN: clang-tidy -checks=* -list-checks -allow-enabling-analyzer-alpha-checkers | grep 'clang-analyzer-alpha' Index: clang-tidy/tool/ClangTidyMain.cpp === --- clang-tidy/tool/ClangTidyMain.cpp +++ clang-tidy/tool/ClangTidyMain.cpp @@ -192,6 +192,14 @@ cl::init(false), cl::cat(ClangTidyCategory)); +/// This option allows enabling the experimental alpha checkers from the static +/// analyzer. This option is set to false and not visible in help, because it is +/// highly not recommended for users. +static cl::opt +AllowEnablingAnalyzerAlphaCheckers("allow-enabling-analyzer-alpha-checkers", + cl::init(false), cl::Hidden, + cl::cat(ClangTidyCategory)); + static cl::opt ExportFixes("export-fixes", cl::desc(R"( YAML file to store suggested fixes in. The stored fixes can be applied to the input source @@ -388,7 +396,8 @@ << EC.message() << "\n"; } ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath); - std::vector EnabledChecks = getCheckNames(EffectiveOptions); + std::vector EnabledChecks = + getCheckNames(EffectiveOptions, AllowEnablingAnalyzerAlphaCheckers); if (ExplainConfig) { // FIXME: Show other ClangTidyOptions' fields, like ExtraArg. @@ -419,7 +428,8 @@ } if (DumpConfig) { -EffectiveOptions.CheckOptions = getCheckOptions(EffectiveOptions); +EffectiveOptions.CheckOptions = +getCheckOptions(EffectiveOptions, AllowEnablingAnalyzerAlphaCheckers); llvm::outs() << configurationAsText( ClangTidyOptions::getDefaults().mergeWith( EffectiveOptions)) @@ -444,7 +454,8 @@ llvm::InitializeAllTargetMCs(); llvm::InitializeAllAsmParsers(); - ClangTidyContext Context(std::move(OwningOptionsProvider)); + ClangTidyContext Context(std::move(OwningOptionsProvider), + AllowEnablingAnalyzerAlphaCheckers); runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS, EnableCheckProfile ? &Profile : nullptr); ArrayRef Errors = Context.getErrors(); Index: clang-tidy/ClangTidyDiagnosticConsumer.h === --- clang-tidy/ClangTidyDiagnosticConsumer.h +++ clang-tidy/ClangTidyDiagnosticConsumer.h @@ -104,7 +104,8 @@ class ClangTidyContext { public: /// \brief Initializes \c ClangTidyContext instance. - ClangTidyContext(std::unique_ptr OptionsProvider); + ClangTidyContext(std::unique_ptr OptionsProvider, + bool AllowEnablingAnalyzerAlphaCheckers = false); ~ClangTidyContext(); @@ -186,6 +187,12 @@ return CurrentBuildDirectory; } + /// \brief If the experimental alpha checkers from the static analyzer can be + /// enabled. + bool canEnableAnalyzerAlphaCheckers() const { +return AllowEnablingAnalyzerAlphaCheckers; + } + private: // Calls setDiagnosticsEngine() and storeError(). friend class ClangTidyDiagnosticConsumer; @@ -217,6 +224,8 @@ llvm::DenseMap CheckNamesByDiagnosticID; ProfileData *Profile; + + bool AllowEnablingAnalyzerAlphaCheckers; }; /// \brief A diagnostic consumer that turns each \c Diagnostic into a Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp === --- clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -177,9 +177,11 @@ }; ClangTidyContext::ClangTidyContext( -std::unique_ptr OptionsProvider) +std::unique_ptr OptionsProvider, +bool AllowEnablingAnalyzerAlphaCheckers) : DiagEngine(nullptr), OptionsProvider(std::move(OptionsProvider)), - Profile(nullptr) { + Profile(nullptr), + AllowEnablingAnalyzerAlphaCheckers(AllowEnablingAnalyzerAlphaCheckers) { // Before the first translation unit we can get errors related to command-line // parsing, use empty string f
[PATCH] D46643: CodeGen: Emit string literal in constant address space
yaxunl created this revision. yaxunl added a reviewer: rjmccall. Some targets have constant address space (e.g. amdgcn). For them string literal should be emitted in constant address space then casted to default address space. https://reviews.llvm.org/D46643 Files: lib/CodeGen/CGDecl.cpp lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/amdgcn-string-literal.cpp Index: test/CodeGenCXX/amdgcn-string-literal.cpp === --- /dev/null +++ test/CodeGenCXX/amdgcn-string-literal.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s + +// CHECK: @.str = private unnamed_addr addrspace(4) constant [6 x i8] c"g_str\00", align 1 +// CHECK: @g_str = addrspace(1) global i8* addrspacecast (i8 addrspace(4)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(4)* @.str, i32 0, i32 0) to i8*), align 8 +// CHECK: @g_array = addrspace(1) global [8 x i8] c"g_array\00", align 1 +// CHECK: @.str.1 = private unnamed_addr addrspace(4) constant [6 x i8] c"l_str\00", align 1 +// CHECK: @_ZZ1fvE7l_array = private unnamed_addr addrspace(4) constant [8 x i8] c"l_array\00", align 1 + +const char* g_str = "g_str"; +char g_array[] = "g_array"; + +void g(const char* p); + +// CHECK-LABEL: define void @_Z1fv() +void f() { + const char* l_str = "l_str"; + + // CHECK: call void @llvm.memcpy.p5i8.p4i8.i64 + char l_array[] = "l_array"; + + g(g_str); + g(g_array); + g(l_str); + g(l_array); + + const char* p = g_str; + g(p); +} \ No newline at end of file Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -4032,6 +4032,9 @@ unsigned AddrSpace = 0; if (CGM.getLangOpts().OpenCL) AddrSpace = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant); + else if (auto AS = CGM.getTarget().getConstantAddressSpace()) { +AddrSpace = CGM.getContext().getTargetAddressSpace(AS.getValue()); + } llvm::Module &M = CGM.getModule(); // Create a global variable for this string @@ -4093,7 +4096,19 @@ SanitizerMD->reportGlobalToASan(GV, S->getStrTokenLoc(0), "", QualType()); - return ConstantAddress(GV, Alignment); + + llvm::Constant *Cast = GV; + if (!getLangOpts().OpenCL) { +if (auto AS = getTarget().getConstantAddressSpace()) { + if (AS != LangAS::Default) +Cast = getTargetCodeGenInfo().performAddrSpaceCast( +*this, GV, AS.getValue(), LangAS::Default, +GV->getValueType()->getPointerTo( +getContext().getTargetAddressSpace(LangAS::Default))); +} + } + + return ConstantAddress(Cast, Alignment); } /// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant @@ -4137,7 +4152,17 @@ GlobalName, Alignment); if (Entry) *Entry = GV; - return ConstantAddress(GV, Alignment); + llvm::Constant *Cast = GV; + if (!getLangOpts().OpenCL) { +if (auto AS = getTarget().getConstantAddressSpace()) { + if (AS != LangAS::Default) +Cast = getTargetCodeGenInfo().performAddrSpaceCast( +*this, GV, AS.getValue(), LangAS::Default, +GV->getValueType()->getPointerTo( +getContext().getTargetAddressSpace(LangAS::Default))); +} + } + return ConstantAddress(Cast, Alignment); } ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary( Index: lib/CodeGen/CGDecl.cpp === --- lib/CodeGen/CGDecl.cpp +++ lib/CodeGen/CGDecl.cpp @@ -1371,7 +1371,8 @@ llvm::Type *BP = AllocaInt8PtrTy; if (Loc.getType() != BP) -Loc = Builder.CreateBitCast(Loc, BP); +Loc = Address(EmitCastToVoidPtrInAllocaAddrSpace(Loc.getPointer()), + Loc.getAlignment()); // If the initializer is all or mostly zeros, codegen with memset then do // a few stores afterward. @@ -1394,7 +1395,11 @@ if (getLangOpts().OpenCL) { AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant); BP = llvm::PointerType::getInt8PtrTy(getLLVMContext(), AS); +} else if (auto OptionalAS = CGM.getTarget().getConstantAddressSpace()) { + AS = CGM.getContext().getTargetAddressSpace(OptionalAS.getValue()); + BP = llvm::PointerType::getInt8PtrTy(getLLVMContext(), AS); } + llvm::GlobalVariable *GV = new llvm::GlobalVariable(CGM.getModule(), constant->getType(), true, llvm::GlobalValue::PrivateLinkage, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46614: [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective
juliehockett updated this revision to Diff 145934. juliehockett added a comment. Adding test https://reviews.llvm.org/D46614 Files: include/clang/Lex/PPCallbacks.h include/clang/Lex/PreprocessingRecord.h lib/CodeGen/MacroPPCallbacks.cpp lib/CodeGen/MacroPPCallbacks.h lib/Frontend/DependencyFile.cpp lib/Frontend/DependencyGraph.cpp lib/Frontend/ModuleDependencyCollector.cpp lib/Frontend/PrintPreprocessedOutput.cpp lib/Frontend/Rewrite/InclusionRewriter.cpp lib/Lex/PPDirectives.cpp lib/Lex/PreprocessingRecord.cpp tools/libclang/Indexing.cpp unittests/Lex/PPCallbacksTest.cpp Index: unittests/Lex/PPCallbacksTest.cpp === --- unittests/Lex/PPCallbacksTest.cpp +++ unittests/Lex/PPCallbacksTest.cpp @@ -39,16 +39,18 @@ StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override { - this->HashLoc = HashLoc; - this->IncludeTok = IncludeTok; - this->FileName = FileName.str(); - this->IsAngled = IsAngled; - this->FilenameRange = FilenameRange; - this->File = File; - this->SearchPath = SearchPath.str(); - this->RelativePath = RelativePath.str(); - this->Imported = Imported; + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override { +this->HashLoc = HashLoc; +this->IncludeTok = IncludeTok; +this->FileName = FileName.str(); +this->IsAngled = IsAngled; +this->FilenameRange = FilenameRange; +this->File = File; +this->SearchPath = SearchPath.str(); +this->RelativePath = RelativePath.str(); +this->Imported = Imported; +this->FileType = FileType; } SourceLocation HashLoc; @@ -60,6 +62,7 @@ SmallString<16> SearchPath; SmallString<16> RelativePath; const Module* Imported; + SrcMgr::CharacteristicKind FileType; }; // Stub to collect data from PragmaOpenCLExtension callbacks. @@ -136,8 +139,9 @@ // Run lexer over SourceText and collect FilenameRange from // the InclusionDirective callback. - CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText, - const char* HeaderPath, bool SystemHeader) { + InclusionDirectiveCallbacks * + InclusionDirectiveCallback(const char *SourceText, + const char *HeaderPath, bool SystemHeader) { std::unique_ptr Buf = llvm::MemoryBuffer::getMemBuffer(SourceText); SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); @@ -168,7 +172,7 @@ } // Callbacks have been executed at this point -- return filename range. -return Callbacks->FilenameRange; +return Callbacks; } PragmaOpenCLExtensionCallbacks::CallbackParameters @@ -222,12 +226,21 @@ } }; +TEST_F(PPCallbacksTest, UserFileCharacteristics) { + const char *Source = "#include \"quoted.h\"\n"; + + SrcMgr::CharacteristicKind Kind = + InclusionDirectiveCallback(Source, "/quoted.h", false)->FileType; + + ASSERT_EQ(SrcMgr::CharacteristicKind::C_User, Kind); +} + TEST_F(PPCallbacksTest, QuotedFilename) { const char* Source = "#include \"quoted.h\"\n"; CharSourceRange Range = -InclusionDirectiveFilenameRange(Source, "/quoted.h", false); +InclusionDirectiveCallback(Source, "/quoted.h", false)->FilenameRange; ASSERT_EQ("\"quoted.h\"", GetSourceString(Range)); } @@ -237,7 +250,7 @@ "#include \n"; CharSourceRange Range = -InclusionDirectiveFilenameRange(Source, "/angled.h", true); +InclusionDirectiveCallback(Source, "/angled.h", true)->FilenameRange; ASSERT_EQ("", GetSourceString(Range)); } @@ -248,7 +261,7 @@ "#include MACRO_QUOTED\n"; CharSourceRange Range = -InclusionDirectiveFilenameRange(Source, "/quoted.h", false); +InclusionDirectiveCallback(Source, "/quoted.h", false)->FilenameRange; ASSERT_EQ("\"quoted.h\"", GetSourceString(Range)); } @@ -259,7 +272,7 @@ "#include MACRO_ANGLED\n"; CharSourceRange Range = -InclusionDirectiveFilenameRange(Source, "/angled.h", true); +InclusionDirectiveCallback(Source, "/angled.h", true)->FilenameRange; ASSERT_EQ("", GetSourceString(Range)); } @@ -270,7 +283,7 @@ "#include MACRO_STRINGIZED(quoted.h)\n"; CharSourceRange Range = -InclusionDirectiveFilenameRange(Source, "/quoted.h", false); +InclusionDirectiveCallback(Source, "/quoted.h", false)->FilenameRange; ASSERT_EQ("\"quoted.h\"", GetSourceString(Range)); } @@ -282,7 +295,7 @@ "#include MACRO_CONCAT(MACRO, ANGLED)\n"; CharSourceRange Range = -InclusionDirectiveFilenameRange(Source, "/angled.h", false); +InclusionDirectiveCallback(Source, "/angled.h", false)->FilenameRange; ASSERT_EQ("", GetSourceString(Range)); } @@ -292
[PATCH] D46614: [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective
aaron.ballman added inline comments. Comment at: unittests/Lex/PPCallbacksTest.cpp:142-143 // the InclusionDirective callback. - CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText, - const char* HeaderPath, bool SystemHeader) { + InclusionDirectiveCallbacks * + InclusionDirectiveCallback(const char *SourceText, + const char *HeaderPath, bool SystemHeader) { aaron.ballman wrote: > The formatting looks off here, did clang-format do this? It would probably be cleaner to provide the old interface as well, but define it to: ``` CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText, const char* HeaderPath, bool SystemHeader) { return InclusionDirectiveCallback(SourceText, HeaderPath, SystemHeader)->FilenameRange; } ``` Comment at: unittests/Lex/PPCallbacksTest.cpp:142-144 + InclusionDirectiveCallbacks * + InclusionDirectiveCallback(const char *SourceText, + const char *HeaderPath, bool SystemHeader) { The formatting looks off here, did clang-format do this? https://reviews.llvm.org/D46614 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46614: [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective
juliehockett updated this revision to Diff 145941. juliehockett marked 3 inline comments as done. juliehockett added a comment. Fixing formatting and tests. https://reviews.llvm.org/D46614 Files: include/clang/Lex/PPCallbacks.h include/clang/Lex/PreprocessingRecord.h lib/CodeGen/MacroPPCallbacks.cpp lib/CodeGen/MacroPPCallbacks.h lib/Frontend/DependencyFile.cpp lib/Frontend/DependencyGraph.cpp lib/Frontend/ModuleDependencyCollector.cpp lib/Frontend/PrintPreprocessedOutput.cpp lib/Frontend/Rewrite/InclusionRewriter.cpp lib/Lex/PPDirectives.cpp lib/Lex/PreprocessingRecord.cpp tools/libclang/Indexing.cpp unittests/Lex/PPCallbacksTest.cpp Index: unittests/Lex/PPCallbacksTest.cpp === --- unittests/Lex/PPCallbacksTest.cpp +++ unittests/Lex/PPCallbacksTest.cpp @@ -39,16 +39,18 @@ StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override { - this->HashLoc = HashLoc; - this->IncludeTok = IncludeTok; - this->FileName = FileName.str(); - this->IsAngled = IsAngled; - this->FilenameRange = FilenameRange; - this->File = File; - this->SearchPath = SearchPath.str(); - this->RelativePath = RelativePath.str(); - this->Imported = Imported; + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override { +this->HashLoc = HashLoc; +this->IncludeTok = IncludeTok; +this->FileName = FileName.str(); +this->IsAngled = IsAngled; +this->FilenameRange = FilenameRange; +this->File = File; +this->SearchPath = SearchPath.str(); +this->RelativePath = RelativePath.str(); +this->Imported = Imported; +this->FileType = FileType; } SourceLocation HashLoc; @@ -60,6 +62,7 @@ SmallString<16> SearchPath; SmallString<16> RelativePath; const Module* Imported; + SrcMgr::CharacteristicKind FileType; }; // Stub to collect data from PragmaOpenCLExtension callbacks. @@ -138,6 +141,13 @@ // the InclusionDirective callback. CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText, const char* HeaderPath, bool SystemHeader) { +return InclusionDirectiveCallback(SourceText, HeaderPath, SystemHeader) +->FilenameRange; + } + + InclusionDirectiveCallbacks * + InclusionDirectiveCallback(const char *SourceText, const char *HeaderPath, + bool SystemHeader) { std::unique_ptr Buf = llvm::MemoryBuffer::getMemBuffer(SourceText); SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); @@ -168,7 +178,7 @@ } // Callbacks have been executed at this point -- return filename range. -return Callbacks->FilenameRange; +return Callbacks; } PragmaOpenCLExtensionCallbacks::CallbackParameters @@ -222,6 +232,15 @@ } }; +TEST_F(PPCallbacksTest, UserFileCharacteristics) { + const char *Source = "#include \"quoted.h\"\n"; + + SrcMgr::CharacteristicKind Kind = + InclusionDirectiveCallback(Source, "/quoted.h", false)->FileType; + + ASSERT_EQ(SrcMgr::CharacteristicKind::C_User, Kind); +} + TEST_F(PPCallbacksTest, QuotedFilename) { const char* Source = "#include \"quoted.h\"\n"; Index: tools/libclang/Indexing.cpp === --- tools/libclang/Indexing.cpp +++ tools/libclang/Indexing.cpp @@ -249,7 +249,8 @@ StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override { + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override { bool isImport = (IncludeTok.is(tok::identifier) && IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import); DataConsumer.ppIncludedFile(HashLoc, FileName, File, isImport, IsAngled, Index: lib/Lex/PreprocessingRecord.cpp === --- lib/Lex/PreprocessingRecord.cpp +++ lib/Lex/PreprocessingRecord.cpp @@ -471,7 +471,8 @@ const FileEntry *File, StringRef SearchPath, StringRef RelativePath, -const Module *Imported) { +const Module *Imported, +SrcMgr::CharacteristicKind FileType) { InclusionDirective::InclusionKind Kind = InclusionDirective::Include; switch (IncludeTok.getIdentifierInfo()->getPPKeywordID()) { Index: lib/Lex/PPDirectives.cpp === --- lib/Lex/PPDirectives.cpp +++ lib/Lex/PPDirectives.cpp @@ -1968,7 +1968,7 @@
[PATCH] D46614: [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective
aaron.ballman accepted this revision. aaron.ballman added a comment. LGTM! https://reviews.llvm.org/D46614 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework
juliehockett added a comment. This will break things in clang-tools-extra without https://reviews.llvm.org/D46615, so I'm going to hold off landing this until that goes through https://reviews.llvm.org/D43341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46541: [CodeGen] Improve diagnostics related to target attributes
craig.topper added a comment. This looks pretty good to me. @echristo what do you think? https://reviews.llvm.org/D46541 ___ 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 added a comment. In https://reviews.llvm.org/D45900#1083377, @rjmccall wrote: > Oh, I see, it's not that the lifetime intrinsics don't handle pointers in the > alloca address space, it's that we might have already promoted them into > `DefaultAS`. > > Do the LLVM uses of lifetime intrinsics actually look through these address > space casts? I'm wondering if we might need to change how we emit the > intrinsics so that they're emitted directly on (bitcasts of) the underlying > allocas. Some passes do not look through address space casts. Although there is InferAddressSpace pass which can eliminate the redundant address space casts, still it is desirable not to emit redundant address space in Clang. To avoid increasing complexity of alloca emitting API, I think we need a way to track the original alloca and the alloca casted to default address space. I can think of two ways: 1. add OriginalPointer member to Address, which is the originally emitted LLVM value for the variable. Whenever we pass the address of a variable we also pass the original LLVM value. 2. add a map to CodeGenFunction to map the casted alloca to the real alloca. Any suggestion? Thanks. https://reviews.llvm.org/D45900 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331893 - [X86] Only enable the __ud2 and __int2c builtins if intrin.h has been included.
Author: ctopper Date: Wed May 9 09:57:48 2018 New Revision: 331893 URL: http://llvm.org/viewvc/llvm-project?rev=331893&view=rev Log: [X86] Only enable the __ud2 and __int2c builtins if intrin.h has been included. Differential Revision: https://reviews.llvm.org/D46332 Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=331893&r1=331892&r2=331893&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed May 9 09:57:48 2018 @@ -1899,8 +1899,8 @@ TARGET_HEADER_BUILTIN(__emulu, "ULLiUiUi TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(__stosb, "vUc*Ucz", "nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(__int2c, "v", "nr", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(__ud2, "v", "nr", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(__int2c, "v", "nhr", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(__ud2, "v", "nhr", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(__readfsbyte, "UcUNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(__readfsword, "UsUNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46332: [X86] Only enable the __ud2 and __int2c builtins if intrin.h has been included.
This revision was automatically updated to reflect the committed changes. Closed by commit rC331893: [X86] Only enable the __ud2 and __int2c builtins if intrin.h has been included. (authored by ctopper, committed by ). Repository: rC Clang https://reviews.llvm.org/D46332 Files: include/clang/Basic/BuiltinsX86.def Index: include/clang/Basic/BuiltinsX86.def === --- include/clang/Basic/BuiltinsX86.def +++ include/clang/Basic/BuiltinsX86.def @@ -1899,8 +1899,8 @@ TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(__stosb, "vUc*Ucz", "nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(__int2c, "v", "nr", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(__ud2, "v", "nr", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(__int2c, "v", "nhr", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(__ud2, "v", "nhr", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(__readfsbyte, "UcUNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(__readfsword, "UsUNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") Index: include/clang/Basic/BuiltinsX86.def === --- include/clang/Basic/BuiltinsX86.def +++ include/clang/Basic/BuiltinsX86.def @@ -1899,8 +1899,8 @@ TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(__stosb, "vUc*Ucz", "nh", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(__int2c, "v", "nr", "intrin.h", ALL_MS_LANGUAGES, "") -TARGET_HEADER_BUILTIN(__ud2, "v", "nr", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(__int2c, "v", "nhr", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(__ud2, "v", "nhr", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(__readfsbyte, "UcUNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(__readfsword, "UsUNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") ___ 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
rjmccall added a comment. In https://reviews.llvm.org/D45900#1093154, @yaxunl wrote: > In https://reviews.llvm.org/D45900#1083377, @rjmccall wrote: > > > Oh, I see, it's not that the lifetime intrinsics don't handle pointers in > > the alloca address space, it's that we might have already promoted them > > into `DefaultAS`. > > > > Do the LLVM uses of lifetime intrinsics actually look through these address > > space casts? I'm wondering if we might need to change how we emit the > > intrinsics so that they're emitted directly on (bitcasts of) the underlying > > allocas. > > > Some passes do not look through address space casts. Although there is > InferAddressSpace pass which can eliminate the redundant address space casts, > still it is desirable not to emit redundant address space in Clang. > > To avoid increasing complexity of alloca emitting API, I think we need a way > to track the original alloca and the alloca casted to default address space. > I can think of two ways: > > 1. add OriginalPointer member to Address, which is the originally emitted > LLVM value for the variable. Whenever we pass the address of a variable we > also pass the original LLVM value. > 2. add a map to CodeGenFunction to map the casted alloca to the real alloca. > > Any suggestion? Thanks. Can we just call CreateLifetimeStart (and push the cleanup to call CreateLifetimeEnd) immediately after creating the alloca instead of waiting until later like we do now? Modifying Address is not appropriate, and adding a map to CGF would be big waste. https://reviews.llvm.org/D45900 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331895 - [OpenCL] Fix typos in emitted enqueue kernel function names
Author: yaxunl Date: Wed May 9 10:07:06 2018 New Revision: 331895 URL: http://llvm.org/viewvc/llvm-project?rev=331895&view=rev Log: [OpenCL] Fix typos in emitted enqueue kernel function names Two typos: vaarg => vararg get_kernel_preferred_work_group_multiple => get_kernel_preferred_work_group_size_multiple Differential Revision: https://reviews.llvm.org/D46601 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=331895&r1=331894&r2=331895&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed May 9 10:07:06 2018 @@ -3164,10 +3164,10 @@ RValue CodeGenFunction::EmitBuiltinExpr( return Ptr; }; -// Could have events and/or vaargs. +// Could have events and/or varargs. if (E->getArg(3)->getType()->isBlockPointerType()) { // No events passed, but has variadic arguments. - Name = "__enqueue_kernel_vaargs"; + Name = "__enqueue_kernel_varargs"; auto Info = CGM.getOpenCLRuntime().emitOpenCLEnqueuedBlock(*this, E->getArg(3)); llvm::Value *Kernel = @@ -3235,7 +3235,7 @@ RValue CodeGenFunction::EmitBuiltinExpr( // Pass the number of variadics to the runtime function too. Args.push_back(ConstantInt::get(Int32Ty, NumArgs - 7)); ArgTys.push_back(Int32Ty); - Name = "__enqueue_kernel_events_vaargs"; + Name = "__enqueue_kernel_events_varargs"; auto *PtrToSizeArray = CreateArrayForSizeVar(7); Args.push_back(PtrToSizeArray); @@ -3276,7 +3276,7 @@ RValue CodeGenFunction::EmitBuiltinExpr( CGM.CreateRuntimeFunction( llvm::FunctionType::get(IntTy, {GenericVoidPtrTy, GenericVoidPtrTy}, false), -"__get_kernel_preferred_work_group_multiple_impl"), +"__get_kernel_preferred_work_group_size_multiple_impl"), {Kernel, Arg})); } case Builtin::BIget_kernel_max_sub_group_size_for_ndrange: Modified: cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl?rev=331895&r1=331894&r2=331895&view=diff == --- cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl Wed May 9 10:07:06 2018 @@ -88,7 +88,7 @@ kernel void device_side_enqueue(global i // B64: %[[TMP:.*]] = alloca [1 x i64] // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0 // B64: store i64 256, i64* %[[TMP1]], align 8 - // COMMON-LABEL: call i32 @__enqueue_kernel_vaargs( + // COMMON-LABEL: call i32 @__enqueue_kernel_varargs( // COMMON-SAME: %opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{([0-9]+)?}}, // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVGK1:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*), // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* [[BLG1]] to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, @@ -109,7 +109,7 @@ kernel void device_side_enqueue(global i // B64: %[[TMP:.*]] = alloca [1 x i64] // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0 // B64: store i64 %{{.*}}, i64* %[[TMP1]], align 8 - // COMMON-LABEL: call i32 @__enqueue_kernel_vaargs( + // COMMON-LABEL: call i32 @__enqueue_kernel_varargs( // COMMON-SAME: %opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{([0-9]+)?}}, // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVGK2:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*), // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* [[BLG2]] to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, @@ -133,7 +133,7 @@ kernel void device_side_enqueue(global i // B64: %[[TMP:.*]] = alloca [1 x i64] // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0 // B64: store i64 256, i64* %[[TMP1]], align 8 - // COMMON-LABEL: call i32 @__enqueue_kernel_events_vaargs + // COMMON-LABEL: call i32 @__enqueue_kernel_events_varargs // COMMON-SAME: (%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}} [[WAIT_EVNT]], %opencl.clk_event_t{{.*}} [[EVNT]], // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVGK3:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*), // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* [[BLG3]] to i8 addrspace(1)*) to i8 addrspace(4)*),
[PATCH] D46601: [OpenCL] Fix typos in emitted enqueue kernel function names
This revision was automatically updated to reflect the committed changes. Closed by commit rL331895: [OpenCL] Fix typos in emitted enqueue kernel function names (authored by yaxunl, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D46601?vs=145773&id=145948#toc Repository: rL LLVM https://reviews.llvm.org/D46601 Files: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl Index: cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl === --- cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl +++ cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl @@ -88,7 +88,7 @@ // B64: %[[TMP:.*]] = alloca [1 x i64] // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0 // B64: store i64 256, i64* %[[TMP1]], align 8 - // COMMON-LABEL: call i32 @__enqueue_kernel_vaargs( + // COMMON-LABEL: call i32 @__enqueue_kernel_varargs( // COMMON-SAME: %opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{([0-9]+)?}}, // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVGK1:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*), // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* [[BLG1]] to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, @@ -109,7 +109,7 @@ // B64: %[[TMP:.*]] = alloca [1 x i64] // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0 // B64: store i64 %{{.*}}, i64* %[[TMP1]], align 8 - // COMMON-LABEL: call i32 @__enqueue_kernel_vaargs( + // COMMON-LABEL: call i32 @__enqueue_kernel_varargs( // COMMON-SAME: %opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{([0-9]+)?}}, // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVGK2:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*), // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* [[BLG2]] to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, @@ -133,7 +133,7 @@ // B64: %[[TMP:.*]] = alloca [1 x i64] // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0 // B64: store i64 256, i64* %[[TMP1]], align 8 - // COMMON-LABEL: call i32 @__enqueue_kernel_events_vaargs + // COMMON-LABEL: call i32 @__enqueue_kernel_events_varargs // COMMON-SAME: (%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}} [[WAIT_EVNT]], %opencl.clk_event_t{{.*}} [[EVNT]], // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVGK3:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*), // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* [[BLG3]] to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, @@ -157,7 +157,7 @@ // B64: %[[TMP:.*]] = alloca [1 x i64] // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0 // B64: store i64 %{{.*}}, i64* %[[TMP1]], align 8 - // COMMON-LABEL: call i32 @__enqueue_kernel_events_vaargs + // COMMON-LABEL: call i32 @__enqueue_kernel_events_varargs // COMMON-SAME: (%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}}* addrspace(4)* [[WAIT_EVNT]], %opencl.clk_event_t{{.*}}* addrspace(4)* [[EVNT]], // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVGK4:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*), // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* [[BLG4]] to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, @@ -179,7 +179,7 @@ // B64: %[[TMP:.*]] = alloca [1 x i64] // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0 // B64: store i64 %{{.*}}, i64* %[[TMP1]], align 8 - // COMMON-LABEL: call i32 @__enqueue_kernel_vaargs + // COMMON-LABEL: call i32 @__enqueue_kernel_varargs // COMMON-SAME: (%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{([0-9]+)?}}, // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVGK5:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*), // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* [[BLG5]] to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, @@ -208,7 +208,7 @@ // B64: store i64 2, i64* %[[TMP2]], align 8 // B64: %[[TMP3:.*]] = getelementptr [3 x i64], [3 x i64]* %[[TMP]], i32 0, i32 2 // B64: store i64 4, i64* %[[TMP3]], align 8 - // COMMON-LABEL: call i32 @__enqueue_kernel_vaargs + // COMMON-LABEL: call i32 @__enqueue_kernel_varargs // COMMON-SAME: (%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{([0-9]+)?}}, // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVGK6:[^ ]+_kernel]] to i8*) to i
[PATCH] D42966: Fix USR generation in the presence of #line directives or linemarkes
ilya-biryukov added a comment. In https://reviews.llvm.org/D42966#1085303, @mikhail.ramalho wrote: > Hi, > > > Where do virtual files come from in the first place? > > From the linemarker: I tried dumping locations in presence of line markers. They have non-null `FileEntry` and a reasonable offset, so the original code should work just fine in presence of line markers. I don't see why changing to presumed locations fixes the issue with not generating the USRs. Could you provide a minimal example where USRs are not generated? It might be the case that there are other ways to fix it. Repository: rC Clang https://reviews.llvm.org/D42966 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework
juliehockett added a comment. In https://reviews.llvm.org/D43341#1093117, @juliehockett wrote: > This will break things in clang-tools-extra without > https://reviews.llvm.org/D46615, so I'm going to hold off landing this until > that goes through Oops wrong patch disregard https://reviews.llvm.org/D43341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46614: [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective
juliehockett added a comment. This will break things in clang-tools-extra without https://reviews.llvm.org/D46615, so I'm going to hold off landing this until that goes through https://reviews.llvm.org/D46614 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46485: Add python tool to dump and construct header maps
bruno added a comment. Ping! Repository: rC Clang https://reviews.llvm.org/D46485 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46651: [OpenCL] Support placement new/delete in Sema
svenvh created this revision. svenvh added reviewers: yaxunl, Anastasia. Herald added a subscriber: cfe-commits. Stop crashing on placement new/delete in OpenCL C++ mode, and reject non-placement new/delete with a diagnostic instead of a crash. Repository: rC Clang https://reviews.llvm.org/D46651 Files: lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaType.cpp test/SemaOpenCLCXX/newdelete.cl Index: test/SemaOpenCLCXX/newdelete.cl === --- /dev/null +++ test/SemaOpenCLCXX/newdelete.cl @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only + +class A { + public: + A() : x(21) {} + int x; +}; + +typedef __SIZE_TYPE__ size_t; +void *operator new(size_t _s, void *ptr) noexcept { + return ptr; +} + +void *operator new[](size_t _s, void *ptr) noexcept { + return ptr; +} + +// Test that only placement new and delete are available. +void test_new_delete(void *buffer, A **a) { + *a = new A; // expected-error {{'non-placement new/delete' is not supported in OpenCL C++}} + delete a; // expected-error {{'delete' is not supported in OpenCL C++}} + + a = new A[20]; // expected-error {{'non-placement new/delete' is not supported in OpenCL C++}} + delete[] a;// expected-error {{'delete' is not supported in OpenCL C++}} + + // Placement new is supported. + *a = new (buffer) A; + + // Placement new is supported. + *a = new (buffer) A[30]; +} Index: lib/Sema/SemaType.cpp === --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -7137,8 +7137,9 @@ // The default address space name for arguments to a function in a // program, or local variables of a function is __private. All function // arguments shall be in the __private address space. - if (State.getSema().getLangOpts().OpenCLVersion <= 120) { - ImpAddr = LangAS::opencl_private; + if (State.getSema().getLangOpts().OpenCLVersion <= 120 && + !State.getSema().getLangOpts().OpenCLCPlusPlus) { +ImpAddr = LangAS::opencl_private; } else { // If address space is not set, OpenCL 2.0 defines non private default // address spaces for some cases: Index: lib/Sema/SemaExprCXX.cpp === --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -2019,6 +2019,15 @@ if (!AllPlaceArgs.empty()) PlacementArgs = AllPlaceArgs; +else { + // OpenCL C++ 1.0 s2.9: non-placement new and delete operators are + // not supported. + if (getLangOpts().OpenCLCPlusPlus) { +Diag(StartLoc, diag::err_openclcxx_not_supported) +<< "non-placement new/delete"; +return ExprError(); + } +} // FIXME: This is wrong: PlacementArgs misses out the first (size) argument. DiagnoseSentinelCalls(OperatorNew, PlacementLParen, PlacementArgs); @@ -2146,7 +2155,8 @@ else if (AllocType->isVariablyModifiedType()) return Diag(Loc, diag::err_variably_modified_new_type) << AllocType; - else if (AllocType.getAddressSpace() != LangAS::Default) + else if (AllocType.getAddressSpace() != LangAS::Default && + !getLangOpts().OpenCLCPlusPlus) return Diag(Loc, diag::err_address_space_qualified_new) << AllocType.getUnqualifiedType() << AllocType.getQualifiers().getAddressSpaceAttributePrintValue(); @@ -3157,6 +3167,11 @@ bool ArrayFormAsWritten = ArrayForm; bool UsualArrayDeleteWantsSize = false; + if (getLangOpts().OpenCLCPlusPlus) { +Diag(StartLoc, diag::err_openclcxx_not_supported) << "delete"; +return ExprError(); + } + if (!Ex.get()->isTypeDependent()) { // Perform lvalue-to-rvalue cast, if needed. Ex = DefaultLvalueConversion(Ex.get()); Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -12981,6 +12981,18 @@ diag::err_operator_new_delete_dependent_result_type) << FnDecl->getDeclName() << ExpectedResultType; + // OpenCL C++: ignore the address space as the operator is valid on any + // address space. + if (SemaRef.getLangOpts().OpenCLCPlusPlus) { +if (auto *PtrTy = ResultType.getTypePtr()->getAs()) { + QualType PteeTy = PtrTy->getPointeeType(); + Qualifiers Quals = PteeTy.getQualifiers(); + Quals.removeAddressSpace(); + ResultType = SemaRef.Context.getQualifiedType(PteeTy.getUnqualifiedType(), Quals); + ResultType = SemaRef.Context.getPointerType(ResultType); +} + } + // Check that the result type is what we expect. if (SemaRef.Context.getCanonicalType(ResultType) != ExpectedResultType) return SemaRef.Diag(FnDecl->getLocation(), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/
[PATCH] D46615: [tools] Updating PPCallbacks::InclusionDirective calls
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. Aside from a minor nit, LGTM (no need for more review, you can fix the nit and commit). Comment at: clang-move/ClangMove.cpp:135 + const clang::Module * /*Imported*/, + SrcMgr::CharacteristicKind FileType) override { if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc))) Put `FileType` into comments so the parameter is unnamed like the other unused ones. https://reviews.llvm.org/D46615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331899 - [OPENMP] Generate unique names for offloading regions id.
Author: abataev Date: Wed May 9 11:02:37 2018 New Revision: 331899 URL: http://llvm.org/viewvc/llvm-project?rev=331899&view=rev Log: [OPENMP] Generate unique names for offloading regions id. It is required to emit unique names for offloading regions ids. Required to support compilation and linking of several compilation units. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/test/OpenMP/target_is_device_ptr_codegen.cpp cfe/trunk/test/OpenMP/target_map_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=331899&r1=331898&r2=331899&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed May 9 11:02:37 2018 @@ -6286,7 +6286,7 @@ void CGOpenMPRuntime::emitTargetOutlined OutlinedFn->setLinkage(llvm::GlobalValue::WeakAnyLinkage); OutlinedFn->setDSOLocal(false); } else { -std::string Name = getName({"omp_offload", "region_id"}); +std::string Name = getName({EntryFnName, "region_id"}); OutlinedFnID = new llvm::GlobalVariable( CGM.getModule(), CGM.Int8Ty, /*isConstant=*/true, llvm::GlobalValue::WeakAnyLinkage, Modified: cfe/trunk/test/OpenMP/target_is_device_ptr_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_is_device_ptr_codegen.cpp?rev=331899&r1=331898&r2=331899&view=diff == --- cfe/trunk/test/OpenMP/target_is_device_ptr_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/target_is_device_ptr_codegen.cpp Wed May 9 11:02:37 2018 @@ -206,12 +206,18 @@ void bar(float *&a, int *&b) { // CK2: [[ST:%.+]] = type { double*, double** } +// CK2-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}_l245.region_id = weak constant i8 0 + // CK2: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} {{8|4}}] // CK2: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 33] +// CK2-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}_l269.region_id = weak constant i8 0 + // CK2: [[SIZE01:@.+]] = {{.+}}constant [2 x i[[sz]]] [i[[sz]] {{8|4}}, i[[sz]] {{8|4}}] // CK2: [[MTYPE01:@.+]] = {{.+}}constant [2 x i64] [i64 32, i64 17] +// CK2-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}_l301.region_id = weak constant i8 0 + // CK2: [[SIZE02:@.+]] = {{.+}}constant [3 x i[[sz]]] [i[[sz]] {{8|4}}, i[[sz]] {{8|4}}, i[[sz]] {{8|4}}] // CK2: [[MTYPE02:@.+]] = {{.+}}constant [3 x i64] [i64 33, i64 0, i64 17] Modified: cfe/trunk/test/OpenMP/target_map_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_codegen.cpp?rev=331899&r1=331898&r2=331899&view=diff == --- cfe/trunk/test/OpenMP/target_map_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/target_map_codegen.cpp Wed May 9 11:02:37 2018 @@ -39,6 +39,8 @@ public: }; double B::VAR = 1.0; +// CK1-LABEL: @.__omp_offloading_{{.*}}implicit_maps_integer{{.*}}_l68.region_id = weak constant i8 0 + // CK1-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288 // CK1-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 288] @@ -94,9 +96,14 @@ void implicit_maps_integer (int a){ // SIMD-ONLY1-NOT: {{__kmpc|__tgt}} #ifdef CK2 +// CK2-LABEL: @.__omp_offloading_{{.*}}implicit_maps_reference{{.*}}_l128.region_id = weak constant i8 0 + // CK2: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288 // CK2: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 288] + +// CK2-LABEL: @.__omp_offloading_{{.*}}implicit_maps_reference{{.*}}_l147.region_id = weak constant i8 0 + // CK2: [[SIZES2:@.+]] = {{.+}}constant [1 x i[[sz]]] zeroinitializer // Map types: OMP_MAP_IS_PTR = 32 // CK2: [[TYPES2:@.+]] = {{.+}}constant [1 x i64] [i64 32] @@ -181,6 +188,8 @@ void implicit_maps_reference (int a, int // SIMD-ONLY2-NOT: {{__kmpc|__tgt}} #ifdef CK3 +// CK3-LABEL: @.__omp_offloading_{{.*}}implicit_maps_parameter{{.*}}_l214.region_id = weak constant i8 0 + // CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288 // CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 288] @@ -233,6 +242,8 @@ void implicit_maps_parameter (int a){ // SIMD-ONLY3-NOT: {{__kmpc|__tgt}} #ifdef CK4 +// CK4-LABEL: @.__omp_offloading_{{.*}}implicit_maps_nested_integer{{.*}}_l276.region_id = weak constant i8 0 + // CK4-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288 // CK4-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 288] @@ -297,6 +308,8 @@ void implicit_maps_nested_integer (int a
[PATCH] D46652: [clang-cl, PCH] Implement support for MS-style PCH through headers
mikerice created this revision. mikerice added reviewers: rnk, thakis, erichkeane, cfe-commits. Implement support for MS-style PCH through headers. This enables support for /Yc and /Yu where the through header is either on the command line or included in the source. It replaces the current support the requires the header also be specified with /FI. This change adds a -cc1 option -pch-through-header that is used to either start or stop compilation during PCH create or use. When creating a PCH, the compilation ends after compilation of the through header. When using a PCH, tokens are skipped until after the through header is seen. Repository: rC Clang https://reviews.llvm.org/D46652 Files: include/clang/Basic/DiagnosticLexKinds.td include/clang/Driver/CC1Options.td include/clang/Frontend/FrontendOptions.h include/clang/Lex/Preprocessor.h include/clang/Lex/PreprocessorOptions.h lib/Driver/Driver.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInstance.cpp lib/Frontend/CompilerInvocation.cpp lib/Lex/PPDirectives.cpp lib/Lex/PPLexerChange.cpp lib/Lex/Preprocessor.cpp lib/Parse/ParseAST.cpp lib/Serialization/ASTReader.cpp test/Driver/cl-pch-search.cpp test/Driver/cl-pch.cpp test/PCH/Inputs/pch-through-use0.cpp test/PCH/Inputs/pch-through-use1.cpp test/PCH/Inputs/pch-through-use2.cpp test/PCH/Inputs/pch-through1.h test/PCH/Inputs/pch-through2.h test/PCH/Inputs/pch-through3.h test/PCH/Inputs/pch-through4.h test/PCH/pch-through.cpp Index: test/PCH/pch-through.cpp === --- /dev/null +++ test/PCH/pch-through.cpp @@ -0,0 +1,72 @@ +// Through header not found (anywhere) +// RUN: not %clang_cc1 -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-does-not-exist.h -o %t %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST0A %s +// CHECK-TEST0A: fatal error:{{.*}} 'Inputs/pch-does-not-exist.h' +// CHECK-TEST0A-SAME: required for precompiled header not found + +// Through header not found in search path +// RUN: not %clang_cc1 -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through2.h -o %t \ +// RUN: %S/Inputs/pch-through-use0.cpp 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST0B %s +// CHECK-TEST0B: fatal error:{{.*}}'Inputs/pch-through2.h' +// CHECK-TEST0B-SAME: required for precompiled header not found + +// No #include of through header during pch create +// RUN: not %clang_cc1 -DSOURCE1 -I %S -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through2.h -o %t %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST1A %s +// CHECK-TEST1A: fatal error:{{.*}} #include of +// CHECK-TEST1A-SAME: 'Inputs/pch-through2.h' not seen while attempting to +// CHECK-TEST1A-SAME: create precompiled header + +#ifdef SOURCE1 +#endif + +// Create +// RUN: %clang_cc1 -DSOURCE2 -I %S -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through2.h -o %t.s2t2 %s + +// Use +// RUN: %clang_cc1 -DSOURCE2 -I %S -include-pch %t.s2t2 \ +// RUN: -pch-through-header=Inputs/pch-through2.h %s + +#ifdef SOURCE2 +#include "Inputs/pch-through1.h" +#include "Inputs/pch-through2.h" +#endif + +// No #include of through header during pch use +// RUN: not %clang_cc1 -I %S -include-pch %t.s2t2 \ +// RUN: -pch-through-header=Inputs/pch-through2.h \ +// RUN: %S/Inputs/pch-through-use1.cpp 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST2A %s +// CHECK-TEST2A: fatal error:{{.*}} #include of +// CHECK-TEST2A-SAME: 'Inputs/pch-through2.h' not seen while attempting to +// CHECK-TEST2A-SAME: use precompiled header + +// check that pch only contains code before the through header. +// RUN: %clang_cc1 -DSOURCE2 -I %S -emit-pch \ +// RUN: -pch-through-header=Inputs/pch-through1.h -o %t.s2t1 %s +// RUN: not %clang_cc1 -I %S -include-pch %t.s2t1 \ +// RUN: -pch-through-header=Inputs/pch-through1.h \ +// RUN: %S/Inputs/pch-through-use1.cpp 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-TEST3 %s +// CHECK-TEST3: error: use of undeclared identifier 'through2' + +#ifdef SOURCE3 +#endif + +// checks for through headers that are also -includes +// RUN: %clang_cc1 -DSOURCE3 -I %S -include Inputs/pch-through1.h \ +// RUN: -pch-through-header=Inputs/pch-through1.h -emit-pch -o %t.s3t1 %s +// RUN: %clang_cc1 -DSOURCE3 -I %S -include Inputs/pch-through1.h \ +// RUN: -include Inputs/pch-through2.h -include Inputs/pch-through3.h \ +// RUN: -pch-through-header=Inputs/pch-through2.h -emit-pch -o %t.s3t2 %s +// Use through header from -includes +// RUN: %clang_cc1 -DSOURCE3 -I %S -include Inputs/pch-through1.h \ +// RUN: -include Inputs/pch-through2.h -include Inputs/pch-through4.h \ +// RUN: -pch-through-header=Inputs/pch-through2.h -include-pch %t.s3t2 \ +// RUN: %S/Inputs/pch-through-use2.cpp -o %t.out + Index: test/PCH/Inputs/pch-through4.h === --- /dev/null +++ test/PCH/Inputs/pch-through4.h @@ -0,0 +1,2 @@ +#define THROUGH4 +in
[PATCH] D46633: [analyzer] add range check for InitList lookup
george.karpenkov added a comment. Looks good, thanks! Repository: rL LLVM https://reviews.llvm.org/D46633 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46643: CodeGen: Emit string literal in constant address space
rjmccall added a comment. The part about string literals looks fine, but: Comment at: lib/CodeGen/CGDecl.cpp:1375 +Loc = Address(EmitCastToVoidPtrInAllocaAddrSpace(Loc.getPointer()), + Loc.getAlignment()); I don't understand why a patch about string literals is changing auto variable emission. https://reviews.llvm.org/D46643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331904 - [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective
Author: juliehockett Date: Wed May 9 11:27:33 2018 New Revision: 331904 URL: http://llvm.org/viewvc/llvm-project?rev=331904&view=rev Log: [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective Adding a SrcMgr::CharacteristicKind parameter to the InclusionDirective in PPCallbacks, and updating calls to that function. This will be useful in https://reviews.llvm.org/D43778 to determine which includes are system headers. Differential Revision: https://reviews.llvm.org/D46614 Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h cfe/trunk/include/clang/Lex/PreprocessingRecord.h cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp cfe/trunk/lib/CodeGen/MacroPPCallbacks.h cfe/trunk/lib/Frontend/DependencyFile.cpp cfe/trunk/lib/Frontend/DependencyGraph.cpp cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/PreprocessingRecord.cpp cfe/trunk/tools/libclang/Indexing.cpp cfe/trunk/unittests/Lex/PPCallbacksTest.cpp Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=331904&r1=331903&r2=331904&view=diff == --- cfe/trunk/include/clang/Lex/PPCallbacks.h (original) +++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed May 9 11:27:33 2018 @@ -117,6 +117,10 @@ public: /// \param Imported The module, whenever an inclusion directive was /// automatically turned into a module import or null otherwise. /// + /// \param FileType The characteristic kind, indicates whether a file or + /// directory holds normal user code, system code, or system code which is + /// implicitly 'extern "C"' in C++ mode. + /// virtual void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, @@ -125,7 +129,8 @@ public: const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) { + const Module *Imported, + SrcMgr::CharacteristicKind FileType) { } /// Callback invoked whenever there was an explicit module-import @@ -367,13 +372,14 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override { + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override { First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, FilenameRange, File, SearchPath, RelativePath, - Imported); + Imported, FileType); Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, FilenameRange, File, SearchPath, RelativePath, - Imported); + Imported, FileType); } void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=331904&r1=331903&r2=331904&view=diff == --- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original) +++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed May 9 11:27:33 2018 @@ -532,8 +532,8 @@ class Token; StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, -StringRef RelativePath, -const Module *Imported) override; +StringRef RelativePath, const Module *Imported, +SrcMgr::CharacteristicKind FileType) override; void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override; void Ifndef(SourceLocation Loc, const Token &MacroNameTok, Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=331904&r1=331903&r2=331904&view=diff == --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original) +++ cfe/trunk/lib/CodeGen/MacroPPCallback
[clang-tools-extra] r331905 - [tools] Updating PPCallbacks::InclusionDirective calls
Author: juliehockett Date: Wed May 9 11:27:37 2018 New Revision: 331905 URL: http://llvm.org/viewvc/llvm-project?rev=331905&view=rev Log: [tools] Updating PPCallbacks::InclusionDirective calls [revision] added SrcMgr::CharacteristicKind to the InclusionDirective callback, this revision updates instances of it in clang-tools-extra. Differential Revision: https://reviews.llvm.org/D46615 Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/clangd/Headers.cpp clang-tools-extra/trunk/modularize/CoverageChecker.cpp clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=331905&r1=331904&r2=331905&view=diff == --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Wed May 9 11:27:37 2018 @@ -131,7 +131,8 @@ public: clang::CharSourceRange FilenameRange, const clang::FileEntry * /*File*/, StringRef SearchPath, StringRef /*RelativePath*/, - const clang::Module * /*Imported*/) override { + const clang::Module * /*Imported*/, + SrcMgr::CharacteristicKind /*FileType*/) override { if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc))) MoveTool->addIncludes(FileName, IsAngled, SearchPath, FileEntry->getName(), FilenameRange, SM); Modified: clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp?rev=331905&r1=331904&r2=331905&view=diff == --- clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp Wed May 9 11:27:37 2018 @@ -28,7 +28,8 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override; + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override; void EndOfMainFile() override; private: @@ -76,7 +77,8 @@ static int getPriority(StringRef Filenam void IncludeOrderPPCallbacks::InclusionDirective( SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, -StringRef SearchPath, StringRef RelativePath, const Module *Imported) { +StringRef SearchPath, StringRef RelativePath, const Module *Imported, +SrcMgr::CharacteristicKind FileType) { // We recognize the first include as a special main module header and want // to leave it in the top position. IncludeDirective ID = {HashLoc, FilenameRange, FileName, IsAngled, false}; Modified: clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=331905&r1=331904&r2=331905&view=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp Wed May 9 11:27:37 2018 @@ -30,7 +30,8 @@ public: StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override; + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override; private: ClangTidyCheck &Check; @@ -94,7 +95,8 @@ IncludeModernizePPCallbacks::IncludeMode void IncludeModernizePPCallbacks::InclusionDirective( SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, -StringRef SearchPath, StringRef RelativePath, const Module *Imported) { +StringRef SearchPath,
[PATCH] D46614: [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective
This revision was automatically updated to reflect the committed changes. Closed by commit rL331904: [clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective (authored by juliehockett, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D46614?vs=145941&id=145971#toc Repository: rL LLVM https://reviews.llvm.org/D46614 Files: cfe/trunk/include/clang/Lex/PPCallbacks.h cfe/trunk/include/clang/Lex/PreprocessingRecord.h cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp cfe/trunk/lib/CodeGen/MacroPPCallbacks.h cfe/trunk/lib/Frontend/DependencyFile.cpp cfe/trunk/lib/Frontend/DependencyGraph.cpp cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/PreprocessingRecord.cpp cfe/trunk/tools/libclang/Indexing.cpp cfe/trunk/unittests/Lex/PPCallbacksTest.cpp Index: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp === --- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp +++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp @@ -50,7 +50,8 @@ StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override { + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override { if (!File) return; Collector.addFile(File->getName()); Index: cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp === --- cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp +++ cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp @@ -77,7 +77,8 @@ StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override; + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override; void WriteLineInfo(StringRef Filename, int Line, SrcMgr::CharacteristicKind FileType, StringRef Extra = StringRef()); @@ -192,7 +193,8 @@ const FileEntry * /*File*/, StringRef /*SearchPath*/, StringRef /*RelativePath*/, - const Module *Imported) { + const Module *Imported, + SrcMgr::CharacteristicKind FileType){ if (Imported) { auto P = ModuleIncludes.insert( std::make_pair(HashLoc.getRawEncoding(), Imported)); Index: cfe/trunk/lib/Frontend/DependencyGraph.cpp === --- cfe/trunk/lib/Frontend/DependencyGraph.cpp +++ cfe/trunk/lib/Frontend/DependencyGraph.cpp @@ -50,7 +50,8 @@ StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override; + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override; void EndOfMainFile() override { OutputGraphFile(); @@ -65,15 +66,17 @@ SysRoot)); } -void DependencyGraphCallback::InclusionDirective(SourceLocation HashLoc, - const Token &IncludeTok, - StringRef FileName, - bool IsAngled, - CharSourceRange FilenameRange, - const FileEntry *File, - StringRef SearchPath, - StringRef RelativePath, - const Module *Imported) { +void DependencyGraphCallback::InclusionDirective( +SourceLocation HashLoc, +const Token &IncludeTok, +StringRef FileName, +bool IsAngled, +CharSourceRange FilenameRange, +const FileEntry *File, +StringRef SearchPath, +StringRef RelativePath, +const Module *Imported, +SrcMgr::CharacteristicKind FileType) { if (!File) return; Index: cfe/trunk/lib/Fro
[PATCH] D46615: [tools] Updating PPCallbacks::InclusionDirective calls
This revision was automatically updated to reflect the committed changes. juliehockett marked an inline comment as done. Closed by commit rL331905: [tools] Updating PPCallbacks::InclusionDirective calls (authored by juliehockett, committed by ). Herald added subscribers: llvm-commits, ilya-biryukov, klimek. Changed prior to commit: https://reviews.llvm.org/D46615?vs=145823&id=145972#toc Repository: rL LLVM https://reviews.llvm.org/D46615 Files: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/clangd/Headers.cpp clang-tools-extra/trunk/modularize/CoverageChecker.cpp clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h Index: clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp @@ -28,7 +28,8 @@ StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override; + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override; void EndOfMainFile() override; private: @@ -76,7 +77,8 @@ void IncludeOrderPPCallbacks::InclusionDirective( SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, -StringRef SearchPath, StringRef RelativePath, const Module *Imported) { +StringRef SearchPath, StringRef RelativePath, const Module *Imported, +SrcMgr::CharacteristicKind FileType) { // We recognize the first include as a special main module header and want // to leave it in the top position. IncludeDirective ID = {HashLoc, FilenameRange, FileName, IsAngled, false}; Index: clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp === --- clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp +++ clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp @@ -25,7 +25,8 @@ bool IsAngled, CharSourceRange FileNameRange, const FileEntry * /*IncludedFile*/, StringRef /*SearchPath*/, StringRef /*RelativePath*/, - const Module * /*ImportedModule*/) override { + const Module * /*ImportedModule*/, + SrcMgr::CharacteristicKind /*FileType*/) override { Inserter->AddInclude(FileNameRef, IsAngled, HashLocation, IncludeToken.getEndLoc()); } Index: clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp @@ -30,7 +30,8 @@ StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module *Imported) override; + const Module *Imported, + SrcMgr::CharacteristicKind FileType) override; private: ClangTidyCheck &Check; @@ -94,7 +95,8 @@ void IncludeModernizePPCallbacks::InclusionDirective( SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, -StringRef SearchPath, StringRef RelativePath, const Module *Imported) { +StringRef SearchPath, StringRef RelativePath, const Module *Imported, +SrcMgr::CharacteristicKind FileType) { // FIXME: Take care of library symbols from the global namespace. // // Reasonable options for the check: Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp === --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp @@ -93,7 +93,8 @@ StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, - const Module
[PATCH] D46651: [OpenCL] Support placement new/delete in Sema
rjmccall added inline comments. Comment at: lib/Sema/SemaExprCXX.cpp:2030 + } +} I think a better interpretation of this rule would be to just error on attempts to use the standard non-placement operator new/delete instead of trying to outlaw the operator declarations. For example, I don't know why a user-defined non-global operator new would be problematic. Repository: rC Clang https://reviews.llvm.org/D46651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45470: Emit an error when include after
vsapsai added a comment. In https://reviews.llvm.org/D45470#1092260, @jfb wrote: > In https://reviews.llvm.org/D45470#1092212, @vsapsai wrote: > > > Here is another approach that should emit an error only when mixing headers > > causes compilation problems. > > > > Have no ideas how to test the change. `-verify` doesn't work with fatal > > errors > > and libcxx doesn't use FileCheck. Performed only manual testing. > > > This worked with `` before `` as well as with the order > reversed? #include #include > fatal error: too many errors emitted, stopping now [-ferror-limit=] #include #include > no errors So when `` is //after// ``, I add one more error to existing. When `` is //before// ``, there are no errors and I don't add anything. https://reviews.llvm.org/D45470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module
juliehockett added inline comments. Comment at: docs/ReleaseNotes.rst:116 + + Checks for allowed system includes and suggests removal of any others. If no + includes are specified, the check will exit without issuing any warnings. Eugene.Zelenko wrote: > Is it necessary to highlight that warnings will not be emitted in case of > disallowed headers are not found? Same in documentation. I'm not sure I understand what you're saying...are you saying if the documentation should not include anything about what happens in the case of no headers? Comment at: docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst:32 + A string containing a semi-colon separated list of allowed include filenames. + The default is an empty string, which allows all includes. aaron.ballman wrote: > This default seems a bit odd to me, but perhaps it's fine. What's novel is > that the check is a no-op by default, so how do Fuchsia developers get the > correct list? Or is there no canonical list and developers are expected to > populate their own manually? The idea is that it's a case-by-case basis -- this may change at some point in the future if we decide there's a standard whitelist of system includes across the board, but at the moment the thought is to allow everything in some places, and use this check to limit them in others. It'll need to be populated on a case-by-case basis, since different directories will have different requirements. https://reviews.llvm.org/D43778 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module
juliehockett updated this revision to Diff 145978. juliehockett marked 3 inline comments as done. juliehockett added a comment. Updating the inclusiondirective to filter out non-system files https://reviews.llvm.org/D43778 Files: clang-tidy/fuchsia/CMakeLists.txt clang-tidy/fuchsia/FuchsiaTidyModule.cpp clang-tidy/fuchsia/RestrictSystemIncludesCheck.cpp clang-tidy/fuchsia/RestrictSystemIncludesCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/fuchsia-restrict-system-includes.rst docs/clang-tidy/checks/list.rst test/clang-tidy/Inputs/fuchsia-restrict-system-includes/a.h test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/j.h test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/s.h test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/t.h test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp test/clang-tidy/fuchsia-restrict-system-includes.cpp Index: test/clang-tidy/fuchsia-restrict-system-includes.cpp === --- /dev/null +++ test/clang-tidy/fuchsia-restrict-system-includes.cpp @@ -0,0 +1,25 @@ +// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \ +// RUN: -- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: 's.h'}]}" \ +// RUN: -- -std=c++11 -I %S/Inputs/fuchsia-restrict-system-includes -isystem %S/Inputs/fuchsia-restrict-system-includes/system + +#include "a.h" + +#include +#include +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed +// CHECK-FIXES-NOT: #include + +#include "s.h" +#include "t.h" +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed +// CHECK-FIXES-NOT: #include "t.h" + +#define foo + +#include foo +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed +// CHECK-FIXES-NOT: #include foo + +#/* comment */ include /* comment */ foo +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed +// CHECK-FIXES-NOT: # /* comment */ include /* comment */ foo Index: test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp === --- /dev/null +++ test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp @@ -0,0 +1,20 @@ +// RUN: cp -r %S/Inputs/fuchsia-restrict-system-includes %T/Inputs +// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \ +// RUN: -- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: 'transitive.h;s.h'}]}" \ +// RUN: -system-headers -header-filter=.* \ +// RUN: -- -std=c++11 -I %T/Inputs/fuchsia-restrict-system-includes -isystem %T/Inputs/fuchsia-restrict-system-includes/system +// RUN: FileCheck -input-file=%T/Inputs/transitive2.h %s -check-prefix=CHECK-HEADER-FIXES + +// transitive.h includes and +#include +// CHECK-MESSAGES: :1:1: warning: system include r.h not allowed, transitively included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/system/transitive.h +// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/system/transitive.h + +// transitive.h includes and +#include "transitive2.h" +// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/transitive2.h +// CHECK-HEADER-FIXES-NOT: #include + +int main() { + // f() is declared in r.h +} Index: test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h === --- /dev/null +++ test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h @@ -0,0 +1,2 @@ +#include +#include Index: test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h === --- /dev/null +++ test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h @@ -0,0 +1,3 @@ +#include +#include +#include Index: test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h === --- /dev/null +++ test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h @@ -0,0 +1 @@ +void f() {} Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -95,6 +95,7 @@ fuchsia-default-arguments fuchsia-multiple-inheritance fuchsia-overloaded-operator + fuchsia-restrict-system-includes fuchsia-statically-constructed-objects fuchsia-trailing-return fuchsia-virtual-inheritance Index: docs/clang-tidy/checks
[PATCH] D46593: Allow copy elision in path concatenation
This revision was automatically updated to reflect the committed changes. Closed by commit rCXX331910: Allow copy elision in path concatenation (authored by xbolva00, committed by ). Repository: rCXX libc++ https://reviews.llvm.org/D46593 Files: include/experimental/filesystem Index: include/experimental/filesystem === --- include/experimental/filesystem +++ include/experimental/filesystem @@ -1140,7 +1140,9 @@ inline _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs, const path& __rhs) { -return path(__lhs) /= __rhs; +path __result(__lhs); +__result /= __rhs; +return __result; } template Index: include/experimental/filesystem === --- include/experimental/filesystem +++ include/experimental/filesystem @@ -1140,7 +1140,9 @@ inline _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs, const path& __rhs) { -return path(__lhs) /= __rhs; +path __result(__lhs); +__result /= __rhs; +return __result; } template ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46656: [Builtins] Improve the IR emitted for MSVC compatible rotr/rotl builtins to match what the middle and backends understand
craig.topper created this revision. craig.topper added a reviewer: spatel. Currently we emit something like rotl(x, n) { n &= bitwidth -1; return n != 0 ? ((x << n) | (x >> (bitwidth - n)) : x; } We use a select to avoid the undefined behavior on the (bitwidth - n) shift. The middle and backend don't really recognize this as a rotate and end up emitting a cmov or control flow because of the select. A better pattern is (x << (n & mask)) | (x << (-n & mask)) where mask is bitwidth - 1. Fixes the main complaint in PR37387. There's still some work to be done if the user writes that sequence directly on a short or char where type promotion rules can prevent it from being recognized. The builtin is emitting direct IR with unpromoted types so that isn't a problem for it. https://reviews.llvm.org/D46656 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/ms-intrinsics-rotations.c Index: test/CodeGen/ms-intrinsics-rotations.c === --- test/CodeGen/ms-intrinsics-rotations.c +++ test/CodeGen/ms-intrinsics-rotations.c @@ -30,69 +30,64 @@ return _rotl8(value, shift); } // CHECK: i8 @test_rotl8 -// CHECK: [[SHIFT:%[0-9]+]] = and i8 %{{[0-9]+}}, 7 -// CHECK: [[NEGSHIFT:%[0-9]+]] = sub i8 8, [[SHIFT]] -// CHECK: [[HIGH:%[0-9]+]] = shl i8 [[VALUE:%[0-9]+]], [[SHIFT]] -// CHECK: [[LOW:%[0-9]+]] = lshr i8 [[VALUE]], [[NEGSHIFT]] -// CHECK: [[ROTATED:%[0-9]+]] = or i8 [[HIGH]], [[LOW]] -// CHECK: [[ISZERO:%[0-9]+]] = icmp eq i8 [[SHIFT]], 0 -// CHECK: [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i8 [[VALUE]], i8 [[ROTATED]] +// CHECK: [[LSHIFT:%[0-9]+]] = and i8 [[SHIFT:%[0-9]+]], 7 +// CHECK: [[HIGH:%[0-9]+]] = shl i8 [[VALUE:%[0-9]+]], [[LSHIFT]] +// CHECK: [[NEGATE:%[0-9]+]] = sub i8 0, [[SHIFT]] +// CHECK: [[RSHIFT:%[0-9]+]] = and i8 [[NEGATE]], 7 +// CHECK: [[LOW:%[0-9]+]] = lshr i8 [[VALUE]], [[RSHIFT]] +// CHECK: [[RESULT:%[0-9]+]] = or i8 [[HIGH]], [[LOW]] // CHECK: ret i8 [[RESULT]] // CHECK } unsigned short test_rotl16(unsigned short value, unsigned char shift) { return _rotl16(value, shift); } // CHECK: i16 @test_rotl16 -// CHECK: [[SHIFT:%[0-9]+]] = and i16 %{{[0-9]+}}, 15 -// CHECK: [[NEGSHIFT:%[0-9]+]] = sub i16 16, [[SHIFT]] -// CHECK: [[HIGH:%[0-9]+]] = shl i16 [[VALUE:%[0-9]+]], [[SHIFT]] -// CHECK: [[LOW:%[0-9]+]] = lshr i16 [[VALUE]], [[NEGSHIFT]] -// CHECK: [[ROTATED:%[0-9]+]] = or i16 [[HIGH]], [[LOW]] -// CHECK: [[ISZERO:%[0-9]+]] = icmp eq i16 [[SHIFT]], 0 -// CHECK: [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i16 [[VALUE]], i16 [[ROTATED]] +// CHECK: [[LSHIFT:%[0-9]+]] = and i16 [[SHIFT:%[0-9]+]], 15 +// CHECK: [[HIGH:%[0-9]+]] = shl i16 [[VALUE:%[0-9]+]], [[LSHIFT]] +// CHECK: [[NEGATE:%[0-9]+]] = sub i16 0, [[SHIFT]] +// CHECK: [[RSHIFT:%[0-9]+]] = and i16 [[NEGATE]], 15 +// CHECK: [[LOW:%[0-9]+]] = lshr i16 [[VALUE]], [[RSHIFT]] +// CHECK: [[RESULT:%[0-9]+]] = or i16 [[HIGH]], [[LOW]] // CHECK: ret i16 [[RESULT]] // CHECK } unsigned int test_rotl(unsigned int value, int shift) { return _rotl(value, shift); } // CHECK: i32 @test_rotl -// CHECK: [[SHIFT:%[0-9]+]] = and i32 %{{[0-9]+}}, 31 -// CHECK: [[NEGSHIFT:%[0-9]+]] = sub i32 32, [[SHIFT]] -// CHECK: [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[SHIFT]] -// CHECK: [[LOW:%[0-9]+]] = lshr i32 [[VALUE]], [[NEGSHIFT]] -// CHECK: [[ROTATED:%[0-9]+]] = or i32 [[HIGH]], [[LOW]] -// CHECK: [[ISZERO:%[0-9]+]] = icmp eq i32 [[SHIFT]], 0 -// CHECK: [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i32 [[VALUE]], i32 [[ROTATED]] +// CHECK: [[LSHIFT:%[0-9]+]] = and i32 [[SHIFT:%[0-9]+]], 31 +// CHECK: [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[LSHIFT]] +// CHECK: [[NEGATE:%[0-9]+]] = sub i32 0, [[SHIFT]] +// CHECK: [[RSHIFT:%[0-9]+]] = and i32 [[NEGATE]], 31 +// CHECK: [[LOW:%[0-9]+]] = lshr i32 [[VALUE]], [[RSHIFT]] +// CHECK: [[RESULT:%[0-9]+]] = or i32 [[HIGH]], [[LOW]] // CHECK: ret i32 [[RESULT]] // CHECK } unsigned LONG test_lrotl(unsigned LONG value, int shift) { return _lrotl(value, shift); } // CHECK-32BIT-LONG: i32 @test_lrotl -// CHECK-32BIT-LONG: [[SHIFT:%[0-9]+]] = and i32 %{{[0-9]+}}, 31 -// CHECK-32BIT-LONG: [[NEGSHIFT:%[0-9]+]] = sub i32 32, [[SHIFT]] -// CHECK-32BIT-LONG: [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[SHIFT]] -// CHECK-32BIT-LONG: [[LOW:%[0-9]+]] = lshr i32 [[VALUE]], [[NEGSHIFT]] -// CHECK-32BIT-LONG: [[ROTATED:%[0-9]+]] = or i32 [[HIGH]], [[LOW]] -// CHECK-32BIT-LONG: [[ISZERO:%[0-9]+]] = icmp eq i32 [[SHIFT]], 0 -// CHECK-32BIT-LONG: [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i32 [[VALUE]], i32 [[ROTATED]] +// CHECK-32BIT-LONG: [[LSHIFT:%[0-9]+]] = and i32 [[SHIFT:%[0-9]+]], 31 +// CHECK-32BIT-LONG: [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[LSHIFT]] +// CHECK-32BIT-LONG: [[NEGATE:%[0-9]+]] = sub i32 0, [[SHIFT]] +// CHECK-32BIT-LONG: [[RSHIFT:%[0-9]+]] = and i32 [[NEGATE]], 31 +// CHECK-32BIT-LONG: [[
[PATCH] D46643: CodeGen: Emit string literal in constant address space
yaxunl marked an inline comment as done. yaxunl added inline comments. Comment at: lib/CodeGen/CGDecl.cpp:1375 +Loc = Address(EmitCastToVoidPtrInAllocaAddrSpace(Loc.getPointer()), + Loc.getAlignment()); rjmccall wrote: > I don't understand why a patch about string literals is changing auto > variable emission. It is a bug about alloca revealed by the lit test ``` char l_array[] = "l_array"; ``` Loc contains the alloca casted to default address space, therefore it needs to be casted back to alloca address space here, otherwise CreateBitCast returns invalid bitcast. Unlike lifetime.start, memcpy does not require alloca address space, so an alternative fix is to let BP take address space of Loc. https://reviews.llvm.org/D46643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46659: [clang-tidy/google-readability-casting] Allow C-style casts to/from Objective-C object types
benhamilton created this revision. benhamilton added reviewers: alexfh, Wizard, hokein. Herald added a subscriber: cfe-commits. Previously, `google-readability-casting` would trigger for Objective-C++ code using C-style casts to or from Objective-C object types. The official Google Objective-C standard says Objective-C++ allows authors to mix the Objective-C style (which uses C-style casts) and C++ (which disallows it): http://google.github.io/styleguide/objcguide.html#style-matches-the-language So, to resolve this conflict, this diff updates `google-readability-casting` to ignore C-style casts to or from Objective-C object types. Test Plan: New tests added. Ran tests with: % make -j16 check-clang-tools Before diff, confirmed tests failed: https://reviews.llvm.org/P8081 After diff, confirrmed tests passed. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46659 Files: clang-tidy/google/AvoidCStyleCastsCheck.cpp test/clang-tidy/google-readability-casting.mm Index: test/clang-tidy/google-readability-casting.mm === --- /dev/null +++ test/clang-tidy/google-readability-casting.mm @@ -0,0 +1,42 @@ +// RUN: clang-tidy %s -checks=-*,google-readability-casting -- \ +// RUN: -xobjective-c++ -fobjc-abi-version=2 -fobjc-arc | count 0 + +// Note: this test expects no diagnostics, but FileCheck cannot handle that, +// hence the use of | count 0. + +#define nil 0 + +@interface Foo +@end + +@protocol Proto +@end + +@interface Bar : Foo +@end + +@interface Baz : Foo +@end + +void foo() { + id nilObj = nil; + Foo *foo = (Foo *)nilObj; + Bar *bar = (Bar *)nilObj; + id ego = (id)foo; + foo = (Foo *)bar; + foo = (id)bar; + id nilProto = (id)bar; + ego = (id)nilProto; + bar = (Bar *)nilProto; + Foo *fooProto = (Foo *)bar; + Baz *baz = (Baz *)bar; + Class klass = (Class)nilObj; + ego = (id)klass; + void *voidStar = nullptr; + foo = (__bridge Foo *)voidStar; + nilProto = (__bridge id)voidStar; + klass = (__bridge Class)voidStar; + voidStar = (__bridge void *)foo; + voidStar = (__bridge void *)nilProto; + voidStar = (__bridge void *)klass; +} Index: clang-tidy/google/AvoidCStyleCastsCheck.cpp === --- clang-tidy/google/AvoidCStyleCastsCheck.cpp +++ clang-tidy/google/AvoidCStyleCastsCheck.cpp @@ -110,6 +110,10 @@ // compiled as C++. if (getCurrentMainFile().endswith(".c")) return; + // Ignore casts between Objective-C types. + if (SourceType->isObjCObjectPointerType() || + DestType->isObjCObjectPointerType()) +return; SourceManager &SM = *Result.SourceManager; Index: test/clang-tidy/google-readability-casting.mm === --- /dev/null +++ test/clang-tidy/google-readability-casting.mm @@ -0,0 +1,42 @@ +// RUN: clang-tidy %s -checks=-*,google-readability-casting -- \ +// RUN: -xobjective-c++ -fobjc-abi-version=2 -fobjc-arc | count 0 + +// Note: this test expects no diagnostics, but FileCheck cannot handle that, +// hence the use of | count 0. + +#define nil 0 + +@interface Foo +@end + +@protocol Proto +@end + +@interface Bar : Foo +@end + +@interface Baz : Foo +@end + +void foo() { + id nilObj = nil; + Foo *foo = (Foo *)nilObj; + Bar *bar = (Bar *)nilObj; + id ego = (id)foo; + foo = (Foo *)bar; + foo = (id)bar; + id nilProto = (id)bar; + ego = (id)nilProto; + bar = (Bar *)nilProto; + Foo *fooProto = (Foo *)bar; + Baz *baz = (Baz *)bar; + Class klass = (Class)nilObj; + ego = (id)klass; + void *voidStar = nullptr; + foo = (__bridge Foo *)voidStar; + nilProto = (__bridge id)voidStar; + klass = (__bridge Class)voidStar; + voidStar = (__bridge void *)foo; + voidStar = (__bridge void *)nilProto; + voidStar = (__bridge void *)klass; +} Index: clang-tidy/google/AvoidCStyleCastsCheck.cpp === --- clang-tidy/google/AvoidCStyleCastsCheck.cpp +++ clang-tidy/google/AvoidCStyleCastsCheck.cpp @@ -110,6 +110,10 @@ // compiled as C++. if (getCurrentMainFile().endswith(".c")) return; + // Ignore casts between Objective-C types. + if (SourceType->isObjCObjectPointerType() || + DestType->isObjCObjectPointerType()) +return; SourceManager &SM = *Result.SourceManager; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46656: [Builtins] Improve the IR emitted for MSVC compatible rotr/rotl builtins to match what the middle and backends understand
spatel accepted this revision. spatel added a comment. This revision is now accepted and ready to land. LGTM - thanks! https://reviews.llvm.org/D46656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.
manojgupta updated this revision to Diff 145988. manojgupta added a comment. Updated test case for error msg with arguments. Updated the documentation. Repository: rC Clang https://reviews.llvm.org/D46300 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td lib/CodeGen/CodeGenModule.cpp lib/Sema/SemaDeclAttr.cpp test/CodeGen/stack-protector.c test/Sema/no_stack_protector.c Index: test/Sema/no_stack_protector.c === --- /dev/null +++ test/Sema/no_stack_protector.c @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void __attribute__((no_stack_protector)) foo() {} +int __attribute__((no_stack_protector)) var; // expected-warning {{'no_stack_protector' attribute only applies to functions}} +void __attribute__((no_stack_protector(2))) bar() {} // expected-error {{'no_stack_protector' attribute takes no arguments}} Index: test/CodeGen/stack-protector.c === --- test/CodeGen/stack-protector.c +++ test/CodeGen/stack-protector.c @@ -22,6 +22,14 @@ printf("%s\n", a); } +// DEF: define {{.*}}void @test2(i8* %msg) #[[B:.*]] { +__attribute__((no_stack_protector)) +void test2(const char *msg) { + char a[strlen(msg) + 1]; + strcpy(a, msg); + printf("%s\n", a); +} + // NOSSP-NOT: attributes #[[A]] = {{.*}} ssp // SSP: attributes #[[A]] = {{.*}} ssp{{ }} // SSPSTRONG: attributes #[[A]] = {{.*}} sspstrong @@ -33,3 +41,15 @@ // SAFESTACK-SSP: attributes #[[A]] = {{.*}} safestack ssp{{ }} // SAFESTACK-SSPSTRONG: attributes #[[A]] = {{.*}} safestack sspstrong // SAFESTACK-SSPREQ: attributes #[[A]] = {{.*}} safestack sspreq + +// NOSSP-NOT: attributes #[[B]] = {{.*}} ssp +// SSP-NOT: attributes #[[B]] = {{.*}} ssp{{ }} +// SSPSTRONG-NOT: attributes #[[B]] = {{.*}} sspstrong +// SSPREQ-NOT: attributes #[[B]] = {{.*}} sspreq + +// SAFESTACK-SSP: attributes #[[B]] = {{.*}} safestack +// SAFESTACK-SSP-NOT: attributes #[[B]] = {{.*}} safestack ssp{{ }} +// SAFESTACK-SSPSTRONG: attributes #[[B]] = {{.*}} safestack +// SAFESTACK-SSPSTRONG-NOT: attributes #[[B]] = {{.*}} safestack sspstrong +// SAFESTACK-SSPREQ: attributes #[[B]] = {{.*}} safestack +// SAFESTACK-SSPREQ-NOT: attributes #[[B]] = {{.*}} safestack sspreq Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -6230,6 +6230,10 @@ case AttributeList::AT_NoInstrumentFunction: // Interacts with -pg. handleSimpleAttribute(S, D, AL); break; + case AttributeList::AT_NoStackProtector: +// Interacts with -fstack-protector options. +handleSimpleAttribute(S, D, AL); +break; case AttributeList::AT_StdCall: case AttributeList::AT_CDecl: case AttributeList::AT_FastCall: Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -1142,12 +1142,14 @@ if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); - if (LangOpts.getStackProtector() == LangOptions::SSPOn) -B.addAttribute(llvm::Attribute::StackProtect); - else if (LangOpts.getStackProtector() == LangOptions::SSPStrong) -B.addAttribute(llvm::Attribute::StackProtectStrong); - else if (LangOpts.getStackProtector() == LangOptions::SSPReq) -B.addAttribute(llvm::Attribute::StackProtectReq); + if (!D || !D->hasAttr()) { +if (LangOpts.getStackProtector() == LangOptions::SSPOn) + B.addAttribute(llvm::Attribute::StackProtect); +else if (LangOpts.getStackProtector() == LangOptions::SSPStrong) + B.addAttribute(llvm::Attribute::StackProtectStrong); +else if (LangOpts.getStackProtector() == LangOptions::SSPReq) + B.addAttribute(llvm::Attribute::StackProtectReq); + } if (!D) { // If we don't have a declaration to control inlining, the function isn't Index: include/clang/Basic/AttrDocs.td === --- include/clang/Basic/AttrDocs.td +++ include/clang/Basic/AttrDocs.td @@ -2740,6 +2740,28 @@ }]; } +def NoStackProtectorDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Clang supports the ``__attribute__((no_stack_protector))`` attribute which disables +the stack protector on the specified function. This attribute is useful for +selectively disabling the stack protector on some functions when building with +``-fstack-protector`` compiler option. + +For example, it disables the stack protector for the function ``foo`` but function +``bar`` will still be built with the stack protector with the ``-fstack-protector`` +option. + +.. code-block:: c + +int __attribute__((no_stack_protector)) +foo (int x); // stack protection will be disabled for foo. + +int bar(int y); // bar can be built with the stack protector. + +}]; +} +
[PATCH] D46659: [clang-tidy/google-readability-casting] Allow C-style casts to/from Objective-C object types
benhamilton added a comment. An alternative implementation would be to allow C-style casts (either always or only for ObjC objects) within Objective-C methods inside Objective-C++ files, but that may get messy with things like shared macros. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46659 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46084: Addition of the Fixed Point _Accum type
leonardchan updated this revision to Diff 145993. leonardchan added a comment. - Restrict usage of fixed point types only to C https://reviews.llvm.org/D46084 Files: include/clang-c/Index.h include/clang/AST/ASTContext.h include/clang/AST/BuiltinTypes.def include/clang/Basic/DiagnosticCommonKinds.td include/clang/Basic/Specifiers.h include/clang/Basic/TokenKinds.def include/clang/Sema/DeclSpec.h include/clang/Serialization/ASTBitCodes.h lib/AST/ASTContext.cpp lib/AST/ExprConstant.cpp lib/AST/ItaniumMangle.cpp lib/AST/MicrosoftMangle.cpp lib/AST/NSAPI.cpp lib/AST/Type.cpp lib/AST/TypeLoc.cpp lib/Analysis/PrintfFormatString.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CodeGenTypes.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/Index/USRGeneration.cpp lib/Parse/ParseDecl.cpp lib/Sema/DeclSpec.cpp lib/Sema/SemaTemplateVariadic.cpp lib/Sema/SemaType.cpp lib/Serialization/ASTCommon.cpp lib/Serialization/ASTReader.cpp test/Frontend/accum.c test/Frontend/accum_errors.c test/Frontend/accum_errors.cpp tools/libclang/CXType.cpp Index: tools/libclang/CXType.cpp === --- tools/libclang/CXType.cpp +++ tools/libclang/CXType.cpp @@ -53,6 +53,12 @@ BTCASE(Float); BTCASE(Double); BTCASE(LongDouble); +BTCASE(ShortAccum); +BTCASE(Accum); +BTCASE(LongAccum); +BTCASE(UShortAccum); +BTCASE(UAccum); +BTCASE(ULongAccum); BTCASE(Float16); BTCASE(Float128); BTCASE(NullPtr); @@ -542,6 +548,12 @@ TKIND(Float); TKIND(Double); TKIND(LongDouble); +TKIND(ShortAccum); +TKIND(Accum); +TKIND(LongAccum); +TKIND(UShortAccum); +TKIND(UAccum); +TKIND(ULongAccum); TKIND(Float16); TKIND(Float128); TKIND(NullPtr); Index: test/Frontend/accum_errors.cpp === --- /dev/null +++ test/Frontend/accum_errors.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -x c++ %s -verify + +// Name namgling is not provided for fixed point types in c++ + +signed short _Accum s_short_accum; // expected-error{{Fixed point types are only allowed in C}} +signed _Accum s_accum; // expected-error{{Fixed point types are only allowed in C}} +signed long _Accum s_long_accum;// expected-error{{Fixed point types are only allowed in C}} +unsigned short _Accum u_short_accum;// expected-error{{Fixed point types are only allowed in C}} +unsigned _Accum u_accum;// expected-error{{Fixed point types are only allowed in C}} +unsigned long _Accum u_long_accum; // expected-error{{Fixed point types are only allowed in C}} + +short _Accum short_accum; // expected-error{{Fixed point types are only allowed in C}} +_Accum accum; // expected-error{{Fixed point types are only allowed in C}} +long _Accum long_accum; // expected-error{{Fixed point types are only allowed in C}} Index: test/Frontend/accum_errors.c === --- /dev/null +++ test/Frontend/accum_errors.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s + +long long _Accum longlong_accum; // expected-error{{'long long _Accum' is invalid}} +unsigned long long _Accum u_longlong_accum; // expected-error{{'long long _Accum' is invalid}} Index: test/Frontend/accum.c === --- /dev/null +++ test/Frontend/accum.c @@ -0,0 +1,26 @@ +// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace + +/* Various contexts where type _Accum can appear. */ + +// Primary fixed point types +signed short _Accum s_short_accum; +signed _Accum s_accum; +signed long _Accum s_long_accum; +unsigned short _Accum u_short_accum; +unsigned _Accum u_accum; +unsigned long _Accum u_long_accum; + +// Aliased fixed point types +short _Accum short_accum; +_Accum accum; +long _Accum long_accum; + +//CHECK: |-VarDecl {{.*}} s_short_accum 'short _Accum' +//CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum' +//CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum' +//CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum' +//CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum' +//CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum' +//CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum' +//CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum' +//CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum' Index: lib/Serialization/ASTReader.cpp === --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -6816,6 +6816,24 @@ case PREDEF_TYPE_LONGDOUBLE_ID: T = Context.LongDoubleTy; break; +case PREDEF_TYPE_SHORT_ACCUM_ID: + T = Context.ShortAccumTy; + break; +case PREDEF_TYPE_ACCUM_ID: + T = Context.Acc
[PATCH] D46603: [Support] TimerGroup changes
lebedev.ri updated this revision to Diff 145994. lebedev.ri added a comment. - Use sane (not the same as the one right before..) suffix for when json-printing mem usage. Admittedly, i haven't tried it, but it just does not make sense otherwise. Repository: rL LLVM https://reviews.llvm.org/D46603 Files: include/llvm/Support/Timer.h lib/Support/Timer.cpp Index: lib/Support/Timer.cpp === --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -22,6 +22,8 @@ #include "llvm/Support/Process.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include + using namespace llvm; // This ugly hack is brought to you courtesy of constructor/destructor ordering @@ -234,6 +236,15 @@ TimerGroupList = this; } +TimerGroup::TimerGroup(StringRef Name, StringRef Description, + const StringMap &Records) +: TimerGroup(Name, Description) { + TimersToPrint.reserve(Records.size()); + for (const auto &P : Records) +TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey()); + assert(TimersToPrint.size() == Records.size() && "Size mismatch"); +} + TimerGroup::~TimerGroup() { // If the timer group is destroyed before the timers it owns, accumulate and // print the timing data. @@ -367,13 +378,17 @@ void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value) { assert(yaml::needsQuotes(Name) == yaml::QuotingType::None && - "TimerGroup name needs no quotes"); + "TimerGroup name should not need quotes"); assert(yaml::needsQuotes(R.Name) == yaml::QuotingType::None && - "Timer name needs no quotes"); - OS << "\t\"time." << Name << '.' << R.Name << suffix << "\": " << Value; + "Timer name should not need quotes"); + constexpr auto max_digits10 = std::numeric_limits::max_digits10; + OS << "\t\"time." << Name << '.' << R.Name << suffix + << "\": " << format("%.*e", max_digits10 - 1, Value); } const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) { + sys::SmartScopedLock L(*TimerLock); + prepareToPrintList(); for (const PrintRecord &R : TimersToPrint) { OS << delim; @@ -387,7 +402,7 @@ printJSONValue(OS, R, ".sys", T.getSystemTime()); if (T.getMemUsed()) { OS << delim; - printJSONValue(OS, R, ".sys", T.getMemUsed()); + printJSONValue(OS, R, ".mem", T.getMemUsed()); } } TimersToPrint.clear(); Index: include/llvm/Support/Timer.h === --- include/llvm/Support/Timer.h +++ include/llvm/Support/Timer.h @@ -10,6 +10,7 @@ #ifndef LLVM_SUPPORT_TIMER_H #define LLVM_SUPPORT_TIMER_H +#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" #include @@ -194,6 +195,10 @@ public: explicit TimerGroup(StringRef Name, StringRef Description); + + explicit TimerGroup(StringRef Name, StringRef Description, + const StringMap &Records); + ~TimerGroup(); void setName(StringRef NewName, StringRef NewDescription) { @@ -207,6 +212,8 @@ /// This static method prints all timers and clears them all out. static void printAll(raw_ostream &OS); + const char *printJSONValues(raw_ostream &OS, const char *delim); + /// Prints all timers as JSON key/value pairs, and clears them all out. static const char *printAllJSONValues(raw_ostream &OS, const char *delim); @@ -223,7 +230,6 @@ void PrintQueuedTimers(raw_ostream &OS); void printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value); - const char *printJSONValues(raw_ostream &OS, const char *delim); }; } // end namespace llvm Index: lib/Support/Timer.cpp === --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -22,6 +22,8 @@ #include "llvm/Support/Process.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include + using namespace llvm; // This ugly hack is brought to you courtesy of constructor/destructor ordering @@ -234,6 +236,15 @@ TimerGroupList = this; } +TimerGroup::TimerGroup(StringRef Name, StringRef Description, + const StringMap &Records) +: TimerGroup(Name, Description) { + TimersToPrint.reserve(Records.size()); + for (const auto &P : Records) +TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey()); + assert(TimersToPrint.size() == Records.size() && "Size mismatch"); +} + TimerGroup::~TimerGroup() { // If the timer group is destroyed before the timers it owns, accumulate and // print the timing data. @@ -367,13 +378,17 @@ void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value) { assert(yaml::ne
[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files
lebedev.ri updated this revision to Diff 145995. lebedev.ri edited the summary of this revision. lebedev.ri added a comment. - Make json less flat, store source filename in it. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D46602 Files: clang-tidy/ClangTidy.cpp clang-tidy/ClangTidy.h clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h clang-tidy/ClangTidyProfiling.cpp clang-tidy/ClangTidyProfiling.h clang-tidy/tool/ClangTidyMain.cpp docs/ReleaseNotes.rst docs/clang-tidy/index.rst test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp Index: test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp === --- /dev/null +++ test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp @@ -0,0 +1,33 @@ +// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T -store-check-profile-elide-prefix=%s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-CONSOLE %s +// RUN: FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -input-file=%T/.yaml -check-prefix=CHECK-FILE %s +// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T/out -store-check-profile-elide-prefix=%s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-CONSOLE %s +// RUN: FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -input-file=%T/out/.yaml -check-prefix=CHECK-FILE %s + +// CHECK-CONSOLE-NOT: ===-=== +// CHECK-CONSOLE-NOT: {{.*}} --- Name --- +// CHECK-CONSOLE-NOT: {{.*}} readability-function-size +// CHECK-CONSOLE-NOT: {{.*}} Total +// CHECK-CONSOLE-NOT: ===-=== + +// CHECK-FILE: { +// CHECK-FILE-NEXT:"file": "{{.*}}clang-tidy-store-check-profile-one-tu.cpp", +// CHECK-FILE-NEXT:"profile": { +// CHECK-FILE-NEXT: "time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, +// CHECK-FILE-NEXT: "time.clang-tidy.readability-function-size.user": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, +// CHECK-FILE-NEXT: "time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}} +// CHECK-FILE-NEXT: } +// CHECK-FILE-NEXT: } + +// CHECK-FILE-NOT: { +// CHECK-FILE-NOT: "file": {{.*}}clang-tidy-store-check-profile-one-tu.cpp{{.*}}, +// CHECK-FILE-NOT: "profile": { +// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, +// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.user": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}, +// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}} +// CHECK-FILE-NOT: } +// CHECK-FILE-NOT: } + +class A { + A() {} + ~A() {} +}; Index: test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp === --- test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp +++ test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp @@ -1,22 +1,31 @@ // RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' %s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' %s // CHECK: ===-=== -// CHECK-NEXT: {{.*}} --- Name --- +// CHECK-NEXT: clang-tidy checks profiling +// CHECK-NEXT: ===-=== +// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock) + +// CHECK: {{.*}} --- Name --- // CHECK-NEXT: {{.*}} readability-function-size // CHECK-NEXT: {{.*}} Total -// CHECK-NEXT: ===-=== // CHECK: ===-=== -// CHECK-NEXT: {{.*}} --- Name --- +// CHECK-NEXT: clang-tidy checks profiling +// CHECK-NEXT: ===-=== +// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock) + +// CHECK: {{.*}} --- Name --- // CHECK-NEXT: {{.*}} readability-function-size // CHECK-NEXT: {{.*}} Total -// CHECK-NEXT: ===-=== // CHECK-NOT: ===-=== +// CHECK-NOT: clang-tidy checks profilin
[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers
smeenai added a comment. Yeah, I think we all agree now that a portability warning isn't really tractable. Note that even for the warnings that motivated this diff, they should have only fired if `size_t` and NSInteger had separate types, so it wasn't a portability warning in that sense to begin with (as in, it would only warn if there was a mismatch for your current target, not if there was a potential mismatch for any target). We still have two options: 1. Special-case NSInteger/NSUInteger on Apple platforms so that they can always be printed using `%z` without any issues. 2. Relax the format specifier warnings (either under a new warning option, e.g. `-Wformat-relaxed`, or by relaxing `-Wformat` itself and adding something like `-Wformat-pedantic`) so that you don't warn when the specifier and the actual type have the same size and alignment, even when the actual type is different (which would also cover the case in 1). I'm personally in favor of 2, and I can start a discussion on cfe-dev if you think we should try to achieve a broader consensus. Whichever option we went with, we would also have to ensure that the optimizer didn't do anything bad (as @aaron.ballman pointed out), both now and in the future. Repository: rC Clang https://reviews.llvm.org/D42933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers
> On May 9, 2018, at 1:25 PM, Shoaib Meenai via Phabricator > wrote: > > smeenai added a comment. > > Yeah, I think we all agree now that a portability warning isn't really > tractable. Note that even for the warnings that motivated this diff, they > should have only fired if `size_t` and NSInteger had separate types, so it > wasn't a portability warning in that sense to begin with (as in, it would > only warn if there was a mismatch for your current target, not if there was a > potential mismatch for any target). > > We still have two options: > > 1. Special-case NSInteger/NSUInteger on Apple platforms so that they can > always be printed using `%z` without any issues. > 2. Relax the format specifier warnings (either under a new warning option, > e.g. `-Wformat-relaxed`, or by relaxing `-Wformat` itself and adding > something like `-Wformat-pedantic`) so that you don't warn when the specifier > and the actual type have the same size and alignment, even when the actual > type is different (which would also cover the case in 1). > > I'm personally in favor of 2, and I can start a discussion on cfe-dev if you > think we should try to achieve a broader consensus. Whichever option we went > with, we would also have to ensure that the optimizer didn't do anything bad > (as @aaron.ballman pointed out), both now and in the future 2 sounds better overall. However I don’t like a relaxed flag because it’s weird when you have relaxed/normal/pedantic. How do they mix? What if I want format warnings, but not “portability” ones. I think we either want to move this to pedantic and (as you propose) only warm on -Wformat if size or alignment don’t match. We can also have a separate -Wformat-portability warning where we try (and fail) to be helpful. Please do start a thread on cfe-dev, much appreciated! > Repository: > rC Clang > > https://reviews.llvm.org/D42933 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR
efriedma added a comment. There is no difference between "signalling" and "non-signalling" unless you're using "#pragma STDC FENV_ACCESS", which is currently not supported. Presumably the work to implement that will include some LLVM IR intrinsic which can encode the difference, but for now we can ignore it. Repository: rC Clang https://reviews.llvm.org/D45616 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! Repository: rC Clang https://reviews.llvm.org/D46300 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.
manojgupta added a comment. Thanks! Repository: rC Clang https://reviews.llvm.org/D46300 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits