r251738 - [MSVC Compat] Permit conversions from pointer-to-function to pointer-to-object iff -fms-compatibility
Author: majnemer Date: Sat Oct 31 03:42:14 2015 New Revision: 251738 URL: http://llvm.org/viewvc/llvm-project?rev=251738&view=rev Log: [MSVC Compat] Permit conversions from pointer-to-function to pointer-to-object iff -fms-compatibility We permit implicit conversion from pointer-to-function to pointer-to-object when -fms-extensions is specified. This is rather unfortunate, move this into -fms-compatibility and only permit it within system headers unless -Wno-error=microsoft-cast is specified. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=251738&r1=251737&r2=251738&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Oct 31 03:42:14 2015 @@ -2635,6 +2635,10 @@ def warn_impcast_null_pointer_to_integer def warn_impcast_floating_point_to_bool : Warning< "implicit conversion turns floating-point number into bool: %0 to %1">, InGroup; +def ext_ms_impcast_fn_obj : ExtWarn< + "implicit conversion between pointer-to-function and pointer-to-object is a " + "Microsoft extension">, + InGroup, DefaultError, SFINAEFailure; def warn_impcast_pointer_to_bool : Warning< "address of%select{| function| array}0 '%1' will always evaluate to " Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=251738&r1=251737&r2=251738&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Oct 31 03:42:14 2015 @@ -2104,7 +2104,7 @@ bool Sema::IsPointerConversion(Expr *Fro } // MSVC allows implicit function to void* type conversion. - if (getLangOpts().MicrosoftExt && FromPointeeType->isFunctionType() && + if (getLangOpts().MSVCCompat && FromPointeeType->isFunctionType() && ToPointeeType->isVoidType()) { ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr, ToPointeeType, @@ -2666,6 +2666,14 @@ bool Sema::CheckPointerConversion(Expr * // The conversion was successful. Kind = CK_DerivedToBase; } + + if (!IsCStyleOrFunctionalCast && FromPointeeType->isFunctionType() && + ToPointeeType->isVoidType()) { +assert(getLangOpts().MSVCCompat && + "this should only be possible with MSVCCompat!"); +Diag(From->getExprLoc(), diag::ext_ms_impcast_fn_obj) +<< From->getSourceRange(); + } } } else if (const ObjCObjectPointerType *ToPtrType = ToType->getAs()) { Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp?rev=251738&r1=251737&r2=251738&view=diff == --- cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp (original) +++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp Sat Oct 31 03:42:14 2015 @@ -12,3 +12,12 @@ void (*PR23733_1)() = static_cast((void *)0); + +long function_prototype(int a); +long (*function_ptr)(int a); + +void function_to_voidptr_conv() { + void *a1 = function_prototype; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}} + void *a2 = &function_prototype; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}} + void *a3 = function_ptr;// expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}} +} Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=251738&r1=251737&r2=251738&view=diff == --- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original) +++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Sat Oct 31 03:42:14 2015 @@ -153,16 +153,6 @@ static void static_func() // expected-wa extern const int static_var; // expected-note {{previous declaration is here}} static const int static_var = 3; // expected-warning {{redeclaring non-static 'static_var' as static is a Microsoft extension}} -long function_prototype(int a); -long (*function_ptr)(int a); - -void function_to_voidptr_conv() { - void *a1 = function_prototype; - void *a2 = &function_prototype
Re: [PATCH] D14014: Checker of proper vfork usage
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:45 @@ +44,3 @@ + CheckerContext &C) { + const Expr *CE = Call.getOriginExpr(); + ygribov wrote: > It seems that other checkers do more or less the same throw-away predicates > (e.g. see isAssignmentOp in DereferenceChecker.cpp). > Frankly this function only handles two common patterns right now > It seems that other checkers do more or less the same throw-away > predicates Both of these just highlight that it's best to make this a utility function: - New checkers will not have to roll their own predicates. - The reusable code will get enhanced in the future and all checkers will benefit from it. Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:64 @@ +63,3 @@ + + // Check for variable initialization. + auto PD = dyn_cast_or_null(P); Ah, right! Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:209 @@ +208,3 @@ + && !isCallWhitelisted(Call.getCalleeIdentifier(), C)) +reportBug("Calling functions (except exec*() or _exit())", C); +} Using regex in a diagnostic is not user friendly. See the comment below. Comment at: lib/StaticAnalyzer/Checkers/VforkChecker.cpp:227 @@ +226,3 @@ + + reportBug("Assigning variables (except return value of vfork)", C); +} It is very important to keep the diagnostics as succinct as possible. The diagnostics in this checker are long as is and I do not think the "except" clauses are helping the user to understand or fix the problem. They will not get the warning in the cases that are described in the "except" clause so why are we talking about this.. Most likely you are using it to make sure that the message is true. How about rephrasing the message to address that issue. For example, you could use something like: "Assigning variables (except return value of vfork) is prohibited after a successful fork" -> "This assignment is prohibited after a successful vfork" http://reviews.llvm.org/D14014 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14213: clang-format: Be slightly more cautious when formatting subsequent lines after a change. With r251474, clang-format could indent the entire rest of the file, if there is a missing clos
djasper created this revision. djasper added a reviewer: klimek. djasper added a subscriber: cfe-commits. Herald added a subscriber: klimek. With this change, clang-format stops formatting when either it leaves the current scope or when it comes back to the initial scope after going into a nested one. http://reviews.llvm.org/D14213 Files: lib/Format/UnwrappedLineFormatter.cpp unittests/Format/FormatTestSelective.cpp Index: unittests/Format/FormatTestSelective.cpp === --- unittests/Format/FormatTestSelective.cpp +++ unittests/Format/FormatTestSelective.cpp @@ -446,6 +446,27 @@ 21, 0)); } +TEST_F(FormatTestSelective, StopFormattingWhenLeavingScope) { + EXPECT_EQ( + "void f() {\n" + " if (a) {\n" + "g();\n" + "h();\n" + "}\n" + "\n" + "void g() {\n" + "}", + format("void f() {\n" + " if (a) {\n" // Assume this was added without the closing brace. + " g();\n" + " h();\n" + "}\n" + "\n" + "void g() {\n" // Make sure not to format this. + "}", + 15, 0)); +} + } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/UnwrappedLineFormatter.cpp === --- lib/Format/UnwrappedLineFormatter.cpp +++ lib/Format/UnwrappedLineFormatter.cpp @@ -812,13 +812,28 @@ AdditionalIndent); const AnnotatedLine *PreviousLine = nullptr; const AnnotatedLine *NextLine = nullptr; - bool PreviousLineFormatted = false; + + // The minimum level of consecutive lines that have been formatted. + unsigned RangeMinLevel = UINT_MAX; + // The level of the previous line. + unsigned PreviousLineLevel = Lines.front()->Level; + for (const AnnotatedLine *Line = Joiner.getNextMergedLine(DryRun, IndentTracker); Line; Line = NextLine) { const AnnotatedLine &TheLine = *Line; unsigned Indent = IndentTracker.getIndent(); -bool FixIndentation = (FixBadIndentation || PreviousLineFormatted) && + +// We continue formatting unchanged lines to adjust their indent, e.g. if a +// scope was added. However, we need to carefully stop doing this when we +// exit the scope of affected lines to prevent indenting a the entire +// remaining file if it currently missing a closing brace. +bool ContinueFormatting = +TheLine.Level > RangeMinLevel || +(TheLine.Level == RangeMinLevel && PreviousLineLevel <= TheLine.Level); +PreviousLineLevel = TheLine.Level; + +bool FixIndentation = (FixBadIndentation || ContinueFormatting) && Indent != TheLine.First->OriginalColumn; bool ShouldFormat = TheLine.Affected || FixIndentation; // We cannot format this line; if the reason is that the line had a @@ -846,7 +861,7 @@ else Penalty += OptimizingLineFormatter(Indenter, Whitespaces, Style, this) .formatLine(TheLine, Indent, DryRun); - PreviousLineFormatted = true; + RangeMinLevel = std::min(RangeMinLevel, TheLine.Level); } else { // If no token in the current line is affected, we still need to format // affected children. @@ -877,7 +892,7 @@ Whitespaces->addUntouchableToken(*Tok, TheLine.InPPDirective); } NextLine = Joiner.getNextMergedLine(DryRun, IndentTracker); - PreviousLineFormatted = false; + RangeMinLevel = UINT_MAX; } if (!DryRun) markFinalized(TheLine.First); Index: unittests/Format/FormatTestSelective.cpp === --- unittests/Format/FormatTestSelective.cpp +++ unittests/Format/FormatTestSelective.cpp @@ -446,6 +446,27 @@ 21, 0)); } +TEST_F(FormatTestSelective, StopFormattingWhenLeavingScope) { + EXPECT_EQ( + "void f() {\n" + " if (a) {\n" + "g();\n" + "h();\n" + "}\n" + "\n" + "void g() {\n" + "}", + format("void f() {\n" + " if (a) {\n" // Assume this was added without the closing brace. + " g();\n" + " h();\n" + "}\n" + "\n" + "void g() {\n" // Make sure not to format this. + "}", + 15, 0)); +} + } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/UnwrappedLineFormatter.cpp === --- lib/Format/UnwrappedLineFormatter.cpp +++ lib/Format/UnwrappedLineFormatter.cpp @@ -812,13 +812,28 @@ AdditionalIndent); const AnnotatedLine *PreviousLine = nullptr; const AnnotatedLine *NextLine = nullptr; - bool PreviousLineFormatted = false; + + // The minimum level of consecutive lines that have been
Re: [PATCH] D14213: clang-format: Be slightly more cautious when formatting subsequent lines after a change. With r251474, clang-format could indent the entire rest of the file, if there is a missing
klimek accepted this revision. klimek added a comment. This revision is now accepted and ready to land. lg http://reviews.llvm.org/D14213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r251760 - clang-format: Be slightly more cautious when formatting subsequent lines after a change. With r251474, clang-format could indent the entire rest of the file, if there is a missing closing br
Author: djasper Date: Sat Oct 31 19:27:35 2015 New Revision: 251760 URL: http://llvm.org/viewvc/llvm-project?rev=251760&view=rev Log: clang-format: Be slightly more cautious when formatting subsequent lines after a change. With r251474, clang-format could indent the entire rest of the file, if there is a missing closing brace, e.g. while writing code in an editor. Summary: With this change, clang-format stops formatting when either it leaves the current scope or when it comes back to the initial scope after going into a nested one. Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14213 Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp cfe/trunk/unittests/Format/FormatTestSelective.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=251760&r1=251759&r2=251760&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Sat Oct 31 19:27:35 2015 @@ -812,13 +812,28 @@ UnwrappedLineFormatter::format(const Sma AdditionalIndent); const AnnotatedLine *PreviousLine = nullptr; const AnnotatedLine *NextLine = nullptr; - bool PreviousLineFormatted = false; + + // The minimum level of consecutive lines that have been formatted. + unsigned RangeMinLevel = UINT_MAX; + // The level of the previous line. + unsigned PreviousLineLevel = Lines.front()->Level; + for (const AnnotatedLine *Line = Joiner.getNextMergedLine(DryRun, IndentTracker); Line; Line = NextLine) { const AnnotatedLine &TheLine = *Line; unsigned Indent = IndentTracker.getIndent(); -bool FixIndentation = (FixBadIndentation || PreviousLineFormatted) && + +// We continue formatting unchanged lines to adjust their indent, e.g. if a +// scope was added. However, we need to carefully stop doing this when we +// exit the scope of affected lines to prevent indenting a the entire +// remaining file if it currently missing a closing brace. +bool ContinueFormatting = +TheLine.Level > RangeMinLevel || +(TheLine.Level == RangeMinLevel && PreviousLineLevel <= TheLine.Level); +PreviousLineLevel = TheLine.Level; + +bool FixIndentation = (FixBadIndentation || ContinueFormatting) && Indent != TheLine.First->OriginalColumn; bool ShouldFormat = TheLine.Affected || FixIndentation; // We cannot format this line; if the reason is that the line had a @@ -846,7 +861,7 @@ UnwrappedLineFormatter::format(const Sma else Penalty += OptimizingLineFormatter(Indenter, Whitespaces, Style, this) .formatLine(TheLine, Indent, DryRun); - PreviousLineFormatted = true; + RangeMinLevel = std::min(RangeMinLevel, TheLine.Level); } else { // If no token in the current line is affected, we still need to format // affected children. @@ -877,7 +892,7 @@ UnwrappedLineFormatter::format(const Sma Whitespaces->addUntouchableToken(*Tok, TheLine.InPPDirective); } NextLine = Joiner.getNextMergedLine(DryRun, IndentTracker); - PreviousLineFormatted = false; + RangeMinLevel = UINT_MAX; } if (!DryRun) markFinalized(TheLine.First); Modified: cfe/trunk/unittests/Format/FormatTestSelective.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestSelective.cpp?rev=251760&r1=251759&r2=251760&view=diff == --- cfe/trunk/unittests/Format/FormatTestSelective.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestSelective.cpp Sat Oct 31 19:27:35 2015 @@ -446,6 +446,27 @@ TEST_F(FormatTestSelective, UnderstandsT 21, 0)); } +TEST_F(FormatTestSelective, StopFormattingWhenLeavingScope) { + EXPECT_EQ( + "void f() {\n" + " if (a) {\n" + "g();\n" + "h();\n" + "}\n" + "\n" + "void g() {\n" + "}", + format("void f() {\n" + " if (a) {\n" // Assume this was added without the closing brace. + " g();\n" + " h();\n" + "}\n" + "\n" + "void g() {\n" // Make sure not to format this. + "}", + 15, 0)); +} + } // end namespace } // end namespace format } // end namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14213: clang-format: Be slightly more cautious when formatting subsequent lines after a change. With r251474, clang-format could indent the entire rest of the file, if there is a missing
This revision was automatically updated to reflect the committed changes. Closed by commit rL251760: clang-format: Be slightly more cautious when formatting subsequent lines… (authored by djasper). Changed prior to commit: http://reviews.llvm.org/D14213?vs=38838&id=38839#toc Repository: rL LLVM http://reviews.llvm.org/D14213 Files: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp cfe/trunk/unittests/Format/FormatTestSelective.cpp Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp === --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp @@ -812,13 +812,28 @@ AdditionalIndent); const AnnotatedLine *PreviousLine = nullptr; const AnnotatedLine *NextLine = nullptr; - bool PreviousLineFormatted = false; + + // The minimum level of consecutive lines that have been formatted. + unsigned RangeMinLevel = UINT_MAX; + // The level of the previous line. + unsigned PreviousLineLevel = Lines.front()->Level; + for (const AnnotatedLine *Line = Joiner.getNextMergedLine(DryRun, IndentTracker); Line; Line = NextLine) { const AnnotatedLine &TheLine = *Line; unsigned Indent = IndentTracker.getIndent(); -bool FixIndentation = (FixBadIndentation || PreviousLineFormatted) && + +// We continue formatting unchanged lines to adjust their indent, e.g. if a +// scope was added. However, we need to carefully stop doing this when we +// exit the scope of affected lines to prevent indenting a the entire +// remaining file if it currently missing a closing brace. +bool ContinueFormatting = +TheLine.Level > RangeMinLevel || +(TheLine.Level == RangeMinLevel && PreviousLineLevel <= TheLine.Level); +PreviousLineLevel = TheLine.Level; + +bool FixIndentation = (FixBadIndentation || ContinueFormatting) && Indent != TheLine.First->OriginalColumn; bool ShouldFormat = TheLine.Affected || FixIndentation; // We cannot format this line; if the reason is that the line had a @@ -846,7 +861,7 @@ else Penalty += OptimizingLineFormatter(Indenter, Whitespaces, Style, this) .formatLine(TheLine, Indent, DryRun); - PreviousLineFormatted = true; + RangeMinLevel = std::min(RangeMinLevel, TheLine.Level); } else { // If no token in the current line is affected, we still need to format // affected children. @@ -877,7 +892,7 @@ Whitespaces->addUntouchableToken(*Tok, TheLine.InPPDirective); } NextLine = Joiner.getNextMergedLine(DryRun, IndentTracker); - PreviousLineFormatted = false; + RangeMinLevel = UINT_MAX; } if (!DryRun) markFinalized(TheLine.First); Index: cfe/trunk/unittests/Format/FormatTestSelective.cpp === --- cfe/trunk/unittests/Format/FormatTestSelective.cpp +++ cfe/trunk/unittests/Format/FormatTestSelective.cpp @@ -446,6 +446,27 @@ 21, 0)); } +TEST_F(FormatTestSelective, StopFormattingWhenLeavingScope) { + EXPECT_EQ( + "void f() {\n" + " if (a) {\n" + "g();\n" + "h();\n" + "}\n" + "\n" + "void g() {\n" + "}", + format("void f() {\n" + " if (a) {\n" // Assume this was added without the closing brace. + " g();\n" + " h();\n" + "}\n" + "\n" + "void g() {\n" // Make sure not to format this. + "}", + 15, 0)); +} + } // end namespace } // end namespace format } // end namespace clang Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp === --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp @@ -812,13 +812,28 @@ AdditionalIndent); const AnnotatedLine *PreviousLine = nullptr; const AnnotatedLine *NextLine = nullptr; - bool PreviousLineFormatted = false; + + // The minimum level of consecutive lines that have been formatted. + unsigned RangeMinLevel = UINT_MAX; + // The level of the previous line. + unsigned PreviousLineLevel = Lines.front()->Level; + for (const AnnotatedLine *Line = Joiner.getNextMergedLine(DryRun, IndentTracker); Line; Line = NextLine) { const AnnotatedLine &TheLine = *Line; unsigned Indent = IndentTracker.getIndent(); -bool FixIndentation = (FixBadIndentation || PreviousLineFormatted) && + +// We continue formatting unchanged lines to adjust their indent, e.g. if a +// scope was added. However, we need to carefully stop doing this when we +// exit the scope of affected lines to prevent indenting a the entire +// remaining file if it currently missing a closing brace. +bool C
Re: [PATCH] D14212: Make hasLHS and hasRHS matchers available for ArraySubscriptExpr
klimek accepted this revision. klimek added a comment. This revision is now accepted and ready to land. lg http://reviews.llvm.org/D14212 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r251738 - [MSVC Compat] Permit conversions from pointer-to-function to pointer-to-object iff -fms-compatibility
I think we more commonly say "function pointer": $ grep 'pointer-to-function' include/clang/Basic/Diagnostic*td | wc -l 3 $ grep 'function pointer' include/clang/Basic/Diagnostic*td | wc -l 7 For "object pointer" and "pointer-to-object" it's currently a tie. For "member pointer" and "pointer-to-member", the former is more common too. We should probably make all of these consistent – any preferences? "foo pointer" reads easier to me than "pointer-to-foo", but I'm not a native speaker. On Sat, Oct 31, 2015 at 1:42 AM, David Majnemer via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: majnemer > Date: Sat Oct 31 03:42:14 2015 > New Revision: 251738 > > URL: http://llvm.org/viewvc/llvm-project?rev=251738&view=rev > Log: > [MSVC Compat] Permit conversions from pointer-to-function to > pointer-to-object iff -fms-compatibility > > We permit implicit conversion from pointer-to-function to > pointer-to-object when -fms-extensions is specified. This is rather > unfortunate, move this into -fms-compatibility and only permit it within > system headers unless -Wno-error=microsoft-cast is specified. > > Modified: > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/lib/Sema/SemaOverload.cpp > cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp > cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=251738&r1=251737&r2=251738&view=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Oct 31 > 03:42:14 2015 > @@ -2635,6 +2635,10 @@ def warn_impcast_null_pointer_to_integer > def warn_impcast_floating_point_to_bool : Warning< > "implicit conversion turns floating-point number into bool: %0 to > %1">, > InGroup; > +def ext_ms_impcast_fn_obj : ExtWarn< > + "implicit conversion between pointer-to-function and pointer-to-object > is a " > + "Microsoft extension">, > + InGroup, DefaultError, SFINAEFailure; > > def warn_impcast_pointer_to_bool : Warning< > "address of%select{| function| array}0 '%1' will always evaluate to " > > Modified: cfe/trunk/lib/Sema/SemaOverload.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=251738&r1=251737&r2=251738&view=diff > > == > --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) > +++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Oct 31 03:42:14 2015 > @@ -2104,7 +2104,7 @@ bool Sema::IsPointerConversion(Expr *Fro >} > >// MSVC allows implicit function to void* type conversion. > - if (getLangOpts().MicrosoftExt && FromPointeeType->isFunctionType() && > + if (getLangOpts().MSVCCompat && FromPointeeType->isFunctionType() && >ToPointeeType->isVoidType()) { > ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr, > ToPointeeType, > @@ -2666,6 +2666,14 @@ bool Sema::CheckPointerConversion(Expr * > // The conversion was successful. > Kind = CK_DerivedToBase; >} > + > + if (!IsCStyleOrFunctionalCast && FromPointeeType->isFunctionType() > && > + ToPointeeType->isVoidType()) { > +assert(getLangOpts().MSVCCompat && > + "this should only be possible with MSVCCompat!"); > +Diag(From->getExprLoc(), diag::ext_ms_impcast_fn_obj) > +<< From->getSourceRange(); > + } > } >} else if (const ObjCObjectPointerType *ToPtrType = > ToType->getAs()) { > > Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp?rev=251738&r1=251737&r2=251738&view=diff > > == > --- cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp (original) > +++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp Sat Oct 31 > 03:42:14 2015 > @@ -12,3 +12,12 @@ void (*PR23733_1)() = static_cast void (*PR23733_2)() = FnPtrTy((void *)0); > void (*PR23733_3)() = (FnPtrTy)((void *)0); > void (*PR23733_4)() = reinterpret_cast((void *)0); > + > +long function_prototype(int a); > +long (*function_ptr)(int a); > + > +void function_to_voidptr_conv() { > + void *a1 = function_prototype; // expected-warning {{implicit > conversion between pointer-to-function and pointer-to-object is a Microsoft > extension}} > + void *a2 = &function_prototype; // expected-warning {{implicit > conversion between pointer-to-function and pointer-to-object is a Microsoft > extension}} > + void *a3 = function_ptr;// expected-warning {{implicit > conversion between point
Re: [PATCH] D14198: Make the modernize-loop-convert's const-detection smarter.
klimek added inline comments. Comment at: clang-tidy/modernize/LoopConvertCheck.cpp:371-373 @@ -370,1 +370,5 @@ +/// \brief Returns false when it can be guaranteed that no container element +/// is going to be modified due to this expression. +static bool canBeModified(ASTContext *Context, const Expr *E) { + auto Parents = Context->getParents(*E); Reading just this function, it is unclear what the 'container' is. Comment at: clang-tidy/modernize/LoopConvertCheck.cpp:392 @@ +391,3 @@ + for (const Usage &U : Usages) { +if (U.Kind != Usage::UK_CaptureByCopy && U.Kind != Usage::UK_CaptureByRef && +canBeModified(Context, U.Expression)) Can't CaptureBuRef be modified? Comment at: test/clang-tidy/modernize-loop-convert-const.cpp:233 @@ +232,3 @@ +void takingReferences() { + // We do it twice to prevent the check from thinking that they are aliases. + But they are aliases. Shouldn't we then go into the const-ness of the aliases? http://reviews.llvm.org/D14198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13388: Add support for querying the visibility of a cursor
klimek added a comment. Sergey, I think you raised concerns whether this is necessary. What are your thoughts? http://reviews.llvm.org/D13388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits