[PATCH] D58065: [analyzer] Document the frontend library

2019-02-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D58065#1400615 , @Szelethus wrote:

> I've also wasted my second weekend trying to make Static Analyzer unit tests 
> run under check-clang-analysis


:) I tried to have a quick look but got confused pretty quickly.

In D58065#1400615 , @Szelethus wrote:

> In D58065#1400154 , @NoQ wrote:
>
> > Old fanboy wisdom: Try to avoid documenting bugs you want to fix!
>
>
> Oh, which one do you mean?


Nothing in particular yet, just my own mistakes :p


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58065/new/

https://reviews.llvm.org/D58065



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


[PATCH] D58243: [OPENMP] Delay emission of the asm target-specific error messages.

2019-02-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Ping!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58243/new/

https://reviews.llvm.org/D58243



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


[PATCH] D58306: [AArch64] Change size suffix for FP16FML intrinsics.

2019-02-17 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

I am discussing this with our GCC team as we would like both Clang/GCC 
implementation to be the same. But you're right that _f16 looks like to be the 
more consistent choice. I will let you know as soon I know more.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58306/new/

https://reviews.llvm.org/D58306



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


r354235 - [analyzer] Make valist.Uninitialized depend on ValistBase

2019-02-17 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sun Feb 17 11:51:42 2019
New Revision: 354235

URL: http://llvm.org/viewvc/llvm-project?rev=354235=rev
Log:
[analyzer] Make valist.Uninitialized depend on ValistBase

Accidentally left this dependency out, resulting in an assert failure if
only valist.Uninitialized is enabled from the valist package.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/test/Analysis/valist-uninitialized.c

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=354235=354234=354235=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Sun Feb 17 
11:51:42 2019
@@ -508,6 +508,7 @@ def ValistBase : Checker<"ValistBase">,
 
 def UninitializedChecker : Checker<"Uninitialized">,
   HelpText<"Check for usages of uninitialized (or already released) 
va_lists.">,
+  Dependencies<[ValistBase]>,
   Documentation;
 
 def UnterminatedChecker : Checker<"Unterminated">,

Modified: cfe/trunk/test/Analysis/valist-uninitialized.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/valist-uninitialized.c?rev=354235=354234=354235=diff
==
--- cfe/trunk/test/Analysis/valist-uninitialized.c (original)
+++ cfe/trunk/test/Analysis/valist-uninitialized.c Sun Feb 17 11:51:42 2019
@@ -1,5 +1,15 @@
-// RUN: %clang_analyze_cc1 -triple hexagon-unknown-linux 
-analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf 
-analyzer-disable-checker=core.CallAndMessage -analyzer-output=text 
-analyzer-store=region -verify %s
-// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu 
-analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf 
-analyzer-disable-checker=core.CallAndMessage -analyzer-output=text 
-analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -triple hexagon-unknown-linux -verify %s \
+// RUN:   -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf \
+// RUN:   -analyzer-disable-checker=core.CallAndMessage \
+// RUN:   -analyzer-output=text
+//
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -verify %s \
+// RUN:   -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf \
+// RUN:   -analyzer-disable-checker=core.CallAndMessage \
+// RUN:   -analyzer-output=text
+//
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu %s \
+// RUN:   -analyzer-checker=core,valist.Uninitialized
 
 #include "Inputs/system-header-simulator-for-valist.h"
 


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


r354233 - [NFC] Add a llvm_unreachable to silence a warning in SubstObjCTypeArgsVisitor

2019-02-17 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sun Feb 17 11:18:38 2019
New Revision: 354233

URL: http://llvm.org/viewvc/llvm-project?rev=354233=rev
Log:
[NFC] Add a llvm_unreachable to silence a warning in SubstObjCTypeArgsVisitor

All cases in the switch are covered. NFC.


Modified:
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=354233=354232=354233=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sun Feb 17 11:18:38 2019
@@ -1184,6 +1184,7 @@ struct SubstObjCTypeArgsVisitor
   return Ctx.getObjCObjectPointerType(resultTy);
   }
 }
+llvm_unreachable("Unexpected ObjCSubstitutionContext!");
   }
 
   QualType VisitFunctionType(const FunctionType *funcType) {


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


[PATCH] D58065: [analyzer] Document the frontend library

2019-02-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Thanks for the review on my patches! I'm a little busy atm (I've also wasted my 
second weekend trying to make Static Analyzer unit tests run under 
check-clang-analysis), but I'll see to fixing these in the coming weeks.

In D58065#1400154 , @NoQ wrote:

> Old fanboy wisdom: Try to avoid documenting bugs you want to fix!


Oh, which one do you mean?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58065/new/

https://reviews.llvm.org/D58065



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


r354232 - Recommit "[AST] Factor out the logic of the various Expr::Ignore*"

2019-02-17 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sun Feb 17 10:50:51 2019
New Revision: 354232

URL: http://llvm.org/viewvc/llvm-project?rev=354232=rev
Log:
Recommit "[AST] Factor out the logic of the various Expr::Ignore*"

(Originally commited in r354215 and reverted in r354216 because of a
 missed failing clang-tidy test (fix in r354228))

Now that the implementation of all of the Expr::Ignore* is in Expr.cpp
we can try to remove some duplication. Do this by separating the logic
of the Expr::Ignore* from the iterative loop.

This is NFC, except for one change: IgnoreParenImpCasts now skips,
among other things, everything that IgnoreImpCasts skips. This means
FullExpr are now skipped by IgnoreParenImpCasts. This was likely an
oversight when FullExpr was added to the nodes skipped by IgnoreImpCasts.

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

Reviewed By: aaron.ballman (with comments from void and rnk)


Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=354232=354231=354232=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Feb 17 10:50:51 2019
@@ -794,7 +794,7 @@ public:
   /// IgnoreParens() + IgnoreImpCasts() until reaching a fixed point. However
   /// this is currently not the case. Instead IgnoreParenImpCasts() skips:
   /// * What IgnoreParens() skips
-  /// * ImplicitCastExpr
+  /// * What IgnoreImpCasts() skips
   /// * MaterializeTemporaryExpr
   /// * SubstNonTypeTemplateParmExpr
   Expr *IgnoreParenImpCasts() LLVM_READONLY;

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=354232=354231=354232=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sun Feb 17 10:50:51 2019
@@ -2556,185 +2556,173 @@ QualType Expr::findBoundMemberType(const
   return QualType();
 }
 
-Expr *Expr::IgnoreImpCasts() {
-  Expr *E = this;
-  while (true) {
-if (auto *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
-else if (auto *FE = dyn_cast(E))
-  E = FE->getSubExpr();
-else
-  break;
-  }
+static Expr *IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
   return E;
 }
 
-Expr *Expr::IgnoreImplicit() {
-  Expr *E = this;
-  Expr *LastE = nullptr;
-  while (E != LastE) {
-LastE = E;
+static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
 
-if (auto *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
+  if (auto *MTE = dyn_cast(E))
+return MTE->GetTemporaryExpr();
 
-if (auto *FE = dyn_cast(E))
-  E = FE->getSubExpr();
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
 
-if (auto *MTE = dyn_cast(E))
-  E = MTE->GetTemporaryExpr();
+  return E;
+}
+
+static Expr *IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->GetTemporaryExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
 
-if (auto *BTE = dyn_cast(E))
-  E = BTE->getSubExpr();
-  }
   return E;
 }
 
-Expr *Expr::IgnoreParens() {
-  Expr *E = this;
-  while (true) {
-if (auto *PE = dyn_cast(E)) {
-  E = PE->getSubExpr();
-  continue;
-}
-if (auto *UO = dyn_cast(E)) {
-  if (UO->getOpcode() == UO_Extension) {
-E = UO->getSubExpr();
-continue;
-  }
-}
-if (auto *GSE = dyn_cast(E)) {
-  if (!GSE->isResultDependent()) {
-E = GSE->getResultExpr();
-continue;
-  }
-}
-if (auto *CE = dyn_cast(E)) {
-  if (!CE->isConditionDependent()) {
-E = CE->getChosenSubExpr();
-continue;
-  }
-}
-if (auto *CE = dyn_cast(E)) {
-  E = CE->getSubExpr();
-  continue;
-}
-return E;
-  }
+static Expr *IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
+}
+
+static Expr *IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == 

[clang-tools-extra] r354228 - [clang-tidy][NFCI] DanglingHandleCheck: Remove a superflous IgnoreParenImpCasts

2019-02-17 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sun Feb 17 10:21:54 2019
New Revision: 354228

URL: http://llvm.org/viewvc/llvm-project?rev=354228=rev
Log:
[clang-tidy][NFCI] DanglingHandleCheck: Remove a superflous IgnoreParenImpCasts

ExprWithCleanups is currently not skipped by IgnoreParenImpCasts, but is skipped
by IgnoreImpCasts. In view of fixing this inconsistency in D57267, remove the
IgnoreParenImpCasts between the ReturnStmt and the ExprWithCleanups which
is not needed since ExprWithCleanups is always created as a direct child of
ReturnStmt (by inspection of each ReturnStmt::Create in Sema/SemaStmt.cpp).

NFC intended.


Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp?rev=354228=354227=354228=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp Sun Feb 
17 10:21:54 2019
@@ -163,9 +163,8 @@ void DanglingHandleCheck::registerMatche
 
   // Return a temporary.
   Finder->addMatcher(
-  returnStmt(
-  has(ignoringParenImpCasts(exprWithCleanups(has(ignoringParenImpCasts(
-  handleFrom(IsAHandle, handleFromTemporaryValue(IsAHandle
+  returnStmt(has(exprWithCleanups(has(ignoringParenImpCasts(handleFrom(
+ IsAHandle, handleFromTemporaryValue(IsAHandle)))
   .bind("bad_stmt"),
   this);
 }


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


[PATCH] D47127: [RISCV] Default enable RISCV linker relaxation

2019-02-17 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354222: [RISCV] Default enable RISCV linker relaxation 
(authored by shiva, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D47127/new/

https://reviews.llvm.org/D47127

Files:
  lib/Driver/ToolChains/Arch/RISCV.cpp
  test/Driver/riscv-features.c


Index: test/Driver/riscv-features.c
===
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -9,5 +9,5 @@
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
-// DEFAULT-NOT: "-target-feature" "+relax"
+// DEFAULT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
Index: lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- lib/Driver/ToolChains/Arch/RISCV.cpp
+++ lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -364,6 +364,18 @@
 getExtensionFeatures(D, Args, Features, MArch, OtherExts);
   }
 
+  // -mrelax is default, unless -mno-relax is specified.
+  bool Relax = true;
+  if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax)) {
+if (A->getOption().matches(options::OPT_mno_relax)) {
+  Relax = false;
+  Features.push_back("-relax");
+}
+  }
+
+  if (Relax)
+Features.push_back("+relax");
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(Args, Features, 
options::OPT_m_riscv_Features_Group);


Index: test/Driver/riscv-features.c
===
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -9,5 +9,5 @@
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
-// DEFAULT-NOT: "-target-feature" "+relax"
+// DEFAULT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
Index: lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- lib/Driver/ToolChains/Arch/RISCV.cpp
+++ lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -364,6 +364,18 @@
 getExtensionFeatures(D, Args, Features, MArch, OtherExts);
   }
 
+  // -mrelax is default, unless -mno-relax is specified.
+  bool Relax = true;
+  if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax)) {
+if (A->getOption().matches(options::OPT_mno_relax)) {
+  Relax = false;
+  Features.push_back("-relax");
+}
+  }
+
+  if (Relax)
+Features.push_back("+relax");
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(Args, Features, options::OPT_m_riscv_Features_Group);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354222 - [RISCV] Default enable RISCV linker relaxation

2019-02-17 Thread Shiva Chen via cfe-commits
Author: shiva
Date: Sun Feb 17 08:05:51 2019
New Revision: 354222

URL: http://llvm.org/viewvc/llvm-project?rev=354222=rev
Log:
[RISCV] Default enable RISCV linker relaxation

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
cfe/trunk/test/Driver/riscv-features.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=354222=354221=354222=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Sun Feb 17 08:05:51 2019
@@ -364,6 +364,18 @@ void riscv::getRISCVTargetFeatures(const
 getExtensionFeatures(D, Args, Features, MArch, OtherExts);
   }
 
+  // -mrelax is default, unless -mno-relax is specified.
+  bool Relax = true;
+  if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax)) {
+if (A->getOption().matches(options::OPT_mno_relax)) {
+  Relax = false;
+  Features.push_back("-relax");
+}
+  }
+
+  if (Relax)
+Features.push_back("+relax");
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(Args, Features, 
options::OPT_m_riscv_Features_Group);

Modified: cfe/trunk/test/Driver/riscv-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-features.c?rev=354222=354221=354222=diff
==
--- cfe/trunk/test/Driver/riscv-features.c (original)
+++ cfe/trunk/test/Driver/riscv-features.c Sun Feb 17 08:05:51 2019
@@ -9,5 +9,5 @@
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
-// DEFAULT-NOT: "-target-feature" "+relax"
+// DEFAULT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"


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


[PATCH] D47127: [RISCV] Default enable RISCV linker relaxation

2019-02-17 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 updated this revision to Diff 187160.
shiva0217 changed the repository for this revision from rL LLVM to rC Clang.
shiva0217 edited projects, added clang; removed LLVM.
shiva0217 added a comment.

Update patch to address Alex's comment.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D47127/new/

https://reviews.llvm.org/D47127

Files:
  lib/Driver/ToolChains/Arch/RISCV.cpp
  test/Driver/riscv-features.c


Index: test/Driver/riscv-features.c
===
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -9,5 +9,5 @@
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
-// DEFAULT-NOT: "-target-feature" "+relax"
+// DEFAULT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
Index: lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- lib/Driver/ToolChains/Arch/RISCV.cpp
+++ lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -364,6 +364,18 @@
 getExtensionFeatures(D, Args, Features, MArch, OtherExts);
   }
 
+  // -mrelax is default, unless -mno-relax is specified.
+  bool Relax = true;
+  if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax)) {
+if (A->getOption().matches(options::OPT_mno_relax)) {
+  Relax = false;
+  Features.push_back("-relax");
+}
+  }
+
+  if (Relax)
+Features.push_back("+relax");
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(Args, Features, 
options::OPT_m_riscv_Features_Group);


Index: test/Driver/riscv-features.c
===
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -9,5 +9,5 @@
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
-// DEFAULT-NOT: "-target-feature" "+relax"
+// DEFAULT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
Index: lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- lib/Driver/ToolChains/Arch/RISCV.cpp
+++ lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -364,6 +364,18 @@
 getExtensionFeatures(D, Args, Features, MArch, OtherExts);
   }
 
+  // -mrelax is default, unless -mno-relax is specified.
+  bool Relax = true;
+  if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax)) {
+if (A->getOption().matches(options::OPT_mno_relax)) {
+  Relax = false;
+  Features.push_back("-relax");
+}
+  }
+
+  if (Relax)
+Features.push_back("+relax");
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(Args, Features, options::OPT_m_riscv_Features_Group);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57087: [clang-tidy] add OverrideMacro to modernize-use-override check

2019-02-17 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

Some Clang warnings use PP.getLastMacroWithSpelling() to determine the user's 
macro automatically.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57087/new/

https://reviews.llvm.org/D57087



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


[PATCH] D58291: [clangd] Include textual diagnostic ID as Diagnostic.code.

2019-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LG but is this information really useful to users? According to LSP `The 
diagnostic's code, which might appear in the user interface.`, I think seeing 
this will be mostly noise for users.




Comment at: clangd/Diagnostics.cpp:39
+#include "clang/Basic/DiagnosticCommentKinds.inc"
+#include "clang/Basic/DiagnosticSemaKinds.inc"
+#include "clang/Basic/DiagnosticAnalysisKinds.inc"

I suppose `CrossTUKinds` is left out intentionally ?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58291/new/

https://reviews.llvm.org/D58291



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


r354216 - Revert "[AST] Factor out the logic of the various Expr::Ignore*"

2019-02-17 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sun Feb 17 05:47:29 2019
New Revision: 354216

URL: http://llvm.org/viewvc/llvm-project?rev=354216=rev
Log:
Revert "[AST] Factor out the logic of the various Expr::Ignore*"

This breaks some clang-tidy checks. For some reason they were
not included in check-clang ?


Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=354216=354215=354216=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Feb 17 05:47:29 2019
@@ -794,7 +794,7 @@ public:
   /// IgnoreParens() + IgnoreImpCasts() until reaching a fixed point. However
   /// this is currently not the case. Instead IgnoreParenImpCasts() skips:
   /// * What IgnoreParens() skips
-  /// * What IgnoreImpCasts() skips
+  /// * ImplicitCastExpr
   /// * MaterializeTemporaryExpr
   /// * SubstNonTypeTemplateParmExpr
   Expr *IgnoreParenImpCasts() LLVM_READONLY;

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=354216=354215=354216=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sun Feb 17 05:47:29 2019
@@ -2556,173 +2556,185 @@ QualType Expr::findBoundMemberType(const
   return QualType();
 }
 
-static Expr *IgnoreImpCastsSingleStep(Expr *E) {
-  if (auto *ICE = dyn_cast(E))
-return ICE->getSubExpr();
-
-  if (auto *FE = dyn_cast(E))
-return FE->getSubExpr();
-
-  return E;
-}
-
-static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
-  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
-  // addition to what IgnoreImpCasts() skips to account for the current
-  // behaviour of IgnoreParenImpCasts().
-  Expr *SubE = IgnoreImpCastsSingleStep(E);
-  if (SubE != E)
-return SubE;
-
-  if (auto *MTE = dyn_cast(E))
-return MTE->GetTemporaryExpr();
-
-  if (auto *NTTP = dyn_cast(E))
-return NTTP->getReplacement();
-
-  return E;
-}
-
-static Expr *IgnoreCastsSingleStep(Expr *E) {
-  if (auto *CE = dyn_cast(E))
-return CE->getSubExpr();
-
-  if (auto *FE = dyn_cast(E))
-return FE->getSubExpr();
-
-  if (auto *MTE = dyn_cast(E))
-return MTE->GetTemporaryExpr();
-
-  if (auto *NTTP = dyn_cast(E))
-return NTTP->getReplacement();
-
+Expr *Expr::IgnoreImpCasts() {
+  Expr *E = this;
+  while (true) {
+if (auto *ICE = dyn_cast(E))
+  E = ICE->getSubExpr();
+else if (auto *FE = dyn_cast(E))
+  E = FE->getSubExpr();
+else
+  break;
+  }
   return E;
 }
 
-static Expr *IgnoreLValueCastsSingleStep(Expr *E) {
-  // Skip what IgnoreCastsSingleStep skips, except that only
-  // lvalue-to-rvalue casts are skipped.
-  if (auto *CE = dyn_cast(E))
-if (CE->getCastKind() != CK_LValueToRValue)
-  return E;
-
-  return IgnoreCastsSingleStep(E);
-}
-
-static Expr *IgnoreBaseCastsSingleStep(Expr *E) {
-  if (auto *CE = dyn_cast(E))
-if (CE->getCastKind() == CK_DerivedToBase ||
-CE->getCastKind() == CK_UncheckedDerivedToBase ||
-CE->getCastKind() == CK_NoOp)
-  return CE->getSubExpr();
-
-  return E;
-}
+Expr *Expr::IgnoreImplicit() {
+  Expr *E = this;
+  Expr *LastE = nullptr;
+  while (E != LastE) {
+LastE = E;
 
-static Expr *IgnoreImplicitSingleStep(Expr *E) {
-  Expr *SubE = IgnoreImpCastsSingleStep(E);
-  if (SubE != E)
-return SubE;
+if (auto *ICE = dyn_cast(E))
+  E = ICE->getSubExpr();
 
-  if (auto *MTE = dyn_cast(E))
-return MTE->GetTemporaryExpr();
+if (auto *FE = dyn_cast(E))
+  E = FE->getSubExpr();
 
-  if (auto *BTE = dyn_cast(E))
-return BTE->getSubExpr();
+if (auto *MTE = dyn_cast(E))
+  E = MTE->GetTemporaryExpr();
 
+if (auto *BTE = dyn_cast(E))
+  E = BTE->getSubExpr();
+  }
   return E;
 }
 
-static Expr *IgnoreParensSingleStep(Expr *E) {
-  if (auto *PE = dyn_cast(E))
-return PE->getSubExpr();
-
-  if (auto *UO = dyn_cast(E)) {
-if (UO->getOpcode() == UO_Extension)
-  return UO->getSubExpr();
-  }
-
-  else if (auto *GSE = dyn_cast(E)) {
-if (!GSE->isResultDependent())
-  return GSE->getResultExpr();
-  }
-
-  else if (auto *CE = dyn_cast(E)) {
-if (!CE->isConditionDependent())
-  return CE->getChosenSubExpr();
+Expr *Expr::IgnoreParens() {
+  Expr *E = this;
+  while (true) {
+if (auto *PE = dyn_cast(E)) {
+  E = PE->getSubExpr();
+  continue;
+}
+if (auto *UO = dyn_cast(E)) {
+  if (UO->getOpcode() == UO_Extension) {
+E = UO->getSubExpr();
+continue;
+  }
+}
+if (auto *GSE = dyn_cast(E)) {
+  if (!GSE->isResultDependent()) {
+E = GSE->getResultExpr();
+continue;
+  }
+}
+if (auto *CE = dyn_cast(E)) {
+  if 

Re: [PATCH] D58326: [Driver][Gnu] Support -nolibc flag

2019-02-17 Thread Roland McGrath via cfe-commits
See
https://fuchsia.googlesource.com/fuchsia/+/48c987febf4077e52985f1ce1edc957b39bc5481/zircon/public/gn/config/BUILD.gn#219
and
https://fuchsia.googlesource.com/fuchsia/+/48c987febf4077e52985f1ce1edc957b39bc5481/zircon/public/gn/config/libc-dummy
for what happens without it...

On Sat, Feb 16, 2019 at 5:29 PM Eric Christopher  wrote:

> Weird. Ok.
>
> On Sat, Feb 16, 2019, 5:20 PM Petr Hosek via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> phosek created this revision.
>> phosek added reviewers: echristo, mcgrathr.
>> Herald added a project: clang.
>> Herald added a subscriber: cfe-commits.
>>
>> This can be used to disable libc linking. This flag is supported by
>> GCC since version 9 as well as some Clang target toolchains.
>>
>>
>> Repository:
>>   rC Clang
>>
>> https://reviews.llvm.org/D58326
>>
>> Files:
>>   clang/lib/Driver/ToolChains/Gnu.cpp
>>   clang/test/Driver/nodefaultlib.c
>>   clang/test/Driver/nolibc.c
>>
>>
>> Index: clang/test/Driver/nolibc.c
>> ===
>> --- /dev/null
>> +++ clang/test/Driver/nolibc.c
>> @@ -0,0 +1,5 @@
>> +// RUN: %clang -target i686-pc-linux-gnu -### -rtlib=libgcc -nolibc %s
>> 2>&1 | FileCheck %s
>> +// CHECK: crtbegin
>> +// CHECK: "-lgcc"
>> +// CHECK-NOT: "-lc"
>> +// CHECK: crtend
>> Index: clang/test/Driver/nodefaultlib.c
>> ===
>> --- clang/test/Driver/nodefaultlib.c
>> +++ clang/test/Driver/nodefaultlib.c
>> @@ -1,4 +1,4 @@
>> -// RUN: %clang -target i686-pc-linux-gnu -### -nodefaultlibs %s 2>&1 |
>> FileCheck -check-prefix=TEST1 %s
>> +// RUN: %clang -target i686-pc-linux-gnu -### -rtlib=libgcc
>> -nodefaultlibs %s 2>&1 | FileCheck -check-prefix=TEST1 %s
>>  // TEST1-NOT: start-group
>>  // TEST1-NOT: "-lgcc"
>>  // TEST1-NOT: "-lc"
>> Index: clang/lib/Driver/ToolChains/Gnu.cpp
>> ===
>> --- clang/lib/Driver/ToolChains/Gnu.cpp
>> +++ clang/lib/Driver/ToolChains/Gnu.cpp
>> @@ -518,7 +518,8 @@
>>if (Args.hasArg(options::OPT_fsplit_stack))
>>  CmdArgs.push_back("--wrap=pthread_create");
>>
>> -  CmdArgs.push_back("-lc");
>> +  if (!Args.hasArg(options::OPT_nolibc))
>> +CmdArgs.push_back("-lc");
>>
>>// Add IAMCU specific libs, if needed.
>>if (IsIAMCU)
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57267: [AST] Factor out the logic of the various Expr::Ignore*

2019-02-17 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354215: [AST] Factor out the logic of the various 
Expr::Ignore* (authored by brunoricci, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57267?vs=185539=187156#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57267/new/

https://reviews.llvm.org/D57267

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/lib/AST/Expr.cpp

Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -794,7 +794,7 @@
   /// IgnoreParens() + IgnoreImpCasts() until reaching a fixed point. However
   /// this is currently not the case. Instead IgnoreParenImpCasts() skips:
   /// * What IgnoreParens() skips
-  /// * ImplicitCastExpr
+  /// * What IgnoreImpCasts() skips
   /// * MaterializeTemporaryExpr
   /// * SubstNonTypeTemplateParmExpr
   Expr *IgnoreParenImpCasts() LLVM_READONLY;
Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -2556,185 +2556,173 @@
   return QualType();
 }
 
-Expr *Expr::IgnoreImpCasts() {
-  Expr *E = this;
-  while (true) {
-if (auto *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
-else if (auto *FE = dyn_cast(E))
-  E = FE->getSubExpr();
-else
-  break;
-  }
+static Expr *IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
   return E;
 }
 
-Expr *Expr::IgnoreImplicit() {
-  Expr *E = this;
-  Expr *LastE = nullptr;
-  while (E != LastE) {
-LastE = E;
+static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
 
-if (auto *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
+  if (auto *MTE = dyn_cast(E))
+return MTE->GetTemporaryExpr();
 
-if (auto *FE = dyn_cast(E))
-  E = FE->getSubExpr();
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
 
-if (auto *MTE = dyn_cast(E))
-  E = MTE->GetTemporaryExpr();
+  return E;
+}
+
+static Expr *IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->GetTemporaryExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
 
-if (auto *BTE = dyn_cast(E))
-  E = BTE->getSubExpr();
-  }
   return E;
 }
 
-Expr *Expr::IgnoreParens() {
-  Expr *E = this;
-  while (true) {
-if (auto *PE = dyn_cast(E)) {
-  E = PE->getSubExpr();
-  continue;
-}
-if (auto *UO = dyn_cast(E)) {
-  if (UO->getOpcode() == UO_Extension) {
-E = UO->getSubExpr();
-continue;
-  }
-}
-if (auto *GSE = dyn_cast(E)) {
-  if (!GSE->isResultDependent()) {
-E = GSE->getResultExpr();
-continue;
-  }
-}
-if (auto *CE = dyn_cast(E)) {
-  if (!CE->isConditionDependent()) {
-E = CE->getChosenSubExpr();
-continue;
-  }
-}
-if (auto *CE = dyn_cast(E)) {
-  E = CE->getSubExpr();
-  continue;
-}
-return E;
-  }
+static Expr *IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
+}
+
+static Expr *IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
 }
 
-/// IgnoreParenCasts - Ignore parentheses and casts.  Strip off any ParenExpr
-/// or CastExprs or ImplicitCastExprs, returning their operand.
-Expr *Expr::IgnoreParenCasts() {
-  Expr *E = this;
-  while (true) {
-E = E->IgnoreParens();
-if (auto *CE = dyn_cast(E)) {
-  E = CE->getSubExpr();
-  continue;
-}
-if (auto *MTE = dyn_cast(E)) {
-  E = MTE->GetTemporaryExpr();
-  continue;
-}
-if (auto *NTTP = dyn_cast(E)) {
-  E = NTTP->getReplacement();
-  continue;
-}
-if (auto *FE = dyn_cast(E)) {
-  E = FE->getSubExpr();
-  continue;
-}
-return E;
-  }
+static Expr *IgnoreImplicitSingleStep(Expr *E) {
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE 

r354215 - [AST] Factor out the logic of the various Expr::Ignore*

2019-02-17 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sun Feb 17 05:32:39 2019
New Revision: 354215

URL: http://llvm.org/viewvc/llvm-project?rev=354215=rev
Log:
[AST] Factor out the logic of the various Expr::Ignore*

Now that the implementation of all of the Expr::Ignore* is in Expr.cpp
we can try to remove some duplication. Do this by separating the logic of
the Expr::Ignore* from the iterative loop.

This is NFC, except for one change: IgnoreParenImpCasts now skips, among
other things, everything that IgnoreImpCasts skips. This means FullExpr
are now skipped by IgnoreParenImpCasts. This was likely an oversight when
FullExpr was added to the nodes skipped by IgnoreImpCasts.

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

Reviewed By: aaron.ballman (with comments from void and rnk)


Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=354215=354214=354215=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Feb 17 05:32:39 2019
@@ -794,7 +794,7 @@ public:
   /// IgnoreParens() + IgnoreImpCasts() until reaching a fixed point. However
   /// this is currently not the case. Instead IgnoreParenImpCasts() skips:
   /// * What IgnoreParens() skips
-  /// * ImplicitCastExpr
+  /// * What IgnoreImpCasts() skips
   /// * MaterializeTemporaryExpr
   /// * SubstNonTypeTemplateParmExpr
   Expr *IgnoreParenImpCasts() LLVM_READONLY;

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=354215=354214=354215=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sun Feb 17 05:32:39 2019
@@ -2556,185 +2556,173 @@ QualType Expr::findBoundMemberType(const
   return QualType();
 }
 
-Expr *Expr::IgnoreImpCasts() {
-  Expr *E = this;
-  while (true) {
-if (auto *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
-else if (auto *FE = dyn_cast(E))
-  E = FE->getSubExpr();
-else
-  break;
-  }
+static Expr *IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
   return E;
 }
 
-Expr *Expr::IgnoreImplicit() {
-  Expr *E = this;
-  Expr *LastE = nullptr;
-  while (E != LastE) {
-LastE = E;
+static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
 
-if (auto *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
+  if (auto *MTE = dyn_cast(E))
+return MTE->GetTemporaryExpr();
 
-if (auto *FE = dyn_cast(E))
-  E = FE->getSubExpr();
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
 
-if (auto *MTE = dyn_cast(E))
-  E = MTE->GetTemporaryExpr();
+  return E;
+}
+
+static Expr *IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->GetTemporaryExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
 
-if (auto *BTE = dyn_cast(E))
-  E = BTE->getSubExpr();
-  }
   return E;
 }
 
-Expr *Expr::IgnoreParens() {
-  Expr *E = this;
-  while (true) {
-if (auto *PE = dyn_cast(E)) {
-  E = PE->getSubExpr();
-  continue;
-}
-if (auto *UO = dyn_cast(E)) {
-  if (UO->getOpcode() == UO_Extension) {
-E = UO->getSubExpr();
-continue;
-  }
-}
-if (auto *GSE = dyn_cast(E)) {
-  if (!GSE->isResultDependent()) {
-E = GSE->getResultExpr();
-continue;
-  }
-}
-if (auto *CE = dyn_cast(E)) {
-  if (!CE->isConditionDependent()) {
-E = CE->getChosenSubExpr();
-continue;
-  }
-}
-if (auto *CE = dyn_cast(E)) {
-  E = CE->getSubExpr();
-  continue;
-}
-return E;
-  }
+static Expr *IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
+}
+
+static Expr *IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
 }
 
-/// IgnoreParenCasts - Ignore parentheses and casts.  Strip off any 

[PATCH] D57087: [clang-tidy] add OverrideMacro to modernize-use-override check

2019-02-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang-tidy/modernize/UseOverrideCheck.cpp:32
+: ClangTidyCheck(Name, Context),
+  OverrideMacro(Options.get("OverrideMacro", "override")),
+  FinalMacro(Options.get("FinalMacro", "final")) {}

alexfh wrote:
> MyDeveloperDay wrote:
> > alexfh wrote:
> > > I'd suggest to default to an empty string and use `override` as a 
> > > fallback right in the code where the diagnostic is generated.
> > So I tried this and and met with some issues with the unit tests where it 
> > seemed to think "override" was a macro, I also found myself just simply 
> > always setting OverrideMacro/Final Macro to "override" and "final" anyway.. 
> > I've changed this round a little to only check for the macro when the 
> > OverrideMacro isn't override. This seems to resolve the problem, let me 
> > know if it still feels wrong.
> In case "override" is not a macro, setting `OverrideMacro` to `override` 
> would be somewhat confusing. We could make set default to `override`, if this 
> makes logic simpler, but then I'd suggest to rename the option to 
> `OverrideSpelling` (same for `final`).
I agree that is a better naming



Comment at: test/clang-tidy/modernize-use-override-with-macro.cpp:2
+// RUN: %check_clang_tidy %s modernize-use-override %t -- \
+// RUN:   -config="{CheckOptions: [{key: 
modernize-use-nodiscard.OverrideMacro, value: 'OVERRIDE'},{key: 
modernize-use-nodiscard.FinalMacro, value: 'FINAL'}]}" \
+// RUN: -- -std=c++11

alexfh wrote:
> "modernize-use-nodiscard"? Does this test pass?
my bad I was having problems with getting lit to work in windows environment, 
so was running the tests externally, I've fixed that now


```
c:/clang/llvm/build/RelWithDebInfo/bin/llvm-lit.py -v 
test/clang-tidy/modernize-use-override*
-- Testing: 5 tests, 5 threads --
PASS: Clang Tools :: clang-tidy/modernize-use-override-cxx98.cpp (1 of 5)
PASS: Clang Tools :: clang-tidy/modernize-use-override-ms.cpp (2 of 5)
PASS: Clang Tools :: 
clang-tidy/modernize-use-override-with-no-macro-inscope.cpp (3 of 5)
PASS: Clang Tools :: clang-tidy/modernize-use-override.cpp (4 of 5)
PASS: Clang Tools :: clang-tidy/modernize-use-override-with-macro.cpp (5 of 5)
Testing Time: 5.13s
  Expected Passes: 5
```




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57087/new/

https://reviews.llvm.org/D57087



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


[PATCH] D57087: [clang-tidy] add OverrideMacro to modernize-use-override check

2019-02-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 187155.
MyDeveloperDay marked 10 inline comments as done.
MyDeveloperDay added a comment.

Address review comments

- change OverrideMacro to OverrideSpelling
- change FinalMacro to FinalSpelling
- fix unit tests
- show warning without fix-it if Macros are not defined


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57087/new/

https://reviews.llvm.org/D57087

Files:
  clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tidy/modernize/UseOverrideCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-override.rst
  test/clang-tidy/modernize-use-override-with-macro.cpp
  test/clang-tidy/modernize-use-override-with-no-macro-inscope.cpp

Index: test/clang-tidy/modernize-use-override-with-no-macro-inscope.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-override-with-no-macro-inscope.cpp
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s modernize-use-override %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-override.OverrideSpelling, value: 'CUSTOM_OVERRIDE'},{key: modernize-use-override.FinalSpelling, value: 'CUSTOM_FINAL'}]}" \
+// RUN: -- -std=c++11
+
+// As if the macro was not defined.
+//#define CUSTOM_OVERRIDE override
+//#define CUSTOM_FINAL override
+
+struct Base {
+  virtual ~Base() {}
+  virtual void a();
+  virtual void b();
+};
+
+struct SimpleCases : public Base {
+public:
+  virtual ~SimpleCases();
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'CUSTOM_OVERRIDE' or (rarely) 'CUSTOM_FINAL' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  virtual ~SimpleCases();
+
+  void a();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this function with 'CUSTOM_OVERRIDE' or (rarely) 'CUSTOM_FINAL' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  void a();
+
+  virtual void b();
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'CUSTOM_OVERRIDE' or (rarely) 'CUSTOM_FINAL' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  virtual void b();
+};
Index: test/clang-tidy/modernize-use-override-with-macro.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-override-with-macro.cpp
@@ -0,0 +1,69 @@
+// RUN: %check_clang_tidy %s modernize-use-override %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-override.OverrideSpelling, value: 'OVERRIDE'},{key: modernize-use-override.FinalSpelling, value: 'FINAL'}]}" \
+// RUN: -- -std=c++11
+
+#define ABSTRACT = 0
+
+#define OVERRIDE override
+#define VIRTUAL virtual
+#define NOT_VIRTUAL
+#define NOT_OVERRIDE
+
+#define MUST_USE_RESULT __attribute__((warn_unused_result))
+#define UNUSED __attribute__((unused))
+
+struct Base {
+  virtual ~Base() {}
+  virtual void a();
+  virtual void b();
+  virtual void c();
+  virtual void e() = 0;
+  virtual void f2() const = 0;
+  virtual void g() = 0;
+  virtual void j() const;
+  virtual void k() = 0;
+  virtual void l() const;
+};
+
+struct SimpleCases : public Base {
+public:
+  virtual ~SimpleCases();
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'OVERRIDE' or (rarely) 'FINAL' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  ~SimpleCases() OVERRIDE;
+
+  void a();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this function with 'OVERRIDE' or (rarely) 'FINAL' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  void a() OVERRIDE;
+
+  virtual void b();
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'OVERRIDE' or (rarely) 'FINAL' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  void b() OVERRIDE;
+
+  virtual void c();
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void c() OVERRIDE;
+
+  virtual void e() = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void e() OVERRIDE = 0;
+
+  virtual void f2() const = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void f2() const OVERRIDE = 0;
+
+  virtual void g() ABSTRACT;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void g() OVERRIDE ABSTRACT;
+
+  virtual void j() const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void j() const OVERRIDE;
+
+  virtual void k() OVERRIDE;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'OVERRIDE' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  void k() OVERRIDE;
+
+  virtual void l() const OVERRIDE;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'OVERRIDE' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  void l() const OVERRIDE;
+};
Index: docs/clang-tidy/checks/modernize-use-override.rst