[PATCH] D70270: clang-tidy: modernize-use-using uses AST and now supports struct defintions and multiple types in a typedef

2019-12-21 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 235039.
poelmanc added a subscriber: sammccall.
poelmanc added a comment.

Update patch to rebase on latest: Changed `SourceLocation::contains` to 
`SourceLocation::fullyContains`, and removed new `SourceLocation` comparison 
operators since coincidentally @sammccall added them just days ago.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70270

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-using.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
  clang/include/clang/Basic/SourceLocation.h

Index: clang/include/clang/Basic/SourceLocation.h
===
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -230,6 +230,11 @@
 return B != X.B || E != X.E;
   }
 
+  // Returns true iff other is wholly contained within this range.
+  bool fullyContains(const SourceRange ) const {
+return B <= other.B && E >= other.E;
+  }
+
   void print(raw_ostream , const SourceManager ) const;
   std::string printToString(const SourceManager ) const;
   void dump(const SourceManager ) const;
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
@@ -84,7 +84,11 @@
 
 typedef int bla1, bla2, bla3;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef int bla1, bla2, bla3;
+// CHECK-MESSAGES: :[[@LINE-2]]:17: warning: use 'using' instead of 'typedef'
+// CHECK-MESSAGES: :[[@LINE-3]]:23: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using bla1 = int;
+// CHECK-FIXES-NEXT: using bla2 = int;
+// CHECK-FIXES-NEXT: using bla3 = int;
 
 #define CODE typedef int INT
 
@@ -136,16 +140,16 @@
 
 typedef struct Q1 { int a; } S1;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef struct Q1 { int a; } S1;
+// CHECK-FIXES: using S1 = struct Q1 { int a; };
 typedef struct { int b; } S2;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef struct { int b; } S2;
+// CHECK-FIXES: using S2 = struct { int b; };
 struct Q2 { int c; } typedef S3;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: struct Q2 { int c; } typedef S3;
+// CHECK-FIXES: using S3 = struct Q2 { int c; };
 struct { int d; } typedef S4;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: struct { int d; } typedef S4;
+// CHECK-FIXES: using S4 = struct { int d; };
 
 namespace my_space {
   class my_cclass {};
@@ -196,11 +200,15 @@
 
 typedef S<(0 > 0), int> S_t, *S_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef S<(0 > 0), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S_t = S<(0 > 0), int>;
+// CHECK-FIXES-NEXT: using S_p = S_t*;
 
 typedef S<(0 < 0), int> S2_t, *S2_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef S<(0 < 0), int> S2_t, *S2_p;
+// CHECK-MESSAGES: :[[@LINE-2]]:29: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S2_t = S<(0 < 0), int>;
+// CHECK-FIXES-NEXT: using S2_p = S2_t*;
 
 typedef S<(0 > 0 && (3 > 1) && (1 < 1)), int> S3_t;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
@@ -213,7 +221,9 @@
 
 typedef Q Q_t, *Q_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef Q Q_t, *Q_p;
+// CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q_t = Q;
+// CHECK-FIXES-NEXT: using Q_p = Q_t*;
 
 typedef Q Q2_t;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
@@ -227,7 +237,9 @@
 
 typedef Q Q3_t, *Q3_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef Q Q3_t, *Q3_p;
+// CHECK-MESSAGES: :[[@LINE-2]]:27: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q3_t = Q;
+// CHECK-FIXES-NEXT: using Q3_p = Q3_t*;
 
 typedef Q Q3_t;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
@@ -246,4 +258,12 @@
 
 typedef Variadic >, S<(0 < 0), Variadic > > > Variadic_t, *Variadic_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef Variadic >, S<(0 < 0), Variadic > > > Variadic_t, *Variadic_p;

[PATCH] D71802: [NFC] Move OptionUtils from Basic to Driver

2019-12-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: thakis, tra.
Herald added a subscriber: mgorny.

https://reviews.llvm.org/D71802

Files:
  clang/include/clang/Basic/OptionUtils.h
  clang/include/clang/Driver/OptionUtils.h
  clang/include/clang/Frontend/Utils.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/OptionUtils.cpp
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OptionUtils.cpp

Index: clang/lib/Driver/OptionUtils.cpp
===
--- /dev/null
+++ clang/lib/Driver/OptionUtils.cpp
@@ -0,0 +1,47 @@
+//===--- OptionUtils.cpp - Utilities for command line arguments ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticDriver.h"
+#include "clang/Driver/OptionUtils.h"
+#include "llvm/Option/ArgList.h"
+
+using namespace clang;
+using namespace llvm::opt;
+
+namespace {
+template 
+IntTy getLastArgIntValueImpl(const ArgList , OptSpecifier Id,
+ IntTy Default, DiagnosticsEngine *Diags,
+ unsigned Base) {
+  IntTy Res = Default;
+  if (Arg *A = Args.getLastArg(Id)) {
+if (StringRef(A->getValue()).getAsInteger(Base, Res)) {
+  if (Diags)
+Diags->Report(diag::err_drv_invalid_int_value)
+<< A->getAsString(Args) << A->getValue();
+}
+  }
+  return Res;
+}
+} // namespace
+
+namespace clang {
+
+int getLastArgIntValue(const ArgList , OptSpecifier Id, int Default,
+   DiagnosticsEngine *Diags, unsigned Base) {
+  return getLastArgIntValueImpl(Args, Id, Default, Diags, Base);
+}
+
+uint64_t getLastArgUInt64Value(const ArgList , OptSpecifier Id,
+   uint64_t Default, DiagnosticsEngine *Diags,
+   unsigned Base) {
+  return getLastArgIntValueImpl(Args, Id, Default, Diags, Base);
+}
+
+} // namespace clang
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -19,6 +19,7 @@
   DriverOptions.cpp
   Job.cpp
   Multilib.cpp
+  OptionUtils.cpp
   Phases.cpp
   SanitizerArgs.cpp
   Tool.cpp
Index: clang/lib/Basic/OptionUtils.cpp
===
--- clang/lib/Basic/OptionUtils.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//===--- OptionUtils.cpp - Utilities for command line arguments ---===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "clang/Basic/OptionUtils.h"
-#include "clang/Basic/Diagnostic.h"
-#include "clang/Basic/DiagnosticDriver.h"
-#include "llvm/Option/ArgList.h"
-
-using namespace clang;
-using namespace llvm::opt;
-
-namespace {
-template 
-IntTy getLastArgIntValueImpl(const ArgList , OptSpecifier Id,
- IntTy Default, DiagnosticsEngine *Diags,
- unsigned Base) {
-  IntTy Res = Default;
-  if (Arg *A = Args.getLastArg(Id)) {
-if (StringRef(A->getValue()).getAsInteger(Base, Res)) {
-  if (Diags)
-Diags->Report(diag::err_drv_invalid_int_value)
-<< A->getAsString(Args) << A->getValue();
-}
-  }
-  return Res;
-}
-} // namespace
-
-namespace clang {
-
-int getLastArgIntValue(const ArgList , OptSpecifier Id, int Default,
-   DiagnosticsEngine *Diags, unsigned Base) {
-  return getLastArgIntValueImpl(Args, Id, Default, Diags, Base);
-}
-
-uint64_t getLastArgUInt64Value(const ArgList , OptSpecifier Id,
-   uint64_t Default, DiagnosticsEngine *Diags,
-   unsigned Base) {
-  return getLastArgIntValueImpl(Args, Id, Default, Diags, Base);
-}
-
-} // namespace clang
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Core
   MC
-  Option
   Support
   )
 
@@ -56,7 +55,6 @@
   ObjCRuntime.cpp
   OpenMPKinds.cpp
   OperatorPrecedence.cpp
-  OptionUtils.cpp
   SanitizerBlacklist.cpp
   SanitizerSpecialCaseList.cpp
   Sanitizers.cpp
Index: clang/include/clang/Frontend/Utils.h
===
--- clang/include/clang/Frontend/Utils.h
+++ clang/include/clang/Frontend/Utils.h
@@ -15,7 +15,7 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LLVM.h"

[PATCH] D71677: [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly.

2019-12-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61087 tests passed, 0 failed 
and 728 were skipped.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71677



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


[PATCH] D71080: [NFC] Separate getLastArgIntValue to Basic

2019-12-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D71080#1794066 , @thakis wrote:

> Why move this to Basic instead of to Driver if you want to use it in Driver? 
> (Frontend depends on Driver so it could then still use it.)


You are right. Driver is a better place. I will create a review for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71080



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


[PATCH] D71677: [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly.

2019-12-21 Thread Eric Astor via Phabricator via cfe-commits
epastor updated this revision to Diff 235035.
epastor marked an inline comment as done.
epastor added a comment.

Fix test; missing anchor meant the previous version would not catch a 
regression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71677

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/mozilla-ms-inline-asm.c
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGen/ms-inline-asm.cpp
  llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
  llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86Operand.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/test/CodeGen/X86/ms-inline-asm-PR44272.ll

Index: llvm/test/CodeGen/X86/ms-inline-asm-PR44272.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/ms-inline-asm-PR44272.ll
@@ -0,0 +1,18 @@
+; RUN: llc < %s -mtriple=i686-- | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s
+
+define void @func() {
+entry:
+  ret void
+}
+
+define void @main() {
+entry:
+  call void asm sideeffect inteldialect "call ${0:P}", "*m,~{dirflag},~{fpsr},~{flags}"(void ()* @func)
+  ret void
+; CHECK-LABEL: main:
+; CHECK: {{## InlineAsm Start|#APP}}
+; CHECK: {{call(l|q) func$}}
+; CHECK: {{## InlineAsm End|#NO_APP}}
+; CHECK: ret{{l|q}}
+}
Index: llvm/lib/Target/X86/X86AsmPrinter.h
===
--- llvm/lib/Target/X86/X86AsmPrinter.h
+++ llvm/lib/Target/X86/X86AsmPrinter.h
@@ -112,7 +112,7 @@
   void PrintMemReference(const MachineInstr *MI, unsigned OpNo, raw_ostream ,
  const char *Modifier);
   void PrintIntelMemReference(const MachineInstr *MI, unsigned OpNo,
-  raw_ostream );
+  raw_ostream , const char *Modifier);
 
 public:
   X86AsmPrinter(TargetMachine , std::unique_ptr Streamer);
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
===
--- llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -337,14 +337,22 @@
   PrintLeaMemReference(MI, OpNo, O, Modifier);
 }
 
+
 void X86AsmPrinter::PrintIntelMemReference(const MachineInstr *MI,
-   unsigned OpNo, raw_ostream ) {
+   unsigned OpNo, raw_ostream ,
+   const char *Modifier) {
   const MachineOperand  = MI->getOperand(OpNo + X86::AddrBaseReg);
   unsigned ScaleVal = MI->getOperand(OpNo + X86::AddrScaleAmt).getImm();
   const MachineOperand  = MI->getOperand(OpNo + X86::AddrIndexReg);
   const MachineOperand  = MI->getOperand(OpNo + X86::AddrDisp);
   const MachineOperand  = MI->getOperand(OpNo + X86::AddrSegmentReg);
 
+  // If we really don't want to print out (rip), don't.
+  bool HasBaseReg = BaseReg.getReg() != 0;
+  if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
+  BaseReg.getReg() == X86::RIP)
+HasBaseReg = false;
+
   // If this has a segment register, print it.
   if (SegReg.getReg()) {
 PrintOperand(MI, OpNo + X86::AddrSegmentReg, O);
@@ -354,7 +362,7 @@
   O << '[';
 
   bool NeedPlus = false;
-  if (BaseReg.getReg()) {
+  if (HasBaseReg) {
 PrintOperand(MI, OpNo + X86::AddrBaseReg, O);
 NeedPlus = true;
   }
@@ -372,7 +380,7 @@
 PrintOperand(MI, OpNo + X86::AddrDisp, O);
   } else {
 int64_t DispVal = DispSpec.getImm();
-if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
+if (DispVal || (!IndexReg.getReg() && !HasBaseReg)) {
   if (NeedPlus) {
 if (DispVal > 0)
   O << " + ";
@@ -525,11 +533,6 @@
 bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
   const char *ExtraCode,
   raw_ostream ) {
-  if (MI->getInlineAsmDialect() == InlineAsm::AD_Intel) {
-PrintIntelMemReference(MI, OpNo, O);
-return false;
-  }
-
   if (ExtraCode && ExtraCode[0]) {
 if (ExtraCode[1] != 0) return true; // Unknown modifier.
 
@@ -543,14 +546,26 @@
   // These only apply to registers, ignore on mem.
   break;
 case 'H':
-  PrintMemReference(MI, OpNo, O, "H");
+  if (MI->getInlineAsmDialect() == InlineAsm::AD_Intel) {
+return true;  // Unsupported modifier in Intel inline assembly.
+  } else {
+PrintMemReference(MI, OpNo, O, "H");
+  }
   return false;
 case 'P': // Don't print @PLT, but do print as memory.
-  PrintMemReference(MI, OpNo, O, "no-rip");
+  if (MI->getInlineAsmDialect() == InlineAsm::AD_Intel) {
+PrintIntelMemReference(MI, OpNo, O, "no-rip");
+  

[PATCH] D71677: [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly.

2019-12-21 Thread Eric Astor via Phabricator via cfe-commits
epastor marked 2 inline comments as done.
epastor added inline comments.



Comment at: llvm/test/CodeGen/X86/ms-inline-asm-PR44272.ll:15
+; CHECK: {{## InlineAsm Start|#APP}}
+; CHECK: call{{l|q}} func
+; CHECK: {{## InlineAsm End|#NO_APP}}

rnk wrote:
> I'd suggest matching for `{{call(l|q) func$}}` so that you don't accidentally 
> match `callq func(%rip)`. Which makes me wonder, does `@PLT` appear here? The 
> test uses no OS in the triple, which probably means ELF, so we probably use a 
> PLT.
Thanks for that catch - completely missed that it'd match with `(%rip)` on the 
end.

Interestingly... no, no `@PLT` in this test. Not sure what's up with that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71677



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


[PATCH] D71791: [CFG] Fix an assertion failure with static initializers

2019-12-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> I am not sure what would be the best way to test this change here.

A unittest, if you're brave :)




Comment at: clang/lib/Analysis/CFG.cpp:5923
+  if (isa(Cond) || isa(Cond))
 return nullptr;
 

Charusso wrote:
> What about the following?:
> ```lang=c
> if (const auto *E = dyn_cast(StmtElem->getStmt()))
>   return E->IgnoreParens();
> return nullptr;
> ```
Not [[ https://llvm.org/docs/CodingStandards.html#assert-liberally | fail-fast 
]] enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71791



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


[PATCH] D71080: [NFC] Separate getLastArgIntValue to Basic

2019-12-21 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Why move this to Basic instead of to Driver if you want to use it in Driver? 
(Frontend depends on Driver so it could then still use it.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71080



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


[PATCH] D71080: [NFC] Separate getLastArgIntValue to Basic

2019-12-21 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7376d9eb3891: [NFC] Separate getLastArgIntValue to Basic 
(authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71080

Files:
  clang/include/clang/Basic/OptionUtils.h
  clang/include/clang/Frontend/Utils.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/OptionUtils.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3716,35 +3716,8 @@
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }
 
-template
-static IntTy getLastArgIntValueImpl(const ArgList , OptSpecifier Id,
-IntTy Default,
-DiagnosticsEngine *Diags) {
-  IntTy Res = Default;
-  if (Arg *A = Args.getLastArg(Id)) {
-if (StringRef(A->getValue()).getAsInteger(10, Res)) {
-  if (Diags)
-Diags->Report(diag::err_drv_invalid_int_value) << A->getAsString(Args)
-   << A->getValue();
-}
-  }
-  return Res;
-}
-
 namespace clang {
 
-// Declared in clang/Frontend/Utils.h.
-int getLastArgIntValue(const ArgList , OptSpecifier Id, int Default,
-   DiagnosticsEngine *Diags) {
-  return getLastArgIntValueImpl(Args, Id, Default, Diags);
-}
-
-uint64_t getLastArgUInt64Value(const ArgList , OptSpecifier Id,
-   uint64_t Default,
-   DiagnosticsEngine *Diags) {
-  return getLastArgIntValueImpl(Args, Id, Default, Diags);
-}
-
 IntrusiveRefCntPtr
 createVFSFromCompilerInvocation(const CompilerInvocation ,
 DiagnosticsEngine ) {
Index: clang/lib/Basic/OptionUtils.cpp
===
--- /dev/null
+++ clang/lib/Basic/OptionUtils.cpp
@@ -0,0 +1,47 @@
+//===--- OptionUtils.cpp - Utilities for command line arguments ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/OptionUtils.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticDriver.h"
+#include "llvm/Option/ArgList.h"
+
+using namespace clang;
+using namespace llvm::opt;
+
+namespace {
+template 
+IntTy getLastArgIntValueImpl(const ArgList , OptSpecifier Id,
+ IntTy Default, DiagnosticsEngine *Diags,
+ unsigned Base) {
+  IntTy Res = Default;
+  if (Arg *A = Args.getLastArg(Id)) {
+if (StringRef(A->getValue()).getAsInteger(Base, Res)) {
+  if (Diags)
+Diags->Report(diag::err_drv_invalid_int_value)
+<< A->getAsString(Args) << A->getValue();
+}
+  }
+  return Res;
+}
+} // namespace
+
+namespace clang {
+
+int getLastArgIntValue(const ArgList , OptSpecifier Id, int Default,
+   DiagnosticsEngine *Diags, unsigned Base) {
+  return getLastArgIntValueImpl(Args, Id, Default, Diags, Base);
+}
+
+uint64_t getLastArgUInt64Value(const ArgList , OptSpecifier Id,
+   uint64_t Default, DiagnosticsEngine *Diags,
+   unsigned Base) {
+  return getLastArgIntValueImpl(Args, Id, Default, Diags, Base);
+}
+
+} // namespace clang
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   Core
   MC
+  Option
   Support
   )
 
@@ -55,6 +56,7 @@
   ObjCRuntime.cpp
   OpenMPKinds.cpp
   OperatorPrecedence.cpp
+  OptionUtils.cpp
   SanitizerBlacklist.cpp
   SanitizerSpecialCaseList.cpp
   Sanitizers.cpp
Index: clang/include/clang/Frontend/Utils.h
===
--- clang/include/clang/Frontend/Utils.h
+++ clang/include/clang/Frontend/Utils.h
@@ -15,6 +15,7 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/OptionUtils.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -34,12 +35,6 @@
 
 class Triple;
 
-namespace opt {
-
-class ArgList;
-
-} // namespace opt
-
 } // namespace llvm
 
 namespace clang {
@@ -230,29 +225,6 @@
 bool ShouldRecoverOnErrors = false,
 std::vector *CC1Args = nullptr);
 
-/// Return the value of the last argument as an integer, or a default. If Diags
-/// is non-null, emits 

[clang] 7376d9e - [NFC] Separate getLastArgIntValue to Basic

2019-12-21 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2019-12-21T20:39:31-05:00
New Revision: 7376d9eb38914ff7b6b5f5901d32743f0ee76b5a

URL: 
https://github.com/llvm/llvm-project/commit/7376d9eb38914ff7b6b5f5901d32743f0ee76b5a
DIFF: 
https://github.com/llvm/llvm-project/commit/7376d9eb38914ff7b6b5f5901d32743f0ee76b5a.diff

LOG: [NFC] Separate getLastArgIntValue to Basic

getLastArgIntValue is a useful utility function to get command line argument as 
an integer.
Currently it is in Frontend so that it can only be used by clang -cc1. Move it 
to basic so
that it can also be used by clang driver.

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

Added: 
clang/include/clang/Basic/OptionUtils.h
clang/lib/Basic/OptionUtils.cpp

Modified: 
clang/include/clang/Frontend/Utils.h
clang/lib/Basic/CMakeLists.txt
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/OptionUtils.h 
b/clang/include/clang/Basic/OptionUtils.h
new file mode 100644
index ..6254f758c2f0
--- /dev/null
+++ b/clang/include/clang/Basic/OptionUtils.h
@@ -0,0 +1,58 @@
+//===- OptionUtils.h - Utilities for command line arguments -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This header contains utilities for command line arguments.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_OPTIONUTILS_H
+#define LLVM_CLANG_BASIC_OPTIONUTILS_H
+
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/Option/OptSpecifier.h"
+
+namespace llvm {
+
+namespace opt {
+
+class ArgList;
+
+} // namespace opt
+
+} // namespace llvm
+
+namespace clang {
+/// Return the value of the last argument as an integer, or a default. If Diags
+/// is non-null, emits an error if the argument is given, but non-integral.
+int getLastArgIntValue(const llvm::opt::ArgList ,
+   llvm::opt::OptSpecifier Id, int Default,
+   DiagnosticsEngine *Diags = nullptr, unsigned Base = 0);
+
+inline int getLastArgIntValue(const llvm::opt::ArgList ,
+  llvm::opt::OptSpecifier Id, int Default,
+  DiagnosticsEngine , unsigned Base = 0) {
+  return getLastArgIntValue(Args, Id, Default, , Base);
+}
+
+uint64_t getLastArgUInt64Value(const llvm::opt::ArgList ,
+   llvm::opt::OptSpecifier Id, uint64_t Default,
+   DiagnosticsEngine *Diags = nullptr,
+   unsigned Base = 0);
+
+inline uint64_t getLastArgUInt64Value(const llvm::opt::ArgList ,
+  llvm::opt::OptSpecifier Id,
+  uint64_t Default,
+  DiagnosticsEngine ,
+  unsigned Base = 0) {
+  return getLastArgUInt64Value(Args, Id, Default, , Base);
+}
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_OPTIONUTILS_H

diff  --git a/clang/include/clang/Frontend/Utils.h 
b/clang/include/clang/Frontend/Utils.h
index 2b142122cb66..d5990d56ba28 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -15,6 +15,7 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/OptionUtils.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -34,12 +35,6 @@ namespace llvm {
 
 class Triple;
 
-namespace opt {
-
-class ArgList;
-
-} // namespace opt
-
 } // namespace llvm
 
 namespace clang {
@@ -230,29 +225,6 @@ std::unique_ptr 
createInvocationFromCommandLine(
 bool ShouldRecoverOnErrors = false,
 std::vector *CC1Args = nullptr);
 
-/// Return the value of the last argument as an integer, or a default. If Diags
-/// is non-null, emits an error if the argument is given, but non-integral.
-int getLastArgIntValue(const llvm::opt::ArgList ,
-   llvm::opt::OptSpecifier Id, int Default,
-   DiagnosticsEngine *Diags = nullptr);
-
-inline int getLastArgIntValue(const llvm::opt::ArgList ,
-  llvm::opt::OptSpecifier Id, int Default,
-  DiagnosticsEngine ) {
-  return getLastArgIntValue(Args, Id, Default, );
-}
-
-uint64_t getLastArgUInt64Value(const llvm::opt::ArgList ,
-   llvm::opt::OptSpecifier Id, uint64_t Default,
-   DiagnosticsEngine *Diags = nullptr);
-
-inline uint64_t getLastArgUInt64Value(const llvm::opt::ArgList ,
-

[PATCH] D71686: Fix false positive in magic number checker

2019-12-21 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- added a comment.

My take: this change fixes a user-reported bug, and does not cause any known 
regressions. I think we should integrate this.


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

https://reviews.llvm.org/D71686



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


[PATCH] D71791: [CFG] Fix an assertion failure with static initializers

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

> I am not sure what would be the best way to test this change here.

I'll admit, I'm a bit out of touch with Clang and will unfortunately be for a 
while, but the short answer is that the unit tests we have for the CFG are 
kinda bad. The constructed CFG has a longer lifetime than the AST its based on 
(see: D63538 ), so we would need to rewrite 
the `BuildCFG()` function that creates it. I have some memories digging into it 
but always got distracted :)

Until then, could you please include the crash you mentioned through a regular 
lit test?




Comment at: clang/lib/Analysis/CFG.cpp:5925-5926
 
   // Only ObjCForCollectionStmt is known not to be a non-Expr terminator, hence
   // the cast<>.
   return cast(Cond)->IgnoreParens();

I guess its time to update and/or move this comment a few lines up, maybe even 
add a descriptive assert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71791



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


[PATCH] D71677: [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly.

2019-12-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2871
+  // differently when referenced in MS-style inline assembly.
+  if (Name.startswith("call") || Name.startswith("lcall")) {
+for (size_t i = 1; i < Operands.size(); ++i) {

epastor wrote:
> rnk wrote:
> > I'm trying to think of other edge cases where we'd want the same treatment. 
> > In theory, we'd want to do this for every control flow instruction that 
> > takes a PC-relative operand, jmp, jcc, jecxz, that might be all. You know, 
> > it actually seems reasonable to set up a naked function that contains an 
> > asm blob which conditionally branches to another function, so I guess we 
> > should support it. In that case, maybe this should be named something like 
> > "isBranchTarget" instead of isCallTarget.
> That would be a valid option, but currently the "P" modifier is documented 
> for LLVM as to-be-used on the operands of `call` instructions. [[ 
> https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers | 
> GNU as ]]) adds it more generally to be applied to functions - and 
> occasionally constants, if you need a constant to avoid all syntax-specific 
> prefixes.
> 
> We could use this for any branch target operand... but we'd need to restrict 
> it to apply only to the specific PC-relative operand, which I think means 
> augmenting the X86 target tables to annotate which operands of which 
> instructions are PC-relative? Also, I'm not sure if that would break 
> pre-existing code in enough cases to be worrying.
I see, so LLVM inherited P from GCC, and it mostly relates to `sym@PLT` 
suffixes, but it also suppresses `sym(%rip)` suffixes, and it is specific to 
calls. In that case, this all makes sense, let's not overgeneralize to all 
branch targets.



Comment at: llvm/test/CodeGen/X86/ms-inline-asm-PR44272.ll:15
+; CHECK: {{## InlineAsm Start|#APP}}
+; CHECK: call{{l|q}} func
+; CHECK: {{## InlineAsm End|#NO_APP}}

I'd suggest matching for `{{call(l|q) func$}}` so that you don't accidentally 
match `callq func(%rip)`. Which makes me wonder, does `@PLT` appear here? The 
test uses no OS in the triple, which probably means ELF, so we probably use a 
PLT.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71677



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


[PATCH] D71221: [HIP] Add option --gpu-max-threads-per-block=n

2019-12-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 235025.
yaxunl added a comment.

revised by Artem's comments.


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

https://reviews.llvm.org/D71221

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
  clang/test/Driver/hip-options.hip

Index: clang/test/Driver/hip-options.hip
===
--- /dev/null
+++ clang/test/Driver/hip-options.hip
@@ -0,0 +1,10 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip --gpu-max-threads-per-block=1024 %s 2>&1 | FileCheck %s
+
+// Check that there are commands for both host- and device-side compilations.
+//
+// CHECK: clang{{.*}}" "-cc1" {{.*}} "-fcuda-is-device"
+// CHECK-SAME: "--gpu-max-threads-per-block=1024"
Index: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -1,13 +1,21 @@
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
-// RUN: -fcuda-is-device -emit-llvm -o - %s | FileCheck %s
+// RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
+// RUN: | FileCheck -check-prefixes=CHECK,DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa --gpu-max-threads-per-block=1024 \
+// RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
+// RUN: | FileCheck -check-prefixes=CHECK,MAX1024 %s
 // RUN: %clang_cc1 -triple nvptx \
 // RUN: -fcuda-is-device -emit-llvm -o - %s | FileCheck %s \
 // RUN: -check-prefix=NAMD
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
-// RUN: -verify -o - %s | FileCheck -check-prefix=NAMD %s
+// RUN: -verify -o - -x hip %s | FileCheck -check-prefix=NAMD %s
 
 #include "Inputs/cuda.h"
 
+__global__ void flat_work_group_size_default() {
+// CHECK: define amdgpu_kernel void @_Z28flat_work_group_size_defaultv() [[FLAT_WORK_GROUP_SIZE_DEFAULT:#[0-9]+]]
+}
+
 __attribute__((amdgpu_flat_work_group_size(32, 64))) // expected-no-diagnostics
 __global__ void flat_work_group_size_32_64() {
 // CHECK: define amdgpu_kernel void @_Z26flat_work_group_size_32_64v() [[FLAT_WORK_GROUP_SIZE_32_64:#[0-9]+]]
@@ -31,7 +39,9 @@
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind optnone "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind optnone "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind optnone "amdgpu-num-vgpr"="64" 
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
+// MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = {{.*}}"amdgpu-flat-work-group-size"="32,64"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = {{.*}}"amdgpu-num-sgpr"="32"
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = {{.*}}"amdgpu-num-vgpr"="64"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2559,6 +2559,12 @@
   << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
   }
   Opts.HIPUseNewLaunchAPI = Args.hasArg(OPT_fhip_new_launch_api);
+  if (Opts.HIP)
+Opts.GPUMaxThreadsPerBlock = getLastArgIntValue(
+Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock);
+  else if (Args.hasArg(OPT_gpu_max_threads_per_block_EQ))
+Diags.Report(diag::warn_ignored_hip_only_option)
+<< Args.getLastArg(OPT_gpu_max_threads_per_block_EQ)->getAsString(Args);
 
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -307,6 +307,14 @@
  false))
 CC1Args.push_back("-fgpu-rdc");
 
+  StringRef MaxThreadsPerBlock =
+  DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ);
+  if (!MaxThreadsPerBlock.empty()) {
+std::string ArgStr =
+std::string("--gpu-max-threads-per-block=") + MaxThreadsPerBlock.str();
+CC1Args.push_back(DriverArgs.MakeArgStringRef(ArgStr));
+  }
+
 

[PATCH] D71746: Fix the "TypeError: a bytes-like object is required, not 'str'" in exploded-graph-rewriter.py on Python 3.5+

2019-12-21 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2203089a60d8: [analyzer] exploded-graph-rewriter: Fix string 
encodings in python3. (authored by dergachev.a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71746

Files:
  clang/utils/analyzer/exploded-graph-rewriter.py


Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -18,6 +18,7 @@
 import logging
 import os
 import re
+import sys
 
 
 #===---===#
@@ -425,7 +426,10 @@
 
 def output(self):
 assert not self._dump_dot_only
-return ''.join(self._output)
+if sys.version_info[0] > 2 and sys.version_info[1] >= 5:
+return ''.join(self._output).encode()
+else:
+return ''.join(self._output)
 
 def _dump(self, s):
 s = s.replace('&', '') \


Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -18,6 +18,7 @@
 import logging
 import os
 import re
+import sys
 
 
 #===---===#
@@ -425,7 +426,10 @@
 
 def output(self):
 assert not self._dump_dot_only
-return ''.join(self._output)
+if sys.version_info[0] > 2 and sys.version_info[1] >= 5:
+return ''.join(self._output).encode()
+else:
+return ''.join(self._output)
 
 def _dump(self, s):
 s = s.replace('&', '') \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2203089 - [analyzer] exploded-graph-rewriter: Fix string encodings in python3.

2019-12-21 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2019-12-21T10:59:38-08:00
New Revision: 2203089a60d826e882e2ccfc5cc5d361b4f91078

URL: 
https://github.com/llvm/llvm-project/commit/2203089a60d826e882e2ccfc5cc5d361b4f91078
DIFF: 
https://github.com/llvm/llvm-project/commit/2203089a60d826e882e2ccfc5cc5d361b4f91078.diff

LOG: [analyzer] exploded-graph-rewriter: Fix string encodings in python3.

Makes sure that the script works fine both in python2 and python3.

Patch by Pavel Samolysov!

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

Added: 


Modified: 
clang/utils/analyzer/exploded-graph-rewriter.py

Removed: 




diff  --git a/clang/utils/analyzer/exploded-graph-rewriter.py 
b/clang/utils/analyzer/exploded-graph-rewriter.py
index 79055b433e8d..f47be59395a7 100755
--- a/clang/utils/analyzer/exploded-graph-rewriter.py
+++ b/clang/utils/analyzer/exploded-graph-rewriter.py
@@ -18,6 +18,7 @@
 import logging
 import os
 import re
+import sys
 
 
 #===---===#
@@ -425,7 +426,10 @@ def _dump_raw(self, s):
 
 def output(self):
 assert not self._dump_dot_only
-return ''.join(self._output)
+if sys.version_info[0] > 2 and sys.version_info[1] >= 5:
+return ''.join(self._output).encode()
+else:
+return ''.join(self._output)
 
 def _dump(self, s):
 s = s.replace('&', '') \



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


[PATCH] D45677: [libcxx] [test] Fix typo in filesystem test

2019-12-21 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

Jim, thanks for accepting the review.  Do you mind landing this on my behalf? I 
don't have commit rights.  Thanks!


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D45677



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


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2019-12-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: JDevlieghere.
dblaikie added a comment.

In D71451#1793828 , @Jac1494 wrote:

> > Am I reading this right that the data would suggest that enabling this 
> > feature /reduces/ the size of debug info sections? That doesn't sound right 
> > - can you explain why that would be the case? (perhaps the data is 
> > incorrect/it wasn't built with -fstandalone-debug?)
>
> Hi @dblaikie  sorry for incorrect data.
>
> Updated result are as per below:
>
> Without "-fstandalone-debug" option :-
>  $size -A -d build_debug_withoutstandalone/bin/clang-10
>  ...
>  ...
>  .comment 159 0
>  .debug_str   2655675 0
>  .debug_loc   941 0
>  .debug_abbrev  10761 0
>  .debug_info  1526674 0
>  .debug_ranges  46672 0
>  .debug_line   149807 0
>  .note.gnu.gold-version28 0
>  Total4786206
>
> With "-fstandalone-debug" option :-
>  $size -A -d build_debug_withstandalone/bin/clang-10
>  ...
>  ...
>  .comment 159 0
>  .debug_str   3997839 0
>  .debug_loc   941 0
>  .debug_abbrev  12746 0
>  .debug_info  2225392 0
>  .debug_ranges  46672 0
>  .debug_line   153779 0
>  .note.gnu.gold-version28 0
>  Total6833045


Ah, that looks more like what I'd expect - so that's a 42% increase in the 
final linked binary size? Yeah, that seems somewhat unlikely to be what anyone 
would want to enable, though I could be wrong (@aprantl @JDevlieghere - you 
folks use standalone-debug by default, have any opinions on this proposed 
change to standalone-debug behavior?)

Could you audit some files & see what sort of things are going in there? It 
might be that a more nuanced definition of "used" is needed.

For instance, does this global variable get emitted?

  extern int i;
  inline int f1() {
return i;
  }
  void f2() {
  }

'i' is used according to the AST, but it's not used even statically by this 
translation unit - f1 is never called here. So if this patch currently emits a 
declaration of 'i' then it shows one way there's some room for improvement - 
specifically I'd motivate the declaration emission by the IR usage itself - 
does the LLVM IR end up with a declaration of 'i' in it (for the purposes of 
loading/storing to it, etc) then add a declaration. This won't catch all cases 
(eg: "extern const int  i = 7; int f() { int x[i]; ... }" - there won't be any 
use of 'i' in the IR in that case), but would potentially be a workable 
tradeoff for now. Catching the "use of a global in a constant context" is part 
of a much broader challenge - to get that and some other existing cases like it 
right, we'd need some kind of reachability analysis of usage. That analysis 
could benefit other areas of debug info too, but is probably a lot more work.


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

https://reviews.llvm.org/D71451



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


[clang] fc5102f - [NFC] test commit reverted

2019-12-21 Thread Stepan Dyatkovskiy via cfe-commits

Author: Stepan Dyatkovskiy
Date: 2019-12-21T22:12:07+04:00
New Revision: fc5102fb6e3d4744c2bb9f0230d088a9777e69cb

URL: 
https://github.com/llvm/llvm-project/commit/fc5102fb6e3d4744c2bb9f0230d088a9777e69cb
DIFF: 
https://github.com/llvm/llvm-project/commit/fc5102fb6e3d4744c2bb9f0230d088a9777e69cb.diff

LOG: [NFC] test commit reverted

Added: 


Modified: 
clang/README.txt

Removed: 




diff  --git a/clang/README.txt b/clang/README.txt
index b5f33bb66dd3..91527b094856 100644
--- a/clang/README.txt
+++ b/clang/README.txt
@@ -24,4 +24,3 @@ on the Clang development mailing list:
 
 If you find a bug in Clang, please file it in the LLVM bug tracker:
   http://llvm.org/bugs/
-



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


[clang] 452ca8e - [NFC] test commit

2019-12-21 Thread Stepan Dyatkovskiy via cfe-commits

Author: Stepan Dyatkovskiy
Date: 2019-12-21T22:11:34+04:00
New Revision: 452ca8e73f26835f94bb3e274adb210d3c3ed5ea

URL: 
https://github.com/llvm/llvm-project/commit/452ca8e73f26835f94bb3e274adb210d3c3ed5ea
DIFF: 
https://github.com/llvm/llvm-project/commit/452ca8e73f26835f94bb3e274adb210d3c3ed5ea.diff

LOG: [NFC] test commit

Added: 


Modified: 
clang/README.txt

Removed: 




diff  --git a/clang/README.txt b/clang/README.txt
index 91527b094856..b5f33bb66dd3 100644
--- a/clang/README.txt
+++ b/clang/README.txt
@@ -24,3 +24,4 @@ on the Clang development mailing list:
 
 If you find a bug in Clang, please file it in the LLVM bug tracker:
   http://llvm.org/bugs/
+



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


[PATCH] D71512: [clang-format] Fix short block when braking after control statement

2019-12-21 Thread Pablo Martin-Gomez via Phabricator via cfe-commits
Bouska added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:586
   verifyFormat("if (true) {\n"
-   "  ff();\n"
"}",

MyDeveloperDay wrote:
> any reason you are changing existing tests?
According to the change that added this test 
(https://reviews.llvm.org/D37140?id=113074), this test was made to check that 
"the wrapping is forced by exceeding the column limit". This should be check at 
the limit condition when the control statement + the block exceed the column 
limit by a few characters. With the current test, the length of the block 
statement alone is sufficient to force the wrapping, that's why with the 
current code this test has the expected wrapping.

Even my change is incorrect, with the control statement, the curly braces, the 
spaces and the statement, it is way above the column limit of 40. I'm going to 
fix that. Alternatively, I just could add another test with the correct length. 
  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71512



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


[PATCH] D71775: [ThreadPool] On Windows, extend usage to all CPU sockets and all NUMA groups

2019-12-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D71775#1793767 , @mehdi_amini wrote:

> > Will it make sense to say "I don't want hyper-threads" ?
>
> Not sure I remember correctly, but I believe one motivation behind avoiding 
> "hyper-threads" and other virtual cores was that while they improve slightly 
> the performance, they also increase the peak memory requirements: using 
> heavyweight_hardware_concurrency() seemed like a good default tradeoff for 
> most end-users.


It all makes sense. After this patch, the memory consumption is doubled when 
using both CPU sockets. Evidently then there's also a discussion about memory 
bandwidth, which doesn't scale in my case, when using both sockets (possibly on 
a AMD Epyc it could be better because is has more memory channels.). This is 
also why enabling the second socket only marginally decrease the timings.

F5603: 6140_two_sockets.PNG 

In Ubisoft's case, time is immensely more valuable (both compute and human) 
than memory sticks. Historically we didn't really use LTO on game productions 
because it was really slow, and often introduced undesirable bugs or 
side-effects. The graphs in D71786  are for 
Rainbow 6: Siege, which is a "smaller" codebase. For larger games, LTO link 
time is more in the range of 1h 20min, both for MSVC and previous versions of 
Clang. If there's a LTO-specific bug in a final build, it is very hard to 
iterate with that kind of timings. In addition, there are hundreds of builds 
every day on the build system, and we want to keep all the cores in the build 
system busy. This is why both build and link times are important to us.

In D71775#1793768 , @mehdi_amini wrote:

> Also: using heavyweight_hardware_concurrency() in the linker but having 
> multiple linker jobs schedules by the build system was another reason (I 
> think LLVM CMake default to 2 parallel link jobs when using ThinLTO for 
> instance).


Understood. If one sets the CPU affinity when starting the application, ie. 
`start /affinity XXX lld-link.exe ...`, then this patch disables dispatching on 
other "processor groups", even if they are available. However, there doesn't 
seem to be a way to //restrain// the application to one "processor group".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71775



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


[clang] 7cee288 - Fix `-Wunused-variable` warning. NFC.

2019-12-21 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2019-12-21T11:10:35-05:00
New Revision: 7cee28858674d233903e92b7a0c49b07b05ed3d3

URL: 
https://github.com/llvm/llvm-project/commit/7cee28858674d233903e92b7a0c49b07b05ed3d3
DIFF: 
https://github.com/llvm/llvm-project/commit/7cee28858674d233903e92b7a0c49b07b05ed3d3.diff

LOG: Fix `-Wunused-variable` warning. NFC.

Added: 


Modified: 
clang/lib/Sema/SemaDeclObjC.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 4fdddfbb7a7e..5fdf6aeed5b4 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -4776,7 +4776,7 @@ Decl *Sema::ActOnMethodDeclaration(
 if (auto *Cat = dyn_cast(IMD->getDeclContext()))
   decl = Cat->IsClassExtension() ? 1 : 2;
 
-if (auto *Cat = dyn_cast(ImpDecl))
+if (isa(ImpDecl))
   impl = 1 + (decl != 0);
 
 Diag(ObjCMethod->getLocation(),



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


[PATCH] D69223: WDocumentation: Implement the \anchor.

2019-12-21 Thread Mark de Wever via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbe1a9b3863b6: [Wdocumentation] Implement \anchor (authored 
by Mordante).

Changed prior to commit:
  https://reviews.llvm.org/D69223?vs=231766=235016#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69223

Files:
  clang/bindings/xml/comment-xml-schema.rng
  clang/include/clang-c/Documentation.h
  clang/include/clang/AST/Comment.h
  clang/include/clang/AST/CommentCommands.td
  clang/lib/AST/CommentSema.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Index/CommentToXML.cpp
  clang/test/AST/ast-dump-comment.cpp
  clang/test/Index/Inputs/CommentXML/valid-inline-command-01.xml
  clang/test/Index/comment-to-html-xml-conversion.cpp
  clang/test/Index/comment-xml-schema.c
  clang/test/Sema/warn-documentation.cpp
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CXComment.cpp

Index: clang/tools/libclang/CXComment.cpp
===
--- clang/tools/libclang/CXComment.cpp
+++ clang/tools/libclang/CXComment.cpp
@@ -159,6 +159,9 @@
 
   case InlineCommandComment::RenderEmphasized:
 return CXCommentInlineCommandRenderKind_Emphasized;
+
+  case InlineCommandComment::RenderAnchor:
+return CXCommentInlineCommandRenderKind_Anchor;
   }
   llvm_unreachable("unknown InlineCommandComment::RenderKind");
 }
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -497,6 +497,9 @@
 case CXCommentInlineCommandRenderKind_Emphasized:
   printf(" RenderEmphasized");
   break;
+case CXCommentInlineCommandRenderKind_Anchor:
+  printf(" RenderAnchor");
+  break;
 }
 for (i = 0, e = clang_InlineCommandComment_getNumArgs(Comment);
  i != e; ++i) {
Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1102,6 +1102,13 @@
 /// \a A
 int test_inline_no_argument_a_good(int);
 
+// expected-warning@+1 {{'\anchor' command does not have a valid word argument}}
+/// \anchor
+int test_inline_no_argument_anchor_bad(int);
+
+/// \anchor A
+int test_inline_no_argument_anchor_good(int);
+
 // expected-warning@+1 {{'@b' command does not have a valid word argument}}
 /// @b
 int test_inline_no_argument_b_bad(int);
Index: clang/test/Index/comment-xml-schema.c
===
--- clang/test/Index/comment-xml-schema.c
+++ clang/test/Index/comment-xml-schema.c
@@ -33,6 +33,8 @@
 // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-enum-01.xml
 //
 // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-para-kind-01.xml
+//
+// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-inline-command-01.xml
 
 // RUN: not xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-01.xml 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID
 // RUN: not xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-02.xml 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID
Index: clang/test/Index/comment-to-html-xml-conversion.cpp
===
--- clang/test/Index/comment-to-html-xml-conversion.cpp
+++ clang/test/Index/comment-to-html-xml-conversion.cpp
@@ -734,6 +734,16 @@
 // CHECK-NEXT: (CXComment_Text Text=[Aaa])
 // CHECK-NEXT: (CXComment_HTMLEndTag Name=[h1])))]
 
+/// \anchor A
+void comment_to_html_conversion_37();
+
+// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_37:{{.*}} FullCommentAsHTML=[ ] FullCommentAsXML=[comment_to_html_conversion_37c:@F@comment_to_html_conversion_37#void comment_to_html_conversion_37() ]
+// CHECK-NEXT:  CommentAST=[
+// CHECK-NEXT:(CXComment_FullComment
+// CHECK-NEXT:   (CXComment_Paragraph
+// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)
+// CHECK-NEXT: (CXComment_InlineCommand CommandName=[anchor] RenderAnchor Arg[0]=A)))]
+
 
 /// Aaa.
 class comment_to_xml_conversion_01 {
Index: clang/test/Index/Inputs/CommentXML/valid-inline-command-01.xml
===
--- /dev/null
+++ clang/test/Index/Inputs/CommentXML/valid-inline-command-01.xml
@@ -0,0 +1,9 @@
+
+
+aaa
+
+  
+
+  
+
+
Index: clang/test/AST/ast-dump-comment.cpp
===
--- 

[PATCH] D70869: [Analyzer] Use a reference in a range-based for

2019-12-21 Thread Mark de Wever via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG70d592d68c7a: [Analyzer] Use a reference in a range-based 
for (authored by Mordante).

Changed prior to commit:
  https://reviews.llvm.org/D70869?vs=231593=235015#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70869

Files:
  clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -505,7 +505,7 @@
   // Recursively examine the base classes.
   // Note that following base classes does not increase the recursion depth.
   if (const auto *RDX = dyn_cast(RD))
-for (const auto II : RDX->bases())
+for (const auto  : RDX->bases())
   if (const RecordDecl *RRD = II.getType()->getAsRecordDecl())
 if (Optional Out =
 findRegionOfInterestInRecord(RRD, State, R, Vec, depth))
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -429,7 +429,7 @@
   // Keep symbolic expressions of iterator positions, container begins and ends
   // alive
   auto RegionMap = State->get();
-  for (const auto Reg : RegionMap) {
+  for (const auto  : RegionMap) {
 const auto Offset = Reg.second.getOffset();
 for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i)
   if (isa(*i))
@@ -437,7 +437,7 @@
   }
 
   auto SymbolMap = State->get();
-  for (const auto Sym : SymbolMap) {
+  for (const auto  : SymbolMap) {
 const auto Offset = Sym.second.getOffset();
 for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i)
   if (isa(*i))
@@ -445,7 +445,7 @@
   }
 
   auto ContMap = State->get();
-  for (const auto Cont : ContMap) {
+  for (const auto  : ContMap) {
 const auto CData = Cont.second;
 if (CData.getBegin()) {
   SR.markLive(CData.getBegin());
@@ -466,7 +466,7 @@
   auto State = C.getState();
 
   auto RegionMap = State->get();
-  for (const auto Reg : RegionMap) {
+  for (const auto  : RegionMap) {
 if (!SR.isLiveRegion(Reg.first)) {
   // The region behind the `LazyCompoundVal` is often cleaned up before
   // the `LazyCompoundVal` itself. If there are iterator positions keyed
@@ -478,14 +478,14 @@
   }
 
   auto SymbolMap = State->get();
-  for (const auto Sym : SymbolMap) {
+  for (const auto  : SymbolMap) {
 if (!SR.isLive(Sym.first)) {
   State = State->remove(Sym.first);
 }
   }
 
   auto ContMap = State->get();
-  for (const auto Cont : ContMap) {
+  for (const auto  : ContMap) {
 if (!SR.isLiveRegion(Cont.first)) {
   // We must keep the container data while it has live iterators to be able
   // to compare them to the begin and the end of the container.
@@ -1456,13 +1456,13 @@
 
 bool hasLiveIterators(ProgramStateRef State, const MemRegion *Cont) {
   auto RegionMap = State->get();
-  for (const auto Reg : RegionMap) {
+  for (const auto  : RegionMap) {
 if (Reg.second.getContainer() == Cont)
   return true;
   }
 
   auto SymbolMap = State->get();
-  for (const auto Sym : SymbolMap) {
+  for (const auto  : SymbolMap) {
 if (Sym.second.getContainer() == Cont)
   return true;
   }
@@ -1472,7 +1472,7 @@
 
 bool isBoundThroughLazyCompoundVal(const Environment ,
const MemRegion *Reg) {
-  for (const auto Binding: Env) {
+  for (const auto  : Env) {
 if (const auto LCVal = Binding.second.getAs()) {
   if (LCVal->getRegion() == Reg)
 return true;
@@ -1488,7 +1488,7 @@
   auto  = State->get_context();
   auto RegionMap = State->get();
   bool Changed = false;
-  for (const auto Reg : RegionMap) {
+  for (const auto  : RegionMap) {
 if (Cond(Reg.second)) {
   RegionMap = RegionMapFactory.add(RegionMap, Reg.first, Proc(Reg.second));
   Changed = true;
@@ -1501,7 +1501,7 @@
   auto  = State->get_context();
   auto SymbolMap = State->get();
   Changed = false;
-  for (const auto Sym : SymbolMap) {
+  for (const auto  : SymbolMap) {
 if (Cond(Sym.second)) {
   SymbolMap = SymbolMapFactory.add(SymbolMap, Sym.first, Proc(Sym.second));
   Changed = true;
Index: clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
@@ -62,7 +62,7 @@
 // lookup by region.
 bool isSymbolTracked(ProgramStateRef 

[clang] 70d592d - [Analyzer] Use a reference in a range-based for

2019-12-21 Thread Mark de Wever via cfe-commits

Author: Mark de Wever
Date: 2019-12-21T14:52:29+01:00
New Revision: 70d592d68c7a8666183308d1daa2322ede87df09

URL: 
https://github.com/llvm/llvm-project/commit/70d592d68c7a8666183308d1daa2322ede87df09
DIFF: 
https://github.com/llvm/llvm-project/commit/70d592d68c7a8666183308d1daa2322ede87df09.diff

LOG: [Analyzer] Use a reference in a range-based for

This avoids unneeded copies when using a range-based for loops.

This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
index b0d101c88517..dd89c53478e8 100644
--- a/clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
@@ -62,7 +62,7 @@ class InnerPointerChecker
 // lookup by region.
 bool isSymbolTracked(ProgramStateRef State, SymbolRef Sym) {
   RawPtrMapTy Map = State->get();
-  for (const auto Entry : Map) {
+  for (const auto  : Map) {
 if (Entry.second.contains(Sym))
   return true;
   }
@@ -236,7 +236,7 @@ void InnerPointerChecker::checkDeadSymbols(SymbolReaper 
,
   ProgramStateRef State = C.getState();
   PtrSet::Factory  = State->getStateManager().get_context();
   RawPtrMapTy RPM = State->get();
-  for (const auto Entry : RPM) {
+  for (const auto  : RPM) {
 if (!SymReaper.isLiveRegion(Entry.first)) {
   // Due to incomplete destructor support, some dead regions might
   // remain in the program state map. Clean them up.
@@ -266,7 +266,7 @@ std::unique_ptr 
getInnerPointerBRVisitor(SymbolRef Sym) {
 
 const MemRegion *getContainerObjRegion(ProgramStateRef State, SymbolRef Sym) {
   RawPtrMapTy Map = State->get();
-  for (const auto Entry : Map) {
+  for (const auto  : Map) {
 if (Entry.second.contains(Sym)) {
   return Entry.first;
 }

diff  --git a/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
index ab4e8112d677..f47776c711ad 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -429,7 +429,7 @@ void IteratorModeling::checkLiveSymbols(ProgramStateRef 
State,
   // Keep symbolic expressions of iterator positions, container begins and ends
   // alive
   auto RegionMap = State->get();
-  for (const auto Reg : RegionMap) {
+  for (const auto  : RegionMap) {
 const auto Offset = Reg.second.getOffset();
 for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i)
   if (isa(*i))
@@ -437,7 +437,7 @@ void IteratorModeling::checkLiveSymbols(ProgramStateRef 
State,
   }
 
   auto SymbolMap = State->get();
-  for (const auto Sym : SymbolMap) {
+  for (const auto  : SymbolMap) {
 const auto Offset = Sym.second.getOffset();
 for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i)
   if (isa(*i))
@@ -445,7 +445,7 @@ void IteratorModeling::checkLiveSymbols(ProgramStateRef 
State,
   }
 
   auto ContMap = State->get();
-  for (const auto Cont : ContMap) {
+  for (const auto  : ContMap) {
 const auto CData = Cont.second;
 if (CData.getBegin()) {
   SR.markLive(CData.getBegin());
@@ -466,7 +466,7 @@ void IteratorModeling::checkDeadSymbols(SymbolReaper ,
   auto State = C.getState();
 
   auto RegionMap = State->get();
-  for (const auto Reg : RegionMap) {
+  for (const auto  : RegionMap) {
 if (!SR.isLiveRegion(Reg.first)) {
   // The region behind the `LazyCompoundVal` is often cleaned up before
   // the `LazyCompoundVal` itself. If there are iterator positions keyed
@@ -478,14 +478,14 @@ void IteratorModeling::checkDeadSymbols(SymbolReaper ,
   }
 
   auto SymbolMap = State->get();
-  for (const auto Sym : SymbolMap) {
+  for (const auto  : SymbolMap) {
 if (!SR.isLive(Sym.first)) {
   State = State->remove(Sym.first);
 }
   }
 
   auto ContMap = State->get();
-  for (const auto Cont : ContMap) {
+  for (const auto  : ContMap) {
 if (!SR.isLiveRegion(Cont.first)) {
   // We must keep the container data while it has live iterators to be able
   // to compare them to the begin and the end of the container.
@@ -1456,13 +1456,13 @@ ProgramStateRef relateSymbols(ProgramStateRef State, 
SymbolRef Sym1,
 
 bool hasLiveIterators(ProgramStateRef State, const MemRegion *Cont) {
   auto RegionMap = State->get();
-  for (const auto Reg : RegionMap) {
+  for (const auto  : RegionMap) {
 if (Reg.second.getContainer() == Cont)
   return true;
   }
 
   auto SymbolMap = State->get();
-  for (const 

[clang] be1a9b3 - [Wdocumentation] Implement \anchor

2019-12-21 Thread Mark de Wever via cfe-commits

Author: Mark de Wever
Date: 2019-12-21T14:52:21+01:00
New Revision: be1a9b3863b6649ef64f25c22394335c47f2ef31

URL: 
https://github.com/llvm/llvm-project/commit/be1a9b3863b6649ef64f25c22394335c47f2ef31
DIFF: 
https://github.com/llvm/llvm-project/commit/be1a9b3863b6649ef64f25c22394335c47f2ef31.diff

LOG: [Wdocumentation] Implement \anchor

Differential revision: https://reviews.llvm.org/D69223

Added: 
clang/test/Index/Inputs/CommentXML/valid-inline-command-01.xml

Modified: 
clang/bindings/xml/comment-xml-schema.rng
clang/include/clang-c/Documentation.h
clang/include/clang/AST/Comment.h
clang/include/clang/AST/CommentCommands.td
clang/lib/AST/CommentSema.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Index/CommentToXML.cpp
clang/test/AST/ast-dump-comment.cpp
clang/test/Index/comment-to-html-xml-conversion.cpp
clang/test/Index/comment-xml-schema.c
clang/test/Sema/warn-documentation.cpp
clang/tools/c-index-test/c-index-test.c
clang/tools/libclang/CXComment.cpp

Removed: 




diff  --git a/clang/bindings/xml/comment-xml-schema.rng 
b/clang/bindings/xml/comment-xml-schema.rng
index 43f3e54c2863..65ea597ed70c 100644
--- a/clang/bindings/xml/comment-xml-schema.rng
+++ b/clang/bindings/xml/comment-xml-schema.rng
@@ -579,6 +579,14 @@
   .*\S.*
 
   
+  
+
+  
+
+\S+
+  
+
+  
   
 
   

diff  --git a/clang/include/clang-c/Documentation.h 
b/clang/include/clang-c/Documentation.h
index ad3dd3bc78be..5bece2cb6758 100644
--- a/clang/include/clang-c/Documentation.h
+++ b/clang/include/clang-c/Documentation.h
@@ -181,7 +181,12 @@ enum CXCommentInlineCommandRenderKind {
* Command argument should be rendered emphasized (typically italic
* font).
*/
-  CXCommentInlineCommandRenderKind_Emphasized
+  CXCommentInlineCommandRenderKind_Emphasized,
+
+  /**
+   * Command argument should not be rendered (since it only defines an anchor).
+   */
+  CXCommentInlineCommandRenderKind_Anchor
 };
 
 /**

diff  --git a/clang/include/clang/AST/Comment.h 
b/clang/include/clang/AST/Comment.h
index 2c284a271bb7..cd9c1ce2bce0 100644
--- a/clang/include/clang/AST/Comment.h
+++ b/clang/include/clang/AST/Comment.h
@@ -94,10 +94,11 @@ class Comment {
 
 unsigned : NumInlineContentCommentBits;
 
-unsigned RenderKind : 2;
+unsigned RenderKind : 3;
+
 unsigned CommandID : CommandInfo::NumCommandIDBits;
   };
-  enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 2 +
+  enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 3 +
CommandInfo::NumCommandIDBits };
 
   class HTMLTagCommentBitfields {
@@ -310,7 +311,8 @@ class InlineCommandComment : public InlineContentComment {
 RenderNormal,
 RenderBold,
 RenderMonospaced,
-RenderEmphasized
+RenderEmphasized,
+RenderAnchor
   };
 
 protected:

diff  --git a/clang/include/clang/AST/CommentCommands.td 
b/clang/include/clang/AST/CommentCommands.td
index 3b0d1603d407..d387df7ce570 100644
--- a/clang/include/clang/AST/CommentCommands.td
+++ b/clang/include/clang/AST/CommentCommands.td
@@ -81,12 +81,13 @@ class RecordLikeDeclarationVerbatimLineCommand 
:
 // InlineCommand
 
//===--===//
 
-def B  : InlineCommand<"b">;
-def C  : InlineCommand<"c">;
-def P  : InlineCommand<"p">;
-def A  : InlineCommand<"a">;
-def E  : InlineCommand<"e">;
-def Em : InlineCommand<"em">;
+def B  : InlineCommand<"b">;
+def C  : InlineCommand<"c">;
+def P  : InlineCommand<"p">;
+def A  : InlineCommand<"a">;
+def E  : InlineCommand<"e">;
+def Em : InlineCommand<"em">;
+def Anchor : InlineCommand<"anchor">;
 
 
//===--===//
 // BlockCommand

diff  --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index dda31e906017..53c1832d1dd2 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -1143,6 +1143,7 @@ Sema::getInlineCommandRenderKind(StringRef Name) const {
   .Case("b", InlineCommandComment::RenderBold)
   .Cases("c", "p", InlineCommandComment::RenderMonospaced)
   .Cases("a", "e", "em", InlineCommandComment::RenderEmphasized)
+  .Case("anchor", InlineCommandComment::RenderAnchor)
   .Default(InlineCommandComment::RenderNormal);
 }
 

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 40c6c8375a60..c30b07137edc 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -1518,6 +1518,9 @@ void JSONNodeDumper::visitInlineCommandComment(
   case comments::InlineCommandComment::RenderMonospaced:
 JOS.attribute("renderKind", "monospaced");
 break;

[clang] 75e500d - Add missing `REQUIRES: hexagon-registered-target`

2019-12-21 Thread David Zarzycki via cfe-commits

Author: David Zarzycki
Date: 2019-12-21T06:45:30-05:00
New Revision: 75e500dd4713e785f0ca7afc37e7ba206a4391b0

URL: 
https://github.com/llvm/llvm-project/commit/75e500dd4713e785f0ca7afc37e7ba206a4391b0
DIFF: 
https://github.com/llvm/llvm-project/commit/75e500dd4713e785f0ca7afc37e7ba206a4391b0.diff

LOG: Add missing `REQUIRES: hexagon-registered-target`

After d567b0ba841d4b6f4b0d906da350a3bb2b2f769f, the test suite no longer
passes if hexagon is disabled.

Added: 


Modified: 
clang/test/Driver/hexagon-toolchain-elf.c

Removed: 




diff  --git a/clang/test/Driver/hexagon-toolchain-elf.c 
b/clang/test/Driver/hexagon-toolchain-elf.c
index 0339619e1c1f..cf7d8bdb3931 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -545,6 +545,7 @@
 // RUN:   -mcpu=hexagonv60 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK081 %s
+// REQUIRES: hexagon-registered-target
 // CHECK081:  "-march=hexagon"
 // CHECK081:  "-mcpu=hexagonv60"
 // 
-



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


[PATCH] D70265: [clang-tidy] Add clang tidy check I.2 to cppcoreguidelines

2019-12-21 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:26
+  hasType(isConstQualified()),
+  hasType(referenceType()), // References can't be changed, only data
+// they reference can be changed

Please write the comments as full sentences with punctuation. I think `... only 
the data they reference ...`.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:32
+
+  const auto GlobalReferenceToNonConst =
+  varDecl(hasGlobalStorage(), hasType(referenceType()),

The matchers here are not pointers/references. Therefore, the llvm guidelines 
say they should not be `const`.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:64
+
+  if (Variable) {
+diag(Variable->getLocation(), "variable %0 is non-const and globally "

each of those `if`s should `return` early, or could multiple match?
If only one can match the structure could be changed a bit to
```
if (const auto* Variable = 
Result.Nodes.getNodeAs("non-const_variable")) {
diag(...);
return;
}
```

If you change the order of the `if`s in the order of matches you expect to 
happen most, this should be a bit faster as well, as retrieving the matches 
introduces some overhead that is not relevant in the current situation.

If you keep only one statement within the `if` you should ellide the braces, 
per coding convention.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:107
+
+  Finds non-const global variables as described in check I.2 of cpp core
+  guidelines.

The official name is "C++ Core Guidelines", i think we should stick to that.
And please ellide the new empty line above.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-non-const-global-variables.rst:6
+
+Finds non-const global variables as described in check I.2 of cpp core
+guidelines.

Please add a link to the affected section and provide a small example (can be 
the example from the guidelines) what is diagnosed and why.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp:46
+  int nonConstMemberVariable = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: member variable 
'nonConstMemberVariable' is globally accessible and non-const, consider making 
it const [cppcoreguidelines-avoid-non-const-global-variables]
+  const int constMemberVariable = 0;

diagnosing those might be undesired. maybe having an option to enable/disable 
this would be nice?
We should try to allow reducing the noise level of clang-tidy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[clang] 5a79cfa - Customize simplified dumping and matching of LambdaExpr

2019-12-21 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2019-12-21T11:02:11Z
New Revision: 5a79cfa32d62f018607438a30b7acb49c2ab97f3

URL: 
https://github.com/llvm/llvm-project/commit/5a79cfa32d62f018607438a30b7acb49c2ab97f3
DIFF: 
https://github.com/llvm/llvm-project/commit/5a79cfa32d62f018607438a30b7acb49c2ab97f3.diff

LOG: Customize simplified dumping and matching of LambdaExpr

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/ASTNodeTraverser.h
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/AST/ASTTraverserTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTNodeTraverser.h 
b/clang/include/clang/AST/ASTNodeTraverser.h
index f097d024c9e8..9dab814b659b 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -128,9 +128,12 @@ class ASTNodeTraverser
   ConstStmtVisitor::Visit(S);
 
   // Some statements have custom mechanisms for dumping their children.
-  if (isa(S) || isa(S)) {
+  if (isa(S) || isa(S))
+return;
+
+  if (isa(S) &&
+  Traversal == ast_type_traits::TK_IgnoreUnlessSpelledInSource)
 return;
-  }
 
   for (const Stmt *SubStmt : S->children())
 Visit(SubStmt);
@@ -646,7 +649,23 @@ class ASTNodeTraverser
   }
 
   void VisitLambdaExpr(const LambdaExpr *Node) {
-Visit(Node->getLambdaClass());
+if (Traversal == ast_type_traits::TK_IgnoreUnlessSpelledInSource) {
+  for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
+const auto *C = Node->capture_begin() + I;
+if (!C->isExplicit())
+  continue;
+if (Node->isInitCapture(C))
+  Visit(C->getCapturedVar());
+else
+  Visit(Node->capture_init_begin()[I]);
+  }
+  dumpTemplateParameters(Node->getTemplateParameterList());
+  for (const auto *P : Node->getCallOperator()->parameters())
+Visit(P);
+  Visit(Node->getBody());
+} else {
+  return Visit(Node->getLambdaClass());
+}
   }
 
   void VisitSizeOfPackExpr(const SizeOfPackExpr *Node) {

diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 8ac35d522843..ab90c745791c 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -138,20 +138,32 @@ class MatchChildASTVisitor
 ScopedIncrement ScopedDepth();
 return (DeclNode == nullptr) || traverse(*DeclNode);
   }
-  bool TraverseStmt(Stmt *StmtNode, DataRecursionQueue *Queue = nullptr) {
-// If we need to keep track of the depth, we can't perform data recursion.
-if (CurrentDepth == 0 || (CurrentDepth <= MaxDepth && MaxDepth < INT_MAX))
-  Queue = nullptr;
 
-ScopedIncrement ScopedDepth();
+  Stmt *getStmtToTraverse(Stmt *StmtNode) {
 Stmt *StmtToTraverse = StmtNode;
-if (auto *ExprNode = dyn_cast_or_null(StmtNode))
-  StmtToTraverse = Finder->getASTContext().traverseIgnored(ExprNode);
+if (auto *ExprNode = dyn_cast_or_null(StmtNode)) {
+  auto *LambdaNode = dyn_cast_or_null(StmtNode);
+  if (LambdaNode && Finder->getASTContext().getTraversalKind() ==
+  ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+StmtToTraverse = LambdaNode;
+  else
+StmtToTraverse = Finder->getASTContext().traverseIgnored(ExprNode);
+}
 if (Traversal ==
 ast_type_traits::TraversalKind::TK_IgnoreImplicitCastsAndParentheses) {
   if (Expr *ExprNode = dyn_cast_or_null(StmtNode))
 StmtToTraverse = ExprNode->IgnoreParenImpCasts();
 }
+return StmtToTraverse;
+  }
+
+  bool TraverseStmt(Stmt *StmtNode, DataRecursionQueue *Queue = nullptr) {
+// If we need to keep track of the depth, we can't perform data recursion.
+if (CurrentDepth == 0 || (CurrentDepth <= MaxDepth && MaxDepth < INT_MAX))
+  Queue = nullptr;
+
+ScopedIncrement ScopedDepth();
+Stmt *StmtToTraverse = getStmtToTraverse(StmtNode);
 if (!StmtToTraverse)
   return true;
 if (!match(*StmtToTraverse))
@@ -203,6 +215,41 @@ class MatchChildASTVisitor
 ScopedIncrement ScopedDepth();
 return traverse(*CtorInit);
   }
+  bool TraverseLambdaExpr(LambdaExpr *Node) {
+if (Finder->getASTContext().getTraversalKind() !=
+ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+  return VisitorBase::TraverseLambdaExpr(Node);
+if (!Node)
+  return true;
+ScopedIncrement ScopedDepth();
+
+for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
+  const auto *C = Node->capture_begin() + I;
+  if (!C->isExplicit())
+continue;
+  if (Node->isInitCapture(C) && !match(*C->getCapturedVar()))
+return false;
+  if 

[clang] a0ce615 - clang is now under the apache2 license

2019-12-21 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2019-12-21T10:52:30+01:00
New Revision: a0ce6155734eaaea315dc82579b230b172fb8ccc

URL: 
https://github.com/llvm/llvm-project/commit/a0ce6155734eaaea315dc82579b230b172fb8ccc
DIFF: 
https://github.com/llvm/llvm-project/commit/a0ce6155734eaaea315dc82579b230b172fb8ccc.diff

LOG: clang is now under the apache2 license

Added: 


Modified: 
clang/www/features.html
clang/www/index.html

Removed: 




diff  --git a/clang/www/features.html b/clang/www/features.html
index 715c9d18dcab..d0b4a7f30fd3 100755
--- a/clang/www/features.html
+++ b/clang/www/features.html
@@ -269,19 +269,18 @@ Integration with IDEs
 
 
 
-Use the LLVM 'BSD' License
+Use the LLVM 'Apache 2' License
 
 
 We actively intend for clang (and LLVM as a whole) to be used for
 commercial projects, not only as a stand-alone compiler but also as a library
-embedded inside a proprietary application.  The BSD license is the simplest way
-to allow this.  We feel that the license encourages contributors to pick up the
-source and work with it, and believe that those individuals and organizations
-will contribute back their work if they do not want to have to maintain a fork
-forever (which is time consuming and expensive when merges are involved).
-Further, nobody makes money on compilers these days, but many people need them
-to get bigger goals accomplished: it makes sense for everyone to work
-together.
+embedded inside a proprietary application. We feel that the license encourages
+contributors to pick up the source and work with it, and believe that those
+individuals and organizations will contribute back their work if they do not
+want to have to maintain a fork forever (which is time consuming and expensive
+when merges are involved). Further, nobody makes money on compilers these days,
+but many people need them to get bigger goals accomplished: it makes sense for
+everyone to work together.
 
 For more information about the LLVM/clang license, please see the https://llvm.org/docs/DeveloperPolicy.html#copyright-license-and-patents;>LLVM
 License

diff  --git a/clang/www/index.html b/clang/www/index.html
index ed826b8ebbdf..ce400d6153d3 100755
--- a/clang/www/index.html
+++ b/clang/www/index.html
@@ -44,7 +44,7 @@ Features and Goals
   Support diverse clients (refactoring, static analysis, code generation,
etc.)
   Allow tight integration with IDEs
-  Use the LLVM 'BSD' License
+  Use the LLVM 'Apache 2' License
   
 
   Internal Design and



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


[clang] 384a287 - Remove a gcc 4.9 comparison as it doesn't make sense

2019-12-21 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2019-12-21T10:46:45+01:00
New Revision: 384a287a87ad0989624eb785293d38f9b710

URL: 
https://github.com/llvm/llvm-project/commit/384a287a87ad0989624eb785293d38f9b710
DIFF: 
https://github.com/llvm/llvm-project/commit/384a287a87ad0989624eb785293d38f9b710.diff

LOG: Remove a gcc 4.9 comparison as it doesn't make sense

Added: 


Modified: 
clang/www/features.html

Removed: 




diff  --git a/clang/www/features.html b/clang/www/features.html
index aeab4e56969d..715c9d18dcab 100755
--- a/clang/www/features.html
+++ b/clang/www/features.html
@@ -91,15 +91,9 @@ Expressive Diagnostics
 highlighting related information so that it is easy to understand at a glance,
 and making the wording as clear as possible.
 
-Here is one simple example that illustrates the 
diff erence between a typical
-GCC and Clang diagnostic:
+Here is one simple example that illustrates the quality of Clang 
diagnostic:
 
 
-  $ gcc-4.9 -fsyntax-only t.c
-  t.c: In function 'int f(int, int)':
-  t.c:7:39: error: invalid operands to binary + (have 'int' and 'struct A')
- return y + func(y ? ((SomeA.X + 40) + SomeA) / 42 + SomeA.X : SomeA.X);
- ^
   $ clang -fsyntax-only t.c
   t.c:7:39: error: invalid operands to binary expression ('int' and 'struct A')
 return y + func(y ? ((SomeA.X + 40) + SomeA) 
/ 42 + SomeA.X : SomeA.X);
@@ -122,7 +116,7 @@ GCC Compatibility
 
 
 GCC is currently the defacto-standard open source compiler today, and it
-routinely compiles a huge volume of code.  GCC supports a huge number of
+routinely compiles a huge volume of code. GCC supports a huge number of
 extensions and features (many of which are undocumented) and a lot of
 code and header files depend on these features in order to build.
 



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


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2019-12-21 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 added a comment.

> Am I reading this right that the data would suggest that enabling this 
> feature /reduces/ the size of debug info sections? That doesn't sound right - 
> can you explain why that would be the case? (perhaps the data is incorrect/it 
> wasn't built with -fstandalone-debug?)

Hi @dblaikie  sorry for incorrect data.

Updated result are as per below:

Without "-fstandalone-debug" option :-
...
...
.comment 159 0
.debug_str   2655675 0
.debug_loc   941 0
.debug_abbrev  10761 0
.debug_info  1526674 0
.debug_ranges  46672 0
.debug_line   149807 0
.note.gnu.gold-version28 0
Total4786206

With "-fstandalone-debug" option :-
...
...
.comment 159 0
.debug_str   3997839 0
.debug_loc   941 0
.debug_abbrev  12746 0
.debug_info  2225392 0
.debug_ranges  46672 0
.debug_line   153779 0
.note.gnu.gold-version28 0
Total6833045


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

https://reviews.llvm.org/D71451



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


[PATCH] D59520: [WebAssembly] Address review comments on r352930

2019-12-21 Thread Dan Gohman via Phabricator via cfe-commits
sunfish marked 10 inline comments as done.
sunfish added a comment.

I apologize for the extraordinary delays here; at long last, I've now addressed 
your feedback.




Comment at: lib/Sema/SemaDeclAttr.cpp:5781-5783
+Sema::mergeImportNameAttr(Decl *D, SourceRange Range,
+  StringRef Name,
+  unsigned AttrSpellingListIndex) {

aaron.ballman wrote:
> I wonder if we want to generalize this with a template (for the attribute 
> type) if we could generalize the diagnostic text a bit more (or add an 
> additional parameter for it)?
The diagnostic name is now generalized, but it seems awkward to pass around the 
numbers to pick which variant of the string to use, so I didn't implement this 
yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59520



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


[PATCH] D59520: [WebAssembly] Address review comments on r352930

2019-12-21 Thread Dan Gohman via Phabricator via cfe-commits
sunfish updated this revision to Diff 235005.
sunfish added a comment.

Address review feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59520

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-wasm.c

Index: clang/test/Sema/attr-wasm.c
===
--- /dev/null
+++ clang/test/Sema/attr-wasm.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+
+void name_a() __attribute__((import_name)); //expected-error {{'import_name' attribute takes one argument}}
+
+int name_b __attribute__((import_name("foo"))); //expected-error {{'import_name' attribute only applies to functions}}
+
+void name_c() __attribute__((import_name("foo", "bar"))); //expected-error {{'import_name' attribute takes one argument}}
+
+void name_d() __attribute__((import_name("foo", "bar", "qux"))); //expected-error {{'import_name' attribute takes one argument}}
+
+__attribute__((import_name("foo"))) void name_e() {} //FIXME-expected-error {{import name cannot be applied to a function with a definition}}
+
+void name_z() __attribute__((import_name("foo"))); //expected-note {{previous attribute is here}}
+
+void name_z() __attribute__((import_name("bar"))); //expected-warning {{import name does not match previous declaration}}
+
+void module_a() __attribute__((import_module)); //expected-error {{'import_module' attribute takes one argument}}
+
+int module_b __attribute__((import_module("foo"))); //expected-error {{'import_module' attribute only applies to functions}}
+
+void module_c() __attribute__((import_module("foo", "bar"))); //expected-error {{'import_module' attribute takes one argument}}
+
+void module_d() __attribute__((import_module("foo", "bar", "qux"))); //expected-error {{'import_module' attribute takes one argument}}
+
+void module_e() __attribute__((import_module("foo"))) {} //FIXME-expected-error {{import module cannot be applied to a function with a definition}}
+
+void module_z() __attribute__((import_module("foo"))); //expected-note {{previous attribute is here}}
+
+void module_z() __attribute__((import_module("bar"))); //expected-warning {{import module does not match previous declaration}}
+
+void both() __attribute__((import_name("foo"), import_module("bar")));
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5776,45 +5776,73 @@
   D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
-static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const ParsedAttr ) {
-  if (!isFunctionOrMethod(D)) {
-S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
-<< "'import_module'" << ExpectedFunction;
-return;
+WebAssemblyImportModuleAttr *
+Sema::mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr ) {
+  auto *FD = cast(D);
+
+  if (const auto *ExistingAttr = FD->getAttr()) {
+if (ExistingAttr->getImportModule() == AL.getImportModule())
+  return nullptr;
+Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0;
+Diag(AL.getLoc(), diag::note_previous_attribute);
+return nullptr;
+  }
+  if (FD->hasBody()) {
+Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
+return nullptr;
   }
+  return ::new (Context) WebAssemblyImportModuleAttr(Context, AL,
+ AL.getImportModule());
+}
 
+WebAssemblyImportNameAttr *
+Sema::mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr ) {
   auto *FD = cast(D);
-  if (FD->isThisDeclarationADefinition()) {
-S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
-return;
+
+  if (const auto *ExistingAttr = FD->getAttr()) {
+if (ExistingAttr->getImportName() == AL.getImportName())
+  return nullptr;
+Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 1;
+Diag(AL.getLoc(), diag::note_previous_attribute);
+return nullptr;
+  }
+  if (FD->hasBody()) {
+Diag(AL.getLoc(), diag::warn_import_on_definition) << 1;
+return nullptr;
   }
+  return ::new (Context) WebAssemblyImportNameAttr(Context, AL,
+   AL.getImportName());
+}
+
+static void
+handleWebAssemblyImportModuleAttr(Sema , Decl *D, const ParsedAttr ) {
+  auto *FD = cast(D);
 
   StringRef Str;
   SourceLocation ArgLoc;
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, ))
 return;
+  if (FD->hasBody()) {
+S.Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
+return;
+  }
 
   FD->addAttr(::new (S.Context)
   WebAssemblyImportModuleAttr(S.Context, AL, Str));
 }
 
-static void handleWebAssemblyImportNameAttr(Sema , Decl