[clang-tools-extra] r339437 - [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

2018-08-10 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Aug 10 08:05:46 2018
New Revision: 339437

URL: http://llvm.org/viewvc/llvm-project?rev=339437&view=rev
Log:
[clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

Summary:
Currently, there is two configured prefixes: `CHECK-FIXES` and `CHECK-MESSAGES`
`CHECK-MESSAGES` checks that there are no test output lines with 
`warning:|error:`, which are not explicitly handled in lit tests.
However there does not seem to be a nice way to enforce for all the `note:` to 
be checked.
This was useful for me when developing D36836.

Reviewers: alexfh, klimek, aaron.ballman, hokein

Reviewed By: alexfh, aaron.ballman

Subscribers: JonasToth, JDevlieghere, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D36892

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=339437&r1=339436&r2=339437&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Fri Aug 10 08:05:46 2018
@@ -650,7 +650,8 @@ clang-tidy tests.
 
 An additional check enabled by ``check_clang_tidy.py`` ensures that
 if `CHECK-MESSAGES:` is used in a file then every warning or error
-must have an associated CHECK in that file.
+must have an associated CHECK in that file. Or, you can use ``CHECK-NOTES:``
+instead, if you want to **also** ensure that all the notes are checked.
 
 To use the ``check_clang_tidy.py`` script, put a .cpp file with the
 appropriate ``RUN`` line in the ``test/clang-tidy`` directory. Use

Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py?rev=339437&r1=339436&r2=339437&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py Fri Aug 10 
08:05:46 2018
@@ -78,6 +78,7 @@ def main():
   file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else ''
   check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
   check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
+  check_notes_prefix = 'CHECK-NOTES' + file_check_suffix
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
@@ -91,9 +92,11 @@ def main():
 
   has_check_fixes = check_fixes_prefix in input_text
   has_check_messages = check_messages_prefix in input_text
+  has_check_notes = check_notes_prefix in input_text
 
-  if not has_check_fixes and not has_check_messages:
-sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, 
check_messages_prefix) )
+  if not has_check_fixes and not has_check_messages and not has_check_notes:
+sys.exit('%s, %s or %s not found in the input' % (check_fixes_prefix,
+ check_messages_prefix, check_notes_prefix) )
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
@@ -154,6 +157,19 @@ def main():
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
   print('FileCheck failed:\n' + e.output.decode())
+  raise
+
+  if has_check_notes:
+notes_file = temp_file_name + '.notes'
+write_file(notes_file, clang_tidy_output)
+try:
+  subprocess.check_output(
+  ['FileCheck', '-input-file=' + notes_file, input_file_name,
+   '-check-prefix=' + check_notes_prefix,
+   '-implicit-check-not={{note|warning|error}}:'],
+  stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as e:
+  print('FileCheck failed:\n' + e.output.decode())
   raise
 
 if __name__ == '__main__':

Modified: clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp?rev=339437&r1=339436&r2=339437&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp Fri 
Aug 10 08:05:46 2018
@@ -20,28 +20,28 @@ class really_creative : public non_deriv
 void problematic() {
   try {
 throw int(42);
-// CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose 
type 'int' is not derived from 'std::exception'
+// CHECK-NOTES: [[@LINE-1]]:11: warning

Re: r339693 - We have in place support for parsing #pragma FENV_ACCESS, but that

2018-08-14 Thread Roman Lebedev via cfe-commits
No test?

On Tue, Aug 14, 2018 at 8:06 PM, Kevin P. Neal via cfe-commits
 wrote:
> Author: kpn
> Date: Tue Aug 14 10:06:56 2018
> New Revision: 339693
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339693&view=rev
> Log:
>
> We have in place support for parsing #pragma FENV_ACCESS, but that
> information is then discarded with a warning to the user that we don't
> support it.
>
> This patch gets us one step closer by getting the info down into the
> AST in most cases.
>
> Reviewed by:rsmith
> Differential Revision:  https://reviews.llvm.org/D49865
>
> Modified:
> cfe/trunk/include/clang/AST/Expr.h
> cfe/trunk/include/clang/Basic/LangOptions.h
> cfe/trunk/include/clang/Basic/TokenKinds.def
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Parse/ParsePragma.cpp
> cfe/trunk/lib/Parse/ParseStmt.cpp
> cfe/trunk/lib/Parse/Parser.cpp
> cfe/trunk/lib/Sema/SemaAttr.cpp
>
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=339693&r1=339692&r2=339693&view=diff
> ==
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr.h Tue Aug 14 10:06:56 2018
> @@ -3269,7 +3269,7 @@ private:
>
>// This is only meaningful for operations on floating point types and 0
>// otherwise.
> -  unsigned FPFeatures : 2;
> +  unsigned FPFeatures : 3;
>SourceLocation OpLoc;
>
>enum { LHS, RHS, END_EXPR };
> @@ -3448,6 +3448,12 @@ public:
>  return FPOptions(FPFeatures).allowFPContractWithinStatement();
>}
>
> +  // Get the FENV_ACCESS status of this operator. Only meaningful for
> +  // operations on floating point types.
> +  bool isFEnvAccessOn() const {
> +return FPOptions(FPFeatures).allowFEnvAccess();
> +  }
> +
>  protected:
>BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
>   ExprValueKind VK, ExprObjectKind OK,
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=339693&r1=339692&r2=339693&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.h Tue Aug 14 10:06:56 2018
> @@ -137,6 +137,14 @@ public:
>  FPC_Fast
>};
>
> +  // TODO: merge FEnvAccessModeKind and FPContractModeKind
> +  enum FEnvAccessModeKind {
> +FEA_Off,
> +
> +FEA_On
> +  };
> +
> +
>  public:
>/// Set of enabled sanitizers.
>SanitizerSet Sanitize;
> @@ -262,14 +270,19 @@ public:
>  /// Floating point control options
>  class FPOptions {
>  public:
> -  FPOptions() : fp_contract(LangOptions::FPC_Off) {}
> +  FPOptions() : fp_contract(LangOptions::FPC_Off),
> +fenv_access(LangOptions::FEA_Off) {}
>
>// Used for serializing.
>explicit FPOptions(unsigned I)
> -  : fp_contract(static_cast(I)) {}
> +  : fp_contract(static_cast(I & 3)),
> +fenv_access(static_cast((I >> 2) & 
> 1))
> +{}
>
>explicit FPOptions(const LangOptions &LangOpts)
> -  : fp_contract(LangOpts.getDefaultFPContractMode()) {}
> +  : fp_contract(LangOpts.getDefaultFPContractMode()),
> +fenv_access(LangOptions::FEA_Off) {}
> +  // FIXME: Use getDefaultFEnvAccessMode() when available.
>
>bool allowFPContractWithinStatement() const {
>  return fp_contract == LangOptions::FPC_On;
> @@ -289,12 +302,24 @@ public:
>
>void setDisallowFPContract() { fp_contract = LangOptions::FPC_Off; }
>
> +  bool allowFEnvAccess() const {
> +return fenv_access == LangOptions::FEA_On;
> +  }
> +
> +  void setAllowFEnvAccess() {
> +fenv_access = LangOptions::FEA_On;
> +  }
> +
> +  void setDisallowFEnvAccess() { fenv_access = LangOptions::FEA_Off; }
> +
>/// Used to serialize this.
> -  unsigned getInt() const { return fp_contract; }
> +  unsigned getInt() const { return fp_contract | (fenv_access << 2); }
>
>  private:
> -  /// Adjust BinaryOperator::FPFeatures to match the bit-field size of this.
> +  /// Adjust BinaryOperator::FPFeatures to match the total bit-field size
> +  /// of these two.
>unsigned fp_contract : 2;
> +  unsigned fenv_access : 1;
>  };
>
>  /// Describes the kind of translation unit being processed.
>
> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=339693&r1=339692&r2=339693&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Aug 14 10:06:56 2018
> @@ -780,6 +780,11 @@ ANNOTATION(pragma_redefine_extname)
>  // handles them.
>  ANNOTATION(pragma_fp_contract)
>

r339995 - [NFC] Some small test updates for Implicit Conversion sanitizer.

2018-08-17 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Aug 17 00:33:25 2018
New Revision: 339995

URL: http://llvm.org/viewvc/llvm-project?rev=339995&view=rev
Log:
[NFC] Some small test updates for Implicit Conversion sanitizer.

Split off from D50250.

Added:
cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c
Modified:
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c

Added: cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c?rev=339995&view=auto
==
--- cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c (added)
+++ cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c Fri Aug 
17 00:33:25 2018
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation 
-fsanitize-recover=implicit-integer-truncation -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void 
@__ubsan_handle_implicit_conversion" --check-prefixes=CHECK
+
+// Test plan:
+//  * Two types - int and char
+//  * Two signs - signed and unsigned
+//  * Square that - we have input and output types.
+// Thus, there are total of (2*2)^2 == 16 tests.
+// These are all the possible variations/combinations of casts.
+// However, not all of them should result in the check.
+// So here, we *only* check which should and which should not result in checks.
+
+// CHECK-DAG: @[[LINE_500_TRUNCATION:.*]] = {{.*}}, i32 500, i32 10 }, {{.*}}, 
{{.*}}, i8 0 }
+// CHECK-DAG: @[[LINE_1100_TRUNCATION:.*]] = {{.*}}, i32 1100, i32 10 }, 
{{.*}}, {{.*}}, i8 0 }
+// CHECK-DAG: @[[LINE_1500_TRUNCATION:.*]] = {{.*}}, i32 1500, i32 10 }, 
{{.*}}, {{.*}}, i8 0 }
+// CHECK-DAG: @[[LINE_1600_TRUNCATION:.*]] = {{.*}}, i32 1600, i32 10 }, 
{{.*}}, {{.*}}, i8 0 }
+
+// CHECK-LABEL: @convert_unsigned_int_to_unsigned_int
+unsigned int convert_unsigned_int_to_unsigned_int(unsigned int x) {
+  // CHECK: }
+#line 100
+  return x;
+}
+
+// CHECK-LABEL: @convert_unsigned_char_to_unsigned_char
+unsigned char convert_unsigned_char_to_unsigned_char(unsigned char x) {
+  // CHECK: }
+#line 200
+  return x;
+}
+
+// CHECK-LABEL: @convert_signed_int_to_signed_int
+signed int convert_signed_int_to_signed_int(signed int x) {
+  // CHECK: }
+#line 300
+  return x;
+}
+
+// CHECK-LABEL: @convert_signed_char_to_signed_char
+signed char convert_signed_char_to_signed_char(signed char x) {
+  // CHECK: }
+#line 400
+  return x;
+}
+
+// CHECK-LABEL: @convert_unsigned_int_to_unsigned_char
+unsigned char convert_unsigned_int_to_unsigned_char(unsigned int x) {
+  // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ 
{{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_500_TRUNCATION]] to i8*)
+  // CHECK: }
+#line 500
+  return x;
+}
+
+// CHECK-LABEL: @convert_unsigned_char_to_unsigned_int
+unsigned int convert_unsigned_char_to_unsigned_int(unsigned char x) {
+  // CHECK: }
+#line 600
+  return x;
+}
+
+// CHECK-LABEL: @convert_unsigned_char_to_signed_int
+signed int convert_unsigned_char_to_signed_int(unsigned char x) {
+  // CHECK: }
+#line 700
+  return x;
+}
+
+// CHECK-LABEL: @convert_signed_char_to_signed_int
+signed int convert_signed_char_to_signed_int(signed char x) {
+  // CHECK: }
+#line 800
+  return x;
+}
+
+// CHECK-LABEL: @convert_unsigned_int_to_signed_int
+signed int convert_unsigned_int_to_signed_int(unsigned int x) {
+  // CHECK: }
+#line 900
+  return x;
+}
+
+// CHECK-LABEL: @convert_signed_int_to_unsigned_int
+unsigned int convert_signed_int_to_unsigned_int(signed int x) {
+  // CHECK: }
+#line 1000
+  return x;
+}
+
+// CHECK-LABEL: @convert_signed_int_to_unsigned_char
+unsigned char convert_signed_int_to_unsigned_char(signed int x) {
+  // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ 
{{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_1100_TRUNCATION]] to i8*)
+  // CHECK: }
+#line 1100
+  return x;
+}
+
+// CHECK-LABEL: @convert_signed_char_to_unsigned_char
+unsigned char convert_signed_char_to_unsigned_char(signed char x) {
+  // CHECK: }
+#line 1200
+  return x;
+}
+
+// CHECK-LABEL: @convert_unsigned_char_to_signed_char
+signed char convert_unsigned_char_to_signed_char(unsigned char x) {
+  // CHECK: }
+#line 1300
+  return x;
+}
+
+// CHECK-LABEL: @convert_signed_char_to_unsigned_int
+unsigned int convert_signed_char_to_unsigned_int(signed char x) {
+  // CHECK: }
+#line 1400
+  return x;
+}
+
+// CHECK-LABEL: @convert_unsigned_int_to_signed_char
+signed char convert_unsigned_int_to_signed_char(unsigned int x) {
+  // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ 
{{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_1500_TRUNCATION]] to i8*)
+  // CHECK: }
+#line 1500
+  return x;
+}
+
+// CHECK-LABEL: @convert_signed_int_to_signed_char
+signed char convert_signed_int_to_signed_cha

[clang-tools-extra] r331822 - Partially revert r331456: [clang-tidy] Remove AnalyzeTemporaryDtors option.

2018-05-08 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue May  8 16:15:58 2018
New Revision: 331822

URL: http://llvm.org/viewvc/llvm-project?rev=331822&view=rev
Log:
Partially revert r331456: [clang-tidy] Remove AnalyzeTemporaryDtors option.

That broke every single .clang-tidy config out there
which happened to specify AnalyzeTemporaryDtors option:

YAML:5:24: error: unknown key 'AnalyzeTemporaryDtors'
AnalyzeTemporaryDtors: false
   ^
Error parsing <...>/.clang-tidy: Invalid argument

More so, that error isn't actually a error, the
clang-tidy does not exit with $? != 0, it continues
with the default config.

Surely this breakage isn't the intended behavior.
But if it is, feel free to revert this commit.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp?rev=331822&r1=331821&r2=331822&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp Tue May  8 16:15:58 
2018
@@ -83,9 +83,11 @@ template <> struct MappingTraits NOpts(
 IO, Options.CheckOptions);
+bool Ignored = false;
 IO.mapOptional("Checks", Options.Checks);
 IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
 IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
+IO.mapOptional("AnalyzeTemporaryDtors", Ignored); // legacy compatibility
 IO.mapOptional("FormatStyle", Options.FormatStyle);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", NOpts->Options);

Modified: clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyOptionsTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyOptionsTest.cpp?rev=331822&r1=331821&r2=331822&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyOptionsTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyOptionsTest.cpp Tue 
May  8 16:15:58 2018
@@ -58,6 +58,7 @@ TEST(ParseConfiguration, ValidConfigurat
   llvm::ErrorOr Options =
   parseConfiguration("Checks: \"-*,misc-*\"\n"
  "HeaderFilterRegex: \".*\"\n"
+ "AnalyzeTemporaryDtors: true\n"
  "User: some.user");
   EXPECT_TRUE(!!Options);
   EXPECT_EQ("-*,misc-*", *Options->Checks);
@@ -69,6 +70,7 @@ TEST(ParseConfiguration, MergeConfigurat
   llvm::ErrorOr Options1 = parseConfiguration(R"(
   Checks: "check1,check2"
   HeaderFilterRegex: "filter1"
+  AnalyzeTemporaryDtors: true
   User: user1
   ExtraArgs: ['arg1', 'arg2']
   ExtraArgsBefore: ['arg-before1', 'arg-before2']
@@ -77,6 +79,7 @@ TEST(ParseConfiguration, MergeConfigurat
   llvm::ErrorOr Options2 = parseConfiguration(R"(
   Checks: "check3,check4"
   HeaderFilterRegex: "filter2"
+  AnalyzeTemporaryDtors: false
   User: user2
   ExtraArgs: ['arg3', 'arg4']
   ExtraArgsBefore: ['arg-before3', 'arg-before4']


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D47067: Update NRVO logic to support early return

2018-05-18 Thread Roman Lebedev via cfe-commits
On Fri, May 18, 2018 at 8:47 PM, tzik via cfe-commits
 wrote:
> Ah, sorry. It's still work in progress for now.
> I'll resend this soon after adding tests and updating comments there.
See Herald rules for exact syntax, but i think adding "[private]" into
the subject
would have prevented it from going live.

> 2018年5月19日(土) 2:41 Arthur O'Dwyer :
>>
>> https://reviews.llvm.org/D47067 is a "Restricted Differential Revision",
>> which I've never seen before!
>> Peanut gallery says: This sounds awesome. How does this change interact
>> with the diagnostics issued by -Wpessimizing-move and -Wreturn-std-move?
>> Should any new test cases be added for those diagnostics?
>>
>>
>> On Fri, May 18, 2018 at 7:12 AM, Taiju Tsuiki via Phabricator via
>> cfe-commits  wrote:
>>>
>>> tzik created this revision.
>>> Herald added a subscriber: cfe-commits.
>>>
>>> The previous implementation misses an opportunity to apply NRVO (Named
>>> Return Value
>>>
>>> Optimization) below. That discourages user to write early return code.
>>> --
>>>
>>> struct Foo {};
>>>
>>> Foo f(bool b) {
>>>
>>>   if (b)
>>> return Foo();
>>>   Foo oo;
>>>   return oo;
>>>
>>> }
>>> -
>>>
>>> That is, we can/should apply RVO for a return statement if it refers a
>>> non-parameter local variable,
>>> and the variable is referred by all return statements reachable from the
>>> variable declaration.
>>> While, the previous implementation disables the RVO in a scope if there
>>> are multiple return
>>> statements that refers different variables.
>>>
>>> On the new algorithm, local variables are in NRVO_Candidate state at
>>> first, and a return
>>> statement changes it to NRVO_Disabled for all visible variables but the
>>> return statement refers.
>>> Then, at the end of the function AST traversal, NRVO is enabled for
>>> variables in NRVO_Candidate
>>> state and refers from at least one return statement.
>>>
>>>
>>> Repository:
>>>   rC Clang
>>>
>>> https://reviews.llvm.org/D47067
>>>
>>> Files:
>>>   include/clang/AST/Decl.h
>>>   include/clang/Sema/Scope.h
>>>   lib/Sema/Scope.cpp
>>>   lib/Sema/SemaDecl.cpp
>>>   lib/Sema/SemaStmt.cpp
>>>   lib/Serialization/ASTReaderDecl.cpp
>>>   lib/Serialization/ASTWriterDecl.cpp
>>>   test/CodeGenCXX/nrvo.cpp
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: Patch to Bugzilla 31373

2017-10-06 Thread Roman Lebedev via cfe-commits
On Fri, Oct 6, 2017 at 3:15 PM, Erik Viktorsson via cfe-commits
 wrote:
Hi.

> Committing a patch to Bugzilla 31373
>
> A novice programmer so hopefully it complies with the coding policy.
I think it may be better to put it to Phabricator, see
https://llvm.org/docs/Phabricator.html#id3

Please do note that you should generate the diff with context (-U99),
and should put the maillist (cfe-dev in this case) as Subscriber.

>
> I had to disable an assert in lib/CodeGen/CGExpr.cpp since it requires that
> all expressions are marked as Used or referenced, which is not possible if
> we want the ShouldDiagnoseUnusedDecl to return true (thus trigger the
> warn_unused_variable  warning).
>
>
>
> The reason I removed the assert statement is because it causes five tests to
> fail. These test are the following:
>
>
>
> ·   clang -cc1 -triple i386-unknown-unknown -mllvm
> -inline-threshold=1024 -O3 -emit-llvm temp-order.cpp
>
> ·   clang -cc1 -debug-info-kind=limited -std=c++11 -emit-llvm
> debug-info-scope.cpp
>
> ·   clang -cc1 -std=c++1z -triple x86_64-apple-macosx10.7.0 -emit-llvm
> cxx1z-init-statement.cpp
>
> ·   clang -cc1 -triple x86_64-apple-darwin10 -emit-llvm condition.cpp
>
> ·   clang -cc1 -emit-llvm cxx-condition.cpp
>
>
>
> /E
Roman.

> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315614 - [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 12 13:16:51 2017
New Revision: 315614

URL: http://llvm.org/viewvc/llvm-project?rev=315614&view=rev
Log:
[Sema] Diagnose tautological comparison with type's min/max values

Summary:
Currently, clang only diagnoses completely out-of-range comparisons (e.g. 
`char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons 
with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: rtrieu, jroelofs, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D38101

Added:
cfe/trunk/test/Sema/tautological-constant-compare.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/outof-range-constant-compare.c
cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=315614&r1=315613&r2=315614&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Oct 12 13:16:51 2017
@@ -78,6 +78,10 @@ Improvements to Clang's diagnostics
   when the signed integer is coerced to an unsigned type for the comparison.
   ``-Wsign-compare`` was adjusted not to warn in this case.
 
+- ``-Wtautological-constant-compare`` is a new warning that warns on
+  tautological comparisons between integer variable of the type ``T`` and the
+  largest/smallest possible integer constant of that same type.
+
 - ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
   on a null pointer. Such pointer arithmetic has an undefined behavior if the
   offset is nonzero. It also now warns about arithmetic on a null pointer

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=315614&r1=315613&r2=315614&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Oct 12 13:16:51 2017
@@ -432,13 +432,15 @@ def StrncatSize : DiagGroup<"strncat-siz
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
 def TautologicalOutOfRangeCompare : 
DiagGroup<"tautological-constant-out-of-range-compare">;
+def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
+[TautologicalUnsignedZeroCompare,
+ 
TautologicalUnsignedEnumZeroCompare,
+ TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
-[TautologicalUnsignedZeroCompare,
- TautologicalUnsignedEnumZeroCompare,
- TautologicalOutOfRangeCompare,
+[TautologicalConstantCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
  TautologicalUndefinedCompare]>;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315614&r1=315613&r2=315614&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 12 13:16:51 
2017
@@ -5938,18 +5938,18 @@ def note_typecheck_assign_const : Note<
   "member function %q1 is declared const here|"
   "%select{|nested }1data member %2 declared const here}0">;
 
-def warn_lunsigned_always_true_comparison : Warning<
-  "comparison of unsigned expression %0 is always %select{false|true}1">,
+def warn_unsigned_always_true_comparison : Warning<
+  "comparison of %select{%3|unsigned expression}0 %2 "
+  "%select{unsigned expression|%3}0 is always %select{false|true}4">,
   InGroup;
-def warn_runsigned_always_true_comparison : Warning<
-  "comparison of %

r315615 - [Analysis] Silence -Wtautological-constant-compare in two tests

2017-10-12 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 12 13:27:41 2017
New Revision: 315615

URL: http://llvm.org/viewvc/llvm-project?rev=315615&view=rev
Log:
[Analysis] Silence -Wtautological-constant-compare in two tests

Yes, did not check that. Need to do better :(
I do not believe it makes sense to do expect that warning here.

Modified:
cfe/trunk/test/Analysis/conversion.c
cfe/trunk/test/Analysis/null-deref-ps.c

Modified: cfe/trunk/test/Analysis/conversion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/conversion.c?rev=315615&r1=315614&r2=315615&view=diff
==
--- cfe/trunk/test/Analysis/conversion.c (original)
+++ cfe/trunk/test/Analysis/conversion.c Thu Oct 12 13:27:41 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -Wno-conversion 
-analyzer-checker=core,alpha.core.Conversion -verify %s
+// RUN: %clang_analyze_cc1 -Wno-conversion -Wno-tautological-constant-compare 
-analyzer-checker=core,alpha.core.Conversion -verify %s
 
 unsigned char U8;
 signed char S8;

Modified: cfe/trunk/test/Analysis/null-deref-ps.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-ps.c?rev=315615&r1=315614&r2=315615&view=diff
==
--- cfe/trunk/test/Analysis/null-deref-ps.c (original)
+++ cfe/trunk/test/Analysis/null-deref-ps.c Thu Oct 12 13:27:41 2017
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region 
-analyzer-purge=none -verify %s -Wno-error=return-type
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region 
-verify %s -Wno-error=return-type
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-Wno-tautological-constant-compare -analyzer-checker=core,deadcode,alpha.core 
-std=gnu99 -analyzer-store=region -analyzer-purge=none -verify %s 
-Wno-error=return-type
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-Wno-tautological-constant-compare -analyzer-checker=core,deadcode,alpha.core 
-std=gnu99 -analyzer-store=region -verify %s -Wno-error=return-type
 
 typedef unsigned uintptr_t;
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315622 - [Analysis] Un-silence -Wtautological-unsigned-zero-compare in null-deref-ps.c

2017-10-12 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 12 14:15:26 2017
New Revision: 315622

URL: http://llvm.org/viewvc/llvm-project?rev=315622&view=rev
Log:
[Analysis] Un-silence -Wtautological-unsigned-zero-compare in null-deref-ps.c

Stage-2 builds failed:

error: 'warning' diagnostics expected but not seen:
  File 
/home/buildbot/modules-slave-2/clang-x86_64-linux-selfhost-modules-2/llvm.src/tools/clang/test/Analysis/null-deref-ps.c
 Line 238: always true

Modified:
cfe/trunk/test/Analysis/null-deref-ps.c

Modified: cfe/trunk/test/Analysis/null-deref-ps.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-ps.c?rev=315622&r1=315621&r2=315622&view=diff
==
--- cfe/trunk/test/Analysis/null-deref-ps.c (original)
+++ cfe/trunk/test/Analysis/null-deref-ps.c Thu Oct 12 14:15:26 2017
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-Wno-tautological-constant-compare -analyzer-checker=core,deadcode,alpha.core 
-std=gnu99 -analyzer-store=region -analyzer-purge=none -verify %s 
-Wno-error=return-type
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-Wno-tautological-constant-compare -analyzer-checker=core,deadcode,alpha.core 
-std=gnu99 -analyzer-store=region -verify %s -Wno-error=return-type
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-Wno-tautological-constant-compare -Wtautological-unsigned-zero-compare 
-analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region 
-analyzer-purge=none -verify %s -Wno-error=return-type
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-Wno-tautological-constant-compare -Wtautological-unsigned-zero-compare 
-analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region 
-verify %s -Wno-error=return-type
 
 typedef unsigned uintptr_t;
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r315614 - [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Roman Lebedev via cfe-commits
On Fri, Oct 13, 2017 at 12:12 AM, Nico Weber  wrote:
> Huh, I consider clang not warning on this a feature, not a bug. Why are we
> trying to match what gcc does here?
Because i have been bitten by this more than once.
It did result in big amount of wasted time, and this "thread":
https://lists.llvm.org/pipermail/llvm-dev/2017-August/116390.html

As with all the clang diagnostics, you can disable them
I personally don't have any opinion on comparisons with
std::numeric_limits<...>::{min,max}()

> Say you have code like this:
>
> int64_t aligned_start = 0;
> int64_t aligned_size = 0;
> CalculateVMAlignedBoundaries(region.offset,
>  region.size,
>  &aligned_start,
>  &aligned_size,
>  &data_offset);
>
> // Ensure that the casts in the mmap call below are sane.
> if (aligned_start < 0 || aligned_size < 0 ||
> aligned_start > std::numeric_limits::max() ||
> static_cast(aligned_size) >
> std::numeric_limits::max() ||
> static_cast(region.size) >
> std::numeric_limits::max()) {
>   DLOG(ERROR) << "Region bounds are not valid for mmap";
>   return false;
> }
>
> This code works in 64-bit and 32-bit. off_t has different sizes on both, so
> the comparison is useful. The warning uselessly fires on this code.
> On Thu, Oct 12, 2017 at 4:16 PM, Roman Lebedev via cfe-commits
>  wrote:
>>
>> Author: lebedevri
>> Date: Thu Oct 12 13:16:51 2017
>> New Revision: 315614
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315614&view=rev
>> Log:
>> [Sema] Diagnose tautological comparison with type's min/max values
>>
>> Summary:
>> Currently, clang only diagnoses completely out-of-range comparisons (e.g.
>> `char` and constant `300`),
>> and comparisons of unsigned and `0`. But gcc also does diagnose the
>> comparisons with the
>> `std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to
>> speak
>>
>> Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
>> Continuation of https://reviews.llvm.org/D37565
>>
>> Reviewers: rjmccall, rsmith, aaron.ballman
>>
>> Reviewed By: rsmith
>>
>> Subscribers: rtrieu, jroelofs, cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D38101
>>
>> Added:
>> cfe/trunk/test/Sema/tautological-constant-compare.c
>> Modified:
>> cfe/trunk/docs/ReleaseNotes.rst
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/Sema/outof-range-constant-compare.c
>> cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c
>>
>> Modified: cfe/trunk/docs/ReleaseNotes.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=315614&r1=315613&r2=315614&view=diff
>>
>> ==
>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
>> +++ cfe/trunk/docs/ReleaseNotes.rst Thu Oct 12 13:16:51 2017
>> @@ -78,6 +78,10 @@ Improvements to Clang's diagnostics
>>when the signed integer is coerced to an unsigned type for the
>> comparison.
>>``-Wsign-compare`` was adjusted not to warn in this case.
>>
>> +- ``-Wtautological-constant-compare`` is a new warning that warns on
>> +  tautological comparisons between integer variable of the type ``T`` and
>> the
>> +  largest/smallest possible integer constant of that same type.
>> +
>>  - ``-Wnull-pointer-arithmetic`` now warns about performing pointer
>> arithmetic
>>on a null pointer. Such pointer arithmetic has an undefined behavior if
>> the
>>offset is nonzero. It also now warns about arithmetic on a null pointer
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=315614&r1=315613&r2=315614&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Oct 12 13:16:51
>> 2017
>> @@ -432,13 +432,15 @@ def StrncatSize : DiagGroup<"strncat-siz
>>  def TautologicalUnsignedZeroCompare :

r315631 - Revert "[Sema] Diagnose tautological comparison with type's min/max values"

2017-10-12 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 12 15:03:20 2017
New Revision: 315631

URL: http://llvm.org/viewvc/llvm-project?rev=315631&view=rev
Log:
Revert "[Sema] Diagnose tautological comparison with type's min/max values"

This reverts r315614,r315615,r315621,r315622
Breaks http://bb9.pgr.jp/#/builders/20/builds/59

/home/bb9/bootstrap-clang-libcxx-lld-i686-linux/llvm-project/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp:95:17:
 error: comparison 'long long' > 9223372036854775807 is always false 
[-Werror,-Wtautological-constant-compare]
if (max_sec > Lim::max()) return false;
~~~ ^ ~~
/home/bb9/bootstrap-clang-libcxx-lld-i686-linux/llvm-project/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp:124:13:
 error: comparison 'long long' < -9223372036854775808 is always false 
[-Werror,-Wtautological-constant-compare]
if (sec < Lim::min() || sec > Lim::max())   return false;
~~~ ^ ~~
/home/bb9/bootstrap-clang-libcxx-lld-i686-linux/llvm-project/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp:124:33:
 error: comparison 'long long' > 9223372036854775807 is always false 
[-Werror,-Wtautological-constant-compare]
if (sec < Lim::min() || sec > Lim::max())   return false;
~~~ ^ ~~
3 errors generated.
--

I'm not yet sure what is the proper fix.

Removed:
cfe/trunk/test/Sema/tautological-constant-compare.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Analysis/conversion.c
cfe/trunk/test/Analysis/null-deref-ps.c
cfe/trunk/test/Sema/outof-range-constant-compare.c
cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=315631&r1=315630&r2=315631&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Oct 12 15:03:20 2017
@@ -78,10 +78,6 @@ Improvements to Clang's diagnostics
   when the signed integer is coerced to an unsigned type for the comparison.
   ``-Wsign-compare`` was adjusted not to warn in this case.
 
-- ``-Wtautological-constant-compare`` is a new warning that warns on
-  tautological comparisons between integer variable of the type ``T`` and the
-  largest/smallest possible integer constant of that same type.
-
 - ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
   on a null pointer. Such pointer arithmetic has an undefined behavior if the
   offset is nonzero. It also now warns about arithmetic on a null pointer

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=315631&r1=315630&r2=315631&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Oct 12 15:03:20 2017
@@ -432,15 +432,13 @@ def StrncatSize : DiagGroup<"strncat-siz
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
 def TautologicalOutOfRangeCompare : 
DiagGroup<"tautological-constant-out-of-range-compare">;
-def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
-[TautologicalUnsignedZeroCompare,
- 
TautologicalUnsignedEnumZeroCompare,
- TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
-[TautologicalConstantCompare,
+[TautologicalUnsignedZeroCompare,
+ TautologicalUnsignedEnumZeroCompare,
+ TautologicalOutOfRangeCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
  TautologicalUndefinedCompare]>;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315631&r1=315630&r2=315631&view=diff
==

Re: [PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Roman Lebedev via cfe-commits
On Fri, Oct 13, 2017 at 1:22 AM, Richard Smith  wrote:
> On 12 October 2017 at 15:11, Roman Lebedev via Phabricator via cfe-commits
>  wrote:
>>
>> lebedev.ri reopened this revision.
>> lebedev.ri added a comment.
>> This revision is now accepted and ready to land.
>>
>> Reverted due to http://bb9.pgr.jp/#/builders/20/builds/59 that i don't
>> currently know how to deal with.
>> It is really sad that i failed to encounter it during testing.
>
>
> I see three issues there:

> 1) A warning in this code due to missing parentheses around a ^ operator.

> 2) This code generating correct warnings in the libc++ test suite.
Yes, this one is the problem.

I'm honestly not sure about these comparisons with
std::numeric_limits<...>::{min,max}()
They is similar to what Nico Weber (CC'd, just in case) is raising in
post-review mail in
https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20171009/206427.html
I personally would very much prefer to have the warning, as explained
in the follow-up mail.

> You could ask EricWF (cc'd) to look at those and either fix them or turn the 
> warning
> flag off for libc++'s tests.
Eric: could you *please* look into that? :)
That is way too deep to change without prior knowledge about the code i think.

> 3) A stage2 / stage3 comparison failure in CGAtomic.cpp. That's pre-existing
> and nothing to do with your change.

Roman.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315875 - [Sema] Re-land: Diagnose tautological comparison with type's min/max values

2017-10-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sun Oct 15 13:13:17 2017
New Revision: 315875

URL: http://llvm.org/viewvc/llvm-project?rev=315875&view=rev
Log:
[Sema] Re-land: Diagnose tautological comparison with type's min/max values

The first attempt, rL315614 was reverted because one libcxx
test broke, and i did not know at the time how to deal with it.

Summary:
Currently, clang only diagnoses completely out-of-range comparisons (e.g. 
`char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons 
with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: rtrieu, jroelofs, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D38101

Added:
cfe/trunk/test/Sema/tautological-constant-compare.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Analysis/conversion.c
cfe/trunk/test/Analysis/null-deref-ps.c
cfe/trunk/test/Sema/outof-range-constant-compare.c
cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=315875&r1=315874&r2=315875&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Sun Oct 15 13:13:17 2017
@@ -78,6 +78,10 @@ Improvements to Clang's diagnostics
   when the signed integer is coerced to an unsigned type for the comparison.
   ``-Wsign-compare`` was adjusted not to warn in this case.
 
+- ``-Wtautological-constant-compare`` is a new warning that warns on
+  tautological comparisons between integer variable of the type ``T`` and the
+  largest/smallest possible integer constant of that same type.
+
 - ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
   on a null pointer. Such pointer arithmetic has an undefined behavior if the
   offset is nonzero. It also now warns about arithmetic on a null pointer

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=315875&r1=315874&r2=315875&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sun Oct 15 13:13:17 2017
@@ -432,13 +432,15 @@ def StrncatSize : DiagGroup<"strncat-siz
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
 def TautologicalOutOfRangeCompare : 
DiagGroup<"tautological-constant-out-of-range-compare">;
+def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
+[TautologicalUnsignedZeroCompare,
+ 
TautologicalUnsignedEnumZeroCompare,
+ TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
-[TautologicalUnsignedZeroCompare,
- TautologicalUnsignedEnumZeroCompare,
- TautologicalOutOfRangeCompare,
+[TautologicalConstantCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
  TautologicalUndefinedCompare]>;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315875&r1=315874&r2=315875&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Oct 15 13:13:17 
2017
@@ -5938,18 +5938,18 @@ def note_typecheck_assign_const : Note<
   "member function %q1 is declared const here|"
   "%select{|nested }1data member %2 declared const here}0">;
 
-def warn_lunsigned_always_true_comparison : Warning<
-  "comparison of unsigned expression %0 is always %select{false|true}1">,
+def warn_unsigned_always_true_comparison : Wa

[libcxx] r315874 - Silence clang's -Wtautological-constant-compare in last_write_time.pass.cpp

2017-10-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sun Oct 15 13:12:42 2017
New Revision: 315874

URL: http://llvm.org/viewvc/llvm-project?rev=315874&view=rev
Log:
Silence clang's -Wtautological-constant-compare in last_write_time.pass.cpp

Previously this broke the builders, when D38101 was committed.
Silence the warning so that it can be re-landed.

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=315874&r1=315873&r2=315874&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Sun Oct 15 13:12:42 2017
@@ -88,6 +88,13 @@ bool TestSupportsNegativeTimes() {
 return !ec && new_write_time <= -5;
 }
 
+// In some configurations, the comparison is tautological and the test is 
valid.
+// We disable the warning so that we can actually test it regardless.
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-constant-compare"
+#endif
+
 bool TestSupportsMaxTime() {
 using namespace std::chrono;
 using Lim = std::numeric_limits;
@@ -106,11 +113,22 @@ bool TestSupportsMaxTime() {
 return !ec && new_write_time > max_sec - 1;
 }
 
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 static const bool SupportsNegativeTimes = TestSupportsNegativeTimes();
 static const bool SupportsMaxTime = TestSupportsMaxTime();
 
 } // end namespace
 
+// In some configurations, the comparison is tautological and the test is 
valid.
+// We disable the warning so that we can actually test it regardless.
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-constant-compare"
+#endif
+
 // Check if a time point is representable on a given filesystem. Check that:
 // (A) 'tp' is representable as a time_t
 // (B) 'tp' is non-negative or the filesystem supports negative times.
@@ -127,6 +145,10 @@ inline bool TimeIsRepresentableByFilesys
 return true;
 }
 
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 TEST_SUITE(exists_test_suite)
 
 TEST_CASE(signature_test)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r315876 - Really do make sure that last_write_time.pass.cpp still works with old clang

2017-10-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sun Oct 15 13:46:12 2017
New Revision: 315876

URL: http://llvm.org/viewvc/llvm-project?rev=315876&view=rev
Log:
Really do make sure that last_write_time.pass.cpp still works with old clang

I *did* try to check that such kind of an issue was not introduced
by the rL315874, but clearly i failed to finish verification.

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=315876&r1=315875&r2=315876&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Sun Oct 15 13:46:12 2017
@@ -89,9 +89,11 @@ bool TestSupportsNegativeTimes() {
 }
 
 // In some configurations, the comparison is tautological and the test is 
valid.
-// We disable the warning so that we can actually test it regardless.
+// We disable the warning so that we can actually test it regardless. Also, 
that
+// diagnostic is pretty new, so also don't fail if old clang does not support 
it
 #if defined(__clang__)
 #pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunknown-warning-option"
 #pragma clang diagnostic ignored "-Wtautological-constant-compare"
 #endif
 
@@ -123,9 +125,11 @@ static const bool SupportsMaxTime = Test
 } // end namespace
 
 // In some configurations, the comparison is tautological and the test is 
valid.
-// We disable the warning so that we can actually test it regardless.
+// We disable the warning so that we can actually test it regardless. Also, 
that
+// diagnostic is pretty new, so also don't fail if old clang does not support 
it
 #if defined(__clang__)
 #pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunknown-warning-option"
 #pragma clang diagnostic ignored "-Wtautological-constant-compare"
 #endif
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r315882 - Fix last_write_time.pass.cpp to work with clang-3.9 and earlier

2017-10-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sun Oct 15 14:52:53 2017
New Revision: 315882

URL: http://llvm.org/viewvc/llvm-project?rev=315882&view=rev
Log:
Fix last_write_time.pass.cpp to work with clang-3.9 and earlier

At least with clang-3.9 and earlier, -Wunknown-pragmas is also needed.

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=315882&r1=315881&r2=315882&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Sun Oct 15 14:52:53 2017
@@ -94,6 +94,7 @@ bool TestSupportsNegativeTimes() {
 #if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wunknown-warning-option"
+#pragma clang diagnostic ignored "-Wunknown-pragmas"
 #pragma clang diagnostic ignored "-Wtautological-constant-compare"
 #endif
 
@@ -130,6 +131,7 @@ static const bool SupportsMaxTime = Test
 #if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wunknown-warning-option"
+#pragma clang diagnostic ignored "-Wunknown-pragmas"
 #pragma clang diagnostic ignored "-Wtautological-constant-compare"
 #endif
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r315874 - Silence clang's -Wtautological-constant-compare in last_write_time.pass.cpp

2017-10-16 Thread Roman Lebedev via cfe-commits
On Mon, Oct 16, 2017 at 8:09 PM, David Blaikie  wrote:
> Would it be better/possible to improve the warning to not have this false
> positive, rather than suppressing it?
I am willing to look into it, once there is a clear minimal test-case,
that does not boil down to completely ignoring std::numeric_limits<>.

Right now, sadly, i do not see any simple false-positive here.

Roman.

> On Sun, Oct 15, 2017 at 1:12 PM Roman Lebedev via cfe-commits
>  wrote:
>>
>> Author: lebedevri
>> Date: Sun Oct 15 13:12:42 2017
>> New Revision: 315874
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315874&view=rev
>> Log:
>> Silence clang's -Wtautological-constant-compare in
>> last_write_time.pass.cpp
>>
>> Previously this broke the builders, when D38101 was committed.
>> Silence the warning so that it can be re-landed.
>>
>> Modified:
>>
>> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>>
>> Modified:
>> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=315874&r1=315873&r2=315874&view=diff
>>
>> ==
>> ---
>> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>> (original)
>> +++
>> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>> Sun Oct 15 13:12:42 2017
>> @@ -88,6 +88,13 @@ bool TestSupportsNegativeTimes() {
>>  return !ec && new_write_time <= -5;
>>  }
>>
>> +// In some configurations, the comparison is tautological and the test is
>> valid.
>> +// We disable the warning so that we can actually test it regardless.
>> +#if defined(__clang__)
>> +#pragma clang diagnostic push
>> +#pragma clang diagnostic ignored "-Wtautological-constant-compare"
>> +#endif
>> +
>>  bool TestSupportsMaxTime() {
>>  using namespace std::chrono;
>>  using Lim = std::numeric_limits;
>> @@ -106,11 +113,22 @@ bool TestSupportsMaxTime() {
>>  return !ec && new_write_time > max_sec - 1;
>>  }
>>
>> +#if defined(__clang__)
>> +#pragma clang diagnostic pop
>> +#endif
>> +
>>  static const bool SupportsNegativeTimes = TestSupportsNegativeTimes();
>>  static const bool SupportsMaxTime = TestSupportsMaxTime();
>>
>>  } // end namespace
>>
>> +// In some configurations, the comparison is tautological and the test is
>> valid.
>> +// We disable the warning so that we can actually test it regardless.
>> +#if defined(__clang__)
>> +#pragma clang diagnostic push
>> +#pragma clang diagnostic ignored "-Wtautological-constant-compare"
>> +#endif
>> +
>>  // Check if a time point is representable on a given filesystem. Check
>> that:
>>  // (A) 'tp' is representable as a time_t
>>  // (B) 'tp' is non-negative or the filesystem supports negative times.
>> @@ -127,6 +145,10 @@ inline bool TimeIsRepresentableByFilesys
>>  return true;
>>  }
>>
>> +#if defined(__clang__)
>> +#pragma clang diagnostic pop
>> +#endif
>> +
>>  TEST_SUITE(exists_test_suite)
>>
>>  TEST_CASE(signature_test)
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: clang patch for -fno-var-tracking-assignments option

2017-10-20 Thread Roman Lebedev via cfe-commits
On Fri, Oct 20, 2017 at 11:44 AM, Mikhail Artemyev via cfe-commits
 wrote:
> Hi All,
>
> The attached patch adds a new option '-fno-var-tracking-assignments' in the
> same group (clang_ignored_f_Group) where the existing '-fno-var-tracking'
> resides.
It might be best to upload it to https://llvm.org/docs/Phabricator.html,
so that it is easier to track, and it won't get lost that way.

> Thanks,
> Mikhail
Roman.

> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316268 - [Sema] Fixes for enum handling for tautological comparison diagnostics

2017-10-21 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sat Oct 21 09:44:03 2017
New Revision: 316268

URL: http://llvm.org/viewvc/llvm-project?rev=316268&view=rev
Log:
[Sema] Fixes for enum handling for tautological comparison diagnostics

Summary:
As Mattias Eriksson has reported in PR35009, in C, for enums, the underlying 
type should
be used when checking for the tautological comparison, unlike C++, where the 
enumerator
values define the value range. So if not in CPlusPlus mode, use the enum 
underlying type.

Also, i have discovered a problem (a crash) when evaluating tautological-ness 
of the following comparison:
```
enum A { A_a = 0 };
if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is 
always false}}
return 0;
```
This affects both the C and C++, but after the first fix, only C++ code was 
affected.
That was also fixed, while preserving (i think?) the proper diagnostic output.

And while there, attempt to enhance the test coverage.
Yes, some tests got moved around, sorry about that :)

Fixes PR35009

Reviewers: aaron.ballman, rsmith, rjmccall

Reviewed By: aaron.ballman

Subscribers: Rakete, efriedma, materi, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D39122

Added:
cfe/trunk/test/Sema/outof-range-enum-constant-compare.c
cfe/trunk/test/Sema/tautological-constant-enum-compare.c
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=316268&r1=316267&r2=316268&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sat Oct 21 09:44:03 2017
@@ -8181,8 +8181,12 @@ struct IntRange {
 if (const AtomicType *AT = dyn_cast(T))
   T = AT->getValueType().getTypePtr();
 
-// For enum types, use the known bit width of the enumerators.
-if (const EnumType *ET = dyn_cast(T)) {
+if (!C.getLangOpts().CPlusPlus) {
+  // For enum types in C code, use the underlying datatype.
+  if (const EnumType *ET = dyn_cast(T))
+T = ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
+} else if (const EnumType *ET = dyn_cast(T)) {
+  // For enum types in C++, use the known bit width of the enumerators.
   EnumDecl *Enum = ET->getDecl();
   // In C++11, enums without definitions can have an explicitly specified
   // underlying type.  Use this type to compute the range.
@@ -8584,8 +8588,10 @@ bool isNonBooleanUnsignedValue(Expr *E)
 }
 
 enum class LimitType {
-  Max, // e.g. 32767 for short
-  Min  // e.g. -32768 for short
+  Max = 1U << 0U,  // e.g. 32767 for short
+  Min = 1U << 1U,  // e.g. -32768 for short
+  Both = Max | Min // When the value is both the Min and the Max limit at the
+   // same time; e.g. in C++, A::a in enum A { a = 0 };
 };
 
 /// Checks whether Expr 'Constant' may be the
@@ -8608,6 +8614,10 @@ llvm::Optional IsTypeLimit(Se
 
   IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
 
+  // Special-case for C++ for enum with one enumerator with value of 0.
+  if (OtherRange.Width == 0)
+return Value == 0 ? LimitType::Both : llvm::Optional();
+
   if (llvm::APSInt::isSameValue(
   llvm::APSInt::getMaxValue(OtherRange.Width,
 OtherT->isUnsignedIntegerType()),
@@ -8620,7 +8630,7 @@ llvm::Optional IsTypeLimit(Se
   Value))
 return LimitType::Min;
 
-  return llvm::Optional();
+  return llvm::None;
 }
 
 bool HasEnumType(Expr *E) {
@@ -8655,9 +8665,12 @@ bool CheckTautologicalComparison(Sema &S
 
   bool ConstIsLowerBound = (Op == BO_LT || Op == BO_LE) ^ RhsConstant;
   bool ResultWhenConstEqualsOther = (Op == BO_LE || Op == BO_GE);
-  bool ResultWhenConstNeOther =
-  ConstIsLowerBound ^ (ValueType == LimitType::Max);
-  if (ResultWhenConstEqualsOther != ResultWhenConstNeOther)
+  if (ValueType != LimitType::Both) {
+bool ResultWhenConstNeOther =
+ConstIsLowerBound ^ (ValueType == LimitType::Max);
+if (ResultWhenConstEqualsOther != ResultWhenConstNeOther)
+  return false; // The comparison is not tautological.
+  } else if (ResultWhenConstEqualsOther == ConstIsLowerBound)
 return false; // The comparison is not tautological.
 
   const bool Result = ResultWhenConstEqualsOther;

Added: cfe/trunk/test/Sema/outof-range-enum-constant-compare.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/outof-range-enum-constant-compare.c?rev=316268&view=auto
==
--- cfe/trunk/test/Sema/outof-range-enum-constant-compare.c (added)
+++ cfe/trunk/test/Sema/outof-range-enum-constant-compare.c Sat Oct 21 09:44:03 
2017
@@ -0,0 +1,379 @@
+// RUN: %c

Re: r316268 - [Sema] Fixes for enum handling for tautological comparison diagnostics

2017-10-23 Thread Roman Lebedev via cfe-commits
On Mon, Oct 23, 2017 at 2:13 PM, Hans Wennborg  wrote:
Hi.

> This seems to have had the side effect of introducing a new warning in
> Chromium builds:
>
> ../../third_party/expat/files/lib/xmlparse.c(2429,24):  error:
> comparison of integers of different signs: 'enum XML_Error' and
> 'unsigned int' [-Werror,-Wsign-compare]
>   if (code > 0 && code < sizeof(message)/sizeof(message[0]))
>    ^ ~~
(I guess this is on windows)

> I'm not sure if this was intentional or not.
>
> The warning seems technically correct here, though not very useful in
> this specific case.
I *believe* that was caused by the fix for IntRange::forValueOfCanonicalType()
to use enum's underlying type for C code. That fix was absolutely intentional.

However that new -Wsign-compare diagnostic (and i suspect there may be
more repercussions) was not really intentional.
However as you have said, and i think i agree, the diagnostic valid.

So perhaps i simply should add a test and release notes entry?

Roman.

> On Sat, Oct 21, 2017 at 6:44 PM, Roman Lebedev via cfe-commits
>  wrote:
>> Author: lebedevri
>> Date: Sat Oct 21 09:44:03 2017
>> New Revision: 316268
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=316268&view=rev
>> Log:
>> [Sema] Fixes for enum handling for tautological comparison diagnostics
>>
>> Summary:
>> As Mattias Eriksson has reported in PR35009, in C, for enums, the underlying 
>> type should
>> be used when checking for the tautological comparison, unlike C++, where the 
>> enumerator
>> values define the value range. So if not in CPlusPlus mode, use the enum 
>> underlying type.
>>
>> Also, i have discovered a problem (a crash) when evaluating 
>> tautological-ness of the following comparison:
>> ```
>> enum A { A_a = 0 };
>> if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 
>> is always false}}
>> return 0;
>> ```
>> This affects both the C and C++, but after the first fix, only C++ code was 
>> affected.
>> That was also fixed, while preserving (i think?) the proper diagnostic 
>> output.
>>
>> And while there, attempt to enhance the test coverage.
>> Yes, some tests got moved around, sorry about that :)
>>
>> Fixes PR35009
>>
>> Reviewers: aaron.ballman, rsmith, rjmccall
>>
>> Reviewed By: aaron.ballman
>>
>> Subscribers: Rakete, efriedma, materi, cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D39122
>>
>> Added:
>> cfe/trunk/test/Sema/outof-range-enum-constant-compare.c
>> cfe/trunk/test/Sema/tautological-constant-enum-compare.c
>> Modified:
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
>> cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=316268&r1=316267&r2=316268&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Sat Oct 21 09:44:03 2017
>> @@ -8181,8 +8181,12 @@ struct IntRange {
>>  if (const AtomicType *AT = dyn_cast(T))
>>T = AT->getValueType().getTypePtr();
>>
>> -// For enum types, use the known bit width of the enumerators.
>> -if (const EnumType *ET = dyn_cast(T)) {
>> +if (!C.getLangOpts().CPlusPlus) {
>> +  // For enum types in C code, use the underlying datatype.
>> +  if (const EnumType *ET = dyn_cast(T))
>> +T = 
>> ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
>> +} else if (const EnumType *ET = dyn_cast(T)) {
>> +  // For enum types in C++, use the known bit width of the enumerators.
>>EnumDecl *Enum = ET->getDecl();
>>// In C++11, enums without definitions can have an explicitly 
>> specified
>>// underlying type.  Use this type to compute the range.
>> @@ -8584,8 +8588,10 @@ bool isNonBooleanUnsignedValue(Expr *E)
>>  }
>>
>>  enum class LimitType {
>> -  Max, // e.g. 32767 for short
>> -  Min  // e.g. -32768 for short
>> +  Max = 1U << 0U,  // e.g. 32767 for short
>> +  Min = 1U << 1U,  // e.g. -32768 for short
>> +  Both = Max | Min // When the value is both the Min and the Max limit at 
&g

r316500 - [Sema] Document+test the -Wsign-compare change for enums in C code [NFC]

2017-10-24 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Oct 24 14:05:43 2017
New Revision: 316500

URL: http://llvm.org/viewvc/llvm-project?rev=316500&view=rev
Log:
[Sema] Document+test the -Wsign-compare change for enums in C code [NFC]

rL316268 / D39122 has fixed PR35009, and now when in C,
these three(?) diagnostics properly use the enum's underlying
datatype.

While it was fixed, the test coverage was clearly insufficient,
because the -Wsign-compare change didn't show up in any of the
tests, until it was reported in the post-commit mail for rL316268.

So add the test for the -Wsign-compare diagnostic for enum
for C code, and while there, document this in the release notes.

The fix itself was obviously correct, so unless we want to silence
this new diagnosed case, i deem this commit to be NFC.

Added:
cfe/trunk/test/Sema/sign-compare-enum.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=316500&r1=316499&r2=316500&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Oct 24 14:05:43 2017
@@ -82,6 +82,10 @@ Improvements to Clang's diagnostics
   tautological comparisons between integer variable of the type ``T`` and the
   largest/smallest possible integer constant of that same type.
 
+- For C code, ``-Wsign-compare``, ``-Wtautological-constant-compare`` and
+  ``-Wtautological-constant-out-of-range-compare`` were adjusted to use the
+  underlying datatype of ``enum``.
+
 - ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
   on a null pointer. Such pointer arithmetic has an undefined behavior if the
   offset is nonzero. It also now warns about arithmetic on a null pointer

Added: cfe/trunk/test/Sema/sign-compare-enum.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/sign-compare-enum.c?rev=316500&view=auto
==
--- cfe/trunk/test/Sema/sign-compare-enum.c (added)
+++ cfe/trunk/test/Sema/sign-compare-enum.c Tue Oct 24 14:05:43 2017
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED 
-verify -Wsign-compare %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify 
-Wsign-compare %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED 
-DSILENCE -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -DSILENCE 
-verify %s
+
+int main() {
+  enum A { A_a = 0, A_b = 1 };
+  static const int message[] = {0, 1};
+  enum A a;
+
+  if (a < 2)
+return 0;
+
+#if defined(SIGNED) && !defined(SILENCE)
+  if (a < sizeof(message)/sizeof(message[0])) // expected-warning {{comparison 
of integers of different signs: 'enum A' and 'unsigned long long'}}
+return 0;
+#else
+  // expected-no-diagnostics
+  if (a < 2U)
+return 0;
+  if (a < sizeof(message)/sizeof(message[0]))
+return 0;
+#endif
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r316268 - [Sema] Fixes for enum handling for tautological comparison diagnostics

2017-10-24 Thread Roman Lebedev via cfe-commits
On Tue, Oct 24, 2017 at 3:00 PM, Hans Wennborg  wrote:
> On Mon, Oct 23, 2017 at 2:02 PM, Roman Lebedev  wrote:
>> On Mon, Oct 23, 2017 at 2:13 PM, Hans Wennborg  wrote:
>> Hi.
>>
>>> This seems to have had the side effect of introducing a new warning in
>>> Chromium builds:
>>>
>>> ../../third_party/expat/files/lib/xmlparse.c(2429,24):  error:
>>> comparison of integers of different signs: 'enum XML_Error' and
>>> 'unsigned int' [-Werror,-Wsign-compare]
>>>   if (code > 0 && code < sizeof(message)/sizeof(message[0]))
>>>    ^ ~~
>> (I guess this is on windows)
>
> Yes.
>
>>
>>> I'm not sure if this was intentional or not.
>>>
>>> The warning seems technically correct here, though not very useful in
>>> this specific case.
>> I *believe* that was caused by the fix for 
>> IntRange::forValueOfCanonicalType()
>> to use enum's underlying type for C code. That fix was absolutely 
>> intentional.
>>
>> However that new -Wsign-compare diagnostic (and i suspect there may be
>> more repercussions) was not really intentional.
>> However as you have said, and i think i agree, the diagnostic valid.
>>
>> So perhaps i simply should add a test and release notes entry?
>
> Sounds reasonable. It turns out we only got this single extra
> -Wsign-compare warning, so it didn't turn out to be a big problem for
> us.

Ok, committed in https://reviews.llvm.org/rL316500
Roman.

>>
>> Roman.
>>
>>> On Sat, Oct 21, 2017 at 6:44 PM, Roman Lebedev via cfe-commits
>>>  wrote:
>>>> Author: lebedevri
>>>> Date: Sat Oct 21 09:44:03 2017
>>>> New Revision: 316268
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=316268&view=rev
>>>> Log:
>>>> [Sema] Fixes for enum handling for tautological comparison diagnostics
>>>>
>>>> Summary:
>>>> As Mattias Eriksson has reported in PR35009, in C, for enums, the 
>>>> underlying type should
>>>> be used when checking for the tautological comparison, unlike C++, where 
>>>> the enumerator
>>>> values define the value range. So if not in CPlusPlus mode, use the enum 
>>>> underlying type.
>>>>
>>>> Also, i have discovered a problem (a crash) when evaluating 
>>>> tautological-ness of the following comparison:
>>>> ```
>>>> enum A { A_a = 0 };
>>>> if (a < 0) // expected-warning {{comparison of unsigned enum expression < 
>>>> 0 is always false}}
>>>> return 0;
>>>> ```
>>>> This affects both the C and C++, but after the first fix, only C++ code 
>>>> was affected.
>>>> That was also fixed, while preserving (i think?) the proper diagnostic 
>>>> output.
>>>>
>>>> And while there, attempt to enhance the test coverage.
>>>> Yes, some tests got moved around, sorry about that :)
>>>>
>>>> Fixes PR35009
>>>>
>>>> Reviewers: aaron.ballman, rsmith, rjmccall
>>>>
>>>> Reviewed By: aaron.ballman
>>>>
>>>> Subscribers: Rakete, efriedma, materi, cfe-commits
>>>>
>>>> Tags: #clang
>>>>
>>>> Differential Revision: https://reviews.llvm.org/D39122
>>>>
>>>> Added:
>>>> cfe/trunk/test/Sema/outof-range-enum-constant-compare.c
>>>> cfe/trunk/test/Sema/tautological-constant-enum-compare.c
>>>> Modified:
>>>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>>> cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
>>>> cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.cpp
>>>>
>>>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>>>> URL: 
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=316268&r1=316267&r2=316268&view=diff
>>>> ==
>>>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>>>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Sat Oct 21 09:44:03 2017
>>>> @@ -8181,8 +8181,12 @@ struct IntRange {
>>>>  if (const AtomicType *AT = dyn_cast(T))
>>>>T = AT->getValueType().getTypePtr();
>>>>
>>>> -// For enum types, use the known bit width of the

Re: [clang-tools-extra] r340800 - [clang-tidy] Abseil: no namepsace check

2018-08-28 Thread Roman Lebedev via cfe-commits
On Tue, Aug 28, 2018 at 10:48 AM, Haojian Wu via cfe-commits
 wrote:
> Author: hokein
> Date: Tue Aug 28 00:48:28 2018
> New Revision: 340800
>
> URL: http://llvm.org/viewvc/llvm-project?rev=340800&view=rev
> Log:
> [clang-tidy] Abseil: no namepsace check
>
> This check ensures that users of Abseil do not open namespace absl in their 
> code, as that violates our compatibility guidelines.
>
> AbseilMatcher.h written by Hugo Gonzalez.

Would it please be possible to use the common notation of adding a line

Differential Revision: https://reviews.llvm.org/D?

so that phabricator automatically properly associates the committed
revision with the differential, and closes it?

Roman.

> Patch by Deanna Garcia!
>
> Added:
> clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h
> clang-tools-extra/trunk/clang-tidy/abseil/NoNamespaceCheck.cpp
> clang-tools-extra/trunk/clang-tidy/abseil/NoNamespaceCheck.h
> clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-no-namespace.rst
> clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/
> clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/external-file.h
> clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/
> 
> clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h
> clang-tools-extra/trunk/test/clang-tidy/abseil-no-namespace.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
> clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
> clang-tools-extra/trunk/docs/ReleaseNotes.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Added: clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h?rev=340800&view=auto
> ==
> --- clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h (added)
> +++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h Tue Aug 28 
> 00:48:28 2018
> @@ -0,0 +1,51 @@
> +//===- AbseilMatcher.h - clang-tidy 
> ---===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--===//
> +//
> +#include "clang/AST/ASTContext.h"
> +#include "clang/ASTMatchers/ASTMatchFinder.h"
> +
> +namespace clang {
> +namespace ast_matchers {
> +
> +/// Matches AST nodes that were found within Abseil files.
> +///
> +/// Example matches Y but not X
> +/// (matcher = cxxRecordDecl(isInAbseilFile())
> +/// \code
> +///   #include "absl/strings/internal-file.h"
> +///   class X {};
> +/// \endcode
> +/// absl/strings/internal-file.h:
> +/// \code
> +///   class Y {};
> +/// \endcode
> +///
> +/// Usable as: Matcher, Matcher, Matcher,
> +/// Matcher
> +
> +AST_POLYMORPHIC_MATCHER(isInAbseilFile,
> +AST_POLYMORPHIC_SUPPORTED_TYPES(
> +Decl, Stmt, TypeLoc, NestedNameSpecifierLoc)) {
> +  auto &SourceManager = Finder->getASTContext().getSourceManager();
> +  SourceLocation Loc = Node.getBeginLoc();
> +  if (Loc.isInvalid())
> +return false;
> +  const FileEntry *FileEntry =
> +  SourceManager.getFileEntryForID(SourceManager.getFileID(Loc));
> +  if (!FileEntry)
> +return false;
> +  StringRef Filename = FileEntry->getName();
> +  llvm::Regex RE(
> +  "absl/(algorithm|base|container|debugging|memory|meta|numeric|strings|"
> +  "synchronization|time|types|utility)");
> +  return RE.match(Filename);
> +}
> +
> +} // namespace ast_matchers
> +} // namespace clang
>
> Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp?rev=340800&r1=340799&r2=340800&view=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp (original)
> +++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp Tue Aug 28 
> 00:48:28 2018
> @@ -12,6 +12,7 @@
>  #include "../ClangTidyModuleRegistry.h"
>  #include "DurationDivisionCheck.h"
>  #include "FasterStrsplitDelimiterCheck.h"
> +#include "NoNamespaceCheck.h"
>  #include "StringFindStartswithCheck.h"
>
>  namespace clang {
> @@ -25,6 +26,7 @@ public:
>  "abseil-duration-division");
>  CheckFactories.registerCheck(
>  "abseil-faster-strsplit-delimiter");
> +CheckFactories.registerCheck("abseil-no-namespace");
>  CheckFactories.registerCheck(
>  "abseil-string-find-startswith");
>}
>
> Modified: clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.

Re: r341140 - Add dump() method for SourceRange

2018-08-30 Thread Roman Lebedev via cfe-commits
I don't think this was reviewed. The differential is not in 'accepted' state.

Roman.

On Fri, Aug 31, 2018 at 2:10 AM, Stephen Kelly via cfe-commits
 wrote:
> Author: steveire
> Date: Thu Aug 30 16:10:52 2018
> New Revision: 341140
>
> URL: http://llvm.org/viewvc/llvm-project?rev=341140&view=rev
> Log:
> Add dump() method for SourceRange
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D50662
>
> Modified:
> cfe/trunk/include/clang/Basic/SourceLocation.h
> cfe/trunk/lib/Basic/SourceLocation.cpp
> cfe/trunk/unittests/Basic/SourceManagerTest.cpp
>
> Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=341140&r1=341139&r2=341140&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
> +++ cfe/trunk/include/clang/Basic/SourceLocation.h Thu Aug 30 16:10:52 2018
> @@ -220,6 +220,10 @@ public:
>bool operator!=(const SourceRange &X) const {
>  return B != X.B || E != X.E;
>}
> +
> +  void print(raw_ostream &OS, const SourceManager &SM) const;
> +  std::string printToString(const SourceManager &SM) const;
> +  void dump(const SourceManager &SM) const;
>  };
>
>  /// Represents a character-granular source range.
>
> Modified: cfe/trunk/lib/Basic/SourceLocation.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceLocation.cpp?rev=341140&r1=341139&r2=341140&view=diff
> ==
> --- cfe/trunk/lib/Basic/SourceLocation.cpp (original)
> +++ cfe/trunk/lib/Basic/SourceLocation.cpp Thu Aug 30 16:10:52 2018
> @@ -80,6 +80,60 @@ LLVM_DUMP_METHOD void SourceLocation::du
>llvm::errs() << '\n';
>  }
>
> +LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager &SM) const {
> +  print(llvm::errs(), SM);
> +  llvm::errs() << '\n';
> +}
> +
> +static PresumedLoc PrintDifference(raw_ostream &OS, const SourceManager &SM,
> +   SourceLocation Loc, PresumedLoc Previous) 
> {
> +  if (Loc.isFileID()) {
> +
> +PresumedLoc PLoc = SM.getPresumedLoc(Loc);
> +
> +if (PLoc.isInvalid()) {
> +  OS << "";
> +  return Previous;
> +}
> +
> +if (Previous.isInvalid() ||
> +strcmp(PLoc.getFilename(), Previous.getFilename()) != 0) {
> +  OS << PLoc.getFilename() << ':' << PLoc.getLine() << ':'
> + << PLoc.getColumn();
> +} else if (Previous.isInvalid() || PLoc.getLine() != Previous.getLine()) 
> {
> +  OS << "line" << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
> +} else {
> +  OS << "col" << ':' << PLoc.getColumn();
> +}
> +return PLoc;
> +  }
> +  auto PrintedLoc = PrintDifference(OS, SM, SM.getExpansionLoc(Loc), 
> Previous);
> +
> +  OS << "  +  PrintedLoc = PrintDifference(OS, SM, SM.getSpellingLoc(Loc), PrintedLoc);
> +  OS << '>';
> +  return PrintedLoc;
> +}
> +
> +void SourceRange::print(raw_ostream &OS, const SourceManager &SM) const {
> +
> +  OS << '<';
> +  auto PrintedLoc = PrintDifference(OS, SM, B, {});
> +  if (B != E) {
> +OS << ", ";
> +PrintDifference(OS, SM, E, PrintedLoc);
> +  }
> +  OS << '>';
> +}
> +
> +LLVM_DUMP_METHOD std::string
> +SourceRange::printToString(const SourceManager &SM) const {
> +  std::string S;
> +  llvm::raw_string_ostream OS(S);
> +  print(OS, SM);
> +  return OS.str();
> +}
> +
>  
> //===--===//
>  // FullSourceLoc
>  
> //===--===//
>
> Modified: cfe/trunk/unittests/Basic/SourceManagerTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/SourceManagerTest.cpp?rev=341140&r1=341139&r2=341140&view=diff
> ==
> --- cfe/trunk/unittests/Basic/SourceManagerTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/SourceManagerTest.cpp Thu Aug 30 16:10:52 2018
> @@ -155,6 +155,54 @@ TEST_F(SourceManagerTest, getColumnNumbe
>EXPECT_EQ(1U, SourceMgr.getColumnNumber(MainFileID, 0, nullptr));
>  }
>
> +TEST_F(SourceManagerTest, locationPrintTest) {
> +  const char *header = "#define IDENTITY(x) x\n";
> +
> +  const char *Source = "int x;\n"
> +   "include \"test-header.h\"\n"
> +   "IDENTITY(int y);\n"
> +   "int z;";
> +
> +  std::unique_ptr HeaderBuf =
> +  llvm::MemoryBuffer::getMemBuffer(header);
> +  std::unique_ptr Buf =
> +  llvm::MemoryBuffer::getMemBuffer(Source);
> +
> +  const FileEntry *SourceFile =
> +  FileMgr.getVirtualFile("/mainFile.cpp", Buf->getBufferSize(), 0);
> +  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
> +
> +  const FileEntry *HeaderFile =
> +  FileMgr.getVirtualFile("/test-header.h", HeaderBuf->getBu

Re: r341141 - Extract parseBindID method

2018-08-30 Thread Roman Lebedev via cfe-commits
I don't think this was reviewed. The differential is not in 'accepted' state.

Roman.

On Fri, Aug 31, 2018 at 2:11 AM, Stephen Kelly via cfe-commits
 wrote:
> Author: steveire
> Date: Thu Aug 30 16:11:01 2018
> New Revision: 341141
>
> URL: http://llvm.org/viewvc/llvm-project?rev=341141&view=rev
> Log:
> Extract parseBindID method
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D51258
>
> Modified:
> cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
> cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
>
> Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h?rev=341141&r1=341140&r2=341141&view=diff
> ==
> --- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h (original)
> +++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h Thu Aug 30 16:11:01 
> 2018
> @@ -234,6 +234,7 @@ private:
>   const NamedValueMap *NamedValues,
>   Diagnostics *Error);
>
> +  bool parseBindID(std::string &BindID);
>bool parseExpressionImpl(VariantValue *Value);
>bool parseMatcherExpressionImpl(const TokenInfo &NameToken,
>VariantValue *Value);
>
> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=341141&r1=341140&r2=341141&view=diff
> ==
> --- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Thu Aug 30 16:11:01 2018
> @@ -359,6 +359,43 @@ bool Parser::parseIdentifierPrefixImpl(V
>return parseMatcherExpressionImpl(NameToken, Value);
>  }
>
> +bool Parser::parseBindID(std::string &BindID) {
> +  // Parse .bind("foo")
> +  assert(Tokenizer->peekNextToken().Kind == TokenInfo::TK_Period);
> +  Tokenizer->consumeNextToken(); // consume the period.
> +  const TokenInfo BindToken = Tokenizer->consumeNextToken();
> +  if (BindToken.Kind == TokenInfo::TK_CodeCompletion) {
> +addCompletion(BindToken, MatcherCompletion("bind(\"", "bind", 1));
> +return false;
> +  }
> +
> +  const TokenInfo OpenToken = Tokenizer->consumeNextToken();
> +  const TokenInfo IDToken = Tokenizer->consumeNextToken();
> +  const TokenInfo CloseToken = Tokenizer->consumeNextToken();
> +
> +  // TODO: We could use different error codes for each/some to be more
> +  //   explicit about the syntax error.
> +  if (BindToken.Kind != TokenInfo::TK_Ident ||
> +  BindToken.Text != TokenInfo::ID_Bind) {
> +Error->addError(BindToken.Range, Error->ET_ParserMalformedBindExpr);
> +return false;
> +  }
> +  if (OpenToken.Kind != TokenInfo::TK_OpenParen) {
> +Error->addError(OpenToken.Range, Error->ET_ParserMalformedBindExpr);
> +return false;
> +  }
> +  if (IDToken.Kind != TokenInfo::TK_Literal || !IDToken.Value.isString()) {
> +Error->addError(IDToken.Range, Error->ET_ParserMalformedBindExpr);
> +return false;
> +  }
> +  if (CloseToken.Kind != TokenInfo::TK_CloseParen) {
> +Error->addError(CloseToken.Range, Error->ET_ParserMalformedBindExpr);
> +return false;
> +  }
> +  BindID = IDToken.Value.getString();
> +  return true;
> +}
> +
>  /// Parse and validate a matcher expression.
>  /// \return \c true on success, in which case \c Value has the matcher 
> parsed.
>  ///   If the input is malformed, or some argument has an error, it
> @@ -425,38 +462,8 @@ bool Parser::parseMatcherExpressionImpl(
>
>std::string BindID;
>if (Tokenizer->peekNextToken().Kind == TokenInfo::TK_Period) {
> -// Parse .bind("foo")
> -Tokenizer->consumeNextToken();  // consume the period.
> -const TokenInfo BindToken = Tokenizer->consumeNextToken();
> -if (BindToken.Kind == TokenInfo::TK_CodeCompletion) {
> -  addCompletion(BindToken, MatcherCompletion("bind(\"", "bind", 1));
> +if (!parseBindID(BindID))
>return false;
> -}
> -
> -const TokenInfo OpenToken = Tokenizer->consumeNextToken();
> -const TokenInfo IDToken = Tokenizer->consumeNextToken();
> -const TokenInfo CloseToken = Tokenizer->consumeNextToken();
> -
> -// TODO: We could use different error codes for each/some to be more
> -//   explicit about the syntax error.
> -if (BindToken.Kind != TokenInfo::TK_Ident ||
> -BindToken.Text != TokenInfo::ID_Bind) {
> -  Error->addError(BindToken.Range, Error->ET_ParserMalformedBindExpr);
> -  return false;
> -}
> -if (OpenToken.Kind != TokenInfo::TK_OpenParen) {
> -  Error->addError(OpenToken.Range, Error->ET_ParserMalformedBindExpr);
> -  return false;
> -}
> -if (IDToken.Kind != TokenInfo::TK_Literal || !IDToken.Value.isString()) {
> -  Error->addError(IDToken.Range, Error->ET_ParserMalformedBindExpr);
> -  return false;
> - 

Re: [clang-tools-extra] r341144 - Extract runCommandsInFile method

2018-08-30 Thread Roman Lebedev via cfe-commits
I don't think this was reviewed. The differential is not in 'accepted' state.

Roman.

On Fri, Aug 31, 2018 at 2:25 AM, Stephen Kelly via cfe-commits
 wrote:
> Author: steveire
> Date: Thu Aug 30 16:25:38 2018
> New Revision: 341144
>
> URL: http://llvm.org/viewvc/llvm-project?rev=341144&view=rev
> Log:
> Extract runCommandsInFile method
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D51260
>
> Modified:
> clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
>
> Modified: clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp?rev=341144&r1=341143&r2=341144&view=diff
> ==
> --- clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp (original)
> +++ clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp Thu Aug 30 
> 16:25:38 2018
> @@ -58,6 +58,24 @@ static cl::list CommandFile
>cl::value_desc("file"),
>cl::cat(ClangQueryCategory));
>
> +bool runCommandsInFile(const char *ExeName, std::string const &FileName,
> +   QuerySession &QS) {
> +  std::ifstream Input(FileName.c_str());
> +  if (!Input.is_open()) {
> +llvm::errs() << ExeName << ": cannot open " << FileName << "\n";
> +return 1;
> +  }
> +  while (Input.good()) {
> +std::string Line;
> +std::getline(Input, Line);
> +
> +QueryRef Q = QueryParser::parse(Line, QS);
> +if (!Q->run(llvm::outs(), QS))
> +  return true;
> +  }
> +  return false;
> +}
> +
>  int main(int argc, const char **argv) {
>llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
>
> @@ -84,19 +102,8 @@ int main(int argc, const char **argv) {
>  }
>} else if (!CommandFiles.empty()) {
>  for (auto I = CommandFiles.begin(), E = CommandFiles.end(); I != E; ++I) 
> {
> -  std::ifstream Input(I->c_str());
> -  if (!Input.is_open()) {
> -llvm::errs() << argv[0] << ": cannot open " << *I << "\n";
> +  if (runCommandsInFile(argv[0], *I, QS))
>  return 1;
> -  }
> -  while (Input.good()) {
> -std::string Line;
> -std::getline(Input, Line);
> -
> -QueryRef Q = QueryParser::parse(Line, QS);
> -if (!Q->run(llvm::outs(), QS))
> -  return 1;
> -  }
>  }
>} else {
>  LineEditor LE("clang-query");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r341141 - Extract parseBindID method

2018-09-06 Thread Roman Lebedev via cfe-commits
On Thu, Sep 6, 2018 at 10:05 PM, Stephen Kelly via cfe-commits
 wrote:
>
> Yes, this was a prerequisite to https://reviews.llvm.org/D51259. For some
> reason the reviewer accepted that one, but not this one. I simply assumed
> that was a mistake and committed this one.
I'm not sure this is how the review works in LLVM, in general.

> Perhaps part of the problem is that I do one thing per commit, and that
> confuses reviewers. Maybe I should squash things for review? I don't know.
You can specify the dependencies between the differentials in phabricator.

> Thanks for any post-commit review!
>
> Stephen.
Roman.

> On 31/08/18 07:06, Roman Lebedev via cfe-commits wrote:
>>
>> I don't think this was reviewed. The differential is not in 'accepted'
>> state.
>>
>> Roman.
>>
>> On Fri, Aug 31, 2018 at 2:11 AM, Stephen Kelly via cfe-commits
>>  wrote:
>>>
>>> Author: steveire
>>> Date: Thu Aug 30 16:11:01 2018
>>> New Revision: 341141
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=341141&view=rev
>>> Log:
>>> Extract parseBindID method
>>>
>>> Subscribers: cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D51258
>>>
>>> Modified:
>>>  cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
>>>  cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
>>>
>>> Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h?rev=341141&r1=341140&r2=341141&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h (original)
>>> +++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h Thu Aug 30
>>> 16:11:01 2018
>>> @@ -234,6 +234,7 @@ private:
>>>const NamedValueMap *NamedValues,
>>>Diagnostics *Error);
>>>
>>> +  bool parseBindID(std::string &BindID);
>>> bool parseExpressionImpl(VariantValue *Value);
>>> bool parseMatcherExpressionImpl(const TokenInfo &NameToken,
>>> VariantValue *Value);
>>>
>>> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=341141&r1=341140&r2=341141&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
>>> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Thu Aug 30 16:11:01 2018
>>> @@ -359,6 +359,43 @@ bool Parser::parseIdentifierPrefixImpl(V
>>> return parseMatcherExpressionImpl(NameToken, Value);
>>>   }
>>>
>>> +bool Parser::parseBindID(std::string &BindID) {
>>> +  // Parse .bind("foo")
>>> +  assert(Tokenizer->peekNextToken().Kind == TokenInfo::TK_Period);
>>> +  Tokenizer->consumeNextToken(); // consume the period.
>>> +  const TokenInfo BindToken = Tokenizer->consumeNextToken();
>>> +  if (BindToken.Kind == TokenInfo::TK_CodeCompletion) {
>>> +addCompletion(BindToken, MatcherCompletion("bind(\"", "bind", 1));
>>> +return false;
>>> +  }
>>> +
>>> +  const TokenInfo OpenToken = Tokenizer->consumeNextToken();
>>> +  const TokenInfo IDToken = Tokenizer->consumeNextToken();
>>> +  const TokenInfo CloseToken = Tokenizer->consumeNextToken();
>>> +
>>> +  // TODO: We could use different error codes for each/some to be more
>>> +  //   explicit about the syntax error.
>>> +  if (BindToken.Kind != TokenInfo::TK_Ident ||
>>> +  BindToken.Text != TokenInfo::ID_Bind) {
>>> +Error->addError(BindToken.Range, Error->ET_ParserMalformedBindExpr);
>>> +return false;
>>> +  }
>>> +  if (OpenToken.Kind != TokenInfo::TK_OpenParen) {
>>> +Error->addError(OpenToken.Range, Error->ET_ParserMalformedBindExpr);
>>> +return false;
>>> +  }
>>> +  if (IDToken.Kind != TokenInfo::TK_Literal ||
>>> !IDToken.Value.isString()) {
>>> +Error->addError(IDToken.Range, Error->ET_ParserMalformedBindExpr);
>>> +return false;
>>> +  }
>>> +  if (CloseToken.Kind != TokenInfo::TK_CloseParen) {
>>>

[clang-tools-extra] r341854 - [clang-tidy] ExprMutationAnalyzer: construct from references. Fixes PR38888

2018-09-10 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Sep 10 12:59:18 2018
New Revision: 341854

URL: http://llvm.org/viewvc/llvm-project?rev=341854&view=rev
Log:
[clang-tidy] ExprMutationAnalyzer: construct from references. Fixes PR3

Summary:
I have hit this the rough way, while trying to use this in D51870.

There is no particular point in storing the pointers, and moreover
the pointers are assumed to be non-null, and that assumption is not
enforced. If they are null, it won't be able to do anything good
with them anyway.

Initially i thought about simply adding asserts() that they are
not null, but taking/storing references looks like even cleaner solution?

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=3 | PR3 ]]

Reviewers: JonasToth, shuaiwang, alexfh, george.karpenkov

Reviewed By: shuaiwang

Subscribers: xazax.hun, a.sidorin, Szelethus, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D51884

Modified:
clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExprMutationAnalyzer.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExprMutationAnalyzer.h
clang-tools-extra/trunk/unittests/clang-tidy/ExprMutationAnalyzerTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp?rev=341854&r1=341853&r2=341854&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp Mon 
Sep 10 12:59:18 2018
@@ -88,8 +88,8 @@ bool ForRangeCopyCheck::handleCopyIsOnly
   // Because the fix (changing to `const auto &`) will introduce an unused
   // compiler warning which can't be suppressed.
   // Since this case is very rare, it is safe to ignore it.
-  if (!utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
-  .isMutated(&LoopVar) &&
+  if (!utils::ExprMutationAnalyzer(*ForRange.getBody(), Context)
+   .isMutated(&LoopVar) &&
   !utils::decl_ref_expr::allDeclRefExprs(LoopVar, *ForRange.getBody(),
  Context)
.empty()) {

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=341854&r1=341853&r2=341854&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
Mon Sep 10 12:59:18 2018
@@ -95,14 +95,14 @@ void UnnecessaryValueParamCheck::check(c
   // Do not trigger on non-const value parameters when they are mutated either
   // within the function body or within init expression(s) when the function is
   // a ctor.
-  if (utils::ExprMutationAnalyzer(Function->getBody(), Result.Context)
+  if (utils::ExprMutationAnalyzer(*Function->getBody(), *Result.Context)
   .isMutated(Param))
 return;
   // CXXCtorInitializer might also mutate Param but they're not part of 
function
   // body, so check them separately here.
   if (const auto *Ctor = dyn_cast(Function)) {
 for (const auto *Init : Ctor->inits()) {
-  if (utils::ExprMutationAnalyzer(Init->getInit(), Result.Context)
+  if (utils::ExprMutationAnalyzer(*Init->getInit(), *Result.Context)
   .isMutated(Param))
 return;
 }

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExprMutationAnalyzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExprMutationAnalyzer.cpp?rev=341854&r1=341853&r2=341854&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/ExprMutationAnalyzer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExprMutationAnalyzer.cpp Mon Sep 
10 12:59:18 2018
@@ -102,7 +102,7 @@ bool ExprMutationAnalyzer::isUnevaluated
   hasDescendant(equalsNode(Exp,
   cxxNoexceptExpr())
  .bind("expr")),
- *Stm, *Context)) != nullptr;
+ Stm, Context)) != nullptr;
 }
 
 const Stmt *
@@ -125,7 +125,7 @@ ExprMutationAnalyzer::findDeclMutation(A
 
 const Stmt *ExprMutationAnalyzer::findDeclMutation(const Decl *Dec) {
   const auto Refs = match(
-  findAll(declRefExpr(to(equalsNode(Dec))).bind("expr")), *Stm, *Context);
+  findAll(declRefExpr(to(equalsNode(Dec))).bind("expr")), Stm, Context);
   for (const auto &RefNodes : Refs) {
 cons

Re: [clang-tools-extra] r342227 - [clangd] NFC: Fix IndexBenchmark CLI arguments handling

2018-09-14 Thread Roman Lebedev via cfe-commits
On Fri, Sep 14, 2018 at 3:21 PM, Kirill Bobyrev via cfe-commits
 wrote:
> Author: omtcyfz
> Date: Fri Sep 14 05:21:09 2018
> New Revision: 342227
>
> URL: http://llvm.org/viewvc/llvm-project?rev=342227&view=rev
> Log:
> [clangd] NFC: Fix IndexBenchmark CLI arguments handling
>
> Modified:
> clang-tools-extra/trunk/clangd/benchmarks/IndexBenchmark.cpp
>
> Modified: clang-tools-extra/trunk/clangd/benchmarks/IndexBenchmark.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/benchmarks/IndexBenchmark.cpp?rev=342227&r1=342226&r2=342227&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/benchmarks/IndexBenchmark.cpp (original)
> +++ clang-tools-extra/trunk/clangd/benchmarks/IndexBenchmark.cpp Fri Sep 14 
> 05:21:09 2018
> @@ -101,9 +101,11 @@ int main(int argc, char *argv[]) {
>}

>IndexFilename = argv[1];
>RequestsFilename = argv[2];
> -  // Trim first two arguments of the benchmark invocation.
> -  argv += 3;
> -  argc -= 3;
> +  // Trim first two arguments of the benchmark invocation and pretend no
> +  // arguments were passed in the first place.
> +  argv[2] = argv[0];
> +  argv += 2;
> +  argc -= 2;
>::benchmark::Initialize(&argc, argv);
Passing-by thought: why is this being done in *this* order?
Why not first let the ::benchmark::Initialize() consume it's flags first?

>::benchmark::RunSpecifiedBenchmarks();
>  }
>
Roman.

> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D45124: [CodeGen] Record if a C++ record is a trivial type

2018-07-23 Thread Roman Lebedev via cfe-commits
Test?

On Mon, Jul 23, 2018 at 11:49 PM, Aaron Smith via Phabricator via
llvm-commits  wrote:
> This revision was automatically updated to reflect the committed changes.
> Closed by commit rC337736: [CodeGen] Record if a C++ record is a trivial type 
> (authored by asmith, committed by ).
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D45124
>
> Files:
>   lib/CodeGen/CGDebugInfo.cpp
>
>
> Index: lib/CodeGen/CGDebugInfo.cpp
> ===
> --- lib/CodeGen/CGDebugInfo.cpp
> +++ lib/CodeGen/CGDebugInfo.cpp
> @@ -2908,6 +2908,10 @@
>Flags |= llvm::DINode::FlagTypePassByReference;
>  else
>Flags |= llvm::DINode::FlagTypePassByValue;
> +
> +// Record if a C++ record is trivial type.
> +if (CXXRD->isTrivial())
> +  Flags |= llvm::DINode::FlagTrivial;
>}
>
>llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
>
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r337815 - [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)

2018-07-24 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Jul 24 01:16:50 2018
New Revision: 337815

URL: http://llvm.org/viewvc/llvm-project?rev=337815&view=rev
Log:
[Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)

Summary:
As discussed in [[ https://bugs.llvm.org/show_bug.cgi?id=38166 | PR38166 ]], we 
need to be able to distinqush whether the cast
we are visiting is actually a cast, or part of an `ExplicitCast`.
There are at least four ways to get there:
1. Introduce a new `CastKind`, and use it instead of `IntegralCast` if we are 
in `ExplicitCast`.

   Would work, but does not scale - what if we will need more of these cast 
kinds?
2. Introduce a flag in `CastExprBits`, whether this cast is part of 
`ExplicitCast` or not.

   Would work, but it isn't immediately clear where it needs to be set.
2. Fix `ScalarExprEmitter::VisitCastExpr()` to visit these `NoOp` casts.

   As pointed out by @rsmith, CodeGenFunction::EmitMaterializeTemporaryExpr 
calls

   skipRValueSubobjectAdjustments, which steps over the CK_NoOp cast`,

   which explains why we currently don't visit those.

   This is probably impossible, as @efriedma points out, that is intentional as 
per `[class.temporary]` in the standard
3. And the simplest one, just record which NoOp casts we skip.

   It just kinda works as-is afterwards.

But, the approach with a flag is the least intrusive one, and is probably the 
best one overall.

Reviewers: rsmith, rjmccall, majnemer, efriedma

Reviewed By: rsmith

Subscribers: cfe-commits, aaron.ballman, vsk, llvm-commits, rsmith

Differential Revision: https://reviews.llvm.org/D49508

Added:
cfe/trunk/test/Sema/multistep-explicit-cast.c
cfe/trunk/test/SemaCXX/multistep-explicit-cast.cpp
cfe/trunk/test/SemaOpenCL/multistep-explicit-cast.cl
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/PCH/cxx_exprs.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=337815&r1=337814&r2=337815&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Jul 24 01:16:50 2018
@@ -2821,6 +2821,7 @@ protected:
   (op && op->containsUnexpandedParameterPack(,
 Op(op) {
 CastExprBits.Kind = kind;
+CastExprBits.PartOfExplicitCast = false;
 setBasePathSize(BasePathSize);
 assert(CastConsistency());
   }
@@ -2835,6 +2836,13 @@ public:
   CastKind getCastKind() const { return (CastKind) CastExprBits.Kind; }
   void setCastKind(CastKind K) { CastExprBits.Kind = K; }
 
+  bool getIsPartOfExplicitCast() const {
+return CastExprBits.PartOfExplicitCast;
+  }
+  void setIsPartOfExplicitCast(bool PartOfExplicitCast) {
+CastExprBits.PartOfExplicitCast = PartOfExplicitCast;
+  }
+
   static const char *getCastKindName(CastKind CK);
   const char *getCastKindName() const { return getCastKindName(getCastKind()); 
}
 

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=337815&r1=337814&r2=337815&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Jul 24 01:16:50 2018
@@ -202,7 +202,8 @@ protected:
 unsigned : NumExprBits;
 
 unsigned Kind : 6;
-unsigned BasePathSize : 32 - 6 - NumExprBits;
+unsigned PartOfExplicitCast : 1;
+unsigned BasePathSize : 32 - 6 - 1 - NumExprBits;
   };
 
   class CallExprBitfields {

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=337815&r1=337814&r2=337815&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jul 24 01:16:50 2018
@@ -2117,6 +2117,9 @@ void ASTDumper::VisitCastExpr(const Cast
   }
   dumpBasePath(OS, Node);
   OS << ">";
+
+  if (Node->getIsPartOfExplicitCast())
+OS << " part_of_explicit_cast";
 }
 
 void ASTDumper::VisitDeclRefExpr(const DeclRefExpr *Node) {

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=337815&r1=337814&r2=337815&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Tue Jul 24 01:16:50 2018
@@ -89,6 +89,14 @@ namespace {
 void CheckCXXCStyleCast(bool FunctionalCast, bool ListInitialization);
 void CheckCStyleCast();
 
+void updatePartO

r338108 - [AST] Sink 'part of explicit cast' down into ImplicitCastExpr

2018-07-27 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Jul 27 00:27:14 2018
New Revision: 338108

URL: http://llvm.org/viewvc/llvm-project?rev=338108&view=rev
Log:
[AST] Sink 'part of explicit cast' down into ImplicitCastExpr

Summary:
As discussed in IRC with @rsmith, it is slightly not good to keep that in the 
`CastExpr` itself:
Given the explicit cast, which is represented in AST as an `ExplicitCastExpr` + 
`ImplicitCastExpr`'s,
only the  `ImplicitCastExpr`'s will be marked as `PartOfExplicitCast`, but not 
the `ExplicitCastExpr` itself.
Thus, it is only ever `true` for `ImplicitCastExpr`'s, so we don't need to 
write/read/dump it for `ExplicitCastExpr`'s.

We don't need to worry that we write the `PartOfExplicitCast` in PCH after 
`CastExpr::path_iterator`,
since the `ExprImplicitCastAbbrev` is only used when the `NumBaseSpecs == 0`, 
i.e. there is no 'path'.

Reviewers: rsmith, rjmccall, erichkeane, aaron.ballman

Reviewed By: rsmith, erichkeane

Subscribers: vsk, cfe-commits, rsmith

Tags: #clang

Differential Revision: https://reviews.llvm.org/D49838

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=338108&r1=338107&r2=338108&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Jul 27 00:27:14 2018
@@ -2830,6 +2830,7 @@ protected:
   /// Construct an empty cast.
   CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
 : Expr(SC, Empty) {
+CastExprBits.PartOfExplicitCast = false;
 setBasePathSize(BasePathSize);
   }
 
@@ -2837,13 +2838,6 @@ public:
   CastKind getCastKind() const { return (CastKind) CastExprBits.Kind; }
   void setCastKind(CastKind K) { CastExprBits.Kind = K; }
 
-  bool getIsPartOfExplicitCast() const {
-return CastExprBits.PartOfExplicitCast;
-  }
-  void setIsPartOfExplicitCast(bool PartOfExplicitCast) {
-CastExprBits.PartOfExplicitCast = PartOfExplicitCast;
-  }
-
   static const char *getCastKindName(CastKind CK);
   const char *getCastKindName() const { return getCastKindName(getCastKind()); 
}
 
@@ -2932,6 +2926,11 @@ public:
 : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0) {
   }
 
+  bool isPartOfExplicitCast() const { return CastExprBits.PartOfExplicitCast; }
+  void setIsPartOfExplicitCast(bool PartOfExplicitCast) {
+CastExprBits.PartOfExplicitCast = PartOfExplicitCast;
+  }
+
   static ImplicitCastExpr *Create(const ASTContext &Context, QualType T,
   CastKind Kind, Expr *Operand,
   const CXXCastPath *BasePath,

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=338108&r1=338107&r2=338108&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Jul 27 00:27:14 2018
@@ -198,11 +198,12 @@ protected:
 
   class CastExprBitfields {
 friend class CastExpr;
+friend class ImplicitCastExpr;
 
 unsigned : NumExprBits;
 
 unsigned Kind : 6;
-unsigned PartOfExplicitCast : 1;
+unsigned PartOfExplicitCast : 1; // Only set for ImplicitCastExpr.
 unsigned BasePathSize : 32 - 6 - 1 - NumExprBits;
   };
 

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=338108&r1=338107&r2=338108&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jul 27 00:27:14 2018
@@ -521,6 +521,7 @@ namespace  {
 // Exprs
 void VisitExpr(const Expr *Node);
 void VisitCastExpr(const CastExpr *Node);
+void VisitImplicitCastExpr(const ImplicitCastExpr *Node);
 void VisitDeclRefExpr(const DeclRefExpr *Node);
 void VisitPredefinedExpr(const PredefinedExpr *Node);
 void VisitCharacterLiteral(const CharacterLiteral *Node);
@@ -2117,8 +2118,11 @@ void ASTDumper::VisitCastExpr(const Cast
   }
   dumpBasePath(OS, Node);
   OS << ">";
+}
 
-  if (Node->getIsPartOfExplicitCast())
+void ASTDumper::VisitImplicitCastExpr(const ImplicitCastExpr *Node) {
+  VisitCastExpr(Node);
+  if (Node->isPartOfExplicitCast())
 OS << " part_of_explicit_cast";
 }
 

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=338108&r1=338107&r2=338108&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/l

r338288 - [clang][ubsan] Implicit Conversion Sanitizer - integer truncation - clang part

2018-07-30 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Jul 30 11:58:30 2018
New Revision: 338288

URL: http://llvm.org/viewvc/llvm-project?rev=338288&view=rev
Log:
[clang][ubsan] Implicit Conversion Sanitizer - integer truncation  - clang part

Summary:
C and C++ are interesting languages. They are statically typed, but weakly.
The implicit conversions are allowed. This is nice, allows to write code
while balancing between getting drowned in everything being convertible,
and nothing being convertible. As usual, this comes with a price:

```
unsigned char store = 0;

bool consume(unsigned int val);

void test(unsigned long val) {
  if (consume(val)) {
// the 'val' is `unsigned long`, but `consume()` takes `unsigned int`.
// If their bit widths are different on this platform, the implicit
// truncation happens. And if that `unsigned long` had a value bigger
// than UINT_MAX, then you may or may not have a bug.

// Similarly, integer addition happens on `int`s, so `store` will
// be promoted to an `int`, the sum calculated (0+768=768),
// and the result demoted to `unsigned char`, and stored to `store`.
// In this case, the `store` will still be 0. Again, not always intended.
store = store + 768; // before addition, 'store' was promoted to int.
  }

  // But yes, sometimes this is intentional.
  // You can either make the conversion explicit
  (void)consume((unsigned int)val);
  // or mask the value so no bits will be *implicitly* lost.
  (void)consume((~((unsigned int)0)) & val);
}
```

Yes, there is a `-Wconversion`` diagnostic group, but first, it is kinda
noisy, since it warns on everything (unlike sanitizers, warning on an
actual issues), and second, there are cases where it does **not** warn.
So a Sanitizer is needed. I don't have any motivational numbers, but i know
i had this kind of problem 10-20 times, and it was never easy to track down.

The logic to detect whether an truncation has happened is pretty simple
if you think about it - https://godbolt.org/g/NEzXbb - basically, just
extend (using the new, not original!, signedness) the 'truncated' value
back to it's original width, and equality-compare it with the original value.

The most non-trivial thing here is the logic to detect whether this
`ImplicitCastExpr` AST node is **actually** an implicit conversion, //or//
part of an explicit cast. Because the explicit casts are modeled as an outer
`ExplicitCastExpr` with some `ImplicitCastExpr`'s as **direct** children.
https://godbolt.org/g/eE1GkJ

Nowadays, we can just use the new `part_of_explicit_cast` flag, which is set
on all the implicitly-added `ImplicitCastExpr`'s of an `ExplicitCastExpr`.
So if that flag is **not** set, then it is an actual implicit conversion.

As you may have noted, this isn't just named 
`-fsanitize=implicit-integer-truncation`.
There are potentially some more implicit conversions to be warned about.
Namely, implicit conversions that result in sign change; implicit conversion
between different floating point types, or between fp and an integer,
when again, that conversion is lossy.

One thing i know isn't handled is bitfields.

This is a clang part.
The compiler-rt part is D48959.

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], [[ 
https://bugs.llvm.org/show_bug.cgi?id=37552 | PR37552 ]], [[ 
https://bugs.llvm.org/show_bug.cgi?id=35409 | PR35409 ]].
Partially fixes [[ https://bugs.llvm.org/show_bug.cgi?id=9821 | PR9821 ]].
Fixes https://github.com/google/sanitizers/issues/940. (other than 
sign-changing implicit conversions)

Reviewers: rjmccall, rsmith, samsonov, pcc, vsk, eugenis, efriedma, kcc, 
erichkeane

Reviewed By: rsmith, vsk, erichkeane

Subscribers: erichkeane, klimek, #sanitizers, aaron.ballman, RKSimon, dtzWill, 
filcab, danielaustin, ygribov, dvyukov, milianw, mclow.lists, cfe-commits, 
regehr

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D48958

Added:
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c
cfe/trunk/test/CodeGenCXX/catch-implicit-integer-truncations.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/include/clang/Basic/Sanitizers.h
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=338288&r1=338287&r2=338288&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Jul 30 11:58:30 2018
@@ -46,7 +46,9 @@ sections with improvements to Clang's su
 Major New Features
 --
 
--  ...
+- A new Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) 
group
+  was a

r338306 - [docs] UndefinedBehaviorSanitizer.rst: {, un}signed-integer-overflow: tune docs

2018-07-30 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Jul 30 14:11:32 2018
New Revision: 338306

URL: http://llvm.org/viewvc/llvm-project?rev=338306&view=rev
Log:
[docs] UndefinedBehaviorSanitizer.rst: {,un}signed-integer-overflow: tune docs

Yes, i erroneously assumed that the "after" was meant,
but i was wrong:
> I really meant "performed before", for cases like 4u / -2,
> where -2 is implicitly converted to UINT_MAX - 2 before
> the computation. Conversions that are performed after
> a computation aren't part of the computation at all,
> so I think it's much clearer that they're not in scope
> for this sanitizer.

Modified:
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=338306&r1=338305&r2=338306&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Jul 30 14:11:32 2018
@@ -131,7 +131,7 @@ Available checks are:
  result of a signed integer computation cannot be represented in its type.
  This includes all the checks covered by ``-ftrapv``, as well as checks for
  signed division overflow (``INT_MIN/-1``), but not checks for
- lossy implicit conversions performed after the computation
+ lossy implicit conversions performed before the computation
  (see ``-fsanitize=implicit-conversion``). Both of these two issues are
  handled by ``-fsanitize=implicit-conversion`` group of checks.
   -  ``-fsanitize=unreachable``: If control flow reaches an unreachable
@@ -140,7 +140,7 @@ Available checks are:
  the result of an unsigned integer computation cannot be represented in its
  type. Unlike signed integer overflow, this is not undefined behavior, but
  it is often unintentional. This sanitizer does not check for lossy 
implicit
- conversions performed after such a computation
+ conversions performed before such a computation
  (see ``-fsanitize=implicit-conversion``).
   -  ``-fsanitize=vla-bound``: A variable-length array whose bound
  does not evaluate to a positive value.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r338489 - [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Jul 31 23:06:16 2018
New Revision: 338489

URL: http://llvm.org/viewvc/llvm-project?rev=338489&view=rev
Log:
[AST] CastExpr: BasePathSize is not large enough.

Summary:
rC337815 / D49508 had to cannibalize one bit of 
`CastExprBitfields::BasePathSize` in order to squeeze `PartOfExplicitCast` 
boolean.
That reduced the maximal value of `PartOfExplicitCast` from 9 bits (~512) down 
to 8 bits (~256).
Apparently, that mattered. Too bad there weren't any tests.
It caused [[ https://bugs.llvm.org/show_bug.cgi?id=38356 | PR38356 ]].

So we need to increase `PartOfExplicitCast` back at least to 9 bits, or a bit 
more.
For obvious reasons, we can't do that in `CastExprBitfields` - that would blow 
up the size of every `Expr`.
So we need to either just add a variable into the `CastExpr` (as done here),
or use `llvm::TrailingObjects`. The latter does not seem to be straight-forward.
Perhaps, that needs to be done not for the `CastExpr` itself, but for all of 
it's `final` children.

Reviewers: rjmccall, rsmith, erichkeane

Reviewed By: rjmccall

Subscribers: bricci, hans, cfe-commits, waddlesplash

Differential Revision: https://reviews.llvm.org/D50050

Added:
cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=338489&r1=338488&r2=338489&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Jul 31 23:06:16 2018
@@ -2787,20 +2787,26 @@ public:
 /// representation in the source code (ExplicitCastExpr's derived
 /// classes).
 class CastExpr : public Expr {
+public:
+  using BasePathSizeTy = unsigned int;
+  static_assert(std::numeric_limits::max() >= 16384,
+"[implimits] Direct and indirect base classes [16384].");
+
 private:
   Stmt *Op;
 
   bool CastConsistency() const;
 
+  BasePathSizeTy *BasePathSize();
+
   const CXXBaseSpecifier * const *path_buffer() const {
 return const_cast(this)->path_buffer();
   }
   CXXBaseSpecifier **path_buffer();
 
-  void setBasePathSize(unsigned basePathSize) {
-CastExprBits.BasePathSize = basePathSize;
-assert(CastExprBits.BasePathSize == basePathSize &&
-   "basePathSize doesn't fit in bits of CastExprBits.BasePathSize!");
+  void setBasePathSize(BasePathSizeTy basePathSize) {
+assert(!path_empty() && basePathSize != 0);
+*(BasePathSize()) = basePathSize;
   }
 
 protected:
@@ -2823,7 +2829,9 @@ protected:
 Op(op) {
 CastExprBits.Kind = kind;
 CastExprBits.PartOfExplicitCast = false;
-setBasePathSize(BasePathSize);
+CastExprBits.BasePathIsEmpty = BasePathSize == 0;
+if (!path_empty())
+  setBasePathSize(BasePathSize);
 assert(CastConsistency());
   }
 
@@ -2831,7 +2839,9 @@ protected:
   CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
 : Expr(SC, Empty) {
 CastExprBits.PartOfExplicitCast = false;
-setBasePathSize(BasePathSize);
+CastExprBits.BasePathIsEmpty = BasePathSize == 0;
+if (!path_empty())
+  setBasePathSize(BasePathSize);
   }
 
 public:
@@ -2859,8 +2869,12 @@ public:
 
   typedef CXXBaseSpecifier **path_iterator;
   typedef const CXXBaseSpecifier * const *path_const_iterator;
-  bool path_empty() const { return CastExprBits.BasePathSize == 0; }
-  unsigned path_size() const { return CastExprBits.BasePathSize; }
+  bool path_empty() const { return CastExprBits.BasePathIsEmpty; }
+  unsigned path_size() const {
+if (path_empty())
+  return 0U;
+return *(const_cast(this)->BasePathSize());
+  }
   path_iterator path_begin() { return path_buffer(); }
   path_iterator path_end() { return path_buffer() + path_size(); }
   path_const_iterator path_begin() const { return path_buffer(); }
@@ -2908,7 +2922,12 @@ public:
 /// @endcode
 class ImplicitCastExpr final
 : public CastExpr,
-  private llvm::TrailingObjects {
+  private llvm::TrailingObjects {
+  size_t numTrailingObjects(OverloadToken) const {
+return path_empty() ? 0 : 1;
+  }
+
 private:
   ImplicitCastExpr(QualType ty, CastKind kind, Expr *op,
unsigned BasePathLength, ExprValueKind VK)
@@ -3013,7 +3032,8 @@ public:
 /// (Type)expr. For example: @c (int)f.
 class CStyleCastExpr final
 : public ExplicitCastExpr,
-  private llvm::TrailingObjects {
+  private llvm::TrailingObjects {
   SourceLocation LPLoc; // the location of the left paren
   SourceLocation RPLoc; // the location of the right paren
 
@@ -3027,6 +3047,10 @@ class CStyleCastExpr final
   explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize)
 : 

Re: r338489 - [AST] CastExpr: BasePathSize is not large enough.

2018-08-01 Thread Roman Lebedev via cfe-commits
On Wed, Aug 1, 2018 at 8:36 PM, Richard Smith  wrote:
> On Tue, 31 Jul 2018, 23:06 Roman Lebedev via cfe-commits,
>  wrote:
>>
>> Author: lebedevri
>> Date: Tue Jul 31 23:06:16 2018
>> New Revision: 338489
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=338489&view=rev
>> Log:
>> [AST] CastExpr: BasePathSize is not large enough.
>>
>> Summary:
>> rC337815 / D49508 had to cannibalize one bit of
>> `CastExprBitfields::BasePathSize` in order to squeeze `PartOfExplicitCast`
>> boolean.
>> That reduced the maximal value of `PartOfExplicitCast` from 9 bits (~512)
>> down to 8 bits (~256).
>> Apparently, that mattered. Too bad there weren't any tests.
>> It caused [[ https://bugs.llvm.org/show_bug.cgi?id=38356 | PR38356 ]].
>>
>> So we need to increase `PartOfExplicitCast` back at least to 9 bits, or a
>> bit more.
>> For obvious reasons, we can't do that in `CastExprBitfields` - that would
>> blow up the size of every `Expr`.
>> So we need to either just add a variable into the `CastExpr` (as done
>> here),
>> or use `llvm::TrailingObjects`. The latter does not seem to be
>> straight-forward.
>> Perhaps, that needs to be done not for the `CastExpr` itself, but for all
>> of it's `final` children.
>>
>> Reviewers: rjmccall, rsmith, erichkeane
>>
>> Reviewed By: rjmccall
>>
>> Subscribers: bricci, hans, cfe-commits, waddlesplash
>>
>> Differential Revision: https://reviews.llvm.org/D50050
>>
>> Added:
>> cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Expr.h
>> cfe/trunk/include/clang/AST/ExprCXX.h
>> cfe/trunk/include/clang/AST/ExprObjC.h
>> cfe/trunk/include/clang/AST/Stmt.h
>> cfe/trunk/lib/AST/Expr.cpp
>> cfe/trunk/lib/AST/ExprCXX.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/Expr.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=338489&r1=338488&r2=338489&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>> +++ cfe/trunk/include/clang/AST/Expr.h Tue Jul 31 23:06:16 2018
>> @@ -2787,20 +2787,26 @@ public:
>>  /// representation in the source code (ExplicitCastExpr's derived
>>  /// classes).
>>  class CastExpr : public Expr {
>> +public:
>> +  using BasePathSizeTy = unsigned int;
>> +  static_assert(std::numeric_limits::max() >= 16384,
>> +"[implimits] Direct and indirect base classes [16384].");
>> +
>>  private:
>>Stmt *Op;
>>
>>bool CastConsistency() const;
>>
>> +  BasePathSizeTy *BasePathSize();
>> +
>>const CXXBaseSpecifier * const *path_buffer() const {
>>  return const_cast(this)->path_buffer();
>>}
>>CXXBaseSpecifier **path_buffer();
>>
>> -  void setBasePathSize(unsigned basePathSize) {
>> -CastExprBits.BasePathSize = basePathSize;
>> -assert(CastExprBits.BasePathSize == basePathSize &&
>> -   "basePathSize doesn't fit in bits of
>> CastExprBits.BasePathSize!");
>> +  void setBasePathSize(BasePathSizeTy basePathSize) {
>> +assert(!path_empty() && basePathSize != 0);
>> +*(BasePathSize()) = basePathSize;
>>}
>>
>>  protected:
>> @@ -2823,7 +2829,9 @@ protected:
>>  Op(op) {
>>  CastExprBits.Kind = kind;
>>  CastExprBits.PartOfExplicitCast = false;
>> -setBasePathSize(BasePathSize);
>> +CastExprBits.BasePathIsEmpty = BasePathSize == 0;
>> +if (!path_empty())
>> +  setBasePathSize(BasePathSize);
>>  assert(CastConsistency());
>>}
>>
>> @@ -2831,7 +2839,9 @@ protected:
>>CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
>>  : Expr(SC, Empty) {
>>  CastExprBits.PartOfExplicitCast = false;
>> -setBasePathSize(BasePathSize);
>> +CastExprBits.BasePathIsEmpty = BasePathSize == 0;
>> +if (!path_empty())
>> +  setBasePathSize(BasePathSize);
>>}
>>
>>  public:
>> @@ -2859,8 +2869,12 @@ public:
>>
>>typedef CXXBaseSpecifier **path_iterator;
>>typedef const CXXBaseSpecifier * const *path_const_iterator;
>> -  bool path_empty() const { return CastExprBits.BasePathSize == 0; }
>> -  unsigned path_size() const { return CastExprBits.BasePathSize; }
>> +  bool pa

r338640 - [NFC][CodeGenCXX] Use -emit-llvm-only instead of -emit-llvm and ignoring it.

2018-08-01 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Aug  1 14:20:58 2018
New Revision: 338640

URL: http://llvm.org/viewvc/llvm-project?rev=338640&view=rev
Log:
[NFC][CodeGenCXX] Use -emit-llvm-only instead of -emit-llvm and ignoring it.

As pointed out by Richard Smith in post-review of r338489.

Modified:
cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp

Modified: cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp?rev=338640&r1=338639&r2=338640&view=diff
==
--- cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp Wed Aug  1 
14:20:58 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o -
+// RUN: %clang_cc1 %s -emit-llvm-only -o -
 
 // https://bugs.llvm.org/show_bug.cgi?id=38356
 // We only check that we do not crash.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r338489 - [AST] CastExpr: BasePathSize is not large enough.

2018-08-01 Thread Roman Lebedev via cfe-commits
r338640

On Wed, Aug 1, 2018 at 8:38 PM, Roman Lebedev  wrote:
> On Wed, Aug 1, 2018 at 8:36 PM, Richard Smith  wrote:
>> On Tue, 31 Jul 2018, 23:06 Roman Lebedev via cfe-commits,
>>  wrote:
>>>
>>> Author: lebedevri
>>> Date: Tue Jul 31 23:06:16 2018
>>> New Revision: 338489
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=338489&view=rev
>>> Log:
>>> [AST] CastExpr: BasePathSize is not large enough.
>>>
>>> Summary:
>>> rC337815 / D49508 had to cannibalize one bit of
>>> `CastExprBitfields::BasePathSize` in order to squeeze `PartOfExplicitCast`
>>> boolean.
>>> That reduced the maximal value of `PartOfExplicitCast` from 9 bits (~512)
>>> down to 8 bits (~256).
>>> Apparently, that mattered. Too bad there weren't any tests.
>>> It caused [[ https://bugs.llvm.org/show_bug.cgi?id=38356 | PR38356 ]].
>>>
>>> So we need to increase `PartOfExplicitCast` back at least to 9 bits, or a
>>> bit more.
>>> For obvious reasons, we can't do that in `CastExprBitfields` - that would
>>> blow up the size of every `Expr`.
>>> So we need to either just add a variable into the `CastExpr` (as done
>>> here),
>>> or use `llvm::TrailingObjects`. The latter does not seem to be
>>> straight-forward.
>>> Perhaps, that needs to be done not for the `CastExpr` itself, but for all
>>> of it's `final` children.
>>>
>>> Reviewers: rjmccall, rsmith, erichkeane
>>>
>>> Reviewed By: rjmccall
>>>
>>> Subscribers: bricci, hans, cfe-commits, waddlesplash
>>>
>>> Differential Revision: https://reviews.llvm.org/D50050
>>>
>>> Added:
>>> cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
>>> Modified:
>>> cfe/trunk/include/clang/AST/Expr.h
>>> cfe/trunk/include/clang/AST/ExprCXX.h
>>> cfe/trunk/include/clang/AST/ExprObjC.h
>>> cfe/trunk/include/clang/AST/Stmt.h
>>> cfe/trunk/lib/AST/Expr.cpp
>>> cfe/trunk/lib/AST/ExprCXX.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/Expr.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=338489&r1=338488&r2=338489&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>>> +++ cfe/trunk/include/clang/AST/Expr.h Tue Jul 31 23:06:16 2018
>>> @@ -2787,20 +2787,26 @@ public:
>>>  /// representation in the source code (ExplicitCastExpr's derived
>>>  /// classes).
>>>  class CastExpr : public Expr {
>>> +public:
>>> +  using BasePathSizeTy = unsigned int;
>>> +  static_assert(std::numeric_limits::max() >= 16384,
>>> +"[implimits] Direct and indirect base classes [16384].");
>>> +
>>>  private:
>>>Stmt *Op;
>>>
>>>bool CastConsistency() const;
>>>
>>> +  BasePathSizeTy *BasePathSize();
>>> +
>>>const CXXBaseSpecifier * const *path_buffer() const {
>>>  return const_cast(this)->path_buffer();
>>>}
>>>CXXBaseSpecifier **path_buffer();
>>>
>>> -  void setBasePathSize(unsigned basePathSize) {
>>> -CastExprBits.BasePathSize = basePathSize;
>>> -assert(CastExprBits.BasePathSize == basePathSize &&
>>> -   "basePathSize doesn't fit in bits of
>>> CastExprBits.BasePathSize!");
>>> +  void setBasePathSize(BasePathSizeTy basePathSize) {
>>> +assert(!path_empty() && basePathSize != 0);
>>> +*(BasePathSize()) = basePathSize;
>>>}
>>>
>>>  protected:
>>> @@ -2823,7 +2829,9 @@ protected:
>>>  Op(op) {
>>>  CastExprBits.Kind = kind;
>>>  CastExprBits.PartOfExplicitCast = false;
>>> -setBasePathSize(BasePathSize);
>>> +CastExprBits.BasePathIsEmpty = BasePathSize == 0;
>>> +if (!path_empty())
>>> +  setBasePathSize(BasePathSize);
>>>  assert(CastConsistency());
>>>}
>>>
>>> @@ -2831,7 +2839,9 @@ protected:
>>>CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
>>>  : Expr(SC, Empty) {
>>>  CastExprBits.PartOfExplicitCast = false;
>>> -setBasePathSize(BasePathSize);
>>> +CastExprBits.BasePathIsEmpty = 

Re: [PATCH] D43120: [clang-tidy] New checker for exceptions that are created but not thrown

2018-02-15 Thread Roman Lebedev via cfe-commits
On Thu, Feb 15, 2018 at 3:48 PM, Aaron Ballman via cfe-commits
 wrote:
> On Thu, Feb 15, 2018 at 4:11 AM, Phabricator via Phabricator
>  wrote:
>> This revision was automatically updated to reflect the committed changes.
>> Closed by commit rL325222: [clang-tidy] New checker for exceptions that are 
>> created but not thrown (authored by xazax, committed by ).
>
> There's nothing wrong with this patch, but it is odd that the
> automated text describes the author but not the committer. I wonder if
> that's a bug?

Committed xazax Thu, Feb 15, 12:08
But there is no https://reviews.llvm.org/p/xazax/, only
https://reviews.llvm.org/p/xazax.hun/

I get that too.
Because committer name (i.e. svn username) does not verbatim match the
Phab username verbatim.

It is a bug i'd say, the match should be email-based.

> ~Aaron
Roman.

> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-06 Thread Roman Lebedev via cfe-commits
On Tue, Jun 6, 2017 at 8:52 PM, David Blaikie  wrote:
>
>
> On Tue, Jun 6, 2017 at 3:59 AM Roman Lebedev via Phabricator
>  wrote:
>>
>> lebedev.ri added a comment.
>>
>> In https://reviews.llvm.org/D33102#773296, @dblaikie wrote:
>>
>> > I still feel like that's more testing than would be ideal (does the
>> > context of the cast matter? Wether it's dereferenced, a struct member
>> > access, assigned, initialized, etc - it doesn't look like it from the code,
>> > etc).
>>
>>
>> Looking at the `CastsAwayConstness()` function in lib/Sema/SemaCast.cpp:
>> https://github.com/llvm-mirror/clang/blob/432ed0e4a6d58f7dda8992a167aad43bc91f76c6/lib/Sema/SemaCast.cpp#L505-L510
>> You can see that it asserts that the pointer is one of three types. So i
>> think it it is best to have maybe slightly overlapping test coverage here,
>> rather than be surprised one day that such trivial cases no longer warn...
>>
>> > But sure. Could you also (manually, I guess) confirm that this matches
>> > GCC's cast-qual behavior (insofar as the warning fires in the same
>> > situations). If there are any deviations, let's chat about them.
>>
>> Sure.
>>
>> 1. Gcc produces the same //count// of the warnings:
>>
>>   $ pwd
>>   llvm/tools/clang/test
>>   $ grep -o "expected-warning" Sema/warn-cast-qual.c | wc -l
>>   14
>>   $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 |
>> grep ": warning: " | wc -l
>>   14
>>   $ gcc -x c++ -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 |
>> grep ": warning: " | wc -l
>>   14
>>   $ grep -o "expected-warning" SemaCXX/warn-cast-qual.cpp | wc -l
>>   39
>>   $ gcc -x c++ -fsyntax-only -Wcast-qual -c SemaCXX/warn-cast-qual.cpp
>> 2>&1 | grep ": warning: " | wc -l
>>   39
>>
>> 2. I'm not quite sure how to non-manually compare the warnings, so i'll
>> just show the gcc output on these three cases. Since the clang warnings are
>> appended as comments at the end of the each line that should warn, visual
>> comparison is possible:

> Works for the positive cases, not the negative ones. (though if the counts
> are exactly the same, then so long as there are no false positives there
> aren't any false negatives either)
Yes, fair enough, i do not have anything to add here.

>>
>>
>> 2.1.
>>
>>   $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c
>>   Sema/warn-cast-qual.c: In function ‘foo’:
>>   Sema/warn-cast-qual.c:9:13: warning: cast discards ‘const’ qualifier
>> from pointer target type [-Wcast-qual]
>>  char *y = (char *)ptr; // expected-warning {{cast from 'const char *'
>> to 'char *' drops const qualifier}}
>>^
>>   Sema/warn-cast-qual.c:10:15: warning: cast discards ‘const’ qualifier
>> from pointer target type [-Wcast-qual]
>>  char **y1 = (char **)ptrptr; // expected-warning {{cast from 'const
>> char *const' to 'char *' drops const qualifier}}
>>  ^
>>   Sema/warn-cast-qual.c:11:21: warning: cast discards ‘const’ qualifier
>> from pointer target type [-Wcast-qual]
>>  const char **y2 = (const char **)ptrptr; // expected-warning {{cast
>> from 'const char *const *' to 'const char **' drops const qualifier}}
>>^
>>   Sema/warn-cast-qual.c:14:14: warning: cast discards ‘const’ qualifier
>> from pointer target type [-Wcast-qual]
>>  char *z1 = (char *)(const void *)ptr; // expected-warning {{cast from
>> 'const void *' to 'char *' drops const qualifier}}
>> ^
>>   Sema/warn-cast-qual.c:17:16: warning: cast discards ‘volatile’ qualifier
>> from pointer target type [-Wcast-qual]
>>  char *vol2 = (char *)vol; // expected-warning {{cast from 'volatile
>> char *' to 'char *' drops volatile qualifier}}
>>   ^
>>   Sema/warn-cast-qual.c:19:17: warning: cast discards ‘const volatile’
>> qualifier from pointer target type [-Wcast-qual]
>>  char *volc2 = (char *)volc; // expected-warning {{cast from 'const
>> volatile char *' to 'char *' drops const and volatile qualifiers}}
>>^
>>   Sema/warn-cast-qual.c:22:28: warning: to be safe all intermediate
>> pointers in cast from ‘int **’ to ‘const int **’ must be ‘const’ qualified
>> [-Wcast-qual]
>>  const int **intptrptrc = (const int **)intptrptr; // expected-warning
>> {{cast from 'int **' to 'const int **' must have all intermediate pointers
>> const qualified}}
>>   ^
>>   Sema/warn-cast-qual.c:23:31: warning: to be safe all intermediate
>> pointers in cast from ‘int **’ to ‘volatile int **’ must be ‘const’
>> qualified [-Wcast-qual]
>>  volatile int **intptrptrv = (volatile int **)intptrptr; //
>> expected-warning {{cast from 'int **' to 'volatile int **' must have all
>> intermediate pointers const qualified}}
>>  ^
>>   Sema/warn-cast-qual.c:29:23: warning: cast discards ‘const’ qualifier
>> from pointer target type [-Wcast-qual]
>>  char **charptrptr = (char **)charptrptrc; // expected-warning {{cast
>> from 'const ch

[clang-tools-extra] r305067 - [clang-tools-extra] ReleaseNotes.rst: test commit: whitespace fix

2017-06-09 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Jun  9 07:00:04 2017
New Revision: 305067

URL: http://llvm.org/viewvc/llvm-project?rev=305067&view=rev
Log:
[clang-tools-extra] ReleaseNotes.rst: test commit: whitespace fix

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=305067&r1=305066&r2=305067&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Fri Jun  9 07:00:04 2017
@@ -100,10 +100,10 @@ Improvements to clang-tidy
   to remove user-defined make functions from ``push_back`` calls on containers
   of custom tuple-like types by providing `TupleTypes` and 
`TupleMakeFunctions`.
 
- - New `modernize-use-noexcept
-   
`_ 
check
+- New `modernize-use-noexcept
+  
`_ 
check
 
-   Replaces dynamic exception specifications with ``noexcept`` or a user 
defined macro.
+  Replaces dynamic exception specifications with ``noexcept`` or a user 
defined macro.
 
 - New `performance-inefficient-vector-operation
   
`_
 check


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r305082 - [clang-tidy] readability-function-size: add NestingThreshold param.

2017-06-09 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Jun  9 09:22:10 2017
New Revision: 305082

URL: http://llvm.org/viewvc/llvm-project?rev=305082&view=rev
Log:
[clang-tidy] readability-function-size: add NestingThreshold param.

Summary:
Finds compound statements which create next nesting level after 
`NestingThreshold` and emits a warning.
Do note that it warns about each compound statement that breaches the 
threshold, but not any of it's sub-statements, to have readable warnings.

I was able to find only one coding style referencing nesting:
  - https://www.kernel.org/doc/html/v4.10/process/coding-style.html#indentation
 > In short, 8-char indents make things easier to read, and have the added 
benefit of warning you when you’re nesting your functions too deep.

This seems too basic, i'm not sure what else to test. Are more tests needed?

Reviewers: alexfh, aaron.ballman, sbenza

Reviewed By: alexfh, aaron.ballman

Subscribers: xazax.hun

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D32942

Modified:
clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-function-size.rst
clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp

Modified: clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp?rev=305082&r1=305081&r2=305082&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp Fri 
Jun  9 09:22:10 2017
@@ -38,6 +38,13 @@ public:
   ++Info.Branches;
 // fallthrough
 case Stmt::CompoundStmtClass:
+  // If this new compound statement is located in a compound statement,
+  // which is already nested NestingThreshold levels deep, record the start
+  // location of this new compound statement
+  if (CurrentNestingLevel == Info.NestingThreshold)
+Info.NestingThresholders.push_back(Node->getLocStart());
+
+  ++CurrentNestingLevel;
   TrackedParent.push_back(true);
   break;
 default:
@@ -47,7 +54,10 @@ public:
 
 Base::TraverseStmt(Node);
 
+if (TrackedParent.back())
+  --CurrentNestingLevel;
 TrackedParent.pop_back();
+
 return true;
   }
 
@@ -59,13 +69,15 @@ public:
   }
 
   struct FunctionInfo {
-FunctionInfo() : Lines(0), Statements(0), Branches(0) {}
-unsigned Lines;
-unsigned Statements;
-unsigned Branches;
+unsigned Lines = 0;
+unsigned Statements = 0;
+unsigned Branches = 0;
+unsigned NestingThreshold = 0;
+std::vector NestingThresholders;
   };
   FunctionInfo Info;
   std::vector TrackedParent;
+  unsigned CurrentNestingLevel = 0;
 };
 
 FunctionSizeCheck::FunctionSizeCheck(StringRef Name, ClangTidyContext *Context)
@@ -73,13 +85,15 @@ FunctionSizeCheck::FunctionSizeCheck(Str
   LineThreshold(Options.get("LineThreshold", -1U)),
   StatementThreshold(Options.get("StatementThreshold", 800U)),
   BranchThreshold(Options.get("BranchThreshold", -1U)),
-  ParameterThreshold(Options.get("ParameterThreshold", -1U)) {}
+  ParameterThreshold(Options.get("ParameterThreshold", -1U)),
+  NestingThreshold(Options.get("NestingThreshold", -1U)) {}
 
 void FunctionSizeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "LineThreshold", LineThreshold);
   Options.store(Opts, "StatementThreshold", StatementThreshold);
   Options.store(Opts, "BranchThreshold", BranchThreshold);
   Options.store(Opts, "ParameterThreshold", ParameterThreshold);
+  Options.store(Opts, "NestingThreshold", NestingThreshold);
 }
 
 void FunctionSizeCheck::registerMatchers(MatchFinder *Finder) {
@@ -90,6 +104,7 @@ void FunctionSizeCheck::check(const Matc
   const auto *Func = Result.Nodes.getNodeAs("func");
 
   FunctionASTVisitor Visitor;
+  Visitor.Info.NestingThreshold = NestingThreshold;
   Visitor.TraverseDecl(const_cast(Func));
   auto &FI = Visitor.Info;
 
@@ -109,7 +124,8 @@ void FunctionSizeCheck::check(const Matc
 
   if (FI.Lines > LineThreshold || FI.Statements > StatementThreshold ||
   FI.Branches > BranchThreshold ||
-  ActualNumberParameters > ParameterThreshold) {
+  ActualNumberParameters > ParameterThreshold ||
+  !FI.NestingThresholders.empty()) {
 diag(Func->getLocation(),
  "function %0 exceeds recommended size/complexity thresholds")
 << Func;
@@ -138,6 +154,12 @@ void FunctionSizeCheck::check(const Matc
  DiagnosticIDs::Note)
 << ActualNumberParameters << ParameterThreshold;
   }
+
+  for (const auto &CSPos : FI.NestingThresholders) {
+diag(CSPos, "nesting level %0 starts

Re: [PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-09 Thread Roman Lebedev via cfe-commits
On Fri, Jun 9, 2017 at 11:28 PM, David Blaikie  wrote:
> Looks all good
OK, thank you.

> please commit whenever you're ready - if you don't have
> commit access, I (or anyone else with commit access) can commit this for
> you.
Will re-test and commit in +~12 hours.

> On Tue, Jun 6, 2017 at 1:57 PM Roman Lebedev  wrote:
>>
>> On Tue, Jun 6, 2017 at 8:52 PM, David Blaikie  wrote:
>> >
>> >
>> > On Tue, Jun 6, 2017 at 3:59 AM Roman Lebedev via Phabricator
>> >  wrote:
>> >>
>> >> lebedev.ri added a comment.
>> >>
>> >> In https://reviews.llvm.org/D33102#773296, @dblaikie wrote:
>> >>
>> >> > I still feel like that's more testing than would be ideal (does the
>> >> > context of the cast matter? Wether it's dereferenced, a struct member
>> >> > access, assigned, initialized, etc - it doesn't look like it from the
>> >> > code,
>> >> > etc).
>> >>
>> >>
>> >> Looking at the `CastsAwayConstness()` function in
>> >> lib/Sema/SemaCast.cpp:
>> >>
>> >> https://github.com/llvm-mirror/clang/blob/432ed0e4a6d58f7dda8992a167aad43bc91f76c6/lib/Sema/SemaCast.cpp#L505-L510
>> >> You can see that it asserts that the pointer is one of three types. So
>> >> i
>> >> think it it is best to have maybe slightly overlapping test coverage
>> >> here,
>> >> rather than be surprised one day that such trivial cases no longer
>> >> warn...
>> >>
>> >> > But sure. Could you also (manually, I guess) confirm that this
>> >> > matches
>> >> > GCC's cast-qual behavior (insofar as the warning fires in the same
>> >> > situations). If there are any deviations, let's chat about them.
>> >>
>> >> Sure.
>> >>
>> >> 1. Gcc produces the same //count// of the warnings:
>> >>
>> >>   $ pwd
>> >>   llvm/tools/clang/test
>> >>   $ grep -o "expected-warning" Sema/warn-cast-qual.c | wc -l
>> >>   14
>> >>   $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 |
>> >> grep ": warning: " | wc -l
>> >>   14
>> >>   $ gcc -x c++ -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1
>> >> |
>> >> grep ": warning: " | wc -l
>> >>   14
>> >>   $ grep -o "expected-warning" SemaCXX/warn-cast-qual.cpp | wc -l
>> >>   39
>> >>   $ gcc -x c++ -fsyntax-only -Wcast-qual -c SemaCXX/warn-cast-qual.cpp
>> >> 2>&1 | grep ": warning: " | wc -l
>> >>   39
>> >>
>> >> 2. I'm not quite sure how to non-manually compare the warnings, so i'll
>> >> just show the gcc output on these three cases. Since the clang warnings
>> >> are
>> >> appended as comments at the end of the each line that should warn,
>> >> visual
>> >> comparison is possible:
>>
>> > Works for the positive cases, not the negative ones. (though if the
>> > counts
>> > are exactly the same, then so long as there are no false positives there
>> > aren't any false negatives either)
>> Yes, fair enough, i do not have anything to add here.
>>
>> >>
>> >>
>> >> 2.1.
>> >>
>> >>   $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c
>> >>   Sema/warn-cast-qual.c: In function ‘foo’:
>> >>   Sema/warn-cast-qual.c:9:13: warning: cast discards ‘const’ qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  char *y = (char *)ptr; // expected-warning {{cast from 'const char
>> >> *'
>> >> to 'char *' drops const qualifier}}
>> >>^
>> >>   Sema/warn-cast-qual.c:10:15: warning: cast discards ‘const’ qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  char **y1 = (char **)ptrptr; // expected-warning {{cast from
>> >> 'const
>> >> char *const' to 'char *' drops const qualifier}}
>> >>  ^
>> >>   Sema/warn-cast-qual.c:11:21: warning: cast discards ‘const’ qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  const char **y2 = (const char **)ptrptr; // expected-warning
>> >> {{cast
>> >> from 'const char *const *' to 'const char **' drops const qualifier}}
>> >>^
>> >>   Sema/warn-cast-qual.c:14:14: warning: cast discards ‘const’ qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  char *z1 = (char *)(const void *)ptr; // expected-warning {{cast
>> >> from
>> >> 'const void *' to 'char *' drops const qualifier}}
>> >> ^
>> >>   Sema/warn-cast-qual.c:17:16: warning: cast discards ‘volatile’
>> >> qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  char *vol2 = (char *)vol; // expected-warning {{cast from
>> >> 'volatile
>> >> char *' to 'char *' drops volatile qualifier}}
>> >>   ^
>> >>   Sema/warn-cast-qual.c:19:17: warning: cast discards ‘const volatile’
>> >> qualifier from pointer target type [-Wcast-qual]
>> >>  char *volc2 = (char *)volc; // expected-warning {{cast from 'const
>> >> volatile char *' to 'char *' drops const and volatile qualifiers}}
>> >>^
>> >>   Sema/warn-cast-qual.c:22:28: warning: to be safe all intermediate
>> >> pointers in cast from ‘int **’ to ‘const int **’ must be ‘const’
>> >> qualified
>> >> [-Wcast-qual]
>> >>  const int **intptrptrc = (const int **)intptrptr; //
>> >> expected-warning
>> >> {{c

Re: [PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-10 Thread Roman Lebedev via cfe-commits
On Sat, Jun 10, 2017 at 7:05 PM, David Blaikie  wrote:
>
>
> On Sat, Jun 10, 2017 at 3:33 AM Roman Lebedev via Phabricator
>  wrote:
>>
>> lebedev.ri planned changes to this revision.
>> lebedev.ri added a comment.
>>
>> In https://reviews.llvm.org/D33102#773296, @dblaikie wrote:
>>
>> > But sure. Could you also (manually, I guess) confirm that this matches
>> > GCC's cast-qual behavior (insofar as the warning fires in the same
>> > situations). If there are any deviations, let's chat about them.
>>
>>
>> Great, you were right :)
>> Found a false-negative:
>>
>>   $ cat /tmp/tst.c
>>   int main() {
>> void* p1 = (void*)"txt";
>> char* p2 = (char*)"txt";
>>   }
>>   $ gcc -x c -Wcast-qual /tmp/tst.c
>>   $ gcc -x c++ -Wcast-qual /tmp/tst.c
>>   /tmp/tst.c: In function ‘int main()’:
>>   /tmp/tst.c:2:21: warning: cast from type ‘const char*’ to type ‘void*’
>> casts away qualifiers [-Wcast-qual]
>>  void* p1 = (void*)"txt";
>>^
>>   /tmp/tst.c:3:21: warning: cast from type ‘const char*’ to type ‘char*’
>> casts away qualifiers [-Wcast-qual]
>>  char* p2 = (char*)"txt";
>>^
>>
>>   $ ./bin/clang -x c -Wcast-qual /tmp/tst.c
>>   $ ./bin/clang -x c++ -Wcast-qual /tmp/tst.c
>>   /tmp/tst.c:3:21: warning: cast from 'const char *' to 'char *' drops
>> const qualifier [-Wcast-qual]
>> char* p2 = (char*)"txt";
>>   ^
>>   1 warning generated.
>>
>> So at least, in C++ mode, it should warn on both lines.
>
>
> Seems reasonable that it should, yes.
>
> (aside: You're still welcome to commit this patch as-is, and provide patches
> for improvements as follow-up (mostly false positives would be more of a
> concern to address before commit))
Yeah...

I have looked around, and best i can figure out is that auto-inserted
`-ImplicitCastExpr  'void *' 
somehow lacks the constness.
I'm not sure where it is inserted, or why the const is missing,
but i guess ImpCastExprToType function is responsible.

TranslationUnitDecl
`-FunctionDecl  line:1:5 main 'int (void)'
  `-CompoundStmt 
`-DeclStmt 
  `-VarDecl  col:9 p2 'void *' cinit
`-CStyleCastExpr  'void *' 
  `-ImplicitCastExpr  'void *' 
`-ImplicitCastExpr  'const char *' 
  `-StringLiteral  'const char [4]' lvalue "txt"

So yeah, i will commit as-is.

>>
>> I'm not sure, should that really not produce a warning in C?
>> (gcc version 6.3.0 20170516 (Debian 6.3.0-18) )

> Probably not, no - string literals have some weird mutability in C (& in
> older versions of C++, even).
I agree. After leaving that comment, i checked AST, and in C, the type
of such string is non-const:

TranslationUnitDecl
`-FunctionDecl  line:1:5 main 'int ()'
  `-CompoundStmt 
`-DeclStmt 
  `-VarDecl  col:9 p2 'char *' cinit
`-CStyleCastExpr  'char *' 
  `-ImplicitCastExpr  'char *' 
`-StringLiteral  'char [4]' lvalue "txt"


And, while there, i found out that -Wcast-align is broken for
reinterpret_cast<>() :/
https://bugs.llvm.org/show_bug.cgi?id=33397

> - Dave
Roman.

>>
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D33102
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305147 - [clang] Implement -Wcast-qual for C++

2017-06-10 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sat Jun 10 12:19:19 2017
New Revision: 305147

URL: http://llvm.org/viewvc/llvm-project?rev=305147&view=rev
Log:
[clang] Implement -Wcast-qual for C++

Summary:
This way, the behavior of that warning flag
more closely resembles that of GCC.

Do note that there is at least one false-negative (see FIXME in tests).

Fixes PR4802.

Testing:
```
ninja check-clang-sema check-clang-semacxx
```

Reviewers: dblaikie, majnemer, rnk

Reviewed By: dblaikie, rnk

Subscribers: cfe-commits, alexfh, rnk

Differential Revision: https://reviews.llvm.org/D33102

Added:
cfe/trunk/test/SemaCXX/warn-cast-qual.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/test/Sema/warn-cast-qual.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=305147&r1=305146&r2=305147&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Sat Jun 10 12:19:19 2017
@@ -52,6 +52,9 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
+-  -Wcast-qual was implemented for C++. C-style casts are now properly
+   diagnosed.
+
 -  -Wunused-lambda-capture warns when a variable explicitly captured
by a lambda is not used in the body of the lambda.
 

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=305147&r1=305146&r2=305147&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Sat Jun 10 12:19:19 2017
@@ -143,6 +143,9 @@ namespace {
   };
 }
 
+static void DiagnoseCastQual(Sema &Self, const ExprResult &SrcExpr,
+ QualType DestType);
+
 // The Try functions attempt a specific way of casting. If they succeed, they
 // return TC_Success. If their way of casting is not appropriate for the given
 // arguments, they return TC_NotApplicable and *may* set diag to a diagnostic
@@ -427,6 +430,10 @@ static void diagnoseBadCast(Sema &S, uns
 /// the same kind of pointer (plain or to-member). Unlike the Sema function,
 /// this one doesn't care if the two pointers-to-member don't point into the
 /// same class. This is because CastsAwayConstness doesn't care.
+/// And additionally, it handles C++ references. If both the types are
+/// references, then their pointee types are returned,
+/// else if only one of them is reference, it's pointee type is returned,
+/// and the other type is returned as-is.
 static bool UnwrapDissimilarPointerTypes(QualType& T1, QualType& T2) {
   const PointerType *T1PtrType = T1->getAs(),
 *T2PtrType = T2->getAs();
@@ -475,6 +482,26 @@ static bool UnwrapDissimilarPointerTypes
 return true;
   }
   
+  const LValueReferenceType *T1RefType = T1->getAs(),
+*T2RefType = T2->getAs();
+  if (T1RefType && T2RefType) {
+T1 = T1RefType->getPointeeType();
+T2 = T2RefType->getPointeeType();
+return true;
+  }
+
+  if (T1RefType) {
+T1 = T1RefType->getPointeeType();
+// T2 = T2;
+return true;
+  }
+
+  if (T2RefType) {
+// T1 = T1;
+T2 = T2RefType->getPointeeType();
+return true;
+  }
+
   return false;
 }
 
@@ -503,11 +530,13 @@ CastsAwayConstness(Sema &Self, QualType
   // the rules are non-trivial. So first we construct Tcv *...cv* as described
   // in C++ 5.2.11p8.
   assert((SrcType->isAnyPointerType() || SrcType->isMemberPointerType() ||
-  SrcType->isBlockPointerType()) &&
+  SrcType->isBlockPointerType() ||
+  DestType->isLValueReferenceType()) &&
  "Source type is not pointer or pointer to member.");
   assert((DestType->isAnyPointerType() || DestType->isMemberPointerType() ||
-  DestType->isBlockPointerType()) &&
- "Destination type is not pointer or pointer to member.");
+  DestType->isBlockPointerType() ||
+  DestType->isLValueReferenceType()) &&
+ "Destination type is not pointer or pointer to member, or 
reference.");
 
   QualType UnwrappedSrcType = Self.Context.getCanonicalType(SrcType), 
UnwrappedDestType = Self.Context.getCanonicalType(DestType);
@@ -2177,6 +2206,8 @@ static TryCastResult TryReinterpretCast(
 
 void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
bool ListInitialization) {
+  assert(Self.getLangOpts().CPlusPlus);
+
   // Handle placeholders.
   if (isPlaceholder()) {
 // C-style casts can resolve __unknown_any types.
@@ -2580,30 +2611,42 @@ void CastOperation::CheckCStyleCast() {
 
   if (Kind == CK_BitCast)
 checkCastAlign();
+}
+
+/// DiagnoseCastQual - Warn whenever casts discards a qualifiers, be it either
+/// const, volatile or both.
+static void DiagnoseCastQual(Sema &Sel

r305148 - Revert "[clang] Implement -Wcast-qual for C++"

2017-06-10 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sat Jun 10 12:49:23 2017
New Revision: 305148

URL: http://llvm.org/viewvc/llvm-project?rev=305148&view=rev
Log:
Revert "[clang] Implement -Wcast-qual for C++"

Breaks -Werror builders.

Removed:
cfe/trunk/test/SemaCXX/warn-cast-qual.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/test/Sema/warn-cast-qual.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=305148&r1=305147&r2=305148&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Sat Jun 10 12:49:23 2017
@@ -52,9 +52,6 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
--  -Wcast-qual was implemented for C++. C-style casts are now properly
-   diagnosed.
-
 -  -Wunused-lambda-capture warns when a variable explicitly captured
by a lambda is not used in the body of the lambda.
 

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=305148&r1=305147&r2=305148&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Sat Jun 10 12:49:23 2017
@@ -143,9 +143,6 @@ namespace {
   };
 }
 
-static void DiagnoseCastQual(Sema &Self, const ExprResult &SrcExpr,
- QualType DestType);
-
 // The Try functions attempt a specific way of casting. If they succeed, they
 // return TC_Success. If their way of casting is not appropriate for the given
 // arguments, they return TC_NotApplicable and *may* set diag to a diagnostic
@@ -430,10 +427,6 @@ static void diagnoseBadCast(Sema &S, uns
 /// the same kind of pointer (plain or to-member). Unlike the Sema function,
 /// this one doesn't care if the two pointers-to-member don't point into the
 /// same class. This is because CastsAwayConstness doesn't care.
-/// And additionally, it handles C++ references. If both the types are
-/// references, then their pointee types are returned,
-/// else if only one of them is reference, it's pointee type is returned,
-/// and the other type is returned as-is.
 static bool UnwrapDissimilarPointerTypes(QualType& T1, QualType& T2) {
   const PointerType *T1PtrType = T1->getAs(),
 *T2PtrType = T2->getAs();
@@ -482,26 +475,6 @@ static bool UnwrapDissimilarPointerTypes
 return true;
   }
   
-  const LValueReferenceType *T1RefType = T1->getAs(),
-*T2RefType = T2->getAs();
-  if (T1RefType && T2RefType) {
-T1 = T1RefType->getPointeeType();
-T2 = T2RefType->getPointeeType();
-return true;
-  }
-
-  if (T1RefType) {
-T1 = T1RefType->getPointeeType();
-// T2 = T2;
-return true;
-  }
-
-  if (T2RefType) {
-// T1 = T1;
-T2 = T2RefType->getPointeeType();
-return true;
-  }
-
   return false;
 }
 
@@ -530,13 +503,11 @@ CastsAwayConstness(Sema &Self, QualType
   // the rules are non-trivial. So first we construct Tcv *...cv* as described
   // in C++ 5.2.11p8.
   assert((SrcType->isAnyPointerType() || SrcType->isMemberPointerType() ||
-  SrcType->isBlockPointerType() ||
-  DestType->isLValueReferenceType()) &&
+  SrcType->isBlockPointerType()) &&
  "Source type is not pointer or pointer to member.");
   assert((DestType->isAnyPointerType() || DestType->isMemberPointerType() ||
-  DestType->isBlockPointerType() ||
-  DestType->isLValueReferenceType()) &&
- "Destination type is not pointer or pointer to member, or 
reference.");
+  DestType->isBlockPointerType()) &&
+ "Destination type is not pointer or pointer to member.");
 
   QualType UnwrappedSrcType = Self.Context.getCanonicalType(SrcType), 
UnwrappedDestType = Self.Context.getCanonicalType(DestType);
@@ -2206,8 +2177,6 @@ static TryCastResult TryReinterpretCast(
 
 void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
bool ListInitialization) {
-  assert(Self.getLangOpts().CPlusPlus);
-
   // Handle placeholders.
   if (isPlaceholder()) {
 // C-style casts can resolve __unknown_any types.
@@ -2611,42 +2580,30 @@ void CastOperation::CheckCStyleCast() {
 
   if (Kind == CK_BitCast)
 checkCastAlign();
-}
-
-/// DiagnoseCastQual - Warn whenever casts discards a qualifiers, be it either
-/// const, volatile or both.
-static void DiagnoseCastQual(Sema &Self, const ExprResult &SrcExpr,
- QualType DestType) {
-  if (SrcExpr.isInvalid())
-return;
-
-  QualType SrcType = SrcExpr.get()->getType();
-  if (!((SrcType->isAnyPointerType() && DestType->isAnyPointerType()) ||
-DestType->isLValueReferenceType()))
-return;
 
+  // -Wcast-qual
   QualType TheOffendingSrcType, TheO

Re: [PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-12 Thread Roman Lebedev via cfe-commits
On Mon, Jun 12, 2017 at 8:16 PM, David Blaikie  wrote:
>
>
> On Mon, Jun 12, 2017 at 10:10 AM Roman Lebedev via Phabricator
>  wrote:
>>
>> lebedev.ri added a comment.
>>
>> So i'm trying to analyze that stage2 warning.
>
>
> Could you link to the buildbot failure to see the original LLVM project code
> triggering this situation?
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3249
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3249/steps/build-stage2-LLVMgold.so/logs/stdio

FAILED: 
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/install/stage1/bin/clang++
  -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_GLOBAL_ISEL -D_DEBUG -D_GNU_SOURCE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Ilib/CodeGen/AsmPrinter
-I/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/lib/CodeGen/AsmPrinter
-Iinclude 
-I/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/include
-fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -std=c++11
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wmissing-field-initializers -pedantic -Wno-long-long
-Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor
-Wstring-conversion -fcolor-diagnostics -ffunction-sections
-fdata-sections -O3-UNDEBUG  -fno-exceptions -fno-rtti -MMD -MT
lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/CodeViewDebug.cpp.o
-MF lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/CodeViewDebug.cpp.o.d
-o lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/CodeViewDebug.cpp.o
-c 
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
In file included from
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:14:
In file included from
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/lib/CodeGen/AsmPrinter/CodeViewDebug.h:17:
In file included from
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h:15:
In file included from
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/include/llvm/IR/DebugInfoMetadata.h:26:
In file included from
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/include/llvm/IR/Metadata.h:23:
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/include/llvm/ADT/PointerUnion.h:161:19:
error: cast from 'void **' to 'const llvm::DISubprogram **' must have
all intermediate pointers const qualified to be safe
[-Werror,-Wcast-qual]
return (PT1 *)Val.getAddrOfPointer();
  ^
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/include/llvm/ADT/TinyPtrVector.h:177:18:
note: in instantiation of member function 'llvm::PointerUnion
*>::getAddrOfPtr1' requested here
  return Val.getAddrOfPtr1();
 ^
/home/buildbot/Buildbot/Slave1a/clang-with-lto-ubuntu/llvm.src/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:1885:33:
note: in instantiation of member function 'llvm::TinyPtrVector::begin' requested here
for (const DISubprogram *SP : MethodItr.second) {
^


>>
>> The testcase //seems// to be: (autogenerated all the variants)
>>
>>   void test_nop() {
>> unsigned char **ptr1 = 0;
>> void **ptr2 = (void **)ptr1;
>>   }
>>   void test_bad() {
>> unsigned char **ptr1 = 0;
>> const void **ptr2 = (const void **)ptr1; // expected-warning {{cast
>> from 'unsigned char **' to 'const void **' must have all intermediate
>> pointers const qualified to be safe}}
>>   }
>>   void test_good0() {
>> unsigned char **ptr1 = 0;
>> void *const *ptr2 = (void *const *)ptr1;
>>   }
>>   void test_good1() {
>> unsigned char **ptr1 = 0;
>> const void *const *ptr2 = (const void *const *)ptr1;
>>   }
>>   void test_good2() {
>> unsigned char *const *ptr1 = 0;
>> void *const *ptr2 = (void *const *)ptr1;
>>   }
>>   void test_good3() {
>> unsigned char *const *ptr1 = 0;
>> const void *const *ptr2 = (const void *const *)ptr1;
>>   }
>>   void test_good4() {
>> const unsigned char **ptr1 = 0;
>> const void **ptr2 = (const void **)ptr1;
>>   }
>>   void test_good5() {
>> const unsigned char **ptr1 = 0;
>> const void *const *ptr2 = (const void *const *)ptr1;
>>   }
>>   void test_good6() {
>> const unsigned char *const *ptr1 = 0;
>> const void *const *ptr2 = (const void *const *)ptr1;
>>   }
>>
>> GCC does not warn about such code at all, clang in C mode does warn about
>> only one combination:
>>
>>   $ gcc -c /tmp/test.c -Wcast-qual
>>   $ echo $?
>>   0
>>   $ clang -c /tmp/test.c -Wcast-qual
>>   /tmp/test.c:7:38: warning: cast from 'unsigned char **' to 'const void
>> **' must have all intermediate pointers const qualified to be safe
>> [-Wcast-qual]
>> const void **ptr2 = (const void **)ptr1; // expected-warning {{cast
>> from 'unsigned char **' to 'const void **' must have all intermediate
>> pointers const qualified to be sa

[clang-tools-extra] r305554 - [clang-tidy] readability-function-size: fix nesting level calculation

2017-06-16 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Jun 16 08:07:47 2017
New Revision: 305554

URL: http://llvm.org/viewvc/llvm-project?rev=305554&view=rev
Log:
[clang-tidy] readability-function-size: fix nesting level calculation

Summary:
A followup for D32942.

Malcolm Parsons has provided a valid testcase that the initial version of the 
check complained about nested `if`'s.
As it turns out, the culprit is the **partially** un-intentional `switch` 
fallthrough.
So rewrite the NestingThreshold logic without ab-using+mis-using that switch 
with fallthrough, and add testcases with nested `if`' where there should be a 
warning and shouldn't be a warning. This results in a cleaner, simpler code, 
too.

I guess, now it would be actually possible to pick some reasonable default for 
`NestingThreshold` setting.

Fixes PR33454.

Reviewers: malcolm.parsons, alexfh

Reviewed By: malcolm.parsons

Subscribers: sbenza, xazax.hun, cfe-commits, aaron.ballman

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D34202

Modified:
clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp

Modified: clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp?rev=305554&r1=305553&r2=305554&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp Fri 
Jun 16 08:07:47 2017
@@ -36,15 +36,8 @@ public:
 case Stmt::ForStmtClass:
 case Stmt::SwitchStmtClass:
   ++Info.Branches;
-// fallthrough
+  LLVM_FALLTHROUGH;
 case Stmt::CompoundStmtClass:
-  // If this new compound statement is located in a compound statement,
-  // which is already nested NestingThreshold levels deep, record the start
-  // location of this new compound statement
-  if (CurrentNestingLevel == Info.NestingThreshold)
-Info.NestingThresholders.push_back(Node->getLocStart());
-
-  ++CurrentNestingLevel;
   TrackedParent.push_back(true);
   break;
 default:
@@ -54,12 +47,24 @@ public:
 
 Base::TraverseStmt(Node);
 
-if (TrackedParent.back())
-  --CurrentNestingLevel;
 TrackedParent.pop_back();
 
 return true;
   }
+
+  bool TraverseCompoundStmt(CompoundStmt *Node) {
+// If this new compound statement is located in a compound statement, which
+// is already nested NestingThreshold levels deep, record the start 
location
+// of this new compound statement.
+if (CurrentNestingLevel == Info.NestingThreshold)
+  Info.NestingThresholders.push_back(Node->getLocStart());
+
+++CurrentNestingLevel;
+Base::TraverseCompoundStmt(Node);
+--CurrentNestingLevel;
+
+return true;
+  }
 
   bool TraverseDecl(Decl *Node) {
 TrackedParent.push_back(false);

Modified: clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp?rev=305554&r1=305553&r2=305554&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp Fri 
Jun 16 08:07:47 2017
@@ -63,8 +63,9 @@ void bar2() { class A { void barx() {;;}
 #define macro() {int x; {int y; {int z;}}}
 
 void baz0() { // 1
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds 
recommended size/complexity
-// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 9 statements (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds 
recommended size/complexity
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 27 lines including whitespace and 
comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
   int a;
   { // 2
 int b;
@@ -87,5 +88,55 @@ void baz0() { // 1
   }
   macro()
 // CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here 
(threshold 2)
-// CHECK-MESSAGES: :[[@LINE-27]]:25: note: expanded from macro 'macro'
+// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+}
+
+// check that nested if's are not reported. this was broken initially
+void nesting_if() { // 1
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds 
recommended size/complexity
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and 
comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
+  if (true) { // 2
+ int j;
+  } else if (true) { // 2
+ int j;
+ if (true) { // 3
+   // CHECK-MESSAGES:

Re: [PATCH] D40939: [analyzer] Avoid element regions of void type.

2017-12-19 Thread Roman Lebedev via cfe-commits
On Tue, Dec 19, 2017 at 8:26 PM, Artem Dergachev via Phabricator via
cfe-commits  wrote:
> NoQ updated this revision to Diff 127548.
> NoQ added a comment.
>
> - Fix comments as suggested by Devin.
> - Point out that arithmetic on void pointers is a GNU extension.
>
>
> https://reviews.llvm.org/D40939
>
> Files:
>   include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
>   lib/StaticAnalyzer/Core/ExprEngine.cpp
>   lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
No tests?

> Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
> ===
> --- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
> +++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
> @@ -988,6 +988,12 @@
>  elementType = resultTy->getPointeeType();
>  }
>
> +// Represent arithmetic on void pointers as arithmetic on char pointers.
> +// It is fine when a TypedValueRegion of char value type represents
> +// a void pointer. Note that arithmetic on void pointers is a GCC 
> extension.
> +if (elementType->isVoidType())
> +  elementType = getContext().CharTy;
> +
>  if (Optional indexV = index.getAs()) {
>return loc::MemRegionVal(MemMgr.getElementRegion(elementType, *indexV,
> superR, 
> getContext()));
> Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
> ===
> --- lib/StaticAnalyzer/Core/ExprEngine.cpp
> +++ lib/StaticAnalyzer/Core/ExprEngine.cpp
> @@ -2178,9 +2178,17 @@
>  ProgramStateRef state = Node->getState();
>
>  if (IsGLValueLike) {
> -  SVal V = state->getLValue(A->getType(),
> -  state->getSVal(Idx, LCtx),
> -  state->getSVal(Base, LCtx));
> +  QualType T = A->getType();
> +
> +  // One of the forbidden LValue types! We still need to have sensible
> +  // symbolic locations to represent this stuff. Note that arithmetic on
> +  // void pointers is a GCC extension.
> +  if (T->isVoidType())
> +T = getContext().CharTy;
> +
> +  SVal V = state->getLValue(T,
> +state->getSVal(Idx, LCtx),
> +state->getSVal(Base, LCtx));
>Bldr.generateNode(A, Node, state->BindExpr(A, LCtx, V), nullptr,
>ProgramPoint::PostLValueKind);
>  } else if (IsVectorType) {
> Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
> ===
> --- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
> +++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
> @@ -961,7 +961,10 @@
>CXXThisRegion(const PointerType *thisPointerTy,
>  const StackArgumentsSpaceRegion *sReg)
>: TypedValueRegion(sReg, CXXThisRegionKind),
> -ThisPointerTy(thisPointerTy) {}
> +ThisPointerTy(thisPointerTy) {
> +assert(ThisPointerTy->getPointeeType()->getAsCXXRecordDecl() &&
> +   "Invalid region type!");
> +  }
>
>static void ProfileRegion(llvm::FoldingSetNodeID &ID,
>  const PointerType *PT,
> @@ -1075,6 +1078,8 @@
>  assert((!Idx.getAs() ||
>  Idx.castAs().getValue().isSigned()) &&
> "The index must be signed");
> +assert(!elementType.isNull() && !elementType->isVoidType() &&
> +   "Invalid region type!");
>}
>
>static void ProfileRegion(llvm::FoldingSetNodeID& ID, QualType elementType,
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321691 - [Sema] -Wtautological-constant-compare is too good. Cripple it.

2018-01-03 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Jan  3 00:45:19 2018
New Revision: 321691

URL: http://llvm.org/viewvc/llvm-project?rev=321691&view=rev
Log:
[Sema] -Wtautological-constant-compare is too good. Cripple it.

Summary:
The diagnostic was mostly introduced in D38101 by me, as a reaction to wasting 
a lot of time, see [[ 
https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20171009/206427.html | 
mail ]].
However, the diagnostic is pretty dumb. While it works with no false-positives,
there are some questionable cases that are diagnosed when one would argue that 
they should not be.

The common complaint is that it diagnoses the comparisons between an `int` and
`long` when compiling for a 32-bit target as tautological, but not when
compiling for 64-bit targets. The underlying problem is obvious: data model.
In most cases, 64-bit target is `LP64` (`int` is 32-bit, `long` and pointer are
64-bit), and the 32-bit target is `ILP32` (`int`, `long`, and pointer are 
32-bit).

I.e. the common pattern is: (pseudocode)
```
#include 
#include 
int main() {
  using T1 = long;
  using T2 = int;

  T1 r;
  if (r < std::numeric_limits::min()) {}
  if (r > std::numeric_limits::max()) {}
}
```
As an example, D39149 was trying to fix this diagnostic in libc++, and it was 
not well-received.

This *could* be "fixed", by changing the diagnostics logic to something like
`if the types of the values being compared are different, but are of the same 
size, then do diagnose`,
and i even attempted to do so in D39462, but as @rjmccall rightfully commented,
that implementation is incomplete to say the least.

So to stop causing trouble, and avoid contaminating upcoming release, lets do 
this workaround:
* move these three diags (`warn_unsigned_always_true_comparison`, 
`warn_unsigned_enum_always_true_comparison`, 
`warn_tautological_constant_compare`) into it's own 
`-Wtautological-constant-in-range-compare`
* Disable them by default
* Make them part of `-Wextra`
* Additionally, give `warn_tautological_constant_compare` it's own flag 
`-Wtautological-type-limit-compare`.
  I'm not happy about that name, but i can't come up with anything better.

This way all three of them can be enabled/disabled either altogether, or 
one-by-one.

Reviewers: aaron.ballman, rsmith, smeenai, rjmccall, rnk, mclow.lists, dim

Reviewed By: aaron.ballman, rsmith, dim

Subscribers: thakis, compnerd, mehdi_amini, dim, hans, cfe-commits, rjmccall

Tags: #clang

Differential Revision: https://reviews.llvm.org/D41512

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/Sema/compare.c
cfe/trunk/test/Sema/tautological-constant-compare.c
cfe/trunk/test/Sema/tautological-constant-enum-compare.c
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.cpp
cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c
cfe/trunk/test/SemaCXX/compare.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=321691&r1=321690&r2=321691&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jan  3 00:45:19 2018
@@ -435,12 +435,16 @@ def StringCompare : DiagGroup<"string-co
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
 def StrncatSize : DiagGroup<"strncat-size">;
+def TautologicalTypeLimitCompare : 
DiagGroup<"tautological-type-limit-compare">;
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
+def TautologicalInRangeCompare : 
DiagGroup<"tautological-constant-in-range-compare",
+   [TautologicalTypeLimitCompare,
+TautologicalUnsignedZeroCompare,
+
TautologicalUnsignedEnumZeroCompare]>;
 def TautologicalOutOfRangeCompare : 
DiagGroup<"tautological-constant-out-of-range-compare">;
 def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
-[TautologicalUnsignedZeroCompare,
- 
TautologicalUnsignedEnumZeroCompare,
+[TautologicalInRangeCompare,
  TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
@@ -715,6 +719,7 @@ def IntToPointerCast : DiagGroup<"int-to
 def Move : DiagGroup<"move", [PessimizingMove, RedundantMove,

Re: [libcxx] r321966 - Mark the transparent version set::count() as const. Thanks to Ivan Matek for the bug report.

2018-01-07 Thread Roman Lebedev via cfe-commits
It seems the test is missing?

On Sun, Jan 7, 2018 at 8:39 PM, Marshall Clow via cfe-commits
 wrote:
> Author: marshall
> Date: Sun Jan  7 09:39:57 2018
> New Revision: 321966
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321966&view=rev
> Log:
> Mark the transparent version set::count() as const. Thanks to Ivan Matek for 
> the bug report.
>
> Modified:
> libcxx/trunk/include/set
>
> Modified: libcxx/trunk/include/set
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/set?rev=321966&r1=321965&r2=321966&view=diff
> ==
> --- libcxx/trunk/include/set (original)
> +++ libcxx/trunk/include/set Sun Jan  7 09:39:57 2018
> @@ -1077,7 +1077,7 @@ public:
>  template 
>  _LIBCPP_INLINE_VISIBILITY
>  typename enable_if<__is_transparent<_Compare, 
> _K2>::value,size_type>::type
> -count(const _K2& __k)  {return 
> __tree_.__count_multi(__k);}
> +count(const _K2& __k) const{return 
> __tree_.__count_multi(__k);}
>  #endif
>
>  _LIBCPP_INLINE_VISIBILITY
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r326202 - [Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>

2018-02-27 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Feb 27 07:19:28 2018
New Revision: 326202

URL: http://llvm.org/viewvc/llvm-project?rev=326202&view=rev
Log:
[Tooling] [1/1] Refactor FrontendActionFactory::create() to return 
std::unique_ptr<>

Summary:
I'm not sure whether there are any principal reasons why it returns raw owning 
pointer,
or it is just a old code that was not updated post-C++11.

I'm not too sure what testing i should do, because `check-all` is not error 
clean here for some reason,
but it does not //appear// asif those failures are related to these changes.

This is Clang-tools-extra part.
Clang part is D43779.

Reviewers: klimek, bkramer, alexfh, pcc

Reviewed By: alexfh

Subscribers: ioeric, jkorous-apple, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D43780

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.h
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp

clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
clang-tools-extra/trunk/modularize/CoverageChecker.cpp
clang-tools-extra/trunk/modularize/Modularize.cpp
clang-tools-extra/trunk/pp-trace/PPTrace.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.h?rev=326202&r1=326201&r2=326202&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.h (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.h Tue Feb 27 07:19:28 2018
@@ -217,8 +217,8 @@ public:
  DeclarationReporter *const Reporter = nullptr)
   : Context(Context), Reporter(Reporter) {}
 
-  clang::FrontendAction *create() override {
-return new ClangMoveAction(Context, Reporter);
+  std::unique_ptr create() override {
+return llvm::make_unique(Context, Reporter);
   }
 
 private:

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=326202&r1=326201&r2=326202&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Tue Feb 27 07:19:28 2018
@@ -527,7 +527,9 @@ void runClangTidy(clang::tidy::ClangTidy
   class ActionFactory : public FrontendActionFactory {
   public:
 ActionFactory(ClangTidyContext &Context) : ConsumerFactory(Context) {}
-FrontendAction *create() override { return new Action(&ConsumerFactory); }
+std::unique_ptr create() override {
+  return llvm::make_unique(&ConsumerFactory);
+}
 
   private:
 class Action : public ASTFrontendAction {

Modified: 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=326202&r1=326201&r2=326202&view=diff
==
--- 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 Tue Feb 27 07:19:28 2018
@@ -53,7 +53,7 @@ class SymbolIndexActionFactory : public
 public:
   SymbolIndexActionFactory(tooling::ExecutionContext *Ctx) : Ctx(Ctx) {}
 
-  clang::FrontendAction *create() override {
+  std::unique_ptr create() override {
 // Wraps the index action and reports collected symbols to the execution
 // context at the end of each translation unit.
 class WrappedIndexAction : public WrapperFrontendAction {
@@ -102,7 +102,8 @@ public:
 auto Includes = llvm::make_unique();
 addSystemHeadersMapping(Includes.get());
 CollectorOpts.Includes = Includes.get();
-return new WrappedIndexAction(
+
+return llvm::make_unique(
 std::make_shared(std::move(CollectorOpts)),
 std::move(Includes), IndexOpts, Ctx);
   }

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h?rev=326202&r1=326201&r2=326202&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h 
(original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h 
Tue Feb 27 07:19:28 2018
@@ -48,8 +48,8 @@ public:
   const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
   : Reporter(Reporter), RegexHeaderMa

r326201 - [Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>

2018-02-27 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Feb 27 07:19:20 2018
New Revision: 326201

URL: http://llvm.org/viewvc/llvm-project?rev=326201&view=rev
Log:
[Tooling] [0/1] Refactor FrontendActionFactory::create() to return 
std::unique_ptr<>

Summary:
Noticed during review of D41102.

I'm not sure whether there are any principal reasons why it returns raw owning 
pointer,
or it is just a old code that was not updated post-C++11.

I'm not too sure what testing i should do, because `check-all` is not error 
clean here for some reason,
but it does not //appear// asif those failures are related to these changes.

This is clang part.
Clang-tools-extra part is D43780.

Reviewers: klimek, bkramer, alexfh, pcc

Reviewed By: alexfh

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D43779

Modified:
cfe/trunk/docs/LibTooling.rst
cfe/trunk/docs/RAVFrontendAction.rst
cfe/trunk/include/clang/Tooling/Tooling.h
cfe/trunk/lib/Tooling/Tooling.cpp
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
cfe/trunk/unittests/AST/EvaluateAsRValueTest.cpp
cfe/trunk/unittests/CrossTU/CrossTranslationUnitTest.cpp
cfe/trunk/unittests/Sema/CodeCompleteTest.cpp
cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp
cfe/trunk/unittests/Tooling/ExecutionTest.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp
cfe/trunk/unittests/Tooling/TestVisitor.h
cfe/trunk/unittests/Tooling/ToolingTest.cpp

Modified: cfe/trunk/docs/LibTooling.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibTooling.rst?rev=326201&r1=326200&r2=326201&view=diff
==
--- cfe/trunk/docs/LibTooling.rst (original)
+++ cfe/trunk/docs/LibTooling.rst Tue Feb 27 07:19:20 2018
@@ -34,7 +34,7 @@ looked for.  Let me give you an example:
   TEST(runToolOnCode, CanSyntaxCheckCode) {
 // runToolOnCode returns whether the action was correctly run over the
 // given code.
-EXPECT_TRUE(runToolOnCode(new clang::SyntaxOnlyAction, "class X {};"));
+EXPECT_TRUE(runToolOnCode(llvm::make_unique(), 
"class X {};"));
   }
 
 Writing a standalone tool

Modified: cfe/trunk/docs/RAVFrontendAction.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/RAVFrontendAction.rst?rev=326201&r1=326200&r2=326201&view=diff
==
--- cfe/trunk/docs/RAVFrontendAction.rst (original)
+++ cfe/trunk/docs/RAVFrontendAction.rst Tue Feb 27 07:19:20 2018
@@ -196,7 +196,7 @@ Now we can combine all of the above into
 
   int main(int argc, char **argv) {
 if (argc > 1) {
-  clang::tooling::runToolOnCode(new FindNamedClassAction, argv[1]);
+  
clang::tooling::runToolOnCode(llvm::make_unique(), 
argv[1]);
 }
   }
 

Modified: cfe/trunk/include/clang/Tooling/Tooling.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Tooling.h?rev=326201&r1=326200&r2=326201&view=diff
==
--- cfe/trunk/include/clang/Tooling/Tooling.h (original)
+++ cfe/trunk/include/clang/Tooling/Tooling.h Tue Feb 27 07:19:20 2018
@@ -94,7 +94,7 @@ public:
   /// \brief Returns a new clang::FrontendAction.
   ///
   /// The caller takes ownership of the returned action.
-  virtual clang::FrontendAction *create() = 0;
+  virtual std::unique_ptr create() = 0;
 };
 
 /// \brief Returns a new FrontendActionFactory for a given type.
@@ -149,8 +149,8 @@ inline std::unique_ptr ToolAction,
+   const Twine &Code, const Twine &FileName = "input.cc",
std::shared_ptr PCHContainerOps =
std::make_shared());
 
@@ -172,7 +172,7 @@ typedef std::vector ToolAction, const Twine &Code,
 const std::vector &Args, const Twine &FileName = "input.cc",
 const Twine &ToolName = "clang-tool",
 std::shared_ptr PCHContainerOps =
@@ -226,8 +226,8 @@ public:
   /// ownership.
   /// \param PCHContainerOps The PCHContainerOperations for loading and 
creating
   /// clang modules.
-  ToolInvocation(std::vector CommandLine, FrontendAction *FAction,
- FileManager *Files,
+  ToolInvocation(std::vector CommandLine,
+ std::unique_ptr FAction, FileManager *Files,
  std::shared_ptr PCHContainerOps =
  std::make_shared());
 
@@ -367,7 +367,9 @@ template 
 std::unique_ptr newFrontendActionFactory() {
   class SimpleFrontendActionFactory : public FrontendActionFactory {
   public:
-clang::FrontendAction *create() override { return new T; }
+std::unique_ptr create() override {
+  return llvm::make_unique();
+}
   };
 
   return std::unique_ptr(
@@ -383,8 +385,9 @@ inline std::unique_ptr create() override {
+  return llvm::make_unique(ConsumerFactory,
+   Callb

[clang-tools-extra] r326203 - Revert "[Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>"

2018-02-27 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Feb 27 07:54:41 2018
New Revision: 326203

URL: http://llvm.org/viewvc/llvm-project?rev=326203&view=rev
Log:
Revert "[Tooling] [1/1] Refactor FrontendActionFactory::create() to return 
std::unique_ptr<>"

This reverts commit rL326202

This broke gcc4.8 builds, compiler just segfaults:
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14909
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/22673

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.h
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp

clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
clang-tools-extra/trunk/modularize/CoverageChecker.cpp
clang-tools-extra/trunk/modularize/Modularize.cpp
clang-tools-extra/trunk/pp-trace/PPTrace.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.h?rev=326203&r1=326202&r2=326203&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.h (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.h Tue Feb 27 07:54:41 2018
@@ -217,8 +217,8 @@ public:
  DeclarationReporter *const Reporter = nullptr)
   : Context(Context), Reporter(Reporter) {}
 
-  std::unique_ptr create() override {
-return llvm::make_unique(Context, Reporter);
+  clang::FrontendAction *create() override {
+return new ClangMoveAction(Context, Reporter);
   }
 
 private:

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=326203&r1=326202&r2=326203&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Tue Feb 27 07:54:41 2018
@@ -527,9 +527,7 @@ void runClangTidy(clang::tidy::ClangTidy
   class ActionFactory : public FrontendActionFactory {
   public:
 ActionFactory(ClangTidyContext &Context) : ConsumerFactory(Context) {}
-std::unique_ptr create() override {
-  return llvm::make_unique(&ConsumerFactory);
-}
+FrontendAction *create() override { return new Action(&ConsumerFactory); }
 
   private:
 class Action : public ASTFrontendAction {

Modified: 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=326203&r1=326202&r2=326203&view=diff
==
--- 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 Tue Feb 27 07:54:41 2018
@@ -53,7 +53,7 @@ class SymbolIndexActionFactory : public
 public:
   SymbolIndexActionFactory(tooling::ExecutionContext *Ctx) : Ctx(Ctx) {}
 
-  std::unique_ptr create() override {
+  clang::FrontendAction *create() override {
 // Wraps the index action and reports collected symbols to the execution
 // context at the end of each translation unit.
 class WrappedIndexAction : public WrapperFrontendAction {
@@ -102,8 +102,7 @@ public:
 auto Includes = llvm::make_unique();
 addSystemHeadersMapping(Includes.get());
 CollectorOpts.Includes = Includes.get();
-
-return llvm::make_unique(
+return new WrappedIndexAction(
 std::make_shared(std::move(CollectorOpts)),
 std::move(Includes), IndexOpts, Ctx);
   }

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h?rev=326203&r1=326202&r2=326203&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h 
(original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h 
Tue Feb 27 07:54:41 2018
@@ -48,8 +48,8 @@ public:
   const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
   : Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
 
-  std::unique_ptr create() override {
-return llvm::make_unique(Reporter, RegexHeaderMap);
+  clang::FrontendAction *create() override {
+return new FindAllSymbolsAction(Reporter, RegexHeaderMap);
   }
 
 private:

Modified: clang-tools-extra/trunk/modularize/CoverageChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cl

r326204 - Revert "[Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>"

2018-02-27 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Feb 27 07:54:55 2018
New Revision: 326204

URL: http://llvm.org/viewvc/llvm-project?rev=326204&view=rev
Log:
Revert "[Tooling] [0/1] Refactor FrontendActionFactory::create() to return 
std::unique_ptr<>"

This reverts commit rL326201

This broke gcc4.8 builds, compiler just segfaults:¬
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14909¬
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/22673¬

Modified:
cfe/trunk/docs/LibTooling.rst
cfe/trunk/docs/RAVFrontendAction.rst
cfe/trunk/include/clang/Tooling/Tooling.h
cfe/trunk/lib/Tooling/Tooling.cpp
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
cfe/trunk/unittests/AST/EvaluateAsRValueTest.cpp
cfe/trunk/unittests/CrossTU/CrossTranslationUnitTest.cpp
cfe/trunk/unittests/Sema/CodeCompleteTest.cpp
cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp
cfe/trunk/unittests/Tooling/ExecutionTest.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp
cfe/trunk/unittests/Tooling/TestVisitor.h
cfe/trunk/unittests/Tooling/ToolingTest.cpp

Modified: cfe/trunk/docs/LibTooling.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibTooling.rst?rev=326204&r1=326203&r2=326204&view=diff
==
--- cfe/trunk/docs/LibTooling.rst (original)
+++ cfe/trunk/docs/LibTooling.rst Tue Feb 27 07:54:55 2018
@@ -34,7 +34,7 @@ looked for.  Let me give you an example:
   TEST(runToolOnCode, CanSyntaxCheckCode) {
 // runToolOnCode returns whether the action was correctly run over the
 // given code.
-EXPECT_TRUE(runToolOnCode(llvm::make_unique(), 
"class X {};"));
+EXPECT_TRUE(runToolOnCode(new clang::SyntaxOnlyAction, "class X {};"));
   }
 
 Writing a standalone tool

Modified: cfe/trunk/docs/RAVFrontendAction.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/RAVFrontendAction.rst?rev=326204&r1=326203&r2=326204&view=diff
==
--- cfe/trunk/docs/RAVFrontendAction.rst (original)
+++ cfe/trunk/docs/RAVFrontendAction.rst Tue Feb 27 07:54:55 2018
@@ -196,7 +196,7 @@ Now we can combine all of the above into
 
   int main(int argc, char **argv) {
 if (argc > 1) {
-  
clang::tooling::runToolOnCode(llvm::make_unique(), 
argv[1]);
+  clang::tooling::runToolOnCode(new FindNamedClassAction, argv[1]);
 }
   }
 

Modified: cfe/trunk/include/clang/Tooling/Tooling.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Tooling.h?rev=326204&r1=326203&r2=326204&view=diff
==
--- cfe/trunk/include/clang/Tooling/Tooling.h (original)
+++ cfe/trunk/include/clang/Tooling/Tooling.h Tue Feb 27 07:54:55 2018
@@ -94,7 +94,7 @@ public:
   /// \brief Returns a new clang::FrontendAction.
   ///
   /// The caller takes ownership of the returned action.
-  virtual std::unique_ptr create() = 0;
+  virtual clang::FrontendAction *create() = 0;
 };
 
 /// \brief Returns a new FrontendActionFactory for a given type.
@@ -149,8 +149,8 @@ inline std::unique_ptr ToolAction,
-   const Twine &Code, const Twine &FileName = "input.cc",
+bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code,
+   const Twine &FileName = "input.cc",
std::shared_ptr PCHContainerOps =
std::make_shared());
 
@@ -172,7 +172,7 @@ typedef std::vector ToolAction, const Twine &Code,
+clang::FrontendAction *ToolAction, const Twine &Code,
 const std::vector &Args, const Twine &FileName = "input.cc",
 const Twine &ToolName = "clang-tool",
 std::shared_ptr PCHContainerOps =
@@ -226,8 +226,8 @@ public:
   /// ownership.
   /// \param PCHContainerOps The PCHContainerOperations for loading and 
creating
   /// clang modules.
-  ToolInvocation(std::vector CommandLine,
- std::unique_ptr FAction, FileManager *Files,
+  ToolInvocation(std::vector CommandLine, FrontendAction *FAction,
+ FileManager *Files,
  std::shared_ptr PCHContainerOps =
  std::make_shared());
 
@@ -367,9 +367,7 @@ template 
 std::unique_ptr newFrontendActionFactory() {
   class SimpleFrontendActionFactory : public FrontendActionFactory {
   public:
-std::unique_ptr create() override {
-  return llvm::make_unique();
-}
+clang::FrontendAction *create() override { return new T; }
   };
 
   return std::unique_ptr(
@@ -385,9 +383,8 @@ inline std::unique_ptr create() override {
-  return llvm::make_unique(ConsumerFactory,
-   Callbacks);
+clang::FrontendAction *create() override {
+  return new ConsumerFactoryAdaptor(ConsumerFactory, Callbacks);
 }
 
   private:

Modified

r327558 - [Parser] (C++) Make -Wextra-semi slightly more useful

2018-03-14 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Mar 14 12:31:34 2018
New Revision: 327558

URL: http://llvm.org/viewvc/llvm-project?rev=327558&view=rev
Log:
[Parser] (C++) Make -Wextra-semi slightly more useful

Summary:
Let's suppose the `-Weverything` is passed.

Given code like
```
void F() {}
;
```
If the code is compiled with `-std=c++03`, it would diagnose that extra sema:
```
:2:1: warning: extra ';' outside of a function is a C++11 extension 
[-Wc++11-extra-semi]
;
^~
```
If the code is compiled with `-std=c++11`, it also would diagnose that extra 
sema:
```
:2:1: warning: extra ';' outside of a function is incompatible with 
C++98 [-Wc++98-compat-pedantic]
;
^~
```

But, let's suppose the C++11 or higher is used, and the used does not care
about `-Wc++98-compat-pedantic`, so he disables that diagnostic.
And that silences the complaint about extra `;` too.
And there is no way to re-enable that particular diagnostic, passing 
`-Wextra-semi` does nothing...

Now, there is also a related `no newline at end of file` diagnostic, which is 
also emitted by `-Wc++98-compat-pedantic`
```
:2:2: warning: C++98 requires newline at end of file 
[-Wc++98-compat-pedantic]
;
 ^
```
But unlike the previous case, if `-Wno-c++98-compat-pedantic` is passed, that 
diagnostic stays displayed:
```
:2:2: warning: no newline at end of file [-Wnewline-eof]
;
 ^
```

This diff refactors the code so `-Wc++98-compat-extra-semi` can be re-enabled, 
after the `-Wc++98-compat-pedantic` was disabled.
This seems ugly, but there does not seem to be any saner way.

Testing: `$ ninja check-clang`

Reviewers: rsmith, rtrieu, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: jordan_rose, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D43162

Added:
cfe/trunk/test/SemaCXX/extra-semi.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/test/Parser/cxx-extra-semi.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=327558&r1=327557&r2=327558&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Mar 14 12:31:34 2018
@@ -151,8 +151,10 @@ def Exceptions : DiagGroup<"exceptions">
 def GNUEmptyInitializer : DiagGroup<"gnu-empty-initializer">;
 def GNUEmptyStruct : DiagGroup<"gnu-empty-struct">;
 def ExtraTokens : DiagGroup<"extra-tokens">;
+def CXX98CompatExtraSemi : DiagGroup<"c++98-compat-extra-semi">;
 def CXX11ExtraSemi : DiagGroup<"c++11-extra-semi">;
-def ExtraSemi : DiagGroup<"extra-semi", [CXX11ExtraSemi]>;
+def ExtraSemi : DiagGroup<"extra-semi", [CXX98CompatExtraSemi,
+ CXX11ExtraSemi]>;
 
 def GNUFlexibleArrayInitializer : DiagGroup<"gnu-flexible-array-initializer">;
 def GNUFlexibleArrayUnionMember : DiagGroup<"gnu-flexible-array-union-member">;
@@ -196,6 +198,7 @@ def CXX98Compat : DiagGroup<"c++98-compa
 def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
 [CXX98Compat,
  CXX98CompatBindToTemporaryCopy,
+ CXX98CompatExtraSemi,
  CXXPre14CompatPedantic,
  CXXPre17CompatPedantic,
  CXXPre2aCompatPedantic]>;

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=327558&r1=327557&r2=327558&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Mar 14 12:31:34 
2018
@@ -39,7 +39,7 @@ def ext_empty_translation_unit : Extensi
   InGroup>;
 def warn_cxx98_compat_top_level_semi : Warning<
   "extra ';' outside of a function is incompatible with C++98">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def ext_extra_semi : Extension<
   "extra ';' %select{"
   "outside of a function|"

Modified: cfe/trunk/test/Parser/cxx-extra-semi.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-extra-semi.cpp?rev=327558&r1=327557&r2=327558&view=diff
==
--- cfe/trunk/test/Parser/cxx-extra-semi.cpp (original)
+++ cfe/trunk/test/Parser/cxx-extra-semi.cpp Wed Mar 14 12:31:34 2018
@@ -38,4 +38,7 @@ union B {
 #if __cplusplus < 201103L
 // expected-warning@-3{{extra ';' outside of a function is a C++11 extension}}
 // expected-warning@-3{{extra ';' outside of a function is a C++11 extension}}
+#elif !defined(PEDANTIC)
+// expected-warning@-6{{extra ';' outside of a

r327725 - [docs] ReleaseNotes: document -Wextra-semi changes.

2018-03-16 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Mar 16 11:01:07 2018
New Revision: 327725

URL: http://llvm.org/viewvc/llvm-project?rev=327725&view=rev
Log:
[docs] ReleaseNotes: document -Wextra-semi changes.

I should have done it in rL327558 / D43162, but forgot..

I'm not 100% sure about the text, but i don't think
it warrants a whole new differential revision.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=327725&r1=327724&r2=327725&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Mar 16 11:01:07 2018
@@ -51,7 +51,13 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
-- ...
+- ``-Wc++98-compat-extra-semi`` is a new flag, which was previously inseparable
+  from ``-Wc++98-compat-pedantic``. The latter still controls the new flag.
+
+- ``-Wextra-semi`` now also controls ``-Wc++98-compat-extra-semi``.
+  Please do note that if you pass ``-Wno-c++98-compat-pedantic``, it implies
+  ``-Wno-c++98-compat-extra-semi``, so if you want that diagnostic, you need
+  to explicitly re-enable it (e.g. by appending ``-Wextra-semi``).
 
 Non-comprehensive list of changes in this release
 -


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r333891 - [clang][tooling] Don't forget to link to clangToolingInclusions.

2018-06-04 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Jun  4 05:04:51 2018
New Revision: 333891

URL: http://llvm.org/viewvc/llvm-project?rev=333891&view=rev
Log:
[clang][tooling] Don't forget to link to clangToolingInclusions.

Fixes build with shared libs, broken by rL333874.
Some buildbot converage is sorely missing.

Modified:
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt?rev=333891&r1=333890&r2=333891&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Mon Jun  4 05:04:51 
2018
@@ -48,6 +48,7 @@ target_link_libraries(ClangdTests
   clangSema
   clangTooling
   clangToolingCore
+  clangToolingInclusions
   LLVMSupport
   LLVMTestingSupport
   )


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333890 - [clang][tooling] Don't forget to link to clangToolingInclusions.

2018-06-04 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Jun  4 05:04:41 2018
New Revision: 333890

URL: http://llvm.org/viewvc/llvm-project?rev=333890&view=rev
Log:
[clang][tooling] Don't forget to link to clangToolingInclusions.

Fixes build with shared libs, broken by rL333874.
Some buildbot converage is sorely missing.

Modified:
cfe/trunk/unittests/Tooling/CMakeLists.txt

Modified: cfe/trunk/unittests/Tooling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CMakeLists.txt?rev=333890&r1=333889&r2=333890&view=diff
==
--- cfe/trunk/unittests/Tooling/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Tooling/CMakeLists.txt Mon Jun  4 05:04:41 2018
@@ -62,5 +62,6 @@ target_link_libraries(ToolingTests
   clangRewrite
   clangTooling
   clangToolingCore
+  clangToolingInclusions
   clangToolingRefactor
   )


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r333891 - [clang][tooling] Don't forget to link to clangToolingInclusions.

2018-06-04 Thread Roman Lebedev via cfe-commits
That was supposed to be "[clangd][tests] Don't forget to link to
clangToolingInclusions.".

On Mon, Jun 4, 2018 at 3:04 PM, Roman Lebedev via cfe-commits
 wrote:
> Author: lebedevri
> Date: Mon Jun  4 05:04:51 2018
> New Revision: 333891
>
> URL: http://llvm.org/viewvc/llvm-project?rev=333891&view=rev
> Log:
> [clang][tooling] Don't forget to link to clangToolingInclusions.
>
> Fixes build with shared libs, broken by rL333874.
> Some buildbot converage is sorely missing.
>
> Modified:
> clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
>
> Modified: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt?rev=333891&r1=333890&r2=333891&view=diff
> ==
> --- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Mon Jun  4 
> 05:04:51 2018
> @@ -48,6 +48,7 @@ target_link_libraries(ClangdTests
>clangSema
>clangTooling
>clangToolingCore
> +  clangToolingInclusions
>LLVMSupport
>LLVMTestingSupport
>)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r333874 - Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

2018-06-04 Thread Roman Lebedev via cfe-commits
This broke building as shared libraries.

I've committed the fix, but the bot coverage is clearly severely missing,
given that such breakages are very often.

Roman.

On Mon, Jun 4, 2018 at 12:04 PM, Eric Liu via cfe-commits
 wrote:
> Author: ioeric
> Date: Mon Jun  4 02:04:12 2018
> New Revision: 333874
>
> URL: http://llvm.org/viewvc/llvm-project?rev=333874&view=rev
> Log:
> Reland "Move #include manipulation code to new lib/Tooling/Inclusions."
>
> This reverts commit r333534 (i.e. reland r332720) after fixing module build.
>
> Differential Revision: https://reviews.llvm.org/D47068
>
> Added:
> cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
>   - copied, changed from r333865, 
> cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
>   - copied, changed from r333865, 
> cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
>   - copied, changed from r333865, 
> cfe/trunk/lib/Tooling/Core/CMakeLists.txt
> cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
>   - copied, changed from r333865, 
> cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
>   - copied, changed from r333865, 
> cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> Removed:
> cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> Modified:
> cfe/trunk/include/clang/Format/Format.h
> cfe/trunk/include/clang/module.modulemap
> cfe/trunk/lib/Format/CMakeLists.txt
> cfe/trunk/lib/Format/Format.cpp
> cfe/trunk/lib/Tooling/CMakeLists.txt
> cfe/trunk/lib/Tooling/Core/CMakeLists.txt
> cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
>
> Modified: cfe/trunk/include/clang/Format/Format.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=333874&r1=333873&r2=333874&view=diff
> ==
> --- cfe/trunk/include/clang/Format/Format.h (original)
> +++ cfe/trunk/include/clang/Format/Format.h Mon Jun  4 02:04:12 2018
> @@ -16,8 +16,8 @@
>  #define LLVM_CLANG_FORMAT_FORMAT_H
>
>  #include "clang/Basic/LangOptions.h"
> -#include "clang/Tooling/Core/IncludeStyle.h"
>  #include "clang/Tooling/Core/Replacement.h"
> +#include "clang/Tooling/Inclusions/IncludeStyle.h"
>  #include "llvm/ADT/ArrayRef.h"
>  #include "llvm/Support/Regex.h"
>  #include 
>
> Removed: cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h?rev=333873&view=auto
> ==
> --- cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (original)
> +++ cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (removed)
> @@ -1,137 +0,0 @@
> -//===--- HeaderIncludes.h - Insert/Delete #includes for C++ code--*- 
> C++-*-===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===--===//
> -
> -#ifndef LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
> -#define LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
> -
> -#include "clang/Basic/SourceManager.h"
> -#include "clang/Tooling/Core/Replacement.h"
> -#include "clang/Tooling/Core/IncludeStyle.h"
> -#include "llvm/Support/Path.h"
> -#include "llvm/Support/Regex.h"
> -#include 
> -
> -namespace clang {
> -namespace tooling {
> -
> -/// This class manages priorities of C++ #include categories and calculates
> -/// priorities for headers.
> -/// FIXME(ioeric): move this class into implementation file when 
> clang-format's
> -/// include sorting functions are also moved here.
> -class IncludeCategoryManager {
> -public:
> -  IncludeCategoryManager(const IncludeStyle &Style, StringRef FileName);
> -
> -  /// Returns the priority of the category which \p IncludeName belongs to.
> -  /// If \p CheckMainHeader is true and \p IncludeName is a main header, 
> returns
> -  /// 0. Otherwise, returns the priority of the matching category or INT_MAX.
> -  /// NOTE: this API is not thread-safe!
> -  int getIncludePriority(StringRef IncludeName, bool CheckMainHeader) const;
> -
> -private:
> -  bool isMainHeader(StringRef IncludeName) const;
> -
> -  const IncludeStyle Style;
> -  bool IsMainFile;
> -  std::string FileName;
> -  // This refers to a substring in FileName.
> -  StringRef FileStem;
> -  // Regex is not thread-safe.
> -  mutable SmallVector CategoryRegexs;
> -};
> -
> -/// Generates replacements for inserting or deleting #include directives in a
> -/// file.
> -class HeaderIncludes {
> 

Re: r333874 - Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

2018-06-04 Thread Roman Lebedev via cfe-commits
This is n-th time i do this kind of fix.
Sure this does resolve the issue, but it would be much better to use
proper means,
and tell people to fix their code, in an automatic way :)

On Mon, Jun 4, 2018 at 7:36 PM, Nico Weber  wrote:
> All chromium bots build with asserts on and we definitely don't want shared
> libs :-) Having the people who care about this build config make sure it
> keeps working seems like a good approach to me.
>
> On Mon, Jun 4, 2018 at 8:15 AM, David Zarzycki via cfe-commits
>  wrote:
>>
>> What’s stopping the project from automatically setting BUILD_SHARED_LIBS
>> to TRUE if asserts are enabled? That’d automatically “force” active
>> developers to test the scenario on their local machines, but not change the
>> way release builds work.
>>
>>
>> > On Jun 4, 2018, at 8:11 AM, Roman Lebedev via cfe-commits
>> >  wrote:
>> >
>> > This broke building as shared libraries.
>> >
>> > I've committed the fix, but the bot coverage is clearly severely
>> > missing,
>> > given that such breakages are very often.
>> >
>> > Roman.
>> >
>> > On Mon, Jun 4, 2018 at 12:04 PM, Eric Liu via cfe-commits
>> >  wrote:
>> >> Author: ioeric
>> >> Date: Mon Jun  4 02:04:12 2018
>> >> New Revision: 333874
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=333874&view=rev
>> >> Log:
>> >> Reland "Move #include manipulation code to new lib/Tooling/Inclusions."
>> >>
>> >> This reverts commit r333534 (i.e. reland r332720) after fixing module
>> >> build.
>> >>
>> >> Differential Revision: https://reviews.llvm.org/D47068
>> >>
>> >> Added:
>> >>cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >>cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>> >>cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>> >>cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>> >>cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
>> >>  - copied, changed from r333865,
>> >> cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
>> >> Removed:
>> >>cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >>cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>> >>cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>> >>cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
>> >> Modified:
>> >>cfe/trunk/include/clang/Format/Format.h
>> >>cfe/trunk/include/clang/module.modulemap
>> >>cfe/trunk/lib/Format/CMakeLists.txt
>> >>cfe/trunk/lib/Format/Format.cpp
>> >>cfe/trunk/lib/Tooling/CMakeLists.txt
>> >>cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>> >>cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
>> >>
>> >> Modified: cfe/trunk/include/clang/Format/Format.h
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=333874&r1=333873&r2=333874&view=diff
>> >>
>> >> ==
>> >> --- cfe/trunk/include/clang/Format/Format.h (original)
>> >> +++ cfe/trunk/include/clang/Format/Format.h Mon Jun  4 02:04:12 2018
>> >> @@ -16,8 +16,8 @@
>> >> #define LLVM_CLANG_FORMAT_FORMAT_H
>> >>
>> >> #include "clang/Basic/LangOptions.h"
>> >> -#include "clang/Tooling/Core/IncludeStyle.h"
>> >> #include "clang/Tooling/Core/Replacement.h"
>> >> +#include "clang/Tooling/Inclusions/IncludeStyle.h"
>> >> #include "llvm/ADT/ArrayRef.h"
>> >> #include "llvm/Support/Regex.h"
>> >> #include 
>> >>
>> >> Removed: cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h?rev=333873&

Re: r333923 - This diff includes changes for supporting the following types.

2018-06-04 Thread Roman Lebedev via cfe-commits
Did you use `arc patch` to get the commit description?
Please make sure that the first line of the commit is reasonable.
In this case it is not reasonable.

On Mon, Jun 4, 2018 at 7:07 PM, Leonard Chan via cfe-commits
 wrote:
> Author: leonardchan
> Date: Mon Jun  4 09:07:52 2018
> New Revision: 333923
>
> URL: http://llvm.org/viewvc/llvm-project?rev=333923&view=rev
> Log:
> This diff includes changes for supporting the following types.
>
> // 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;
> This diff only allows for declaration of the fixed point types. Assignment 
> and other operations done on fixed point types according to 
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in 
> future patches. The saturated versions of these types and the equivalent 
> _Fract types will also be added in future patches.
>
> The tests included are for asserting that we can declare these types.
>
> Fixed the test that was failing by not checking for dso_local on some
> targets.
>
> Differential Revision: https://reviews.llvm.org/D46084
>
> Added:
> cfe/trunk/test/Frontend/fixed_point.c
> cfe/trunk/test/Frontend/fixed_point_bit_widths.c
> cfe/trunk/test/Frontend/fixed_point_errors.c
> cfe/trunk/test/Frontend/fixed_point_errors.cpp
> cfe/trunk/test/Frontend/fixed_point_not_enabled.c
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/BuiltinTypes.def
> cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
> cfe/trunk/include/clang/Basic/LangOptions.def
> cfe/trunk/include/clang/Basic/Specifiers.h
> cfe/trunk/include/clang/Basic/TargetInfo.h
> cfe/trunk/include/clang/Basic/TokenKinds.def
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Sema/DeclSpec.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/lib/AST/NSAPI.cpp
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/lib/AST/TypeLoc.cpp
> cfe/trunk/lib/Analysis/PrintfFormatString.cpp
> cfe/trunk/lib/Basic/TargetInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Index/USRGeneration.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Sema/DeclSpec.cpp
> cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/lib/Serialization/ASTCommon.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/tools/libclang/CXType.cpp
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=333923&r1=333922&r2=333923&view=diff
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Mon Jun  4 09:07:52 2018
> @@ -3182,8 +3182,14 @@ enum CXTypeKind {
>CXType_Float128 = 30,
>CXType_Half = 31,
>CXType_Float16 = 32,
> +  CXType_ShortAccum = 33,
> +  CXType_Accum = 34,
> +  CXType_LongAccum = 35,
> +  CXType_UShortAccum = 36,
> +  CXType_UAccum = 37,
> +  CXType_ULongAccum = 38,
>CXType_FirstBuiltin = CXType_Void,
> -  CXType_LastBuiltin  = CXType_Float16,
> +  CXType_LastBuiltin = CXType_ULongAccum,
>
>CXType_Complex = 100,
>CXType_Pointer = 101,
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=333923&r1=333922&r2=333923&view=diff
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Jun  4 09:07:52 2018
> @@ -1007,6 +1007,9 @@ public:
>CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy;
>CanQualType UnsignedLongLongTy, UnsignedInt128Ty;
>CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty;
> +  CanQualType ShortAccumTy, AccumTy,
> +  LongAccumTy;  // ISO/IEC JTC1 SC22 WG14 N1169 Extension
> +  CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy;
>CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
>CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
>CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
>
> Modified: cfe/trunk/include/clang/AST/Built

Re: [clang-tools-extra] r333994 - [clang-tidy] fix broken test (no compile command) from r331763

2018-06-05 Thread Roman Lebedev via cfe-commits
This is strange.

First, i'm pretty sure the test worked for me before.
Second, this commit actually *breaks* those two tests for me:

$ ninja check-clang-tools
[0/1] Running the Clang extra tools' regression tests
FAIL: Clang Tools ::
clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp (123 of 867)
 TEST 'Clang Tools ::
clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp' FAILED

Script:
--
: 'RUN: at line 1';   clang-tidy -enable-check-profile
-checks='-*,readability-function-size'
/build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
-- 2>&1 | FileCheck --match-full-lines
-implicit-check-not='{{warning:|error:}}' /build/clang
-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
--
Exit Code: 2

Command Output (stderr):
--
FileCheck error: '-' is empty.
FileCheck command line:  FileCheck --match-full-lines
-implicit-check-not={{warning:|error:}}
/build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp

--


FAIL: Clang Tools ::
clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp (125 of 867)
 TEST 'Clang Tools ::
clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp' FAILED

Script:
--
: 'RUN: at line 1';   clang-tidy -enable-check-profile
-checks='-*,readability-function-size'
/build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
/build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
-- 2>&1 |
FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}'
/build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
--
Exit Code: 2

Command Output (stderr):
--
FileCheck error: '-' is empty.
FileCheck command line:  FileCheck --match-full-lines
-implicit-check-not={{warning:|error:}}
/build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp

--

Roman.

On Tue, Jun 5, 2018 at 12:42 PM, Sam McCall via cfe-commits
 wrote:
> Author: sammccall
> Date: Tue Jun  5 02:42:06 2018
> New Revision: 333994
>
> URL: http://llvm.org/viewvc/llvm-project?rev=333994&view=rev
> Log:
> [clang-tidy] fix broken test (no compile command) from r331763
>
> Modified:
> 
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
> 
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
>
> Modified: 
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp?rev=333994&r1=333993&r2=333994&view=diff
> ==
> --- 
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
>  (original)
> +++ 
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
>  Tue Jun  5 02:42:06 2018
> @@ -1,4 +1,4 @@
> -// RUN: clang-tidy -enable-check-profile 
> -checks='-*,readability-function-size' %s 2>&1 | FileCheck --match-full-lines 
> -implicit-check-not='{{warning:|error:}}' %s
> +// RUN: clang-tidy -enable-check-profile 
> -checks='-*,readability-function-size' %s -- 2>&1 | FileCheck 
> --match-full-lines -implicit-check-not='{{warning:|error:}}' %s
>
>  // CHECK: 
> ===-===
>  // CHECK-NEXT: {{.*}}  --- Name ---
>
> Modified: 
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp?rev=333994&r1=333993&r2=333994&view=diff
> ==
> --- 
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
>  (original)
> +++ 
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
>  Tue Jun  5 02:42:06 2018
> @@ -1,4 +1,4 @@
> -// RUN: clang-tidy -enable-check-profile 
> -checks='-*,readability-function-size' %s %s 2>&1 | FileCheck 
> --match-full-lines -implicit-check-not='{{warning:|error:}}' %s
> +// 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 ---
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r333994 - [clang-tidy] fix broken test (no compile command) from r331763

2018-06-05 Thread Roman Lebedev via cfe-commits
Ah, hm, yes, that was a further local problem in https://reviews.llvm.org/D46602
And i didn't double-check on master initially, because that causes all
the checks to be rebuilt :/

So thanks for the fix!

Roman.


On Tue, Jun 5, 2018 at 1:40 PM, Sam McCall  wrote:
> Hi Roman,
>
> Definitely something different in our configs, but it wasn't just me - a
> couple of colleagues have mentioned those tests as being broken for a while!
>
> The problem is the lack of compilation database, so I can imagine it can
> depend on filesystem layout, e.g. whether you have a separate build/source
> directory. (Potentially the CDB from llvm itself may be picked up or not)
>
> I can't tell from your lit output whether clang-tidy or FileCheck failed,
> what does this command return for you?
>
> bin/clang-tidy -enable-check-profile -checks='-*,readability-function-size'
> ../src/llvm/tools/clang/tools/extra/test/clang-tid
> y/clang-tidy-enable-check-profile-one-tu.cpp --
>
> (adjust path as needed)
>
> On Tue, Jun 5, 2018 at 12:30 PM Roman Lebedev  wrote:
>>
>> This is strange.
>>
>> First, i'm pretty sure the test worked for me before.
>> Second, this commit actually *breaks* those two tests for me:
>>
>> $ ninja check-clang-tools
>> [0/1] Running the Clang extra tools' regression tests
>> FAIL: Clang Tools ::
>> clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp (123 of 867)
>>  TEST 'Clang Tools ::
>> clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp' FAILED
>> 
>> Script:
>> --
>> : 'RUN: at line 1';   clang-tidy -enable-check-profile
>> -checks='-*,readability-function-size'
>>
>> /build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
>> -- 2>&1 | FileCheck --match-full-lines
>> -implicit-check-not='{{warning:|error:}}' /build/clang
>> -tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
>> --
>> Exit Code: 2
>>
>> Command Output (stderr):
>> --
>> FileCheck error: '-' is empty.
>> FileCheck command line:  FileCheck --match-full-lines
>> -implicit-check-not={{warning:|error:}}
>>
>> /build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
>>
>> --
>>
>> 
>> FAIL: Clang Tools ::
>> clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp (125 of 867)
>>  TEST 'Clang Tools ::
>> clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp' FAILED
>> 
>> Script:
>> --
>> : 'RUN: at line 1';   clang-tidy -enable-check-profile
>> -checks='-*,readability-function-size'
>>
>> /build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
>>
>> /build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
>> -- 2>&1 |
>> FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}'
>>
>> /build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
>> --
>> Exit Code: 2
>>
>> Command Output (stderr):
>> --
>> FileCheck error: '-' is empty.
>> FileCheck command line:  FileCheck --match-full-lines
>> -implicit-check-not={{warning:|error:}}
>>
>> /build/clang-tools-extra/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
>>
>> --
>>
>> Roman.
>>
>> On Tue, Jun 5, 2018 at 12:42 PM, Sam McCall via cfe-commits
>>  wrote:
>> > Author: sammccall
>> > Date: Tue Jun  5 02:42:06 2018
>> > New Revision: 333994
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=333994&view=rev
>> > Log:
>> > [clang-tidy] fix broken test (no compile command) from r331763
>> >
>> > Modified:
>> >
>> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
>> >
>> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
>> >
>> > Modified:
>> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp?rev=333994&r1=333993&r2=333994&view=diff
>> >
>> > ==
>> > ---
>> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
>> > (original)
>> > +++
>> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
>> > Tue Jun  5 02:42:06 2018
>> > @@ -1,4 +1,4 @@
>> > -// RUN: clang-tidy -enable-check-profile
>> > -checks='-*,readability-function-size' %s 2>&1 | FileCheck
>> > --match-full-lines -implicit-check-not='{{warning:|error:}}' %s
>> > +// RUN: clang-tidy -enable-check-profile
>> > -checks='-*,readability-function-size' %s -- 2>&1 | FileCheck
>> > --match-full-lines -implicit-check-not='{{warning:|error:}}' %s
>> >
>> >  // CHECK:
>> > ===-===
>> >  // CHECK-NEXT: {{.*}}  --- Name ---
>> >
>> > Modified:
>> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
>> > U

[clang-tools-extra] r334101 - [clang-tidy] Store checks profiling info as JSON files

2018-06-06 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Jun  6 08:07:51 2018
New Revision: 334101

URL: http://llvm.org/viewvc/llvm-project?rev=334101&view=rev
Log:
[clang-tidy] Store checks profiling info as JSON files

Summary:
Continuation of D46504.

Example output:
```
  $ clang-tidy -enable-check-profile -store-check-profile=. 
-checks=-*,readability-function-size source.cpp
  $ # Note that there won't be timings table printed to the console.
  $ cat *.json
  {
  "file": "/path/to/source.cpp",
  "timestamp": "2018-05-16 16:13:18.717446360",
  "profile": {
"time.clang-tidy.readability-function-size.wall": 1.0421266555786133e+00,
"time.clang-tidy.readability-function-size.user": 9.208840005421e-01,
"time.clang-tidy.readability-function-size.sys": 1.24188974e-01
  }
  }
```

There are two arguments that control profile storage:

* `-store-check-profile=`

  By default reports are printed in tabulated format to stderr. When this option
  is passed, these per-TU profiles are instead stored as JSON.
  If the prefix is not an absolute path, it is considered to be relative to the
  directory from where you have run :program:`clang-tidy`. All `.` and `..`
  patterns in the path are collapsed, and symlinks are resolved.

  Example:
  Let's suppose you have a source file named `example.cpp`, located in
  `/source` directory.

  * If you specify `-store-check-profile=/tmp`, then the profile will be saved
to `/tmp/-example.cpp.json`

  * If you run :program:`clang-tidy` from within `/foo` directory, and specify
`-store-check-profile=.`, then the profile will still be saved to
`/foo/-example.cpp.json`

Reviewers: alexfh, sbenza, george.karpenkov, NoQ, aaron.ballman

Reviewed By: alexfh, george.karpenkov, aaron.ballman

Subscribers: Quuxplusone, JonasToth, aaron.ballman, llvm-commits, rja, 
Eugene.Zelenko, xazax.hun, mgrang, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D46602

Added:

clang-tools-extra/trunk/test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/ClangTidyProfiling.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyProfiling.h
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst

clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp

clang-tools-extra/trunk/test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=334101&r1=334100&r2=334101&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Wed Jun  6 08:07:51 2018
@@ -363,7 +363,8 @@ ClangTidyASTConsumerFactory::CreateASTCo
 
   std::unique_ptr Profiling;
   if (Context.getEnableProfiling()) {
-Profiling = llvm::make_unique();
+Profiling = llvm::make_unique(
+Context.getProfileStorageParams());
 FinderOptions.CheckProfiling.emplace(Profiling->Records);
   }
 
@@ -492,7 +493,7 @@ void runClangTidy(clang::tidy::ClangTidy
   const CompilationDatabase &Compilations,
   ArrayRef InputFiles,
   llvm::IntrusiveRefCntPtr BaseFS,
-  bool EnableCheckProfile) {
+  bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
   ClangTool Tool(Compilations, InputFiles,
  std::make_shared(), BaseFS);
 
@@ -533,6 +534,7 @@ void runClangTidy(clang::tidy::ClangTidy
   Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
   Tool.appendArgumentsAdjuster(PluginArgumentsRemover);
   Context.setEnableProfiling(EnableCheckProfile);
+  Context.setProfileStoragePrefix(StoreCheckProfile);
 
   ClangTidyDiagnosticConsumer DiagConsumer(Context);
 

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=334101&r1=334100&r2=334101&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Wed Jun  6 08:07:51 2018
@@ -227,11 +227,15 @@ getCheckOptions(const ClangTidyOptions &
 ///
 /// \param EnableCheckProfile If provided, it enables check profile collection
 /// in MatchFinder, and will contain the result of the profile.
+/// \param StoreCheckProfile If provided, and EnableCheckProfile is true,
+/// the profile will not be o

r344230 - [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

2018-10-11 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 11 02:09:50 2018
New Revision: 344230

URL: http://llvm.org/viewvc/llvm-project?rev=344230&view=rev
Log:
[clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and 
signed checks

Summary:
As per IRC disscussion, it seems we really want to have more fine-grained 
`-fsanitize=implicit-integer-truncation`:
* A check when both of the types are unsigned.
* Another check for the other cases (either one of the types is signed, or both 
of the types is signed).

This is clang part.
Compiler-rt part is D50902.

Reviewers: rsmith, vsk, Sanitizers

Reviewed by: rsmith

Differential Revision: https://reviews.llvm.org/D50901

Added:

cfe/trunk/test/CodeGen/catch-implicit-signed-integer-truncations-basics-negatives.c
cfe/trunk/test/CodeGen/catch-implicit-signed-integer-truncations-basics.c
  - copied, changed from r344205, 
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c

cfe/trunk/test/CodeGen/catch-implicit-unsigned-integer-truncations-basics-negatives.c
cfe/trunk/test/CodeGen/catch-implicit-unsigned-integer-truncations-basics.c
  - copied, changed from r344205, 
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c
Modified:
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c
cfe/trunk/test/CodeGenCXX/catch-implicit-integer-truncations.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=344230&r1=344229&r2=344230&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Oct 11 02:09:50 2018
@@ -89,11 +89,16 @@ Available checks are:
   -  ``-fsanitize=function``: Indirect call of a function through a
  function pointer of the wrong type (Darwin/Linux, C++ and x86/x86_64
  only).
-  -  ``-fsanitize=implicit-integer-truncation``: Implicit conversion from
+  -  ``-fsanitize=implicit-unsigned-integer-truncation``,
+ ``-fsanitize=implicit-signed-integer-truncation``: Implicit conversion 
from
  integer of larger bit width to smaller bit width, if that results in data
  loss. That is, if the demoted value, after casting back to the original
  width, is not equal to the original value before the downcast.
- Issues caught by this sanitizer are not undefined behavior,
+ The ``-fsanitize=implicit-unsigned-integer-truncation`` handles 
conversions
+ between two ``unsigned`` types, while
+ ``-fsanitize=implicit-signed-integer-truncation`` handles the rest of the
+ conversions - when either one, or both of the types are signed.
+ Issues caught by these sanitizers are not undefined behavior,
  but are often unintentional.
   -  ``-fsanitize=integer-divide-by-zero``: Integer division by zero.
   -  ``-fsanitize=nonnull-attribute``: Passing null pointer as a function
@@ -160,6 +165,10 @@ You can also use the following check gro
  behavior (e.g. unsigned integer overflow).
  Enables ``signed-integer-overflow``, ``unsigned-integer-overflow``,
  ``shift``, ``integer-divide-by-zero``, and 
``implicit-integer-truncation``.
+  -  ``fsanitize=implicit-integer-truncation``: Checks for implicit integral
+ conversions that result in data loss.
+ Enables ``implicit-unsigned-integer-truncation`` and
+ ``implicit-signed-integer-truncation``.
   -  ``-fsanitize=implicit-conversion``: Checks for suspicious behaviours of
  implicit conversions.
  Currently, only ``-fsanitize=implicit-integer-truncation`` is implemented.

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=344230&r1=344229&r2=344230&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Oct 11 02:09:50 2018
@@ -135,7 +135,13 @@ SANITIZER_GROUP("undefined", Undefined,
 SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined)
 
 // ImplicitConversionSanitizer
-SANITIZER("implicit-integer-truncation", ImplicitIntegerTruncation)
+SANITIZER("implicit-unsigned-integer-truncation",
+  ImplicitUnsignedIntegerTruncation)
+SANITIZER("implicit-signed-integer-truncation", 
ImplicitSignedIntegerTruncation)
+SANITIZER_GROUP("implicit-integer-truncation", ImplicitIntegerTruncation,
+ImplicitUnsi

[clang-tools-extra] r344755 - [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

2018-10-18 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 18 13:06:40 2018
New Revision: 344755

URL: http://llvm.org/viewvc/llvm-project?rev=344755&view=rev
Log:
[clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT 
DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

Summary:
Detects when the integral literal or floating point (decimal or hexadecimal)
literal has non-uppercase suffix, and suggests to make the suffix uppercase,
with fix-it.

All valid combinations of suffixes are supported.

```
  auto x = 1;  // OK, no suffix.

  auto x = 1u; // warning: integer literal suffix 'u' is not upper-case

  auto x = 1U; // OK, suffix is uppercase.

  ...
```

References:
* [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 
| CERT DCL16-C ]]
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a 
literal suffix
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case

Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D52670

Added:

clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl16-c.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-uppercase-literal-suffix.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst

clang-tools-extra/trunk/test/clang-tidy/cert-uppercase-literal-suffix-integer.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-custom-list.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix.h
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=344755&r1=344754&r2=344755&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Thu Oct 18 
13:06:40 2018
@@ -16,6 +16,7 @@
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
 #include "../performance/MoveConstructorInitCheck.h"
+#include "../readability/UppercaseLiteralSuffixCheck.h"
 #include "CommandProcessorCheck.h"
 #include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
@@ -65,6 +66,8 @@ public:
 // C checkers
 // DCL
 CheckFactories.registerCheck("cert-dcl03-c");
+CheckFactories.registerCheck(
+"cert-dcl16-c");
 // ENV
 CheckFactories.registerCheck("cert-env33-c");
 // FLP
@@ -78,6 +81,13 @@ public:
 CheckFactories.registerCheck(
 "cert-msc32-c");
   }
+
+  ClangTidyOptions getModuleOptions() override {
+ClangTidyOptions Options;
+ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
+Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
+return Options;
+  }
 };
 
 } // namespace cert

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=344755&r1=344754&r2=344755&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Thu Oct 18 13:06:40 
2018
@@ -24,5 +24,6 @@ add_clang_library(clangTidyCERTModule
   clangTidyGoo

[clang-tools-extra] r344757 - [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

2018-10-18 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 18 13:16:44 2018
New Revision: 344757

URL: http://llvm.org/viewvc/llvm-project?rev=344757&view=rev
Log:
[clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, 
HICPP)

Summary:
Finds classes that not only contain the data (non-static member variables),
but also have logic (non-static member functions), and diagnoses all member
variables that have any other scope other than `private`. They should be
made `private`, and manipulated exclusively via the member functions.

Optionally, classes with all member variables being `public` could be
ignored, and optionally all `public` member variables could be ignored.

Options
---

* IgnoreClassesWithAllMemberVariablesBeingPublic

  Allows to completely ignore classes if **all** the member variables in that
  class have `public` visibility.

* IgnorePublicMemberVariables

  Allows to ignore (not diagnose) **all** the member variables with `public`
  visibility scope.

References:
* MISRA 11-0-1 Member data in non-POD class types shall be private.
* 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently
* 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rc-private
* 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-protected

Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, zinovy.nis, cfe-commits, rnkovacs, nemanjai, 
mgorny, xazax.hun, kbarton

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D52771

Added:

clang-tools-extra/trunk/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp

clang-tools-extra/trunk/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-non-private-member-variables-in-classes.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst

clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=344757&r1=344756&r2=344757&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Thu Oct 18 13:16:44 2018
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "../misc/NonPrivateMemberVariablesInClassesCheck.h"
 #include "../misc/UnconventionalAssignOperatorCheck.h"
 #include "../readability/MagicNumbersCheck.h"
 #include "AvoidGotoCheck.h"
@@ -47,6 +48,8 @@ public:
 CheckFactories.registerCheck(
 "cppcoreguidelines-narrowing-conversions");
 CheckFactories.registerCheck("cppcoreguidelines-no-malloc");
+
CheckFactories.registerCheck(
+"cppcoreguidelines-non-private-member-variables-in-classes");
 CheckFactories.registerCheck(
 "cppcoreguidelines-owning-memory");
 CheckFactories.registerCheck(
@@ -75,6 +78,16 @@ public:
 CheckFactories.registerCheck(
 "cppcoreguidelines-c-copy-assignment-signature");
   }
+
+  ClangTidyOptions getModuleOptions() override {
+ClangTidyOptions Options;
+ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
+
+Opts["cppcoreguidelines-non-private-member-variables-in-classes."
+ "IgnoreClassesWithAllMemberVariablesBeingPublic"] = "1";
+
+return Options;
+  }
 };
 
 // Register the LLVMTidyModule using this statically initialized variable.

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=344757&r1=344756&r2=344757&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Thu Oct 18 13:16:44 
2018
@@ -6,6 +6,7 @@ add_clang_library(clangTidyMiscModule
   MisplacedConstCheck.cpp
   NewDeleteOverloadsCheck.cpp
   NonCopyableObjects.cpp
+  NonPrivateMemberVariablesInClassesCheck.cpp
   RedundantExpressionCheck.cpp
   StaticAssertChec

[clang-tools-extra] r344758 - [clang-tidy] readability-uppercase-literal-suffix: specify target for fp tests

2018-10-18 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 18 13:27:10 2018
New Revision: 344758

URL: http://llvm.org/viewvc/llvm-project?rev=344758&view=rev
Log:
[clang-tidy] readability-uppercase-literal-suffix: specify target for fp tests

__float128 isn't universally avaliable.

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp?rev=344758&r1=344757&r2=344758&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
 Thu Oct 18 13:27:10 2018
@@ -1,7 +1,7 @@
-// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I 
%S
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- 
-target x86_64-pc-linux-gnu -I %S
 // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -I %S
-// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -I %S
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -target x86_64-pc-linux-gnu -I %S
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target 
x86_64-pc-linux-gnu -I %S
 
 #include "readability-uppercase-literal-suffix.h"
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp?rev=344758&r1=344757&r2=344758&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
 Thu Oct 18 13:27:10 2018
@@ -1,7 +1,7 @@
-// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I 
%S
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- 
-target x86_64-pc-linux-gnu -I %S
 // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -I %S
-// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -I %S
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -target x86_64-pc-linux-gnu -I %S
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target 
x86_64-pc-linux-gnu -I %S
 
 #include "readability-uppercase-literal-suffix.h"
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r344760 - [clang-tidy] readability-uppercase-literal-suffix: specify target for opencl test

2018-10-18 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 18 13:59:03 2018
New Revision: 344760

URL: http://llvm.org/viewvc/llvm-project?rev=344760&view=rev
Log:
[clang-tidy] readability-uppercase-literal-suffix: specify target for opencl 
test

I'm not sure if it will actually help or not.
ppc64be-clang-lnt-test bot is failing.

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp?rev=344760&r1=344759&r2=344760&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp
 Thu Oct 18 13:59:03 2018
@@ -1,7 +1,7 @@
-// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I 
%S -std=cl2.0 -x cl
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- 
-target x86_64-pc-linux-gnu -I %S -std=cl2.0 -x cl
 // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -I %S -std=cl2.0 -x cl
-// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -I %S 
-std=cl2.0 -x cl
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -target x86_64-pc-linux-gnu -I %S -std=cl2.0 -x cl
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target 
x86_64-pc-linux-gnu -I %S -std=cl2.0 -x cl
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r344772 - [clang-tidy] readability-uppercase-literal-suffix: specify target for ms test too

2018-10-18 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 18 23:04:07 2018
New Revision: 344772

URL: http://llvm.org/viewvc/llvm-project?rev=344772&view=rev
Log:
[clang-tidy] readability-uppercase-literal-suffix: specify target for ms test 
too

Apparently the bots were still failing with this.
Sadly, i did not see *this* failure when i last looked.

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp?rev=344772&r1=344771&r2=344772&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp
 Thu Oct 18 23:04:07 2018
@@ -1,7 +1,7 @@
-// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I 
%S -fms-extensions
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- 
-target x86_64-pc-linux-gnu -I %S -fms-extensions
 // RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -I %S -fms-extensions
-// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -I %S 
-fms-extensions
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -target x86_64-pc-linux-gnu -I %S -fms-extensions
+// RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target 
x86_64-pc-linux-gnu -I %S -fms-extensions
 
 #include "readability-uppercase-literal-suffix.h"
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r345305 - [clang-tidy] Revert my readability-uppercase-literal-suffix check.

2018-10-25 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 25 12:44:51 2018
New Revision: 345305

URL: http://llvm.org/viewvc/llvm-project?rev=345305&view=rev
Log:
[clang-tidy] Revert my readability-uppercase-literal-suffix check.

There are some lurking issues with the handling of the SourceManager.
Somehow sometimes we end up extracting completely wrong
portions of the source buffer.

Reverts r344772, r44760, r344758, r344755.

Removed:

clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl16-c.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-uppercase-literal-suffix.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst

clang-tools-extra/trunk/test/clang-tidy/cert-uppercase-literal-suffix-integer.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-custom-list.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix.h
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=345305&r1=345304&r2=345305&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Thu Oct 25 
12:44:51 2018
@@ -16,7 +16,6 @@
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
 #include "../performance/MoveConstructorInitCheck.h"
-#include "../readability/UppercaseLiteralSuffixCheck.h"
 #include "CommandProcessorCheck.h"
 #include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
@@ -66,8 +65,6 @@ public:
 // C checkers
 // DCL
 CheckFactories.registerCheck("cert-dcl03-c");
-CheckFactories.registerCheck(
-"cert-dcl16-c");
 // ENV
 CheckFactories.registerCheck("cert-env33-c");
 // FLP
@@ -81,13 +78,6 @@ public:
 CheckFactories.registerCheck(
 "cert-msc32-c");
   }
-
-  ClangTidyOptions getModuleOptions() override {
-ClangTidyOptions Options;
-ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
-Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
-return Options;
-  }
 };
 
 } // namespace cert

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=345305&r1=345304&r2=345305&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Thu Oct 25 12:44:51 
2018
@@ -24,6 +24,5 @@ add_clang_library(clangTidyCERTModule
   clangTidyGoogleModule
   clangTidyMiscModule
   clangTidyPerformanceModule
-  clangTidyReadabilityModule
   clangTidyUtils
   )

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp?rev=345305&r1=345304&r2=345305&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp Thu Oct 25 
12:44:51 2018
@@ -35,7 +35,6 @@
 #include "../readability/BracesAroundStatementsCheck.h"
 #include "../readability/FunctionSizeCheck.h"
 #include "../readability/IdentifierNamingChec

[clang-tools-extra] r345381 - [clang-tidy] Re-commit: Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

2018-10-26 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Oct 26 06:09:27 2018
New Revision: 345381

URL: http://llvm.org/viewvc/llvm-project?rev=345381&view=rev
Log:
[clang-tidy] Re-commit: Add new 'readability-uppercase-literal-suffix' check 
(CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

Summary:
Detects when the integral literal or floating point (decimal or hexadecimal)
literal has non-uppercase suffix, and suggests to make the suffix uppercase,
with fix-it.

All valid combinations of suffixes are supported.

```
  auto x = 1;  // OK, no suffix.

  auto x = 1u; // warning: integer literal suffix 'u' is not upper-case

  auto x = 1U; // OK, suffix is uppercase.

  ...
```

This is a re-commit, the original was reverted by me in
rL345305 due to discovered bugs. (implicit code, template instantiation)
Tests were added, and the bugs were fixed.
I'm unable to find any further bugs, hopefully there aren't any..

References:
* [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 
| CERT DCL16-C ]]
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a 
literal suffix
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case

Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D52670

Added:

clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl16-c.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-uppercase-literal-suffix.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst

clang-tools-extra/trunk/test/clang-tidy/cert-uppercase-literal-suffix-integer.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-custom-list.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix.h
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=345381&r1=345380&r2=345381&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Fri Oct 26 
06:09:27 2018
@@ -16,6 +16,7 @@
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
 #include "../performance/MoveConstructorInitCheck.h"
+#include "../readability/UppercaseLiteralSuffixCheck.h"
 #include "CommandProcessorCheck.h"
 #include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
@@ -65,6 +66,8 @@ public:
 // C checkers
 // DCL
 CheckFactories.registerCheck("cert-dcl03-c");
+CheckFactories.registerCheck(
+"cert-dcl16-c");
 // ENV
 CheckFactories.registerCheck("cert-env33-c");
 // FLP
@@ -78,6 +81,13 @@ public:
 CheckFactories.registerCheck(
 "cert-msc32-c");
   }
+
+  ClangTidyOptions getModuleOptions() override {
+ClangTidyOptions Options;
+ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
+Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
+return Options;
+  }
 };
 
 } // namespace cert

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=345381&r1=345380&r2=345381&view=diff
===

r345594 - [clang] Move two utility functions into SourceManager

2018-10-30 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Oct 30 05:37:16 2018
New Revision: 345594

URL: http://llvm.org/viewvc/llvm-project?rev=345594&view=rev
Log:
[clang] Move two utility functions into SourceManager

Summary: So we can keep that not-so-great logic in one place.

Reviewers: rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: nemanjai, kbarton, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D53837

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=345594&r1=345593&r2=345594&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Oct 30 05:37:16 2018
@@ -1428,6 +1428,18 @@ public:
 return getFileID(Loc) == getMainFileID();
   }
 
+  /// Returns whether \p Loc is located in a  file.
+  bool isWrittenInBuiltinFile(SourceLocation Loc) const {
+StringRef Filename(getPresumedLoc(Loc).getFilename());
+return Filename.equals("");
+  }
+
+  /// Returns whether \p Loc is located in a  file.
+  bool isWrittenInCommandLineFile(SourceLocation Loc) const {
+StringRef Filename(getPresumedLoc(Loc).getFilename());
+return Filename.equals("");
+  }
+
   /// Returns if a SourceLocation is in a system header.
   bool isInSystemHeader(SourceLocation Loc) const {
 return isSystem(getFileCharacteristic(Loc));

Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=345594&r1=345593&r2=345594&view=diff
==
--- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original)
+++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp Tue Oct 30 05:37:16 2018
@@ -88,16 +88,6 @@ SourceLocation MacroPPCallbacks::getCorr
   return SourceLocation();
 }
 
-static bool isBuiltinFile(SourceManager &SM, SourceLocation Loc) {
-  StringRef Filename(SM.getPresumedLoc(Loc).getFilename());
-  return Filename.equals("");
-}
-
-static bool isCommandLineFile(SourceManager &SM, SourceLocation Loc) {
-  StringRef Filename(SM.getPresumedLoc(Loc).getFilename());
-  return Filename.equals("");
-}
-
 void MacroPPCallbacks::updateStatusToNextScope() {
   switch (Status) {
   case NoScope:
@@ -127,7 +117,7 @@ void MacroPPCallbacks::FileEntered(Sourc
 updateStatusToNextScope();
 return;
   case BuiltinScope:
-if (isCommandLineFile(PP.getSourceManager(), Loc))
+if (PP.getSourceManager().isWrittenInCommandLineFile(Loc))
   return;
 updateStatusToNextScope();
 LLVM_FALLTHROUGH;
@@ -147,7 +137,7 @@ void MacroPPCallbacks::FileExited(Source
   default:
 llvm_unreachable("Do not expect to exit a file from current scope");
   case BuiltinScope:
-if (!isBuiltinFile(PP.getSourceManager(), Loc))
+if (!PP.getSourceManager().isWrittenInBuiltinFile(Loc))
   // Skip next scope and change status to MainFileScope.
   Status = MainFileScope;
 return;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r345610 - [clang-tidy] cppcoreguidelines-macro-usage: print macro names

2018-10-30 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Oct 30 08:52:36 2018
New Revision: 345610

URL: http://llvm.org/viewvc/llvm-project?rev=345610&view=rev
Log:
[clang-tidy] cppcoreguidelines-macro-usage: print macro names

Summary:
The macro may not have location (or more generally, the location may not exist),
e.g. if it originates from compiler's command-line.

The check complains on all the macros, even those without the location info.
Which means, it only says it does not like it. What is 'it'? I have no idea.
If we don't print the name, then there is no way to deal with that situation.

And in general, not printing name here forces the user to try to understand,
given, the macro definition location, what is the macro name?
This isn't fun.

Also, ignores-by-default the macros originating from command-line,
with an option to not ignore those.

I suspect some more issues may crop up later.

Reviewers: JonasToth, aaron.ballman, hokein, xazax.hun, alexfh

Reviewed By: JonasToth, aaron.ballman

Subscribers: nemanjai, kbarton, rnkovacs, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D53817

Added:

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-macro-usage-command-line-macros.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/MacroUsageCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-macro-usage-caps-only.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-macro-usage-custom.cpp
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-macro-usage.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp?rev=345610&r1=345609&r2=345610&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp 
Tue Oct 30 08:52:36 2018
@@ -31,32 +31,41 @@ bool isCapsOnly(StringRef Name) {
 
 class MacroUsageCallbacks : public PPCallbacks {
 public:
-  MacroUsageCallbacks(MacroUsageCheck *Check, StringRef RegExp, bool CapsOnly)
-  : Check(Check), RegExp(RegExp), CheckCapsOnly(CapsOnly) {}
+  MacroUsageCallbacks(MacroUsageCheck *Check, const SourceManager &SM,
+  StringRef RegExp, bool CapsOnly, bool IgnoreCommandLine)
+  : Check(Check), SM(SM), RegExp(RegExp), CheckCapsOnly(CapsOnly),
+IgnoreCommandLineMacros(IgnoreCommandLine) {}
   void MacroDefined(const Token &MacroNameTok,
 const MacroDirective *MD) override {
 if (MD->getMacroInfo()->isUsedForHeaderGuard() ||
 MD->getMacroInfo()->getNumTokens() == 0)
   return;
 
+if (IgnoreCommandLineMacros &&
+SM.isWrittenInCommandLineFile(MD->getLocation()))
+  return;
+
 StringRef MacroName = MacroNameTok.getIdentifierInfo()->getName();
 if (!CheckCapsOnly && !llvm::Regex(RegExp).match(MacroName))
-  Check->warnMacro(MD);
+  Check->warnMacro(MD, MacroName);
 
 if (CheckCapsOnly && !isCapsOnly(MacroName))
-  Check->warnNaming(MD);
+  Check->warnNaming(MD, MacroName);
   }
 
 private:
   MacroUsageCheck *Check;
+  const SourceManager &SM;
   StringRef RegExp;
   bool CheckCapsOnly;
+  bool IgnoreCommandLineMacros;
 };
 } // namespace
 
 void MacroUsageCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "AllowedRegexp", AllowedRegexp);
   Options.store(Opts, "CheckCapsOnly", CheckCapsOnly);
+  Options.store(Opts, "IgnoreCommandLineMacros", IgnoreCommandLineMacros);
 }
 
 void MacroUsageCheck::registerPPCallbacks(CompilerInstance &Compiler) {
@@ -64,31 +73,34 @@ void MacroUsageCheck::registerPPCallback
 return;
 
   Compiler.getPreprocessor().addPPCallbacks(
-  llvm::make_unique(this, AllowedRegexp,
- CheckCapsOnly));
+  llvm::make_unique(this, Compiler.getSourceManager(),
+ AllowedRegexp, CheckCapsOnly,
+ IgnoreCommandLineMacros));
 }
 
-void MacroUsageCheck::warnMacro(const MacroDirective *MD) {
+void MacroUsageCheck::warnMacro(const MacroDirective *MD, StringRef MacroName) 
{
   StringRef Message =
-  "macro used to declare a constant; consider using a 'constexpr' "
+  "macro '%0' used to declare a constant; consider using a 'constexpr' "
   "constant";
 
   /// A variadic macro is function-like at the same time. Therefore variadic
   /// macros are checked first and will be excluded for the function-like
   /// diagnostic.
   if (MD->getMacroInfo()->isVariadic())
-Message = "variadic macro used; con

r345660 - [clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang part

2018-10-30 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Oct 30 14:58:56 2018
New Revision: 345660

URL: http://llvm.org/viewvc/llvm-project?rev=345660&view=rev
Log:
[clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang part

This is the second half of Implicit Integer Conversion Sanitizer.
It completes the first half, and finally makes the sanitizer
fully functional! Only the bitfield handling is missing.

Summary:
C and C++ are interesting languages. They are statically typed, but weakly.
The implicit conversions are allowed. This is nice, allows to write code
while balancing between getting drowned in everything being convertible,
and nothing being convertible. As usual, this comes with a price:

```
void consume(unsigned int val);

void test(int val) {
  consume(val);
  // The 'val' is `signed int`, but `consume()` takes `unsigned int`.
  // If val is negative, then consume() will be operating on a large
  // unsigned value, and you may or may not have a bug.

  // But yes, sometimes this is intentional.
  // Making the conversion explicit silences the sanitizer.
  consume((unsigned int)val);
}
```

Yes, there is a `-Wsign-conversion`` diagnostic group, but first, it is kinda
noisy, since it warns on everything (unlike sanitizers, warning on an
actual issues), and second, likely there are cases where it does **not** warn.

The actual detection is pretty easy. We just need to check each of the values
whether it is negative, and equality-compare the results of those comparisons.
The unsigned value is obviously non-negative. Zero is non-negative too.
https://godbolt.org/g/w93oj2

We do not have to emit the check *always*, there are obvious situations
where we can avoid emitting it, since it would **always** get optimized-out.
But i do think the tautological IR (`icmp ult %x, 0`, which is always false)
should be emitted, and the middle-end should cleanup it.

This sanitizer is in the `-fsanitize=implicit-conversion` group,
and is a logical continuation of D48958 
`-fsanitize=implicit-integer-truncation`.
As for the ordering, i'we opted to emit the check **after**
`-fsanitize=implicit-integer-truncation`. At least on these simple 16 test 
cases,
this results in 1 of the 12 emitted checks being optimized away,
as compared to 0 checks being optimized away if the order is reversed.

This is a clang part.
The compiler-rt part is D50251.

Finishes fixing [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], [[ 
https://bugs.llvm.org/show_bug.cgi?id=37552 | PR37552 ]], [[ 
https://bugs.llvm.org/show_bug.cgi?id=35409 | PR35409 ]].
Finishes partially fixing [[ https://bugs.llvm.org/show_bug.cgi?id=9821 | 
PR9821 ]].
Finishes fixing https://github.com/google/sanitizers/issues/940.

Only the bitfield handling is missing.

Reviewers: vsk, rsmith, rjmccall, #sanitizers, erichkeane

Reviewed By: rsmith

Subscribers: chandlerc, filcab, cfe-commits, regehr

Tags: #sanitizers, #clang

Differential Revision: https://reviews.llvm.org/D50250

Added:
cfe/trunk/test/CodeGen/catch-implicit-conversions-basics.c
  - copied, changed from r345649, 
cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c

cfe/trunk/test/CodeGen/catch-implicit-integer-arithmetic-value-change-basics.c
  - copied, changed from r345649, 
cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c
cfe/trunk/test/CodeGen/catch-implicit-integer-sign-changes-basics.c
cfe/trunk/test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c
cfe/trunk/test/CodeGen/catch-implicit-integer-sign-changes.c

cfe/trunk/test/CodeGen/catch-implicit-signed-integer-truncation-or-sign-change.c

cfe/trunk/test/CodeGenCXX/catch-implicit-integer-sign-changes-true-negatives.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=345660&r1=345659&r2=345660&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Oct 30 14:58:56 2018
@@ -198,6 +198,29 @@ Static Analyzer
 Undefined Behavior Sanitizer (UBSan)
 
 
+* The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) group
+  was extended. One more type of issues is caught - implicit integer sign 
change.
+  (``-fsanitize=implicit-integer-sign-change``).
+  This makes the Implicit Conversion Sanitizer feature-complete,
+  with only missing piece being bitfield handling.
+  While there is a ``-Wsign-conversion`` diagnostic group that catches this 
kind
+  of issues, it is both noisy, and does not catch **all** the cases.
+
+  .. code-block:: c++
+

r351105 - [clang][UBSan] Sanitization for alignment assumptions.

2019-01-14 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Jan 14 11:09:27 2019
New Revision: 351105

URL: http://llvm.org/viewvc/llvm-project?rev=351105&view=rev
Log:
[clang][UBSan] Sanitization for alignment assumptions.

Summary:
UB isn't nice. It's cool and powerful, but not nice.
Having a way to detect it is nice though.
[[ https://wg21.link/p1007r3 | P1007R3: std::assume_aligned ]] / 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1007r2.pdf says:
```
We propose to add this functionality via a library function instead of a core 
language attribute.
...
If the pointer passed in is not aligned to at least N bytes, calling 
assume_aligned results in undefined behaviour.
```

This differential teaches clang to sanitize all the various variants of this 
assume-aligned attribute.

Requires D54588 for LLVM IRBuilder changes.
The compiler-rt part is D54590.

Reviewers: ABataev, craig.topper, vsk, rsmith, rnk, #sanitizers, erichkeane, 
filcab, rjmccall

Reviewed By: rjmccall

Subscribers: chandlerc, ldionne, EricWF, mclow.lists, cfe-commits, bkramer

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D54589

Added:

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
cfe/trunk/test/CodeGen/catch-alignment-assumption-blacklist.c

cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
cfe/trunk/test/CodeGen/catch-alignment-assumption-openmp.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=351105&r1=351104&r2=351105&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Jan 14 11:09:27 2019
@@ -321,6 +321,49 @@ Undefined Behavior Sanitizer (UBSan)
 * The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) has
   learned to sanitize compound assignment operators.
 
+* ``alignment`` check has learned to sanitize the assume_aligned-like 
attributes:
+
+  .. code-block:: c++
+
+  typedef char **__attribute__((align_value(1024))) aligned_char;
+  struct ac_struct {
+aligned_char a;
+  };
+  char **load_from_ac_struct(struct ac_struct *x) {
+return x->a; // <- check that loaded 'a' is aligned
+  }
+
+  char **passthrough(__attribute__((align_value(1024))) char **x) {
+return x; // <- check the pointer passed as function argument
+  }
+
+  char **__attribute__((alloc_align(2)))
+  alloc_align(int size, unsigned long alignment);
+
+  char **caller(int size) {
+return alloc_align(size, 1024); // <- check returned pointer
+  }
+
+  char **__attribute__((assume_aligned(1024))) get_ptr();
+
+  char **caller2() {
+return get_ptr(); // <- check returned pointer
+  }
+
+  void *caller3(char **x) {
+return __builtin_assume_aligned(x, 1024);  // <- check returned pointer
+  }
+
+  void *caller4(char **x, unsigned long offset) {
+return __builtin_assume_aligned(x, 1024, offset);  // <- check 
returned pointer accounting for the offest
+  }
+
+  void process(char *data, int width) {
+  #pragma omp for simd aligned(data : 1024) // <- aligned clause will 
be checked.
+  for (int x = 0; x < width; x++)
+  data[x] *= data[x];
+  }
+
 Core Analysis Improvements
 ==
 

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=351105&r1=351104&r2=351105&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Jan 14 11:09:27 2019
@@ -72,7 +72,7 @@ Available checks
 Available checks are:
 
   -  ``-fsanitize=alignment``: U

Re: r351159 - Revert alignment assumptions changes

2019-01-14 Thread Roman Lebedev via cfe-commits
Thank you for the revert.

On Tue, Jan 15, 2019 at 6:41 AM Vlad Tsyrklevich via cfe-commits
 wrote:
>
> Author: vlad.tsyrklevich
> Date: Mon Jan 14 19:38:02 2019
> New Revision: 351159
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351159&view=rev
> Log:
> Revert alignment assumptions changes
>
> Revert r351104-6, r351109, r351110, r351119, r351134, and r351153. These
> changes fail on the sanitizer bots.
>
> Removed:
> 
> cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
> 
> cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
> 
> cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
> 
> cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
> 
> cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
> 
> cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
> cfe/trunk/test/CodeGen/catch-alignment-assumption-blacklist.c
> 
> cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
> 
> cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
> 
> cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
> cfe/trunk/test/CodeGen/catch-alignment-assumption-openmp.cpp
> Modified:
> cfe/trunk/docs/ReleaseNotes.rst
> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/CodeGen/CGCall.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
>
> Modified: cfe/trunk/docs/ReleaseNotes.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=351159&r1=351158&r2=351159&view=diff
> ==
> --- cfe/trunk/docs/ReleaseNotes.rst (original)
> +++ cfe/trunk/docs/ReleaseNotes.rst Mon Jan 14 19:38:02 2019
> @@ -321,49 +321,6 @@ Undefined Behavior Sanitizer (UBSan)
>  * The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) has
>learned to sanitize compound assignment operators.
>
> -* ``alignment`` check has learned to sanitize the assume_aligned-like 
> attributes:
> -
> -  .. code-block:: c++
> -
> -  typedef char **__attribute__((align_value(1024))) aligned_char;
> -  struct ac_struct {
> -aligned_char a;
> -  };
> -  char **load_from_ac_struct(struct ac_struct *x) {
> -return x->a; // <- check that loaded 'a' is aligned
> -  }
> -
> -  char **passthrough(__attribute__((align_value(1024))) char **x) {
> -return x; // <- check the pointer passed as function argument
> -  }
> -
> -  char **__attribute__((alloc_align(2)))
> -  alloc_align(int size, unsigned long alignment);
> -
> -  char **caller(int size) {
> -return alloc_align(size, 1024); // <- check returned pointer
> -  }
> -
> -  char **__attribute__((assume_aligned(1024))) get_ptr();
> -
> -  char **caller2() {
> -return get_ptr(); // <- check returned pointer
> -  }
> -
> -  void *caller3(char **x) {
> -return __builtin_assume_aligned(x, 1024);  // <- check returned 
> pointer
> -  }
> -
> -  void *caller4(char **x, unsigned long offset) {
> -return __builtin_assume_aligned(x, 1024, offset);  // <- check 
> returned pointer accounting for the offest
> -  }
> -
> -  void process(char *data, int width) {
> -  #pragma omp for simd aligned(data : 1024) // <- aligned clause 
> will be checked.
> -  for (int x = 0; x < width; x++)
> -  data[x] *= data[x];
> -  }
> -
>  Core Analysis Improvements
>  ==
>
>
> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=351159&r1=351158&r2=351159&view=diff
> ==
> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Jan 14 19:38:02 2019
> @@ -72,7 +72,7 @@ Available checks
>  Available checks are:
>
>-  ``-fsanitize=alignment``: Use of a misaligned pointer or creation
> - of a misaligned reference. Also sanitizes assume_aligned-like 
> attributes.
> + of a misaligned reference.
>-  ``-fsanitize=bool``: Load of a ``bool`` value which is neither
>   ``true`` nor ``false``.
>-  ``-fsanitize=builtin``: Passing invalid values to compiler builtins.
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=351159&r1=351158&r2=351159&view

r351177 - [clang][UBSan] Sanitization for alignment assumptions.

2019-01-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Jan 15 01:44:25 2019
New Revision: 351177

URL: http://llvm.org/viewvc/llvm-project?rev=351177&view=rev
Log:
[clang][UBSan] Sanitization for alignment assumptions.

Summary:
UB isn't nice. It's cool and powerful, but not nice.
Having a way to detect it is nice though.
[[ https://wg21.link/p1007r3 | P1007R3: std::assume_aligned ]] / 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1007r2.pdf says:
```
We propose to add this functionality via a library function instead of a core 
language attribute.
...
If the pointer passed in is not aligned to at least N bytes, calling 
assume_aligned results in undefined behaviour.
```

This differential teaches clang to sanitize all the various variants of this 
assume-aligned attribute.

Requires D54588 for LLVM IRBuilder changes.
The compiler-rt part is D54590.

This is a second commit, the original one was r351105,
which was mass-reverted in r351159 because 2 compiler-rt tests were failing.

Reviewers: ABataev, craig.topper, vsk, rsmith, rnk, #sanitizers, erichkeane, 
filcab, rjmccall

Reviewed By: rjmccall

Subscribers: chandlerc, ldionne, EricWF, mclow.lists, cfe-commits, bkramer

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D54589

Added:

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
cfe/trunk/test/CodeGen/catch-alignment-assumption-blacklist.c

cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp

cfe/trunk/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
cfe/trunk/test/CodeGen/catch-alignment-assumption-openmp.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=351177&r1=351176&r2=351177&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Jan 15 01:44:25 2019
@@ -321,6 +321,49 @@ Undefined Behavior Sanitizer (UBSan)
 * The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) has
   learned to sanitize compound assignment operators.
 
+* ``alignment`` check has learned to sanitize the assume_aligned-like 
attributes:
+
+  .. code-block:: c++
+
+  typedef char **__attribute__((align_value(1024))) aligned_char;
+  struct ac_struct {
+aligned_char a;
+  };
+  char **load_from_ac_struct(struct ac_struct *x) {
+return x->a; // <- check that loaded 'a' is aligned
+  }
+
+  char **passthrough(__attribute__((align_value(1024))) char **x) {
+return x; // <- check the pointer passed as function argument
+  }
+
+  char **__attribute__((alloc_align(2)))
+  alloc_align(int size, unsigned long alignment);
+
+  char **caller(int size) {
+return alloc_align(size, 1024); // <- check returned pointer
+  }
+
+  char **__attribute__((assume_aligned(1024))) get_ptr();
+
+  char **caller2() {
+return get_ptr(); // <- check returned pointer
+  }
+
+  void *caller3(char **x) {
+return __builtin_assume_aligned(x, 1024);  // <- check returned pointer
+  }
+
+  void *caller4(char **x, unsigned long offset) {
+return __builtin_assume_aligned(x, 1024, offset);  // <- check 
returned pointer accounting for the offest
+  }
+
+  void process(char *data, int width) {
+  #pragma omp for simd aligned(data : 1024) // <- aligned clause will 
be checked.
+  for (int x = 0; x < width; x++)
+  data[x] *= data[x];
+  }
+
 Core Analysis Improvements
 ==
 

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=351177&r1=351176&r2=351177&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehavio

r351188 - [OpenCL] opencl-c.h: read_image*(): sampler-less, and image{1, 2}d_array_t variants are OpenCL-1.2+, mark them as such

2019-01-15 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Jan 15 03:20:02 2019
New Revision: 351188

URL: http://llvm.org/viewvc/llvm-project?rev=351188&view=rev
Log:
[OpenCL] opencl-c.h: read_image*(): sampler-less, and image{1,2}d_array_t 
variants are OpenCL-1.2+, mark them as such

Summary:
Refer to [[ 
https://www.khronos.org/registry/OpenCL/specs/opencl-1.1.pdf#page=242 | 
`6.11.13.2 Built-in Image Functions` ]],
and [[ https://www.khronos.org/registry/OpenCL/specs/opencl-1.1.pdf#page=306 | 
`9.6.8 Image Read and Write Functions` ]] of the OpenCL 1.1 spec.

* There is no mention of `image1d_array_t` and `image2d_array_t` anywhere in 
the OpenCL 1.1 spec.
* All the `read_image{f,i,ui,h}()` functions, as of OpenCL 1.1 spec, have a 
second required parameter `sampler_t sampler`

Should have prevented the following regression:
https://redmine.darktable.org/issues/12493

Reviewers: yaxunl, Anastasia, echuraev, asavonic

Reviewed By: Anastasia

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D56646

Modified:
cfe/trunk/lib/Headers/opencl-c.h

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=351188&r1=351187&r2=351188&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Tue Jan 15 03:20:02 2019
@@ -14610,6 +14610,7 @@ int4 __purefn __ovld read_imagei(read_on
 uint4 __purefn __ovld read_imageui(read_only image3d_t image, sampler_t 
sampler, int4 coord);
 uint4 __purefn __ovld read_imageui(read_only image3d_t image, sampler_t 
sampler, float4 coord);
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 float4 __purefn __ovld read_imagef(read_only image2d_array_t image_array, 
sampler_t sampler, int4 coord);
 float4 __purefn __ovld read_imagef(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord);
 
@@ -14617,6 +14618,7 @@ int4 __purefn __ovld read_imagei(read_on
 int4 __purefn __ovld read_imagei(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord);
 uint4 __purefn __ovld read_imageui(read_only image2d_array_t image_array, 
sampler_t sampler, int4 coord);
 uint4 __purefn __ovld read_imageui(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord);
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 
 float4 __purefn __ovld read_imagef(read_only image1d_t image, sampler_t 
sampler, int coord);
 float4 __purefn __ovld read_imagef(read_only image1d_t image, sampler_t 
sampler, float coord);
@@ -14626,6 +14628,7 @@ int4 __purefn __ovld read_imagei(read_on
 uint4 __purefn __ovld read_imageui(read_only image1d_t image, sampler_t 
sampler, int coord);
 uint4 __purefn __ovld read_imageui(read_only image1d_t image, sampler_t 
sampler, float coord);
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 float4 __purefn __ovld read_imagef(read_only image1d_array_t image_array, 
sampler_t sampler, int2 coord);
 float4 __purefn __ovld read_imagef(read_only image1d_array_t image_array, 
sampler_t sampler, float2 coord);
 
@@ -14633,6 +14636,7 @@ int4 __purefn __ovld read_imagei(read_on
 int4 __purefn __ovld read_imagei(read_only image1d_array_t image_array, 
sampler_t sampler, float2 coord);
 uint4 __purefn __ovld read_imageui(read_only image1d_array_t image_array, 
sampler_t sampler, int2 coord);
 uint4 __purefn __ovld read_imageui(read_only image1d_array_t image_array, 
sampler_t sampler, float2 coord);
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 
 #ifdef cl_khr_depth_images
 float __purefn __ovld read_imagef(read_only image2d_depth_t image, sampler_t 
sampler, float2 coord);
@@ -14735,6 +14739,8 @@ uint4 __purefn __ovld read_imageui(read_
 #endif //cl_khr_mipmap_image
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+
 /**
 * Sampler-less Image Access
 */
@@ -14768,24 +14774,31 @@ float4 __purefn __ovld read_imagef(read_
 int4 __purefn __ovld read_imagei(read_only image3d_t image, int4 coord);
 uint4 __purefn __ovld read_imageui(read_only image3d_t image, int4 coord);
 
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+
 // Image read functions returning half4 type
 #ifdef cl_khr_fp16
 half4 __purefn __ovld read_imageh(read_only image1d_t image, sampler_t 
sampler, int coord);
 half4 __purefn __ovld read_imageh(read_only image1d_t image, sampler_t 
sampler, float coord);
-half4 __purefn __ovld read_imageh(read_only image1d_array_t image, sampler_t 
sampler, int2 coord);
-half4 __purefn __ovld read_imageh(read_only image1d_array_t image, sampler_t 
sampler, float2 coord);
 half4 __purefn __ovld read_imageh(read_only image2d_t image, sampler_t 
sampler, int2 coord);
 half4 __purefn __ovld read_imageh(read_only image2d_t image, sampler_t 
sampler, float2 coord);
 half4 __purefn __ovld read_imageh(read_only image3d_t image, sampler_t 
sampler, int4 coord);
 half4 __purefn __ovld read_imageh(read_only image3d_t image, sampler_t 

Re: [PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

2019-01-17 Thread Roman Lebedev via cfe-commits
Please also note that "safe" functions are C11 Annex K, and it is Optional.
I believe glibc does not implement it, and has no intention of implementing it.
By memory, i'm not sure any library other than Microsoft's does provide it.

On Thu, Jan 17, 2019 at 9:17 PM Kristóf Umann via Phabricator
 wrote:
>
> Szelethus requested changes to this revision.
> Szelethus added a comment.
> This revision now requires changes to proceed.
>
> In D35068#811436 , @NoQ wrote:
>
> > I wonder how noisy this check is - did you test it on large codebases? 
> > Because these functions are popular, and in many cases it'd be fine to use 
> > insecure functions, i wonder if it's worth it to have this check on by 
> > default. Like, if it's relatively quiet - it's fine, but if it'd constitute 
> > 90% of the analyzer's warnings on popular projects, that'd probably not be 
> > fine.
>
>
>
>
> In D35068#1049530 , 
> @george.karpenkov wrote:
>
> > @koldaniel Have you evaluated this checker? On which codebases? Were the 
> > warnings real security issues, or were they mostly spurious? The code seems 
> > fine, but I'm not sure whether it should be in `security` or in `alpha`.
>
>
> Sorry, didn't read the discussion, there are some fair points in the quoted 
> comments.
>
> In D35068#1069880 , @koldaniel wrote:
>
> > I've evaluated this checker on LLVM+Clang, there were only a few (about 15) 
> > warnings,  because of the C11 flag check at the beginning of the checker 
> > body. However, if this check was removed, number of the warnings would be 
> > increased significantly. I wouldn't say the findings were real security 
> > issues, most of the warnings were about usages of deprecated functions, 
> > which has not been considered unsecure (but which may cause problems if the 
> > code is modified in an improper way in the future).
>
>
> My problem is that LLVM+Clang isn't really a C (neither a C11) project, and I 
> think judging this checker on it is a little misleading. Could you please 
> test it on some C11 projects? I think tmux uses C11.
>
> In D35068#1361195 , @xazax.hun wrote:
>
> > I think this is quiet coding guideline specific check which is useful for a 
> > set of  security critical projects. As this is an opt in kind of check, I 
> > think it does no harm to have it upstream.
>
>
> I do generally agree with this statement, but I'd be more comfortable either 
> landing it in alpha or seeing some other results.
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D35068/new/
>
> https://reviews.llvm.org/D35068
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r352090 - [NFC][clang] Test updates for CreateAlignmentAssumption() changes in D54653

2019-01-24 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Jan 24 11:32:49 2019
New Revision: 352090

URL: http://llvm.org/viewvc/llvm-project?rev=352090&view=rev
Log:
[NFC][clang] Test updates for CreateAlignmentAssumption() changes in D54653

Differential Revision: https://reviews.llvm.org/D57175

Modified:
cfe/trunk/test/CodeGen/alloc-align-attr.c

cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp

Modified: cfe/trunk/test/CodeGen/alloc-align-attr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alloc-align-attr.c?rev=352090&r1=352089&r2=352090&view=diff
==
--- cfe/trunk/test/CodeGen/alloc-align-attr.c (original)
+++ cfe/trunk/test/CodeGen/alloc-align-attr.c Thu Jan 24 11:32:49 2019
@@ -6,11 +6,9 @@ __INT32_TYPE__*m1(__INT32_TYPE__ i) __at
 __INT32_TYPE__ test1(__INT32_TYPE__ a) {
 // CHECK: define i32 @test1
   return *m1(a);
-// CHECK: call i32* @m1(i32 [[PARAM1:%[^\)]+]]) 
-// CHECK: [[ALIGNCAST1:%.+]] = sext i32 [[PARAM1]] to i64
-// CHECK: [[ISPOS1:%.+]] = icmp sgt i64 [[ALIGNCAST1]], 0
-// CHECK: [[POSMASK1:%.+]] = sub i64 [[ALIGNCAST1]], 1
-// CHECK: [[MASK1:%.+]] = select i1 [[ISPOS1]], i64 [[POSMASK1]], i64 0
+// CHECK: call i32* @m1(i32 [[PARAM1:%[^\)]+]])
+// CHECK: [[ALIGNCAST1:%.+]] = zext i32 [[PARAM1]] to i64
+// CHECK: [[MASK1:%.+]] = sub i64 [[ALIGNCAST1]], 1
 // CHECK: [[PTRINT1:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], [[MASK1]]
 // CHECK: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
@@ -22,10 +20,8 @@ __INT32_TYPE__ test2(__SIZE_TYPE__ a) {
   return *m1(a);
 // CHECK: [[CONV2:%.+]] = trunc i64 %{{.+}} to i32
 // CHECK: call i32* @m1(i32 [[CONV2]])
-// CHECK: [[ALIGNCAST2:%.+]] = sext i32 [[CONV2]] to i64
-// CHECK: [[ISPOS2:%.+]] = icmp sgt i64 [[ALIGNCAST2]], 0
-// CHECK: [[POSMASK2:%.+]] = sub i64 [[ALIGNCAST2]], 1
-// CHECK: [[MASK2:%.+]] = select i1 [[ISPOS2]], i64 [[POSMASK2]], i64 0
+// CHECK: [[ALIGNCAST2:%.+]] = zext i32 [[CONV2]] to i64
+// CHECK: [[MASK2:%.+]] = sub i64 [[ALIGNCAST2]], 1
 // CHECK: [[PTRINT2:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR2:%.+]] = and i64 [[PTRINT2]], [[MASK2]]
 // CHECK: [[MASKCOND2:%.+]] = icmp eq i64 [[MASKEDPTR2]], 0
@@ -39,9 +35,7 @@ __INT32_TYPE__ test3(__INT32_TYPE__ a) {
   return *m2(a);
 // CHECK: [[CONV3:%.+]] = sext i32 %{{.+}} to i64
 // CHECK: call i32* @m2(i64 [[CONV3]])
-// CHECK: [[ISPOS3:%.+]] = icmp sgt i64 [[CONV3]], 0
-// CHECK: [[POSMASK3:%.+]] = sub i64 [[CONV3]], 1
-// CHECK: [[MASK3:%.+]] = select i1 [[ISPOS3]], i64 [[POSMASK3]], i64 0
+// CHECK: [[MASK3:%.+]] = sub i64 [[CONV3]], 1
 // CHECK: [[PTRINT3:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR3:%.+]] = and i64 [[PTRINT3]], [[MASK3]]
 // CHECK: [[MASKCOND3:%.+]] = icmp eq i64 [[MASKEDPTR3]], 0
@@ -52,10 +46,8 @@ __INT32_TYPE__ test3(__INT32_TYPE__ a) {
 __INT32_TYPE__ test4(__SIZE_TYPE__ a) {
 // CHECK: define i32 @test4
   return *m2(a);
-// CHECK: call i32* @m2(i64 [[PARAM4:%[^\)]+]]) 
-// CHECK: [[ISPOS4:%.+]] = icmp sgt i64 [[PARAM4]], 0
-// CHECK: [[POSMASK4:%.+]] = sub i64 [[PARAM4]], 1
-// CHECK: [[MASK4:%.+]] = select i1 [[ISPOS4]], i64 [[POSMASK4]], i64 0
+// CHECK: call i32* @m2(i64 [[PARAM4:%[^\)]+]])
+// CHECK: [[MASK4:%.+]] = sub i64 [[PARAM4]], 1
 // CHECK: [[PTRINT4:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR4:%.+]] = and i64 [[PTRINT4]], [[MASK4]]
 // CHECK: [[MASKCOND4:%.+]] = icmp eq i64 [[MASKEDPTR4]], 0
@@ -72,11 +64,9 @@ __INT32_TYPE__ test5(__int128_t a) {
 // CHECK: define i32 @test5
   struct Empty e;
   return *m3(e, a);
-// CHECK: call i32* @m3(i64 %{{.*}}, i64 %{{.*}}) 
+// CHECK: call i32* @m3(i64 %{{.*}}, i64 %{{.*}})
 // CHECK: [[ALIGNCAST5:%.+]] = trunc i128 %{{.*}} to i64
-// CHECK: [[ISPOS5:%.+]] = icmp sgt i64 [[ALIGNCAST5]], 0
-// CHECK: [[POSMASK5:%.+]] = sub i64 [[ALIGNCAST5]], 1
-// CHECK: [[MASK5:%.+]] = select i1 [[ISPOS5]], i64 [[POSMASK5]], i64 0
+// CHECK: [[MASK5:%.+]] = sub i64 [[ALIGNCAST5]], 1
 // CHECK: [[PTRINT5:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR5:%.+]] = and i64 [[PTRINT5]], [[MASK5]]
 // CHECK: [[MASKCOND5:%.+]] = icmp eq i64 [[MASKEDPTR5]], 0
@@ -88,11 +78,9 @@ __INT32_TYPE__ test6(__int128_t a) {
 // CHECK: define i32 @test6
   struct MultiArgs e;
   return *m4(e, a);
-// CHECK: call i32* @m4(i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}) 
+// CHECK: call i32* @m4(i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
 // CHECK: [[ALIGNCAST6:%.+]] = trunc i128 %{{.*}} to i64
-// CHECK: [[ISPOS6:%.+]] = icmp sgt i64 [[ALIGNCAST6]], 0
-// CHECK: [[POSMASK6:%.+]] = sub i64 [[ALIGNCAST6]], 1
-// CHECK: [[MASK6:%.+]] = select i1 [[ISPOS6]], i64 [[POSMASK6]], i64 0
+// CHECK: [[MASK6:%.+]] = sub i64 [[ALIGNCAST6]], 1
 // CHECK: [[PTRINT6:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR6:%.+]] = and i64 [[PTRINT6]], [[MASK6]]
 // CHECK: [[MASKCOND6:%.+]] = icmp eq i64 [[MASKEDPTR6]], 0

Modified: 
cfe/trunk/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
URL: 
http://llvm.or

[clang-tools-extra] r352224 - Temporairly disable readability-uppercase-literal-suffix tests that depend on _Float16, to get bots back to green

2019-01-25 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Jan 25 10:05:43 2019
New Revision: 352224

URL: http://llvm.org/viewvc/llvm-project?rev=352224&view=rev
Log:
Temporairly disable readability-uppercase-literal-suffix tests that depend on 
_Float16, to get bots back to green

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp?rev=352224&r1=352223&r2=352224&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
 Fri Jan 25 10:05:43 2019
@@ -3,6 +3,8 @@
 // RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -target x86_64-pc-linux-gnu -I %S
 // RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target 
x86_64-pc-linux-gnu -I %S
 
+// REQUIRES: disabled
+
 #include "readability-uppercase-literal-suffix.h"
 
 void floating_point_suffix() {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp?rev=352224&r1=352223&r2=352224&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
 Fri Jan 25 10:05:43 2019
@@ -3,6 +3,8 @@
 // RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-fix -- -target x86_64-pc-linux-gnu -I %S
 // RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
-warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target 
x86_64-pc-linux-gnu -I %S
 
+// REQUIRES: disabled
+
 #include "readability-uppercase-literal-suffix.h"
 
 void floating_point_suffix() {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r352219 - Allow 'static' storage specifier on an out-of-line member function template

2019-01-25 Thread Roman Lebedev via cfe-commits
This review is invalid, since the lists weren't subscribed.

On Fri, Jan 25, 2019 at 8:01 PM Erich Keane via cfe-commits
 wrote:
>
> Author: erichkeane
> Date: Fri Jan 25 09:01:42 2019
> New Revision: 352219
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352219&view=rev
> Log:
> Allow 'static' storage specifier on an out-of-line member function template
> declaration in MSVCCompat mode
>
> Microsoft compiler permits the use of 'static' storage specifier outside
> of a class definition if it's on an out-of-line member function template
> declaration.
>
> This patch allows 'static' storage specifier on an out-of-line member
> function template declaration with a warning in Clang (To be compatible
> with Microsoft).
>
> Intel C/C++ compiler allows the 'static' keyword with a warning in
> Microsoft mode. GCC allows this with -fpermissive.
>
> Patch By: Manna
>
> Differential Revision: https://reviews.llvm.org/D56473
>
> Change-Id: I97b2d9e9d57cecbcd545d17e2523142a85ca2702
>
> Added:
> cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp   (with 
> props)
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaDecl.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=352219&r1=352218&r2=352219&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 25 09:01:42 
> 2019
> @@ -1585,6 +1585,9 @@ def err_explicit_non_ctor_or_conv_functi
>  def err_static_not_bitfield : Error<"static member %0 cannot be a 
> bit-field">;
>  def err_static_out_of_line : Error<
>"'static' can only be specified inside the class definition">;
> +def ext_static_out_of_line : ExtWarn<
> +  err_static_out_of_line.Text>,
> +  InGroup;
>  def err_storage_class_for_static_member : Error<
>"static data member definition cannot specify a storage class">;
>  def err_typedef_not_bitfield : Error<"typedef member %0 cannot be a 
> bit-field">;
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=352219&r1=352218&r2=352219&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jan 25 09:01:42 2019
> @@ -8625,8 +8625,12 @@ Sema::ActOnFunctionDeclarator(Scope *S,
>
>// Complain about the 'static' specifier if it's on an out-of-line
>// member function definition.
> +
> +  // MSVC permits the use of a 'static' storage specifier on an 
> out-of-line
> +  // member function template declaration, warn about this.
>Diag(D.getDeclSpec().getStorageClassSpecLoc(),
> -   diag::err_static_out_of_line)
> +   NewFD->getDescribedFunctionTemplate() && getLangOpts().MSVCCompat
> +   ? diag::ext_static_out_of_line : diag::err_static_out_of_line)
>  << 
> FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
>  }
>
>
> Added: cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp?rev=352219&view=auto
> ==
> --- cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp (added)
> +++ cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp Fri Jan 
> 25 09:01:42 2019
> @@ -0,0 +1,11 @@
> +// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
> +
> +struct C {
> +  template  static int foo(T);
> +};
> +
> +template  static int C::foo(T) {
> +  //expected-warning@-1 {{'static' can only be specified inside the class 
> definition}}
> +  return 0;
> +}
> +
>
> Propchange: cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp
> --
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp
> --
> svn:keywords = "Author Date Id Rev URL"
>
> Propchange: cfe/trunk/test/SemaCXX/warn-static-outside-class-definition.cpp
> --
> svn:mime-type = text/plain
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r352390 - [clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

2019-01-28 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Jan 28 09:04:11 2019
New Revision: 352390

URL: http://llvm.org/viewvc/llvm-project?rev=352390&view=rev
Log:
[clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

Summary:
As discussed in https://reviews.llvm.org/D57112#inline-506781,
'flush' clause does not exist in the OpenMP spec, it can not be
specified, and `OMPFlushClause` class is just a helper class.

Therefore `OPENMP_CLAUSE()` in `clang/Basic/OpenMPKinds.def`
should not contain 'flush' "clause".

I have simply removed the `OPENMP_CLAUSE(flush, OMPFlushClause)`
from `clang/Basic/OpenMPKinds.def`, grepped for `OPENMP_CLAUSE`
and added `OPENMP_CLAUSE(flush, OMPFlushClause)` back to the **every**
place where `OPENMP_CLAUSE` is defined and `clang/Basic/OpenMPKinds.def`
is then included.

So as-is, this patch is a NFC. Possibly, some of these
`OPENMP_CLAUSE(flush, OMPFlushClause)` should be dropped,
i don't really know.

Test plan: `ninja check-clang`

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: guansong, arphaman, cfe-commits

Tags: #openmp

Differential Revision: https://reviews.llvm.org/D57280

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=352390&r1=352389&r2=352390&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Jan 28 09:04:11 2019
@@ -5318,6 +5318,7 @@ public:
 
 #define OPENMP_CLAUSE(Name, Class)  \
   RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 
   RetTy Visit(PTR(OMPClause) S) {
@@ -5326,6 +5327,7 @@ public:
 default: llvm_unreachable("Unknown clause kind!");
 #define OPENMP_CLAUSE(Name, Class)  \
 case OMPC_ ## Name : return Visit ## Class(static_cast(S));
+OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 }
   }
@@ -5357,6 +5359,7 @@ public:
   : OS(OS), Policy(Policy) {}
 
 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S);
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 };
 

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=352390&r1=352389&r2=352390&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Jan 28 09:04:11 2019
@@ -529,6 +529,7 @@ private:
   bool TraverseOMPLoopDirective(OMPLoopDirective *S);
   bool TraverseOMPClause(OMPClause *C);
 #define OPENMP_CLAUSE(Name, Class) bool Visit##Class(Class *C);
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
   /// Process clauses with list of variables.
   template  bool VisitOMPClauseList(T *Node);
@@ -2788,6 +2789,7 @@ bool RecursiveASTVisitor::Trave
   case OMPC_##Name:
\
 TRY_TO(Visit##Class(static_cast(C))); 
\
 break;
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
   case OMPC_threadprivate:
   case OMPC_uniform:

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=352390&r1=352389&r2=352390&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Mon Jan 28 09:04:11 2019
@@ -258,7 +258,6 @@ OPENMP_CLAUSE(ordered, OMPOrderedClause)
 OPENMP_CLAUSE(nowait, OMPNowaitClause)
 OPENMP_CLAUSE(untied, OMPUntiedClause)
 OPENMP_CLAUSE(mergeable, OMPMergeableClause)
-OPENMP_CLAUSE(flush, OMPFlushClause)
 OPENMP_CLAUSE(read, OMPReadClause)
 OPENMP_CLAUSE(write, OMPWriteClause)
 OPENMP_CLAUSE(update, OMPUpdateClause)

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=352390&r1=352389&r2=352390&view=diff
==
--- cfe/trunk/include/clang/Basic/O

r352631 - [ASTDumper][OpenMP] CapturedDecl has a 'nothrow' bit

2019-01-30 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Jan 30 07:41:20 2019
New Revision: 352631

URL: http://llvm.org/viewvc/llvm-project?rev=352631&view=rev
Log:
[ASTDumper][OpenMP] CapturedDecl has a 'nothrow' bit

Summary:
Was trying to understand how complicated it would be to write
a clang-tidy `openmp-exception-escape`-ish check once D57100 lands.

Just so it happens, all the data is already there,
it is just conveniently omitted from AST dump.

Reviewers: aaron.ballman, steveire, ABataev

Reviewed By: ABataev

Subscribers: ABataev, guansong, cfe-commits

Tags: #openmp, #clang

Differential Revision: https://reviews.llvm.org/D57452

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/AST/dump.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352631&r1=352630&r2=352631&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Jan 30 07:41:20 2019
@@ -727,6 +727,8 @@ void ASTDumper::VisitPragmaDetectMismatc
 }
 
 void ASTDumper::VisitCapturedDecl(const CapturedDecl *D) {
+  if (D->isNothrow())
+OS << " nothrow";
   dumpStmt(D->getBody());
 }
 

Modified: cfe/trunk/test/AST/dump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/dump.cpp?rev=352631&r1=352630&r2=352631&view=diff
==
--- cfe/trunk/test/AST/dump.cpp (original)
+++ cfe/trunk/test/AST/dump.cpp Wed Jan 30 07:41:20 2019
@@ -61,7 +61,7 @@ struct S {
 // CHECK-NEXT: |   | `-ImplicitCastExpr {{.+}}  'int' 

 // CHECK-NEXT: |   |   `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
 // CHECK-NEXT: |   `-CapturedStmt {{.+}} 
-// CHECK-NEXT: | |-CapturedDecl {{.+}} <> 
+// CHECK-NEXT: | |-CapturedDecl {{.+}} <>  
nothrow
 // CHECK-NEXT: | | |-ForStmt {{.+}} 
 // CHECK:  | | | `-UnaryOperator {{.+}}  'int' lvalue prefix '++'
 // CHECK-NEXT: | | |   `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} 'a' 'int &'


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r352631 - [ASTDumper][OpenMP] CapturedDecl has a 'nothrow' bit

2019-01-30 Thread Roman Lebedev via cfe-commits
On Wed, Jan 30, 2019 at 6:46 PM Aaron Ballman  wrote:
>
> On Wed, Jan 30, 2019 at 10:41 AM Roman Lebedev via cfe-commits
>  wrote:
> >
> > Author: lebedevri
> > Date: Wed Jan 30 07:41:20 2019
> > New Revision: 352631
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=352631&view=rev
> > Log:
> > [ASTDumper][OpenMP] CapturedDecl has a 'nothrow' bit
> >
> > Summary:
> > Was trying to understand how complicated it would be to write
> > a clang-tidy `openmp-exception-escape`-ish check once D57100 lands.
> >
> > Just so it happens, all the data is already there,
> > it is just conveniently omitted from AST dump.
> >
> > Reviewers: aaron.ballman, steveire, ABataev
> >
> > Reviewed By: ABataev
> >
> > Subscribers: ABataev, guansong, cfe-commits
> >
> > Tags: #openmp, #clang
> >
> > Differential Revision: https://reviews.llvm.org/D57452
> >
> > Modified:
> > cfe/trunk/lib/AST/ASTDumper.cpp
> > cfe/trunk/test/AST/dump.cpp
> >
> > Modified: cfe/trunk/lib/AST/ASTDumper.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352631&r1=352630&r2=352631&view=diff
> > ==
> > --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
> > +++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Jan 30 07:41:20 2019
> > @@ -727,6 +727,8 @@ void ASTDumper::VisitPragmaDetectMismatc
> >  }
> >
> >  void ASTDumper::VisitCapturedDecl(const CapturedDecl *D) {
> > +  if (D->isNothrow())
> > +OS << " nothrow";
>
> These changes should be to the TextNodeDumper, not the ASTDumper.
TextNodeDumper does not have a function that handles CapturedDecl.
Was there some RFC about this on cfe-dev i missed?
If not, might be a good idea to publicly state this..

> ~Aaron
Roman.

> >dumpStmt(D->getBody());
> >  }
> >
> >
> > Modified: cfe/trunk/test/AST/dump.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/dump.cpp?rev=352631&r1=352630&r2=352631&view=diff
> > ==
> > --- cfe/trunk/test/AST/dump.cpp (original)
> > +++ cfe/trunk/test/AST/dump.cpp Wed Jan 30 07:41:20 2019
> > @@ -61,7 +61,7 @@ struct S {
> >  // CHECK-NEXT: |   | `-ImplicitCastExpr {{.+}}  'int' 
> > 
> >  // CHECK-NEXT: |   |   `-DeclRefExpr {{.+}}  'int' lvalue 
> > OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
> >  // CHECK-NEXT: |   `-CapturedStmt {{.+}}  > line:[[@LINE-14]]:9>
> > -// CHECK-NEXT: | |-CapturedDecl {{.+}} <>  > sloc>
> > +// CHECK-NEXT: | |-CapturedDecl {{.+}} <>  > sloc> nothrow
> >  // CHECK-NEXT: | | |-ForStmt {{.+}}  > line:[[@LINE-16]]:9>
> >  // CHECK:  | | | `-UnaryOperator {{.+}}  > col:9> 'int' lvalue prefix '++'
> >  // CHECK-NEXT: | | |   `-DeclRefExpr {{.+}}  'int' lvalue 
> > OMPCapturedExpr {{.+}} 'a' 'int &'
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r352793 - [WebAssembly] Add bulk memory target feature

2019-01-31 Thread Roman Lebedev via cfe-commits
And another review that omitted lists.


On Fri, Feb 1, 2019 at 12:02 AM Thomas Lively via cfe-commits
 wrote:
>
> Author: tlively
> Date: Thu Jan 31 13:02:19 2019
> New Revision: 352793
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352793&view=rev
> Log:
> [WebAssembly] Add bulk memory target feature
>
> Summary: Also clean up some preexisting target feature code.
>
> Reviewers: aheejin
>
> Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, jfb
>
> Differential Revision: https://reviews.llvm.org/D57495
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
> cfe/trunk/lib/Basic/Targets/WebAssembly.h
> cfe/trunk/test/Preprocessor/wasm-target-features.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352793&r1=352792&r2=352793&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Thu Jan 31 13:02:19 2019
> @@ -2155,6 +2155,8 @@ def msign_ext : Flag<["-"], "msign-ext">
>  def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group;
>  def mexception_handing : Flag<["-"], "mexception-handling">, 
> Group;
>  def mno_exception_handing : Flag<["-"], "mno-exception-handling">, 
> Group;
> +def mbulk_memory : Flag<["-"], "mbulk-memory">, Group;
> +def mno_bulk_memory : Flag<["-"], "mno-bulk-memory">, 
> Group;
>
>  def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
>Flags<[HelpHidden]>,
>
> Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.cpp?rev=352793&r1=352792&r2=352793&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets/WebAssembly.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets/WebAssembly.cpp Thu Jan 31 13:02:19 2019
> @@ -40,6 +40,7 @@ bool WebAssemblyTargetInfo::hasFeature(S
>.Case("nontrapping-fptoint", HasNontrappingFPToInt)
>.Case("sign-ext", HasSignExt)
>.Case("exception-handling", HasExceptionHandling)
> +  .Case("bulk-memory", HasBulkMemory)
>.Default(false);
>  }
>
> @@ -59,6 +60,14 @@ void WebAssemblyTargetInfo::getTargetDef
>  Builder.defineMacro("__wasm_simd128__");
>if (SIMDLevel >= UnimplementedSIMD128)
>  Builder.defineMacro("__wasm_unimplemented_simd128__");
> +  if (HasNontrappingFPToInt)
> +Builder.defineMacro("__wasm_nontrapping_fptoint__");
> +  if (HasSignExt)
> +Builder.defineMacro("__wasm_sign_ext__");
> +  if (HasExceptionHandling)
> +Builder.defineMacro("__wasm_exception_handling__");
> +  if (HasBulkMemory)
> +Builder.defineMacro("__wasm_bulk_memory__");
>  }
>
>  void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap &Features,
> @@ -93,6 +102,8 @@ bool WebAssemblyTargetInfo::initFeatureM
>  Features["sign-ext"] = true;
>if (HasExceptionHandling)
>  Features["exception-handling"] = true;
> +  if (HasBulkMemory)
> +Features["bulk-memory"] = true;
>
>return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
>  }
> @@ -140,6 +151,14 @@ bool WebAssemblyTargetInfo::handleTarget
>HasExceptionHandling = false;
>continue;
>  }
> +if (Feature == "+bulk-memory") {
> +  HasBulkMemory = true;
> +  continue;
> +}
> +if (Feature == "-bulk-memory") {
> +  HasBulkMemory = false;
> +  continue;
> +}
>
>  Diags.Report(diag::err_opt_not_valid_with_opt)
>  << Feature << "-target-feature";
>
> Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.h?rev=352793&r1=352792&r2=352793&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets/WebAssembly.h (original)
> +++ cfe/trunk/lib/Basic/Targets/WebAssembly.h Thu Jan 31 13:02:19 2019
> @@ -30,14 +30,14 @@ class LLVM_LIBRARY_VISIBILITY WebAssembl
>  UnimplementedSIMD128,
>} SIMDLevel = NoSIMD;
>
> -  bool HasNontrappingFPToInt;
> -  bool HasSignExt;
> -  bool HasExceptionHandling;
> +  bool HasNontrappingFPToInt = false;
> +  bool HasSignExt = false;
> +  bool HasExceptionHandling = false;
> +  bool HasBulkMemory = false;
>
>  public:
>explicit WebAssemblyTargetInfo(const llvm::Triple &T, const TargetOptions 
> &)
> -  : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
> -HasSignExt(false), HasExceptionHandling(false) {
> +  : TargetInfo(T) {
>  NoAsmVariants = true;
>  SuitableAlign = 128;
>  LargeArrayMinWidth = 128;
>
> Modified: cfe/trunk/test/Preprocessor/wasm-target-features.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/wasm-target-features.c?rev=352793&r1=352

Re: r345660 - [clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang part

2018-10-31 Thread Roman Lebedev via cfe-commits
On Thu, Nov 1, 2018 at 3:03 AM Friedman, Eli  wrote:
>
> On 10/30/2018 2:58 PM, Roman Lebedev via cfe-commits wrote:
> > Author: lebedevri
> > Date: Tue Oct 30 14:58:56 2018
> > New Revision: 345660
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=345660&view=rev
> > Log:
> > [clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang 
> > part
> >
> > This is the second half of Implicit Integer Conversion Sanitizer.
> > It completes the first half, and finally makes the sanitizer
> > fully functional! Only the bitfield handling is missing.
>
> This is causing failures on the polly-aosp buildbot
> (http://lab.llvm.org:8011/builders/aosp-O3-polly-before-vectorizer-unprofitable/builds/690/steps/build-aosp/logs/stdio
> ).  I haven't tried to reduce the issue yet; let me know if you need help.
Thanks!
I'm able to cause a similar crash, will handle it from here.
It *should* be trivial/fast to triage, so maybe the revert can be
avoided. Or not.

> -Eli
Roman.

> --
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
> Foundation Collaborative Project
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r345816 - [clang][CodeGen] ImplicitIntegerSignChangeSanitizer: actually ignore NOP casts.

2018-11-01 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Nov  1 01:56:51 2018
New Revision: 345816

URL: http://llvm.org/viewvc/llvm-project?rev=345816&view=rev
Log:
[clang][CodeGen] ImplicitIntegerSignChangeSanitizer: actually ignore NOP casts.

I fully expected for that to be handled by the canonical type check,
but it clearly wasn't. Sadly, somehow it hide until now.

Reported by Eli Friedman.

Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=345816&r1=345815&r2=345816&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Nov  1 01:56:51 2018
@@ -1127,10 +1127,9 @@ void ScalarExprEmitter::EmitIntegerSignC
   // Now, we do not need to emit the check in *all* of the cases.
   // We can avoid emitting it in some obvious cases where it would have been
   // dropped by the opt passes (instcombine) always anyways.
-  // If it's a cast between the same type, just differently-sugared. no check.
-  QualType CanonSrcType = CGF.getContext().getCanonicalType(SrcType);
-  QualType CanonDstType = CGF.getContext().getCanonicalType(DstType);
-  if (CanonSrcType == CanonDstType)
+  // If it's a cast between effectively the same type, no check.
+  // NOTE: this is *not* equivalent to checking the canonical types.
+  if (SrcSigned == DstSigned && SrcBits == DstBits)
 return;
   // At least one of the values needs to have signed type.
   // If both are unsigned, then obviously, neither of them can be negative.

Modified: 
cfe/trunk/test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c?rev=345816&r1=345815&r2=345816&view=diff
==
--- cfe/trunk/test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c 
(original)
+++ cfe/trunk/test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c 
Thu Nov  1 01:56:51 2018
@@ -138,3 +138,15 @@ uint32_t unsigned_int_to_uint32(unsigned
 uint32_t uint32_to_uint32(uint32_t src) {
   return src;
 }
+
+// "Transparent" Enum.
+// == 
//
+
+enum a { b = ~2147483647 };
+enum a c();
+void d(int);
+void e();
+void e() {
+  enum a f = c();
+  d(f);
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r345660 - [clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang part

2018-11-01 Thread Roman Lebedev via cfe-commits
On Thu, Nov 1, 2018 at 9:39 AM Roman Lebedev  wrote:
>
> On Thu, Nov 1, 2018 at 3:03 AM Friedman, Eli  wrote:
> >
> > On 10/30/2018 2:58 PM, Roman Lebedev via cfe-commits wrote:
> > > Author: lebedevri
> > > Date: Tue Oct 30 14:58:56 2018
> > > New Revision: 345660
> > >
> > > URL: http://llvm.org/viewvc/llvm-project?rev=345660&view=rev
> > > Log:
> > > [clang][ubsan] Implicit Conversion Sanitizer - integer sign change - 
> > > clang part
> > >
> > > This is the second half of Implicit Integer Conversion Sanitizer.
> > > It completes the first half, and finally makes the sanitizer
> > > fully functional! Only the bitfield handling is missing.
> >
> > This is causing failures on the polly-aosp buildbot
> > (http://lab.llvm.org:8011/builders/aosp-O3-polly-before-vectorizer-unprofitable/builds/690/steps/build-aosp/logs/stdio
> > ).  I haven't tried to reduce the issue yet; let me know if you need help.
> Thanks!
> I'm able to cause a similar crash, will handle it from here.
> It *should* be trivial/fast to triage, so maybe the revert can be
> avoided. Or not.
Fixed in r345816.

> > -Eli
Roman.

> > --
> > Employee of Qualcomm Innovation Center, Inc.
> > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
> > Foundation Collaborative Project
> >
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r346461 - Ignore implicit things like ConstantExpr.

2018-11-08 Thread Roman Lebedev via cfe-commits
Test?

On Fri, Nov 9, 2018 at 4:34 AM Bill Wendling via cfe-commits
 wrote:
>
> Author: void
> Date: Thu Nov  8 17:32:30 2018
> New Revision: 346461
>
> URL: http://llvm.org/viewvc/llvm-project?rev=346461&view=rev
> Log:
> Ignore implicit things like ConstantExpr.
>
> Modified:
> 
> clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
>
> Modified: 
> clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp?rev=346461&r1=346460&r2=346461&view=diff
> ==
> --- 
> clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
>  (original)
> +++ 
> clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
>  Thu Nov  8 17:32:30 2018
> @@ -58,7 +58,8 @@ void NoexceptMoveConstructorCheck::check
>  // where expr evaluates to false.
>  if (ProtoType->canThrow() == CT_Can) {
>Expr *E = ProtoType->getNoexceptExpr();
> -  if (!isa(ProtoType->getNoexceptExpr())) {
> +  E = E->IgnoreImplicit();
> +  if (!isa(E)) {
>  diag(E->getExprLoc(),
>   "noexcept specifier on the move %0 evaluates to 'false'")
>  << MethodType;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r346548 - Use the correct address space when bitcasting func pointer to int pointer

2018-11-09 Thread Roman Lebedev via cfe-commits
The codegen change can't be tested?
On Fri, Nov 9, 2018 at 10:44 PM Dylan McKay via cfe-commits
 wrote:
>
> Author: dylanmckay
> Date: Fri Nov  9 11:42:05 2018
> New Revision: 346548
>
> URL: http://llvm.org/viewvc/llvm-project?rev=346548&view=rev
> Log:
> Use the correct address space when bitcasting func pointer to int pointer
>
> When we cast a function pointer to an int pointer, at some pointer later
> it gets bitcasted back to a function and called.
>
> In backends that have a nonzero program memory address space specified
> in the data layout, the old code would lose the address space data. When
> LLVM later attempted to generate the bitcast from i8* to i8(..)*
> addrspace(1), it would fail because the pointers are not in the same
> address space.
>
> With this patch, the address space of the function will carry on to the
> address space of the i8* pointer. This is because all function pointers
> in Harvard architectures need to be assigned to the correct address
> space.
>
> This has no effect to any in-tree backends except AVR.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGException.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGException.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=346548&r1=346547&r2=346548&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGException.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGException.cpp Fri Nov  9 11:42:05 2018
> @@ -250,7 +250,11 @@ static llvm::Constant *getPersonalityFn(
>  static llvm::Constant *getOpaquePersonalityFn(CodeGenModule &CGM,
>  const EHPersonality &Personality) {
>llvm::Constant *Fn = getPersonalityFn(CGM, Personality);
> -  return llvm::ConstantExpr::getBitCast(Fn, CGM.Int8PtrTy);
> +  llvm::PointerType* Int8PtrTy = llvm::PointerType::get(
> +  llvm::Type::getInt8Ty(CGM.getLLVMContext()),
> +  CGM.getDataLayout().getProgramAddressSpace());
> +
> +  return llvm::ConstantExpr::getBitCast(Fn, Int8PtrTy);
>  }
>
>  /// Check whether a landingpad instruction only uses C++ features.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r346835 - [clang-tidy] Avoid C arrays check

2018-11-14 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Nov 14 01:01:08 2018
New Revision: 346835

URL: http://llvm.org/viewvc/llvm-project?rev=346835&view=rev
Log:
[clang-tidy] Avoid C arrays check

Summary:
[[ https://bugs.llvm.org/show_bug.cgi?id=39224 | PR39224 ]]
As discussed, we can't always do the transform automatically due to that 
array-to-pointer decay of C array.
In order to detect whether we can do said transform, we'd need to be able to 
see all usages of said array,
which is, i would say, rather impossible if e.g. it is in the header.
Thus right now no fixit exists.

Exceptions: `extern "C"` code.

References:
* [[ 
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es27-use-stdarray-or-stack_array-for-arrays-on-the-stack
 | CPPCG ES.27: Use std::array or stack_array for arrays on the stack ]]
* [[ 
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#slcon1-prefer-using-stl-array-or-vector-instead-of-a-c-array
 | CPPCG SL.con.1: Prefer using STL array or vector instead of a C array ]]
* HICPP `4.1.1 Ensure that a function argument does not undergo an 
array-to-pointer conversion`
* MISRA `5-2-12 An identifier with array type passed as a function argument 
shall not decay to a pointer`

Reviewers: aaron.ballman, JonasToth, alexfh, hokein, xazax.hun

Reviewed By: JonasToth

Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D53771

Added:
clang-tools-extra/trunk/clang-tidy/modernize/AvoidCArraysCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/AvoidCArraysCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-avoid-c-arrays.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-avoid-c-arrays.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-avoid-c-arrays.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=346835&r1=346834&r2=346835&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Wed Nov 
14 01:01:08 2018
@@ -28,6 +28,7 @@ add_clang_library(clangTidyCppCoreGuidel
   clangLex
   clangTidy
   clangTidyMiscModule
+  clangTidyModernizeModule
   clangTidyReadabilityModule
   clangTidyUtils
   clangTooling

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=346835&r1=346834&r2=346835&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Wed Nov 14 01:01:08 2018
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/NonPrivateMemberVariablesInClassesCheck.h"
 #include "../misc/UnconventionalAssignOperatorCheck.h"
+#include "../modernize/AvoidCArraysCheck.h"
 #include "../readability/MagicNumbersCheck.h"
 #include "AvoidGotoCheck.h"
 #include "InterfacesGlobalInitCheck.h"
@@ -40,6 +41,8 @@ namespace cppcoreguidelines {
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-avoid-c-arrays");
 CheckFactories.registerCheck(
 "cppcoreguidelines-avoid-goto");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp?rev=346835&r1=346834&r2=346835&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp Wed Nov 14 
01:01:08 2018
@@ -22,6 +22,7 @@
 #include "../misc/NewDeleteOverloadsCheck.h"
 #include "../misc/StaticAssertCheck.h"
 #include "../bugprone/UndelegatedConstructorCheck.h"
+#include "..

r347339 - [clang][Parse] Diagnose useless null statements / empty init-statements

2018-11-20 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Nov 20 10:59:05 2018
New Revision: 347339

URL: http://llvm.org/viewvc/llvm-project?rev=347339&view=rev
Log:
[clang][Parse] Diagnose useless null statements / empty init-statements

Summary:
clang has `-Wextra-semi` (D43162), which is not dictated by the currently 
selected standard.
While that is great, there is at least one more source of need-less semis - 
'null statements'.
Sometimes, they are needed:
```
for(int x = 0; continueToDoWork(x); x++)
  ; // Ugly code, but the semi is needed here.
```

But sometimes they are just there for no reason:
```
switch(X) {
case 0:
  return -2345;
case 5:
  return 0;
default:
  return 42;
}; // <- oops

;;; <- PS, still not diagnosed. Clearly this is junk.
```

Additionally:
```
if(; // <- empty init-statement
   true)
  ;

switch (; // empty init-statement
x) {
  ...
}

for (; // <- empty init-statement
 int y : S())
  ;
}

As usual, things may or may not go sideways in the presence of macros.
While evaluating this diag on my codebase of interest, it was unsurprisingly
discovered that Google Test macros are *very* prone to this.
And it seems many issues are deep within the GTest itself, not
in the snippets passed from the codebase that uses GTest.

So after some thought, i decided not do issue a diagnostic if the semi
is within *any* macro, be it either from the normal header, or system header.

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=39111 | PR39111 ]]

Reviewers: rsmith, aaron.ballman, efriedma

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52695

Added:
cfe/trunk/test/Parser/extra-semi-resulting-in-nullstmt-in-init-statement.cpp
cfe/trunk/test/Parser/extra-semi-resulting-in-nullstmt.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=347339&r1=347338&r2=347339&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Nov 20 10:59:05 2018
@@ -55,6 +55,63 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
+- ``-Wextra-semi-stmt`` is a new diagnostic that diagnoses extra semicolons,
+  much like ``-Wextra-semi``. This new diagnostic diagnoses all *unnecessary*
+  null statements (expression statements without an expression), unless: the
+  semicolon directly follows a macro that was expanded to nothing or if the
+  semicolon is within the macro itself. This applies to macros defined in 
system
+  headers as well as user-defined macros.
+
+  .. code-block:: c++
+
+  #define MACRO(x) int x;
+  #define NULLMACRO(varname)
+
+  void test() {
+; // <- warning: ';' with no preceding expression is a null statement
+
+while (true)
+  ; // OK, it is needed.
+
+switch (my_enum) {
+case E1:
+  // stuff
+  break;
+case E2:
+  ; // OK, it is needed.
+}
+
+MACRO(v0;) // Extra semicolon, but within macro, so ignored.
+
+MACRO(v1); // <- warning: ';' with no preceding expression is a null 
statement
+
+NULLMACRO(v2); // ignored, NULLMACRO expanded to nothing.
+  }
+
+- ``-Wempty-init-stmt`` is a new diagnostic that diagnoses empty 
init-statements
+  of ``if``, ``switch``, ``range-based for``, unless: the semicolon directly
+  follows a macro that was expanded to nothing or if the semicolon is within 
the
+  macro itself (both macros from system headers, and normal macros). This
+  diagnostic is in the ``-Wextra-semi-stmt`` group and is enabled in
+  ``-Wextra``.
+
+  .. code-block:: c++
+
+  void test() {
+if(; // <- warning: init-statement of 'if' is a null statement
+   true)
+  ;
+
+switch (; // <- warning: init-statement of 'switch' is a null statement
+x) {
+  ...
+}
+
+for (; // <- warning: init-statement of 'range-based for' is a null 
statement
+ int y : S())
+  ;
+  }
+
 
 Non-comprehensive list of changes in this release
 -

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=347339&r1=347338&r2=347339&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Nov 20 10:59:05 2018
@@ -162,6 +162,8 @@ def GNUEmptyStruct : DiagG

Re: [PATCH] D53812: [Analyzer] Iterator Checker - Forbid increments past the begin() and decrements past the end() of containers

2018-11-30 Thread Roman Lebedev via cfe-commits
""Re: [PATCH] D53812: [Analyzer] Iterator Checker - Forbid increments
past the begin() and decrements past the end() of containers"
Is it be or that reads backwards?
Why can't you increment past the begin()? Can you decrement past the
begin() instead?
And the opposite for the end().

On Sat, Dec 1, 2018 at 1:17 AM Artem Dergachev via Phabricator via
cfe-commits  wrote:
>
> NoQ accepted this revision.
> NoQ added a comment.
> This revision is now accepted and ready to land.
>
> Makes perfect sense to me!
>
>
>
> 
> Comment at: test/Analysis/iterator-range.cpp:190
> +  auto i0 = L.begin();
> +  --i0;  // expected-warning{{Iterator accessed outside of its range}}
> +}
> 
> I guess we'll have to come up with a separate warning text for this case, as 
> there's no access happening through the iterator.
>
> Regardless of how the final message would look, i suggest adding logic for 
> having a different message now, so that we didn't forget about this case 
> later.
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D53812/new/
>
> https://reviews.llvm.org/D53812
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r348302 - [Documentation] Make options section in Clang-tidy readability-uppercase-literal-suffix consistent with other checks.

2018-12-04 Thread Roman Lebedev via cfe-commits
On Wed, Dec 5, 2018 at 12:21 AM Eugene Zelenko via cfe-commits
 wrote:
>
> Author: eugenezelenko
> Date: Tue Dec  4 13:19:08 2018
> New Revision: 348302
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348302&view=rev
> Log:
> [Documentation] Make options section in Clang-tidy 
> readability-uppercase-literal-suffix consistent with other checks.
Thank you!

> Modified:
> 
> clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
>
> Modified: 
> clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst?rev=348302&r1=348301&r2=348302&view=diff
> ==
> --- 
> clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
>  (original)
> +++ 
> clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
>  Tue Dec  4 13:19:08 2018
> @@ -25,13 +25,21 @@ All valid combinations of suffixes are s
>
>...
>
> -Optionally, a list of the destination suffixes can be provided. When the 
> suffix
> -is found, a case-insensitive lookup in that list is made, and if a 
> replacement
> -is found that is different from the current suffix, then the diagnostic is
> -issued. This allows for fine-grained control of what suffixes to consider and
> -what their replacements should be.
> +Options
> +---
>
> -For example, given a list ``L;uL``:
> +.. option:: NewSuffixes
> +
> +  Optionally, a list of the destination suffixes can be provided. When the
> +  suffix is found, a case-insensitive lookup in that list is made, and if a
> +  replacement is found that is different from the current suffix, then the
> +  diagnostic is issued. This allows for fine-grained control of what 
> suffixes to
> +  consider and what their replacements should be.
> +
> +Example
> +^^^
> +
> +Given a list `L;uL`:
>
>  * ``l`` -> ``L``
>  * ``L`` will be kept as is.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [cfe-dev] r347339 - [clang][Parse] Diagnose useless null statements / empty init-statements

2018-12-04 Thread Roman Lebedev via cfe-commits
On Wed, Dec 5, 2018 at 4:07 AM Artem Dergachev via cfe-commits
 wrote:
>
>
>
> On 12/4/18 5:04 PM, George Karpenkov via cfe-dev wrote:
> >
> >> On Dec 4, 2018, at 4:47 PM, Aaron Ballman  wrote:
> >>
> >> On Tue, Dec 4, 2018 at 7:35 PM George Karpenkov  
> >> wrote:
> >>> Hi Roman,
Hi.

> >>> I’m against this new warning.
> >>>
> >>> A very common idiom is defining a “DEBUG” macro to be a no-op in release, 
> >>> and a logging function otherwise.
> >>> The new introduced warning warns on all such cases (e.g. 
> >>> 'DEBUG(“mystring”);')
> >> Yeah, that's not good.
It does warn on such cases when the macro not expanded to nothing, yes.

> >>> As noted in the review, Clang warnings should generally not be used to 
> >>> diagnose style issues — and an extra semicolon does not seem to be a 
> >>> common bug source.
I don't disagree.
The alternative solution would be to try to squeeze this bit of info
into the AST,
without increasing the size of the particular type, and then emit the
diag in clang-tidy.
I did consider it, it seemed like a over-engineering.

> >>> It is a problem in practice for us since we have projects which enable 
> >>> all available warnings and also enable “-Werror”.
Hm, they have asked for -Weverything and they got it. Seems to be
working as intended.
When in previous discussions elsewhere i have talked about
-Weverything, i was always
been told that it isn't supposed to be used like that (admittedly, i
*do* use it like that :)).

Could you explain how is this different from any other warning that is
considered pointless by the project?
Why not simply disable it?

> >> Would you be okay with the warning if it was only diagnosed when the
> >> source location of the semi-colon is not immediately preceded by a
> >> macro expansion location? e.g.,
> >>
> >> EMPTY_EXPANSION(12); // Not diagnosed
> >> EMPTY_EXPANSION; // Not diagnosed
> >> ; // Diagnosed
> > This could work provided that all empty space preceding the semicolon is 
> > ignored (as the macro could be separated by space(s) or newline(s).
> > I’m not sure the complexity would be worth it, as I haven’t seen bugs 
> > arising from extra semicolons and empty statements,
> > but it would take care of my use case.
> >
>
> Or rather when the *previous* semicolon is coming from a macro.
I don't like this. clang is already wa-a-ay too forgiving about
macros, it almost ignores almost every warning in macros.
It was an *intentional* decision to still warn on useless ';' after
non-empty macros.
So at most i would be ok with emitting the macro case under -W{flag}-macro.
Thoughts?

> >> ~Aaron
> >>
> >>> Regards,
> >>> George
Roman.

> >>>> On Nov 20, 2018, at 10:59 AM, Roman Lebedev via cfe-commits 
> >>>>  wrote:
> >>>>
> >>>> Author: lebedevri
> >>>> Date: Tue Nov 20 10:59:05 2018
> >>>> New Revision: 347339
> >>>>
> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=347339&view=rev
> >>>> Log:
> >>>> [clang][Parse] Diagnose useless null statements / empty init-statements
> >>>>
> >>>> Summary:
> >>>> clang has `-Wextra-semi` (D43162), which is not dictated by the 
> >>>> currently selected standard.
> >>>> While that is great, there is at least one more source of need-less 
> >>>> semis - 'null statements'.
> >>>> Sometimes, they are needed:
> >>>> ```
> >>>> for(int x = 0; continueToDoWork(x); x++)
> >>>> ; // Ugly code, but the semi is needed here.
> >>>> ```
> >>>>
> >>>> But sometimes they are just there for no reason:
> >>>> ```
> >>>> switch(X) {
> >>>> case 0:
> >>>> return -2345;
> >>>> case 5:
> >>>> return 0;
> >>>> default:
> >>>> return 42;
> >>>> }; // <- oops
> >>>>
> >>>> ;;; <- PS, still not diagnosed. Clearly this is junk.
> >>>> ```
> >>>>
> >>>> Additionally:
> >>>> ```
> >>>> if(; // <- empty init-statement
> >>>>   true)
> >>>> ;
> >>>>
> >>>> switch (; // empty init-statement
> >>>>x) {
> >>>> ...
> >>>> 

Re: r348471 - Add test for ObjC generics

2018-12-06 Thread Roman Lebedev via cfe-commits
Can you please write better commit messages, especially the first subject line?
E.g. this should have been "[AST][NFC] Add dump test for ObjC generics"

On Thu, Dec 6, 2018 at 12:26 PM Stephen Kelly via cfe-commits
 wrote:
>
> Author: steveire
> Date: Thu Dec  6 01:23:59 2018
> New Revision: 348471
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348471&view=rev
> Log:
> Add test for ObjC generics
>
> Modified:
> cfe/trunk/test/AST/ast-dump-decl.m
>
> Modified: cfe/trunk/test/AST/ast-dump-decl.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.m?rev=348471&r1=348470&r2=348471&view=diff
> ==
> --- cfe/trunk/test/AST/ast-dump-decl.m (original)
> +++ cfe/trunk/test/AST/ast-dump-decl.m Thu Dec  6 01:23:59 2018
> @@ -81,6 +81,14 @@
>  // CHECK-NEXT:   ObjCProtocol{{.*}} 'P'
>  // CHECK-NEXT:   ObjCMethodDecl{{.*}} bar
>
> +@interface TestGenericInterface : A {
> +}
> +@end
> +// CHECK:  ObjCInterfaceDecl{{.*}} TestGenericInterface
> +// CHECK-NEXT:   -ObjCTypeParamDecl
> +// CHECK-NEXT:   -super ObjCInterface
> +// CHECK-NEXT:   -ObjCProtocol
> +
>  @implementation TestObjCClass (TestObjCCategoryDecl)
>  - (void) bar {
>  }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   >