[clang] 073cdb2 - [clang][test] Minor fixes in testcase absolute-paths-symlinks.c

2019-12-26 Thread Karl-Johan Karlsson via cfe-commits

Author: Karl-Johan Karlsson
Date: 2019-12-26T09:33:21+01:00
New Revision: 073cdb239044dc056a3c79b995265f640ffb40e6

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

LOG: [clang][test] Minor fixes in testcase absolute-paths-symlinks.c

This is a follow up commit to address post-commit comment in D70527.

Added: 


Modified: 
clang/test/Frontend/absolute-paths-symlinks.c

Removed: 




diff  --git a/clang/test/Frontend/absolute-paths-symlinks.c 
b/clang/test/Frontend/absolute-paths-symlinks.c
index e91a96fc0922..8170910b6f6e 100644
--- a/clang/test/Frontend/absolute-paths-symlinks.c
+++ b/clang/test/Frontend/absolute-paths-symlinks.c
@@ -1,9 +1,9 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
-// RUN: cp "%s" "test.c"
-// RUN: ln -sf "test.c" "link.c"
-// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-absolute-paths "link.c" 
2>&1|FileCheck %s
+// RUN: cp %s test.c
+// RUN: ln -sf test.c link.c
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-absolute-paths link.c 2>&1 
| FileCheck %s
 
 // Verify that -fdiagnostics-absolute-paths resolve symbolic links in
 // diagnostics messages.
@@ -13,3 +13,5 @@
 This do not compile
 
 // REQUIRES: shell
+// Don't make symlinks on Windows.
+// UNSUPPORTED: system-windows



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


[PATCH] D70527: [clang] Fix the canonicalization of paths in -fdiagnostics-absolute-paths

2019-12-26 Thread Karl-Johan Karlsson via Phabricator via cfe-commits
Ka-Ka marked 3 inline comments as done.
Ka-Ka added a comment.

I have now updated the testcase according to comments by @MaskRay in commit 
073cdb239044 

Thanks for post-commit review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70527



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


[PATCH] D71903: [Coroutines][6/6] Clang schedules new passes

2019-12-26 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
modocache added reviewers: GorNishanov, lewissbaker, chandlerc, junparser.
Herald added subscribers: cfe-commits, EricWF.
Herald added a project: clang.

Depends on https://reviews.llvm.org/D71902.

The last in a series of six patches that ports the LLVM coroutines
passes to the new pass manager infrastructure.

This patch has Clang schedule the new coroutines passes when the
`-fexperimental-new-pass-manager` option is used. With this and the
previous 5 patches, Clang is capable of building and successfully
running the test suite of large coroutines projects such as
https://github.com/lewissbaker/cppcoro with
`ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=On`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71903

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp


Index: clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -0,0 +1,18 @@
+// Tests that coroutine passes are added to and run by the new pass manager
+// pipeline, at -O0 and above.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
+// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
+// RUN:   -O1 %s 2>&1 | FileCheck %s
+//
+// CHECK: Starting llvm::Module pass manager run.
+// CHECK: Running pass:{{.*}}CoroEarlyPass
+// CHECK: Running pass:{{.*}}CoroSplitPass
+// CHECK: Running pass:{{.*}}CoroElidePass
+// CHECK: Running pass:{{.*}}CoroSplitPass
+// CHECK: Running pass:{{.*}}CoroCleanupPass
+// CHECK: Finished llvm::Module pass manager run.
+void foo() {}
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,10 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Transforms/Coroutines.h"
+#include "llvm/Transforms/Coroutines/CoroCleanup.h"
+#include "llvm/Transforms/Coroutines/CoroEarly.h"
+#include "llvm/Transforms/Coroutines/CoroElide.h"
+#include "llvm/Transforms/Coroutines/CoroSplit.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
@@ -1133,6 +1137,16 @@
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))
 MPM.addPass(createModuleToFunctionPassAdaptor(BoundsCheckingPass()));
 
+  // For IR that makes use of coroutines intrinsics, coroutine passes must
+  // be run, even at -O0.
+  if (LangOpts.Coroutines) {
+MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass()));
+MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CoroSplitPass()));
+MPM.addPass(createModuleToFunctionPassAdaptor(CoroElidePass()));
+MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CoroSplitPass()));
+MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
+  }
+
   // Lastly, add semantically necessary passes for LTO.
   if (IsLTO || IsThinLTO) {
 MPM.addPass(CanonicalizeAliasesPass());
@@ -1206,6 +1220,15 @@
   MPM.addPass(InstrProfiling(*Options, false));
 });
 
+  if (LangOpts.Coroutines)
+PB.registerPipelineStartEPCallback([](ModulePassManager &MPM) {
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass()));
+  
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CoroSplitPass()));
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroElidePass()));
+  
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CoroSplitPass()));
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
+});
+
   if (IsThinLTO) {
 MPM = PB.buildThinLTOPreLinkDefaultPipeline(
 Level, CodeGenOpts.DebugPassManager);


Index: clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -0,0 +1,18 @@
+// Tests that coroutine passes are added to and run by the new pass manager
+// pipeline, at -O0 and above.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O1 %s 2>&1 | FileCheck %s
+//
+// CHECK: Starting llvm::Module pass manager run.
+// CHECK: 

[PATCH] D71907: [WPD/VFE] Always emit vcall_visibility metadata for -fwhole-program-vtables

2019-12-26 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: pcc, ostannard, evgeny777, steven_wu.
Herald added subscribers: dexonsmith, hiraditya, Prazek, mehdi_amini.
Herald added projects: clang, LLVM.

First patch to support Safe Whole Program Devirtualization Enablement,
see RFC here: http://lists.llvm.org/pipermail/llvm-dev/2019-December/137543.html

Always emit !vcall_visibility metadata under -fwhole-program-vtables,
and not just for -fvirtual-function-elimination. The vcall visibility
metadata will (in a subsequent patch) be used to communicate to WPD
which vtables are safe to devirtualize, and we will optionally convert
the metadata to hidden visibility at link time. Subsequent follow on
patches will help enable this by adding vcall_visibility metadata to the
ThinLTO summaries, and always emit type test intrinsics under
-fwhole-program-vtables (and not just for vtables with hidden
visibility).

In order to do this safely with VFE, since for VFE all vtable loads must
be type checked loads which will no longer be the case, this patch adds
a new "Virtual Function Elim" module flag to communicate to GlobalDCE
whether to perform VFE using the vcall_visibility metadata.

One additional advantage of using the vcall_visibility metadata to drive
more WPD at LTO link time is that we can use the same mechanism to
enable more aggressive VFE at LTO link time as well. The link time
option proposed in the RFC will convert vcall_visibility metadata to
hidden (aka linkage unit visibility), which combined with
-fvirtual-function-elimination will allow it to be done more
aggressively at LTO link time under the same conditions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71907

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
  llvm/include/llvm/IR/GlobalObject.h
  llvm/lib/IR/Metadata.cpp
  llvm/lib/Transforms/IPO/GlobalDCE.cpp
  llvm/lib/Transforms/IPO/GlobalSplit.cpp
  llvm/test/Transforms/GlobalDCE/virtual-functions-base-call.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-base-pointer-call.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-derived-call.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-derived-pointer-call.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-novfe.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll
  llvm/test/Transforms/GlobalDCE/virtual-functions.ll
  llvm/test/Transforms/GlobalDCE/vtable-rtti.ll

Index: llvm/test/Transforms/GlobalDCE/vtable-rtti.ll
===
--- llvm/test/Transforms/GlobalDCE/vtable-rtti.ll
+++ llvm/test/Transforms/GlobalDCE/vtable-rtti.ll
@@ -39,9 +39,10 @@
 declare dso_local noalias nonnull i8* @_Znwm(i64)
 @_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8*
 
-!llvm.module.flags = !{!3}
+!llvm.module.flags = !{!3, !4}
 
 !0 = !{i64 16, !"_ZTS1A"}
 !1 = !{i64 16, !"_ZTSM1AFvvE.virtual"}
 !2 = !{i64 2} ; translation-unit vcall visibility
 !3 = !{i32 1, !"LTOPostLink", i32 1}
+!4 = !{i32 1, !"Virtual Function Elim", i32 1}
Index: llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll
===
--- llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll
+++ llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll
@@ -85,10 +85,11 @@
 
 declare dso_local noalias nonnull i8* @_Znwm(i64)
 
-!llvm.module.flags = !{}
+!llvm.module.flags = !{!5}
 
 !0 = !{i64 16, !"_ZTS1A"}
 !1 = !{i64 16, !"_ZTSM1AFvvE.virtual"}
 !2 = !{i64 0} ; public vcall visibility
 !3 = !{i64 1} ; linkage-unit vcall visibility
 !4 = !{i64 2} ; translation-unit vcall visibility
+!5 = !{i32 1, !"Virtual Function Elim", i32 1}
Index: llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll
===
--- llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll
+++ llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll
@@ -85,7 +85,7 @@
 
 declare dso_local noalias nonnull i8* @_Znwm(i64)
 
-!llvm.module.flags = !{!5}
+!llvm.module.flags = !{!5, !6}
 
 !0 = !{i64 16, !"_ZTS1A"}
 !1 = !{i64 16, !"_ZTSM1AFvvE.virtual"}
@@ -93,3 +93,4 @@
 !3 = !{i64 1} ; linkage-unit vcall visibility
 !4 = !{i64 2} ; translation-unit vcall visibility
 !5 = !{i32 1, !"LTOPostLink", i32 1}
+!6 = !{i32 1, !"Virtual Function Elim", i32 1}
Index: llvm/test/Transforms/GlobalDCE/virtual-functions.ll
===
--- llvm/test/Transforms/GlobalDCE/virtual-functions.ll
+++ llvm/test/Transforms/GlobalDCE/virtual-functions.ll
@@ -48,8 +48,11 @@
   ret i32 %call1
 }
 
+!llvm.module.flags = !{!4}
+
 !0 = !{i64 16, !"_ZTS1A"}
 !1 = !{i64 16, !"_ZT

[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2019-12-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.
Herald added a subscriber: whisperity.

In D71707#1791394 , @jankratochvil 
wrote:

> In D71707#1791280 , @labath wrote:
>
> > - disallowing casts to intptr_t seems too restrictive -- I doubt many 
> > people are doing that, but I guess this type exists for a reason, and since 
> > the type (and it's signedness) is spelled out in the source, it shouldn't 
> > be too surprising that sign-extension can happen later
>
>
> I was trying to find what is `intptr_t` good for and I haven't found any 
> valid reason. It seems to me nobody knows that either. Which is why I find 
> correct to report it. This checker has many false positives (or "not really a 
> bug") anyway.


I agree that restricting casts to `intptr_t` is too restrictive. `intptr_t` is 
good for all the same things as `uintptr_t` -- it depends on why you want to 
use the pointer value as an integer value as to what it is good for.

I'm also concerned about the number of false positives found by this checker, 
but I think fixing this would fix some of the more egregious false positives.

>> - requiring a literal uintptr_t (or a typedef of it) may be also problematic 
>> -- the user could obtain an integer type of the same bit width through some 
>> other means (e.g. `#ifdef`). OTOH, without that (and just checking the bit 
>> width for instance), one would have to actually compile for a 32-bit target 
>> to get this warning. I don't know what's the practice for this in 
>> clang-tidy...
> 
> Yes, I wanted first to check the widths but then I realized user would need a 
> 32-bit host for that which is too difficult to (1) get nowadays and (2) 
> primarily to build there LLVM.

Have you considered language extensions like `__ptr32`, `__ptr64`, `__sptr`, 
and `__uptr` 
(https://docs.microsoft.com/en-us/cpp/cpp/ptr32-ptr64?view=vs-2019) which we 
also support? I think those probably should factor into this new check as well.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp:21-22
+void PointerCastWideningCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus && !getLangOpts().C99)
+return;
+

Why limiting this to C++ and >= C99? You can get pointer widening casts through 
extensions in C89, for instance.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp:24
+
+  
Finder->addMatcher(castExpr(unless(isInTemplateInstantiation())).bind("cast"),
+ this);

I think you should use `hasCastKind()` in this matcher as well.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp:36
+  for (QualType DestTypeCheck = DestType;;) {
+if (DestTypeCheck.getAsString() == "uintptr_t")
+  return;

How well does this work with something like `std::uinptr_t` from ``?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp:3
+
+#include 
+

You should replicate the contents of the system header rather than including it 
for tests -- this ensures you are testing the same thing on all platforms.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp:11
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: do not use cast of a pointer 
'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may 
sign-extend [bugprone-pointer-cast-widening]
+  intptr_t ip = reinterpret_cast(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not use cast of a pointer 
'void *' to non-uintptr_t 'intptr_t' (aka 'long') which may sign-extend 
[bugprone-pointer-cast-widening]

This should not diagnose.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp:17
+  t2 t = (t2)p;
+}

I'd also like to see tests for implicit casts as well as pointer width and sign 
extension language extensions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707



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


[clang] 6c5d1f4 - [OpenMP][NFCI] Use the libFrontend ProcBindKind in Clang

2019-12-26 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2019-12-26T11:04:07-06:00
New Revision: 6c5d1f40ff8deb2c001736c5a5bc085322910ad1

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

LOG: [OpenMP][NFCI] Use the libFrontend ProcBindKind in Clang

This removes the OpenMPProcBindClauseKind enum in favor of
llvm::omp::ProcBindKind which lives in OpenMPConstants.h and was
introduced in D70109.

No change in behavior is expected.

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index d47951682658..26f8389f9cfa 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -30,6 +30,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/TrailingObjects.h"
@@ -945,7 +946,7 @@ class OMPProcBindClause : public OMPClause {
   SourceLocation LParenLoc;
 
   /// A kind of the 'proc_bind' clause.
-  OpenMPProcBindClauseKind Kind = OMPC_PROC_BIND_unknown;
+  llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown;
 
   /// Start location of the kind in source code.
   SourceLocation KindKwLoc;
@@ -953,7 +954,7 @@ class OMPProcBindClause : public OMPClause {
   /// Set kind of the clause.
   ///
   /// \param K Kind of clause.
-  void setProcBindKind(OpenMPProcBindClauseKind K) { Kind = K; }
+  void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; }
 
   /// Set clause kind location.
   ///
@@ -969,7 +970,7 @@ class OMPProcBindClause : public OMPClause {
   /// \param StartLoc Starting location of the clause.
   /// \param LParenLoc Location of '('.
   /// \param EndLoc Ending location of the clause.
-  OMPProcBindClause(OpenMPProcBindClauseKind A, SourceLocation ALoc,
+  OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc,
 SourceLocation StartLoc, SourceLocation LParenLoc,
 SourceLocation EndLoc)
   : OMPClause(OMPC_proc_bind, StartLoc, EndLoc), LParenLoc(LParenLoc),
@@ -986,7 +987,7 @@ class OMPProcBindClause : public OMPClause {
   SourceLocation getLParenLoc() const { return LParenLoc; }
 
   /// Returns kind of the clause.
-  OpenMPProcBindClauseKind getProcBindKind() const { return Kind; }
+  llvm::omp::ProcBindKind getProcBindKind() const { return Kind; }
 
   /// Returns location of clause kind.
   SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; }

diff  --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index 25a4f652d155..38e8c3204475 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -110,9 +110,6 @@
 #ifndef OPENMP_DEFAULT_KIND
 #  define OPENMP_DEFAULT_KIND(Name)
 #endif
-#ifndef OPENMP_PROC_BIND_KIND
-#  define OPENMP_PROC_BIND_KIND(Name)
-#endif
 #ifndef OPENMP_SCHEDULE_KIND
 #define OPENMP_SCHEDULE_KIND(Name)
 #endif
@@ -358,11 +355,6 @@ OPENMP_CANCEL_CLAUSE(if)
 OPENMP_DEFAULT_KIND(none)
 OPENMP_DEFAULT_KIND(shared)
 
-// Static attributes for 'proc_bind' clause.
-OPENMP_PROC_BIND_KIND(master)
-OPENMP_PROC_BIND_KIND(close)
-OPENMP_PROC_BIND_KIND(spread)
-
 // Static attributes for 'schedule' clause.
 OPENMP_SCHEDULE_KIND(static)
 OPENMP_SCHEDULE_KIND(dynamic)
@@ -1081,7 +1073,6 @@ OPENMP_LASTPRIVATE_KIND(conditional)
 #undef OPENMP_DEPEND_KIND
 #undef OPENMP_SCHEDULE_MODIFIER
 #undef OPENMP_SCHEDULE_KIND
-#undef OPENMP_PROC_BIND_KIND
 #undef OPENMP_DEFAULT_KIND
 #undef OPENMP_CLAUSE
 #undef OPENMP_CRITICAL_CLAUSE

diff  --git a/clang/include/clang/Basic/OpenMPKinds.h 
b/clang/include/clang/Basic/OpenMPKinds.h
index 9572528d5c3e..302312325308 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -81,14 +81,6 @@ enum OpenMPDefaultClauseKind {
   OMPC_DEFAULT_unknown
 };
 
-

[PATCH] D71842: Allow newlines in AST Matchers in clang-query files

2019-12-26 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 235353.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71842

Files:
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-query/Query.h
  clang-tools-extra/clang-query/QueryParser.cpp
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
  clang/include/clang/ASTMatchers/Dynamic/Parser.h
  clang/lib/ASTMatchers/Dynamic/Parser.cpp
  clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Index: clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -207,10 +207,12 @@
 
 TEST(ParserTest, FullParserTest) {
   Diagnostics Error;
-  llvm::Optional VarDecl(Parser::parseMatcherExpression(
+
+  StringRef Code =
   "varDecl(hasInitializer(binaryOperator(hasLHS(integerLiteral()),"
-  "  hasOperatorName(\"+\"",
-  &Error));
+  "  hasOperatorName(\"+\"";
+  llvm::Optional VarDecl(
+  Parser::parseMatcherExpression(Code, &Error));
   EXPECT_EQ("", Error.toStringFull());
   Matcher M = VarDecl->unconditionalConvertTo();
   EXPECT_TRUE(matches("int x = 1 + false;", M));
@@ -218,8 +220,9 @@
   EXPECT_FALSE(matches("int x = 1 - false;", M));
   EXPECT_FALSE(matches("int x = true - 1;", M));
 
-  llvm::Optional HasParameter(Parser::parseMatcherExpression(
-  "functionDecl(hasParameter(1, hasName(\"x\")))", &Error));
+  Code = "functionDecl(hasParameter(1, hasName(\"x\")))";
+  llvm::Optional HasParameter(
+  Parser::parseMatcherExpression(Code, &Error));
   EXPECT_EQ("", Error.toStringFull());
   M = HasParameter->unconditionalConvertTo();
 
@@ -228,20 +231,18 @@
 
   // Test named values.
   auto NamedValues = getTestNamedValues();
+
+  Code = "functionDecl(hasParamA, hasParameter(1, hasName(nameX)))";
   llvm::Optional HasParameterWithNamedValues(
-  Parser::parseMatcherExpression(
-  "functionDecl(hasParamA, hasParameter(1, hasName(nameX)))",
-  nullptr, &NamedValues, &Error));
+  Parser::parseMatcherExpression(Code, nullptr, &NamedValues, &Error));
   EXPECT_EQ("", Error.toStringFull());
   M = HasParameterWithNamedValues->unconditionalConvertTo();
 
   EXPECT_TRUE(matches("void f(int a, int x);", M));
   EXPECT_FALSE(matches("void f(int x, int a);", M));
 
-
-  EXPECT_TRUE(!Parser::parseMatcherExpression(
-   "hasInitializer(\nbinaryOperator(hasLHS(\"A\")))",
-   &Error).hasValue());
+  Code = "hasInitializer(\nbinaryOperator(hasLHS(\"A\")))";
+  EXPECT_TRUE(!Parser::parseMatcherExpression(Code, &Error).hasValue());
   EXPECT_EQ("1:1: Error parsing argument 1 for matcher hasInitializer.\n"
 "2:5: Error parsing argument 1 for matcher binaryOperator.\n"
 "2:20: Error building matcher hasLHS.\n"
@@ -252,9 +253,11 @@
 
 TEST(ParserTest, VariadicMatchTest) {
   Diagnostics Error;
-  llvm::Optional OM(Parser::parseMatcherExpression(
-  "stmt(objcMessageExpr(hasAnySelector(\"methodA\", \"methodB:\")))",
-  &Error));
+
+  StringRef Code =
+  "stmt(objcMessageExpr(hasAnySelector(\"methodA\", \"methodB:\")))";
+  llvm::Optional OM(
+  Parser::parseMatcherExpression(Code, &Error));
   EXPECT_EQ("", Error.toStringFull());
   auto M = OM->unconditionalConvertTo();
   EXPECT_TRUE(matchesObjC("@interface I @end "
@@ -324,15 +327,132 @@
 ParseWithError("callee(\"A\")"));
 }
 
+TEST(ParserTest, ParseMultiline) {
+  StringRef Code;
+
+  llvm::Optional M;
+  {
+Code = R"matcher(varDecl(
+  hasName("foo")
+  )
+)matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(varDecl(
+  # Internal comment
+  hasName("foo") # Internal comment
+# Internal comment
+  )
+)matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(decl().bind(
+  "paramName")
+)matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(decl().bind(
+  "paramName"
+  )
+)matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(decl(decl()
+, decl()))matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(decl(decl(),
+decl()))matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = "namedDecl(hasName(\"n\"\n))";
+Diagnostics Error;
+EXPECT_TRUE

[PATCH] D71842: Allow newlines in AST Matchers in clang-query files

2019-12-26 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked 9 inline comments as done.
steveire added inline comments.



Comment at: clang-tools-extra/clang-query/Query.cpp:111
+  }
+  int maxLength = firstLine.size();
   std::string prefixText = "Matcher: ";

aaron.ballman wrote:
> `MaxLength` and perhaps this type should be `unsigned` or `size_t` rather 
> than `int` to avoid the unnecessary type conversion?
This is where `auto` makes most sense, but I made it `unsigned` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71842



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


[PATCH] D71907: [WPD/VFE] Always emit vcall_visibility metadata for -fwhole-program-vtables

2019-12-26 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson marked an inline comment as done.
tejohnson added inline comments.



Comment at: llvm/lib/IR/Metadata.cpp:1505
+  // updating.
+  eraseMetadata(LLVMContext::MD_vcall_visibility);
   addMetadata(LLVMContext::MD_vcall_visibility,

The erasing of old metadata is needed to enable upgrading the visibility to 
hidden (linkage unit) in a subsequent patch. Made that change here as well as 
the associated rename of the method to try to contain the main vcall visibility 
metadata changes in a single patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71907



___
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-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.
Herald added a subscriber: whisperity.



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

vingeldal wrote:
> JonasToth wrote:
> > 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.
> There could be multiple matches but there could still be some early returns.
> An example of a multi match would be:
> 
> namespace {
> int i = 0;
> }
> int * i_ptr = &i;
> 
> There would be two warnings for i_ptr, since it is:
>  1. A global non-const variable it self and...
>  2. because it globally exposes the non-const variable i.
> 
> I'll add early returns where possible.
> 
> ...Now that I think about it I realize I'v missed checking for member 
> variables referencing or pointing to non-const data,
> I'll add that tigether with some more testing.
Based on my reading of the C++ core guideline, I think there should be a 
different two diagnostics. One for the declaration of `i` and one for the 
declaration of `i_ptr`, because of this from the rule:

> The rule against global variables applies to namespace scope variables as 
> well.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:29
+  unless(anyOf(
+  isConstexpr(), hasDeclContext(namespaceDecl(isAnonymous())),
+  hasType(isConstQualified()),

Why are you filtering out anonymous namespaces?



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

I'd sink the local variables into the if statement:
```
if (const auto *Var = Result.Nodes.getNodeAs("non-const_variable")) {
  ...
}
```
(If you don't want to wrap lines, you can make the string literals a bit 
shorter.)



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:106
+ "variable %0 provides global access to non-const type, consider "
+ "making the pointed to data const")
+<< Pointer; // FIXME: Add fix-it hint to Pointer

pointed to -> pointed-to



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:120
+if (MemberReference) {
+  ;
+  diag(MemberReference->getLocation(),

Spurious semicolon



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:123-124
+   "member variable %0 provides global access to non-const type, "
+   "consider "
+   "making the referenced data const")
+  << MemberReference; // FIXME: Add fix-it hint to MemberReference

Can re-flow this string literal.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:130
+if (MemberPointer) {
+  ;
+  diag(MemberPointer->getLocation(),

Spurious semicolon.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:133
+   "member variable %0 provides global access to non-const type, "
+   "consider "
+   "making the pointed to data const")

Can re-flow this string literal.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:134
+   "consider "
+   "making the pointed to data const")
+  << MemberPointer; // FIXME: Add fix-it hint to MemberPointer

pointed to -> pointed-to



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-non-const-global-variables.rst:9
+By default this check considers public member variables to be global variables,
+there is an option, NoMembers, to turn of checks of member variables.
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ri-global

Add backticks around things that should be in code font like `NoMembers`.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguideline

[PATCH] D70289: [OpenMP][NFCI] Use the libFrontend ProcBindKind in Clang

2019-12-26 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c5d1f40ff8d: [OpenMP][NFCI] Use the libFrontend 
ProcBindKind in Clang (authored by jdoerfert).
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D70289?vs=229446&id=235356#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70289

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -247,7 +247,7 @@
   auto FiniCB = [&](InsertPointTy CodeGenIP) { ++NumFinalizationPoints; };
 
   IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
-  Loc, BodyGenCB, PrivCB, FiniCB, nullptr, nullptr, OMP_PB_default, false);
+  Loc, BodyGenCB, PrivCB, FiniCB, nullptr, nullptr, OMP_PROC_BIND_default, false);
 
   EXPECT_EQ(NumBodiesGenerated, 1U);
   EXPECT_EQ(NumPrivatizedVars, 1U);
@@ -342,7 +342,7 @@
 
   IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
   Loc, BodyGenCB, PrivCB, FiniCB, Builder.CreateIsNotNull(F->arg_begin()),
-  nullptr, OMP_PB_default, false);
+  nullptr, OMP_PROC_BIND_default, false);
 
   EXPECT_EQ(NumBodiesGenerated, 1U);
   EXPECT_EQ(NumPrivatizedVars, 1U);
@@ -466,7 +466,7 @@
 
   IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
   Loc, BodyGenCB, PrivCB, FiniCB, Builder.CreateIsNotNull(F->arg_begin()),
-  nullptr, OMP_PB_default, true);
+  nullptr, OMP_PROC_BIND_default, true);
 
   EXPECT_EQ(NumBodiesGenerated, 1U);
   EXPECT_EQ(NumPrivatizedVars, 0U);
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -271,7 +271,7 @@
 getOrCreateRuntimeFunction(OMPRTL___kmpc_push_num_threads), Args);
   }
 
-  if (ProcBind != OMP_PB_default) {
+  if (ProcBind != OMP_PROC_BIND_default) {
 // Build call __kmpc_push_proc_bind(&Ident, global_tid, proc_bind)
 Value *Args[] = {
 Ident, ThreadID,
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -250,7 +250,7 @@
 #endif
 
 #define __OMP_PROC_BIND_KIND(Name, Value)  \
-  OMP_PROC_BIND_KIND(OMP_PB_##Name, #Name, Value)
+  OMP_PROC_BIND_KIND(OMP_PROC_BIND_##Name, #Name, Value)
 
 __OMP_PROC_BIND_KIND(master, 2)
 __OMP_PROC_BIND_KIND(close, 3)
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6090,7 +6090,7 @@
 }
 
 void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *C) {
-  Record.push_back(C->getProcBindKind());
+  Record.push_back(unsigned(C->getProcBindKind()));
   Record.AddSourceLocation(C->getLParenLoc());
   Record.AddSourceLocation(C->getProcBindKindKwLoc());
 }
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -11771,8 +11771,7 @@
 }
 
 void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
-  C->setProcBindKind(
-   static_cast(Record.readInt()));
+  C->setProcBindKind(static_cast(Record.readInt()));
   C->setLParenLoc(Record.readSourceLocation());
   C->setProcBindKindKwLoc(Record.readSourceLocation());
 }
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -1616,7 +1616,7 @@
   ///
   /// By default, performs semantic analysis to build the new OpenMP clause.
   /// Subclasses may override this routine to provide different behavior.
-  OMPClause *RebuildOMPProcBindClause(OpenMPProcBindClauseKind Kind,
+  OMPClause *RebuildOMPProcBindClause(ProcBindKind Kind,
 

[PATCH] D70876: [clang-tidy] Add spuriously-wake-up-functions check

2019-12-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp:22
+  auto hasUniqueLock = hasDescendant(declRefExpr(hasDeclaration(
+  varDecl(hasType(asString("std::unique_lock"));
+

These should all use `::std::whatever` to guard against pathological code that 
uses `std` inside of another namespace.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp:80
+Str << " or used with a condition parameter";
+  diag(MatchedWait->getExprLoc(), Str.str().str()) << waitName;
+}

This should be simplified into:
```
const auto *MatchedWait = Result.Nodes.getNodeAs("wait");
StringRef WaitName = MatchedWait->getDirectCallee()->getName();
diag(MatchedWait->getExprLoc(), "'%0' should be placed inside a while statement 
%select{|or used with a conditional parameter}1") << WaitName << (WaitName != 
"cnd_wait" && WaitName != cnd_timedwait);
```



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-spuriously-wake-up-functions.rst:6
+
+Finds ``cnd_wait``, ``wait``, ``wait_for``, or ``wait_until`` function calls
+when the function is not invoked from a loop that checks whether a condition

Missing `cnd_timedwait`



Comment at: 
clang-tools-extra/test/clang-tidy/Inputs/bugprone-spuriously-wake-up-functions/chrono.h:49
+} // namespace std
\ No newline at end of file


Please add a newline to the end of the file.



Comment at: 
clang-tools-extra/test/clang-tidy/Inputs/bugprone-spuriously-wake-up-functions/condition_variable.h:41
+} // namespace std
\ No newline at end of file


Please add a newline to the end of the file.



Comment at: 
clang-tools-extra/test/clang-tidy/Inputs/bugprone-spuriously-wake-up-functions/cstdint.h:4
+}
\ No newline at end of file


Please add a newline to the end of the file.



Comment at: 
clang-tools-extra/test/clang-tidy/Inputs/bugprone-spuriously-wake-up-functions/mutex.h:20
+} // namespace std
\ No newline at end of file


Please add a newline to the end of the file.



Comment at: 
clang-tools-extra/test/clang-tidy/Inputs/bugprone-spuriously-wake-up-functions/ratio.h:29
+} // namespace std
\ No newline at end of file


Please add a newline to the end of the file.



Comment at: 
clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.cpp:2
+// RUN: %check_clang_tidy %s bugprone-spuriously-wake-up-functions %t -- -- -I 
%S/Inputs/bugprone-spuriously-wake-up-functions/
+#include "condition_variable.h"
+#define NULL 0

Are you planning to use these declarations in multiple test files? If not, then 
we typically put all of the header code into the test file rather than added as 
explicit files.



Comment at: 
clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.cpp:99
+  }
+}

You are missing test cases that use other kinds of loops, like a `do..while` or 
`for` loop.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70876



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


[PATCH] D71911: [ThinLTO] Summarize vcall_visibility metadata

2019-12-26 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: pcc, evgeny777, steven_wu.
Herald added subscribers: arphaman, dexonsmith, hiraditya, inglorion, Prazek, 
mehdi_amini.
Herald added projects: clang, LLVM.

Second patch in series to support Safe Whole Program Devirtualization
Enablement, see RFC here:
http://lists.llvm.org/pipermail/llvm-dev/2019-December/137543.html

Summarize vcall_visibility metadata in ThinLTO global variable summary.

Depends on D71907 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71911

Files:
  clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/test/Assembler/thinlto-vtable-summary.ll

Index: llvm/test/Assembler/thinlto-vtable-summary.ll
===
--- llvm/test/Assembler/thinlto-vtable-summary.ll
+++ llvm/test/Assembler/thinlto-vtable-summary.ll
@@ -29,9 +29,9 @@
 
 ^0 = module: (path: "", hash: (0, 0, 0, 0, 0))
 ^1 = gv: (name: "_ZN1A1nEi") ; guid = 1621563287929432257
-^2 = gv: (name: "_ZTV1B", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), vTableFuncs: ((virtFunc: ^3, offset: 16), (virtFunc: ^1, offset: 24)), refs: (^3, ^1 ; guid = 5283576821522790367
+^2 = gv: (name: "_ZTV1B", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0, vcall_visibility: 0), vTableFuncs: ((virtFunc: ^3, offset: 16), (virtFunc: ^1, offset: 24)), refs: (^3, ^1 ; guid = 5283576821522790367
 ^3 = gv: (name: "_ZN1B1fEi") ; guid = 7162046368816414394
-^4 = gv: (name: "_ZTV1C", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0), vTableFuncs: ((virtFunc: ^5, offset: 16), (virtFunc: ^1, offset: 24)), refs: (^1, ^5 ; guid = 1362402378846296
+^4 = gv: (name: "_ZTV1C", summaries: (variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), varFlags: (readonly: 0, writeonly: 0, vcall_visibility: 0), vTableFuncs: ((virtFunc: ^5, offset: 16), (virtFunc: ^1, offset: 24)), refs: (^1, ^5 ; guid = 1362402378846296
 ^5 = gv: (name: "_ZN1C1fEi") ; guid = 14876272565662207556
 ^6 = typeidCompatibleVTable: (name: "_ZTS1A", summary: ((offset: 16, ^2), (offset: 16, ^4))) ; guid = 7004155349499253778
 ^7 = typeidCompatibleVTable: (name: "_ZTS1B", summary: ((offset: 16, ^2))) ; guid = 6203814149063363976
Index: llvm/lib/IR/AsmWriter.cpp
===
--- llvm/lib/IR/AsmWriter.cpp
+++ llvm/lib/IR/AsmWriter.cpp
@@ -2896,10 +2896,14 @@
 }
 
 void AssemblyWriter::printGlobalVarSummary(const GlobalVarSummary *GS) {
+  auto VTableFuncs = GS->vTableFuncs();
   Out << ", varFlags: (readonly: " << GS->VarFlags.MaybeReadOnly << ", "
-  << "writeonly: " << GS->VarFlags.MaybeWriteOnly << ")";
+  << "writeonly: " << GS->VarFlags.MaybeWriteOnly;
+  if (!VTableFuncs.empty())
+Out << ", "
+<< "vcall_visibility: " << GS->VarFlags.VCallVisibility;
+  Out << ")";
 
-  auto VTableFuncs = GS->vTableFuncs();
   if (!VTableFuncs.empty()) {
 Out << ", vTableFuncs: (";
 FieldSeparator FS;
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1028,7 +1028,8 @@
 }
 
 static uint64_t getEncodedGVarFlags(GlobalVarSummary::GVarFlags Flags) {
-  uint64_t RawFlags = Flags.MaybeReadOnly | (Flags.MaybeWriteOnly << 1);
+  uint64_t RawFlags = Flags.MaybeReadOnly | (Flags.MaybeWriteOnly << 1) |
+  Flags.VCallVisibility << 2;
   return RawFlags;
 }
 
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -985,8 +985,9 @@
 
 // Decode the flags for GlobalVariable in the summary
 static GlobalVarSummary::GVarFlags getDecodedGVarFlags(uint64_t RawFlags) {
-  return GlobalVarSummary::GVarFlags((RawFlags & 0x1) ? true : false,
- (RawFlags & 0x2) ? true : false);
+  return GlobalVarSummary::GVarFlags(
+  (RawFlags & 0x1) ? true : false, (RawFlags & 0x2) ? true : false,
+  (GlobalObject::VCallVisibility)(RawFlags >> 2));
 }
 
 static GlobalValue::VisibilityTypes getDecodedVisibility(uns

[PATCH] D71842: Allow newlines in AST Matchers in clang-query files

2019-12-26 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked 2 inline comments as done.
steveire added inline comments.



Comment at: clang-tools-extra/clang-query/QueryParser.cpp:243-244
 
-return new LetQuery(Name, Value);
+auto Q = new LetQuery(Name, Value);
+Q->RemainingContent = Line;
+return Q;

aaron.ballman wrote:
> Would it make more sense to have `Query` with another constructor to hold the 
> remaining content, and then thread that through `LetQuery`, `MatchQuery`, 
> etc? Whether there is remaining content or not seems like a pretty important 
> property of the query, so it seems reasonable to let people construct with 
> that information rather than set it after the fact.
> 
> If not, these should be `auto *` rather than deducing the pointer.
I think it is set after the fact because it is set in `endQuery()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71842



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


[PATCH] D71842: Allow newlines in AST Matchers in clang-query files

2019-12-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from some `auto` -> `auto *` nits.




Comment at: clang-tools-extra/clang-query/QueryParser.cpp:243-244
 
-return new LetQuery(Name, Value);
+auto Q = new LetQuery(Name, Value);
+Q->RemainingContent = Line;
+return Q;

steveire wrote:
> aaron.ballman wrote:
> > Would it make more sense to have `Query` with another constructor to hold 
> > the remaining content, and then thread that through `LetQuery`, 
> > `MatchQuery`, etc? Whether there is remaining content or not seems like a 
> > pretty important property of the query, so it seems reasonable to let 
> > people construct with that information rather than set it after the fact.
> > 
> > If not, these should be `auto *` rather than deducing the pointer.
> I think it is set after the fact because it is set in `endQuery()`.
Okay, that's reasonable. Thanks! Can you switch to `auto *` for these cases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71842



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


[PATCH] D71846: [ASTMatchers] Fix for https://bugs.llvm.org/show_bug.cgi?id=44364

2019-12-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a minor style nit.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4325-4326
+  internal::Matcher, InnerMatcher) {
+  const Stmt *const Init = Node.getInit();
+  return (Init != nullptr && InnerMatcher.matches(*Init, Finder, Builder));
+}

Can drop the top-level `const` qualifier on the pointer (we don't typically do 
that). And can remove the extra parens around the `return` expression. e.g.,
```
const Stmt *Init = Node.getInit();
return Init && InnerMatcher.matches(*Init, Finder, Builder);
```


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

https://reviews.llvm.org/D71846



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


[PATCH] D71913: [LTO/WPD] Enable aggressive WPD under LTO option

2019-12-26 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: pcc, evgeny777, steven_wu.
Herald added subscribers: dang, dexonsmith, MaskRay, hiraditya, arichardson, 
inglorion, Prazek, emaste.
Herald added a reviewer: espindola.
Herald added projects: clang, LLVM.

Third part in series to support Safe Whole Program Devirtualization
Enablement, see RFC here:
http://lists.llvm.org/pipermail/llvm-dev/2019-December/137543.html

This patch adds type test metadata under -fwhole-program-vtables,
even for classes without hidden visibility. It then changes WPD to skip
devirtualization for a virtual function call when any of the compatible
vtables has public vcall visibility.

Additionally, internal LLVM options as well as lld and gold-plugin
options are added which enable upgrading all public vcall visibility
to linkage unit (hidden) visibility during LTO. This enables the more
aggressive WPD to kick in based on LTO time knowledge of the visibility
guarantees.

Support was added to all flavors of LTO WPD (regular, hybrid and
index-only), and to both the new and old LTO APIs.

Unfortunately it was not simple to split the first and second parts of
this part of the change (the unconditional emission of type tests and
the upgrading of the vcall visiblity) as I needed a way to upgrade the
public visibility on legacy WPD llvm assembly tests that don't include
linkage unit vcall visibility specifiers, to avoid a lot of test churn.

I also added a mechanism to LowerTypeTests that allows dropping type
test assume sequences we now aggressively insert when we invoke
distributed ThinLTO backends with null indexes, which is used in testing
mode, and which doesn't invoke the normal ThinLTO backend pipeline.

Depends on D71907  and D71911 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71913

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  clang/test/CodeGenCXX/lto-visibility-inference.cpp
  clang/test/CodeGenCXX/thinlto-distributed-type-metadata.cpp
  clang/test/CodeGenCXX/type-metadata.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/ELF/Options.td
  lld/test/ELF/lto/devirt_vcall_vis_public.ll
  llvm/include/llvm/LTO/Config.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
  llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/ThinLTO/X86/cache-typeid-resolutions.ll
  llvm/test/ThinLTO/X86/cfi-devirt.ll
  llvm/test/ThinLTO/X86/devirt-after-icp.ll
  llvm/test/ThinLTO/X86/devirt.ll
  llvm/test/ThinLTO/X86/devirt2.ll
  llvm/test/ThinLTO/X86/devirt_available_externally.ll
  llvm/test/ThinLTO/X86/devirt_promote.ll
  llvm/test/ThinLTO/X86/devirt_promote_legacy.ll
  llvm/test/ThinLTO/X86/devirt_single_hybrid.ll
  llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll
  llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
  llvm/test/Transforms/WholeProgramDevirt/bad-read-from-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/branch-funnel-threshold.ll
  llvm/test/Transforms/WholeProgramDevirt/branch-funnel.ll
  llvm/test/Transforms/WholeProgramDevirt/constant-arg.ll
  llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl-check.ll
  llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl.ll
  llvm/test/Transforms/WholeProgramDevirt/expand-check.ll
  llvm/test/Transforms/WholeProgramDevirt/export-nothing.ll
  llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll
  llvm/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll
  llvm/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll
  llvm/test/Transforms/WholeProgramDevirt/export-unsuccessful-checked.ll
  llvm/test/Transforms/WholeProgramDevirt/export-vcp.ll
  llvm/test/Transforms/WholeProgramDevirt/import-indir.ll
  llvm/test/Transforms/WholeProgramDevirt/import-no-dominating-assume.ll
  llvm/test/Transforms/WholeProgramDevirt/import.ll
  llvm/test/Transforms/WholeProgramDevirt/non-constant-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/pointer-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/soa-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/struct-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/uniform-retval-invoke.ll
  llvm/test/Transforms/WholeProgramDevirt/uniform-retval.ll
  llvm/test/Transforms/WholeProgramDevirt/unique-retval.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-accesses-memory.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-decl.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-no-this.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-non-constant-arg.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-too-wide-ints.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-type-mismatch.ll
  llvm/test/Transform

[clang-tools-extra] 6a3ecf4 - Allow newlines in AST Matchers in clang-query files

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

Author: Stephen Kelly
Date: 2019-12-26T20:00:59Z
New Revision: 6a3ecf4dc7ec299394e71b3124df2b3a34ed4ac3

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

LOG: Allow newlines in AST Matchers in clang-query files

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-query/Query.cpp
clang-tools-extra/clang-query/Query.h
clang-tools-extra/clang-query/QueryParser.cpp
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
clang/include/clang/ASTMatchers/Dynamic/Parser.h
clang/lib/ASTMatchers/Dynamic/Parser.cpp
clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/Query.cpp 
b/clang-tools-extra/clang-query/Query.cpp
index 675fd968f46e..8eafc5eed750 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -101,9 +101,24 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession 
&QS) const {
 Finder.matchAST(AST->getASTContext());
 
 if (QS.PrintMatcher) {
-  std::string prefixText = "Matcher: ";
-  OS << "\n  " << prefixText << Source << "\n";
-  OS << "  " << std::string(prefixText.size() + Source.size(), '=') << 
'\n';
+  SmallVector Lines;
+  Source.split(Lines, "\n");
+  auto FirstLine = Lines[0];
+  Lines.erase(Lines.begin(), Lines.begin() + 1);
+  while (!Lines.empty() && Lines.back().empty()) {
+Lines.resize(Lines.size() - 1);
+  }
+  unsigned MaxLength = FirstLine.size();
+  std::string PrefixText = "Matcher: ";
+  OS << "\n  " << PrefixText << FirstLine;
+
+  for (auto Line : Lines) {
+OS << "\n" << std::string(PrefixText.size() + 2, ' ') << Line;
+MaxLength = std::max(MaxLength, Line.rtrim().size());
+  }
+
+  OS << "\n"
+ << "  " << std::string(PrefixText.size() + MaxLength, '=') << "\n\n";
 }
 
 for (auto MI = Matches.begin(), ME = Matches.end(); MI != ME; ++MI) {

diff  --git a/clang-tools-extra/clang-query/Query.h 
b/clang-tools-extra/clang-query/Query.h
index 56af486984ee..78bcbc79cdf8 100644
--- a/clang-tools-extra/clang-query/Query.h
+++ b/clang-tools-extra/clang-query/Query.h
@@ -44,6 +44,7 @@ struct Query : llvm::RefCountedBase {
   /// \return false if an error occurs, otherwise return true.
   virtual bool run(llvm::raw_ostream &OS, QuerySession &QS) const = 0;
 
+  StringRef RemainingContent;
   const QueryKind Kind;
 };
 

diff  --git a/clang-tools-extra/clang-query/QueryParser.cpp 
b/clang-tools-extra/clang-query/QueryParser.cpp
index 4da2f5da79d4..c94a5c8c5a00 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -26,7 +26,10 @@ namespace query {
 // is found before End, return StringRef().  Begin is adjusted to exclude the
 // lexed region.
 StringRef QueryParser::lexWord() {
-  Line = Line.ltrim();
+  Line = Line.drop_while([this](char c) {
+// Don't trim newlines.
+return StringRef(" \t\v\f\r").contains(c);
+  });
 
   if (Line.empty())
 // Even though the Line is empty, it contains a pointer and
@@ -34,12 +37,12 @@ StringRef QueryParser::lexWord() {
 // code completion.
 return Line;
 
-  if (Line.front() == '#') {
-Line = {};
-return StringRef();
-  }
+  StringRef Word;
+  if (Line.front() == '#')
+Word = Line.substr(0, 1);
+  else
+Word = Line.take_until(isWhitespace);
 
-  StringRef Word = Line.take_until(isWhitespace);
   Line = Line.drop_front(Word.size());
   return Word;
 }
@@ -125,9 +128,25 @@ template  QueryRef 
QueryParser::parseSetOutputKind() {
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
-  const StringRef Extra = Line;
-  if (!lexWord().empty())
-return new InvalidQuery("unexpected extra input: '" + Extra + "'");
+  StringRef Extra = Line;
+  StringRef ExtraTrimmed = Extra.drop_while(
+  [](char c) { return StringRef(" \t\v\f\r").contains(c); });
+
+  if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') ||
+  (ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' &&
+   ExtraTrimmed[1] == '\n'))
+Q->RemainingContent = Extra;
+  else {
+StringRef TrailingWord = lexWord();
+if (TrailingWord.front() == '#') {
+  Line = Line.drop_until([](char c) { return c == '\n'; });
+  Line = Line.drop_front();
+  return endQuery(Q);
+}
+if (!TrailingWord.empty()) {
+  return new InvalidQuery("unexpected extra input: '" + Extra + "'");
+}
+  }
   return Q;
 }
 
@@ -193,7 +212,11 @@ QueryRef QueryParser::doParse() {
   switch (QKind) {
   case PQK_Comment:
   case PQK_NoOp:
-return new NoOpQuery;
+

[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2019-12-26 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Ping ping goes the trolley.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687



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


[PATCH] D71842: Allow newlines in AST Matchers in clang-query files

2019-12-26 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a3ecf4dc7ec: Allow newlines in AST Matchers in clang-query 
files (authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D71842?vs=235353&id=235370#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71842

Files:
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-query/Query.h
  clang-tools-extra/clang-query/QueryParser.cpp
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
  clang/include/clang/ASTMatchers/Dynamic/Parser.h
  clang/lib/ASTMatchers/Dynamic/Parser.cpp
  clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Index: clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -207,10 +207,12 @@
 
 TEST(ParserTest, FullParserTest) {
   Diagnostics Error;
-  llvm::Optional VarDecl(Parser::parseMatcherExpression(
+
+  StringRef Code =
   "varDecl(hasInitializer(binaryOperator(hasLHS(integerLiteral()),"
-  "  hasOperatorName(\"+\"",
-  &Error));
+  "  hasOperatorName(\"+\"";
+  llvm::Optional VarDecl(
+  Parser::parseMatcherExpression(Code, &Error));
   EXPECT_EQ("", Error.toStringFull());
   Matcher M = VarDecl->unconditionalConvertTo();
   EXPECT_TRUE(matches("int x = 1 + false;", M));
@@ -218,8 +220,9 @@
   EXPECT_FALSE(matches("int x = 1 - false;", M));
   EXPECT_FALSE(matches("int x = true - 1;", M));
 
-  llvm::Optional HasParameter(Parser::parseMatcherExpression(
-  "functionDecl(hasParameter(1, hasName(\"x\")))", &Error));
+  Code = "functionDecl(hasParameter(1, hasName(\"x\")))";
+  llvm::Optional HasParameter(
+  Parser::parseMatcherExpression(Code, &Error));
   EXPECT_EQ("", Error.toStringFull());
   M = HasParameter->unconditionalConvertTo();
 
@@ -228,20 +231,18 @@
 
   // Test named values.
   auto NamedValues = getTestNamedValues();
+
+  Code = "functionDecl(hasParamA, hasParameter(1, hasName(nameX)))";
   llvm::Optional HasParameterWithNamedValues(
-  Parser::parseMatcherExpression(
-  "functionDecl(hasParamA, hasParameter(1, hasName(nameX)))",
-  nullptr, &NamedValues, &Error));
+  Parser::parseMatcherExpression(Code, nullptr, &NamedValues, &Error));
   EXPECT_EQ("", Error.toStringFull());
   M = HasParameterWithNamedValues->unconditionalConvertTo();
 
   EXPECT_TRUE(matches("void f(int a, int x);", M));
   EXPECT_FALSE(matches("void f(int x, int a);", M));
 
-
-  EXPECT_TRUE(!Parser::parseMatcherExpression(
-   "hasInitializer(\nbinaryOperator(hasLHS(\"A\")))",
-   &Error).hasValue());
+  Code = "hasInitializer(\nbinaryOperator(hasLHS(\"A\")))";
+  EXPECT_TRUE(!Parser::parseMatcherExpression(Code, &Error).hasValue());
   EXPECT_EQ("1:1: Error parsing argument 1 for matcher hasInitializer.\n"
 "2:5: Error parsing argument 1 for matcher binaryOperator.\n"
 "2:20: Error building matcher hasLHS.\n"
@@ -252,9 +253,11 @@
 
 TEST(ParserTest, VariadicMatchTest) {
   Diagnostics Error;
-  llvm::Optional OM(Parser::parseMatcherExpression(
-  "stmt(objcMessageExpr(hasAnySelector(\"methodA\", \"methodB:\")))",
-  &Error));
+
+  StringRef Code =
+  "stmt(objcMessageExpr(hasAnySelector(\"methodA\", \"methodB:\")))";
+  llvm::Optional OM(
+  Parser::parseMatcherExpression(Code, &Error));
   EXPECT_EQ("", Error.toStringFull());
   auto M = OM->unconditionalConvertTo();
   EXPECT_TRUE(matchesObjC("@interface I @end "
@@ -324,15 +327,132 @@
 ParseWithError("callee(\"A\")"));
 }
 
+TEST(ParserTest, ParseMultiline) {
+  StringRef Code;
+
+  llvm::Optional M;
+  {
+Code = R"matcher(varDecl(
+  hasName("foo")
+  )
+)matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(varDecl(
+  # Internal comment
+  hasName("foo") # Internal comment
+# Internal comment
+  )
+)matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(decl().bind(
+  "paramName")
+)matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(decl().bind(
+  "paramName"
+  )
+)matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(decl(decl()
+, decl()))matcher";
+Diagnostics Error;
+EXPECT_TRUE(Parser::parseMatcherExpression(Code, &Error).hasValue());
+  }
+
+  {
+Code = R"matcher(decl(decl(),
+decl()))matcher";
+   

[clang] 831b636 - Revert "Allow newlines in AST Matchers in clang-query files"

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

Author: Stephen Kelly
Date: 2019-12-26T20:16:23Z
New Revision: 831b636861ea33c3cc1c1c28384fb1800facf792

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

LOG: Revert "Allow newlines in AST Matchers in clang-query files"

This reverts commit 6a3ecf4dc7ec299394e71b3124df2b3a34ed4ac3.

Added: 


Modified: 
clang-tools-extra/clang-query/Query.cpp
clang-tools-extra/clang-query/Query.h
clang-tools-extra/clang-query/QueryParser.cpp
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
clang/include/clang/ASTMatchers/Dynamic/Parser.h
clang/lib/ASTMatchers/Dynamic/Parser.cpp
clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/Query.cpp 
b/clang-tools-extra/clang-query/Query.cpp
index 8eafc5eed750..675fd968f46e 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -101,24 +101,9 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession 
&QS) const {
 Finder.matchAST(AST->getASTContext());
 
 if (QS.PrintMatcher) {
-  SmallVector Lines;
-  Source.split(Lines, "\n");
-  auto FirstLine = Lines[0];
-  Lines.erase(Lines.begin(), Lines.begin() + 1);
-  while (!Lines.empty() && Lines.back().empty()) {
-Lines.resize(Lines.size() - 1);
-  }
-  unsigned MaxLength = FirstLine.size();
-  std::string PrefixText = "Matcher: ";
-  OS << "\n  " << PrefixText << FirstLine;
-
-  for (auto Line : Lines) {
-OS << "\n" << std::string(PrefixText.size() + 2, ' ') << Line;
-MaxLength = std::max(MaxLength, Line.rtrim().size());
-  }
-
-  OS << "\n"
- << "  " << std::string(PrefixText.size() + MaxLength, '=') << "\n\n";
+  std::string prefixText = "Matcher: ";
+  OS << "\n  " << prefixText << Source << "\n";
+  OS << "  " << std::string(prefixText.size() + Source.size(), '=') << 
'\n';
 }
 
 for (auto MI = Matches.begin(), ME = Matches.end(); MI != ME; ++MI) {

diff  --git a/clang-tools-extra/clang-query/Query.h 
b/clang-tools-extra/clang-query/Query.h
index 78bcbc79cdf8..56af486984ee 100644
--- a/clang-tools-extra/clang-query/Query.h
+++ b/clang-tools-extra/clang-query/Query.h
@@ -44,7 +44,6 @@ struct Query : llvm::RefCountedBase {
   /// \return false if an error occurs, otherwise return true.
   virtual bool run(llvm::raw_ostream &OS, QuerySession &QS) const = 0;
 
-  StringRef RemainingContent;
   const QueryKind Kind;
 };
 

diff  --git a/clang-tools-extra/clang-query/QueryParser.cpp 
b/clang-tools-extra/clang-query/QueryParser.cpp
index c94a5c8c5a00..4da2f5da79d4 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -26,10 +26,7 @@ namespace query {
 // is found before End, return StringRef().  Begin is adjusted to exclude the
 // lexed region.
 StringRef QueryParser::lexWord() {
-  Line = Line.drop_while([this](char c) {
-// Don't trim newlines.
-return StringRef(" \t\v\f\r").contains(c);
-  });
+  Line = Line.ltrim();
 
   if (Line.empty())
 // Even though the Line is empty, it contains a pointer and
@@ -37,12 +34,12 @@ StringRef QueryParser::lexWord() {
 // code completion.
 return Line;
 
-  StringRef Word;
-  if (Line.front() == '#')
-Word = Line.substr(0, 1);
-  else
-Word = Line.take_until(isWhitespace);
+  if (Line.front() == '#') {
+Line = {};
+return StringRef();
+  }
 
+  StringRef Word = Line.take_until(isWhitespace);
   Line = Line.drop_front(Word.size());
   return Word;
 }
@@ -128,25 +125,9 @@ template  QueryRef 
QueryParser::parseSetOutputKind() {
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
-  StringRef Extra = Line;
-  StringRef ExtraTrimmed = Extra.drop_while(
-  [](char c) { return StringRef(" \t\v\f\r").contains(c); });
-
-  if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') ||
-  (ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' &&
-   ExtraTrimmed[1] == '\n'))
-Q->RemainingContent = Extra;
-  else {
-StringRef TrailingWord = lexWord();
-if (TrailingWord.front() == '#') {
-  Line = Line.drop_until([](char c) { return c == '\n'; });
-  Line = Line.drop_front();
-  return endQuery(Q);
-}
-if (!TrailingWord.empty()) {
-  return new InvalidQuery("unexpected extra input: '" + Extra + "'");
-}
-  }
+  const StringRef Extra = Line;
+  if (!lexWord().empty())
+return new InvalidQuery("unexpected extra input: '" + Extra + "'");
   return Q;
 }
 
@@ -212,11 +193,7 @@ QueryRef QueryParser::doParse() {
   switch (QKind) {
   case PQK_Comment:
   case PQK_NoOp:
-Line = Line.drop_until([](char c) { return c == '\n'; });
-Line = Line.dr

[clang] 522ee29 - Allow newlines in AST Matchers in clang-query files

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

Author: Stephen Kelly
Date: 2019-12-26T20:40:33Z
New Revision: 522ee29a4fb3814db604b585c8637247477ec057

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

LOG: Allow newlines in AST Matchers in clang-query files

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-query/Query.cpp
clang-tools-extra/clang-query/Query.h
clang-tools-extra/clang-query/QueryParser.cpp
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
clang/include/clang/ASTMatchers/Dynamic/Parser.h
clang/lib/ASTMatchers/Dynamic/Parser.cpp
clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/Query.cpp 
b/clang-tools-extra/clang-query/Query.cpp
index 675fd968f46e..8eafc5eed750 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -101,9 +101,24 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession 
&QS) const {
 Finder.matchAST(AST->getASTContext());
 
 if (QS.PrintMatcher) {
-  std::string prefixText = "Matcher: ";
-  OS << "\n  " << prefixText << Source << "\n";
-  OS << "  " << std::string(prefixText.size() + Source.size(), '=') << 
'\n';
+  SmallVector Lines;
+  Source.split(Lines, "\n");
+  auto FirstLine = Lines[0];
+  Lines.erase(Lines.begin(), Lines.begin() + 1);
+  while (!Lines.empty() && Lines.back().empty()) {
+Lines.resize(Lines.size() - 1);
+  }
+  unsigned MaxLength = FirstLine.size();
+  std::string PrefixText = "Matcher: ";
+  OS << "\n  " << PrefixText << FirstLine;
+
+  for (auto Line : Lines) {
+OS << "\n" << std::string(PrefixText.size() + 2, ' ') << Line;
+MaxLength = std::max(MaxLength, Line.rtrim().size());
+  }
+
+  OS << "\n"
+ << "  " << std::string(PrefixText.size() + MaxLength, '=') << "\n\n";
 }
 
 for (auto MI = Matches.begin(), ME = Matches.end(); MI != ME; ++MI) {

diff  --git a/clang-tools-extra/clang-query/Query.h 
b/clang-tools-extra/clang-query/Query.h
index 56af486984ee..78bcbc79cdf8 100644
--- a/clang-tools-extra/clang-query/Query.h
+++ b/clang-tools-extra/clang-query/Query.h
@@ -44,6 +44,7 @@ struct Query : llvm::RefCountedBase {
   /// \return false if an error occurs, otherwise return true.
   virtual bool run(llvm::raw_ostream &OS, QuerySession &QS) const = 0;
 
+  StringRef RemainingContent;
   const QueryKind Kind;
 };
 

diff  --git a/clang-tools-extra/clang-query/QueryParser.cpp 
b/clang-tools-extra/clang-query/QueryParser.cpp
index 4da2f5da79d4..db4b9a4b0530 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -26,7 +26,10 @@ namespace query {
 // is found before End, return StringRef().  Begin is adjusted to exclude the
 // lexed region.
 StringRef QueryParser::lexWord() {
-  Line = Line.ltrim();
+  Line = Line.drop_while([this](char c) {
+// Don't trim newlines.
+return StringRef(" \t\v\f\r").contains(c);
+  });
 
   if (Line.empty())
 // Even though the Line is empty, it contains a pointer and
@@ -34,12 +37,12 @@ StringRef QueryParser::lexWord() {
 // code completion.
 return Line;
 
-  if (Line.front() == '#') {
-Line = {};
-return StringRef();
-  }
+  StringRef Word;
+  if (Line.front() == '#')
+Word = Line.substr(0, 1);
+  else
+Word = Line.take_until(isWhitespace);
 
-  StringRef Word = Line.take_until(isWhitespace);
   Line = Line.drop_front(Word.size());
   return Word;
 }
@@ -125,9 +128,25 @@ template  QueryRef 
QueryParser::parseSetOutputKind() {
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
-  const StringRef Extra = Line;
-  if (!lexWord().empty())
-return new InvalidQuery("unexpected extra input: '" + Extra + "'");
+  StringRef Extra = Line;
+  StringRef ExtraTrimmed = Extra.drop_while(
+  [](char c) { return StringRef(" \t\v\f\r").contains(c); });
+
+  if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') ||
+  (ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' &&
+   ExtraTrimmed[1] == '\n'))
+Q->RemainingContent = Extra;
+  else {
+StringRef TrailingWord = lexWord();
+if (!TrailingWord.empty() && TrailingWord.front() == '#') {
+  Line = Line.drop_until([](char c) { return c == '\n'; });
+  Line = Line.drop_while([](char c) { return c == '\n'; });
+  return endQuery(Q);
+}
+if (!TrailingWord.empty()) {
+  return new InvalidQuery("unexpected extra input: '" + Extra + "'");
+}
+  }
   return Q;
 }
 
@@ -193,7 +212,11 @@ QueryRef QueryParser::doParse() {
   switch (QKind) {
   case PQK_Co

[PATCH] D71846: [ASTMatchers] Fix for https://bugs.llvm.org/show_bug.cgi?id=44364

2019-12-26 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

So I wasn't happy with the vagueness of the else after return check 
implementation. Almost finished rewriting the check to properly handle the if 
statements with condition variables based on scope restrictions and where decls 
are used etc.

  int *varInitAndCondition() {
if (int *X = g(); X != nullptr) {
  return X;
} else {
  h(&X);
  return X;
}
  }
  int *varInitAndConditionUnusedInElseWithDecl() {
int *Y = g();
if (int *X = g(); X != nullptr) {
  return X;
} else {
  int *Y = g();
  h(&Y);
}
return Y;
  }

transforms to

  int *varInitAndCondition() {
int *X = g();
if (X != nullptr) {
  return X;
}
h(&X);
return X;
  }
  int *varInitAndConditionUnusedInElseWithDecl() {
int *Y = g();
if (int *X = g(); X != nullptr) {
  return X;
} else {
  int *Y = g();
  h(&Y);
}
return Y;
  }

There's a few more test cases but that's the general idea. I'm having a little 
trouble writing the test cases as I can't run them on my windows machine to 
verify they report correctly


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

https://reviews.llvm.org/D71846



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


Re: [clang] ce1f95a - Reland "[clang] Remove the DIFlagArgumentNotModified debug info flag"

2019-12-26 Thread David Blaikie via cfe-commits
On Wed, Nov 20, 2019 at 1:08 AM Djordje Todorovic via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Djordje Todorovic
> Date: 2019-11-20T10:08:07+01:00
> New Revision: ce1f95a6e077693f93d8869245f911aff3eb7e4c
>
> URL:
> https://github.com/llvm/llvm-project/commit/ce1f95a6e077693f93d8869245f911aff3eb7e4c
> DIFF:
> https://github.com/llvm/llvm-project/commit/ce1f95a6e077693f93d8869245f911aff3eb7e4c.diff
>
> LOG: Reland "[clang] Remove the DIFlagArgumentNotModified debug info flag"
>
> It turns out that the ExprMutationAnalyzer can be very slow when AST
> gets huge in some cases. The idea is to move this analysis to the LLVM
> back-end level (more precisely, in the LiveDebugValues pass). The new
> approach will remove the performance regression, simplify the
> implementation and give us front-end independent implementation.
>

What if the LLVM backend optimized out a dead store? (then we might
concnlude that the argument is not modified, when it actually is modified?)


>
> Differential Revision: https://reviews.llvm.org/D68206
>
> Added:
>
>
> Modified:
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/lib/CodeGen/CGDebugInfo.h
>
> lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
>
> Removed:
> clang/test/CodeGen/debug-info-param-modification.c
>
>
>
> 
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index 116517a9cb99..a9b3831aa0b5 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -18,7 +18,6 @@
>  #include "CodeGenFunction.h"
>  #include "CodeGenModule.h"
>  #include "ConstantEmitter.h"
> -#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
>  #include "clang/AST/ASTContext.h"
>  #include "clang/AST/DeclFriend.h"
>  #include "clang/AST/DeclObjC.h"
> @@ -3686,15 +3685,6 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD,
> SourceLocation Loc,
>if (HasDecl && isa(D))
>  DeclCache[D->getCanonicalDecl()].reset(SP);
>
> -  // We use the SPDefCache only in the case when the debug entry values
> option
> -  // is set, in order to speed up parameters modification analysis.
> -  //
> -  // FIXME: Use AbstractCallee here to support ObjCMethodDecl.
> -  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl)
> -if (auto *FD = dyn_cast(D))
> -  if (FD->hasBody() && !FD->param_empty())
> -SPDefCache[FD].reset(SP);
> -
>// Push the function onto the lexical block stack.
>LexicalBlockStack.emplace_back(SP);
>
> @@ -4097,11 +4087,6 @@ llvm::DILocalVariable
> *CGDebugInfo::EmitDeclare(const VarDecl *VD,
>   llvm::DebugLoc::get(Line, Column, Scope,
> CurInlinedAt),
>   Builder.GetInsertBlock());
>
> -  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
> -if (auto *PD = dyn_cast(VD))
> -  ParamCache[PD].reset(D);
> -  }
> -
>return D;
>  }
>
> @@ -4717,29 +4702,6 @@ void CGDebugInfo::setDwoId(uint64_t Signature) {
>TheCU->setDWOId(Signature);
>  }
>
> -/// Analyzes each function parameter to determine whether it is constant
> -/// throughout the function body.
> -static void analyzeParametersModification(
> -ASTContext &Ctx,
> -llvm::DenseMap &SPDefCache,
> -llvm::DenseMap &ParamCache)
> {
> -  for (auto &SP : SPDefCache) {
> -auto *FD = SP.first;
> -assert(FD->hasBody() && "Functions must have body here");
> -const Stmt *FuncBody = (*FD).getBody();
> -for (auto Parm : FD->parameters()) {
> -  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, Ctx);
> -  if (FuncAnalyzer.isMutated(Parm))
> -continue;
> -
> -  auto I = ParamCache.find(Parm);
> -  assert(I != ParamCache.end() && "Parameters should be already
> cached");
> -  auto *DIParm = cast(I->second);
> -  DIParm->setIsNotModified();
> -}
> -  }
> -}
> -
>  void CGDebugInfo::finalize() {
>// Creating types might create further types - invalidating the current
>// element and the size(), so don't cache/reference them.
> @@ -4812,10 +4774,6 @@ void CGDebugInfo::finalize() {
>  if (auto MD = TypeCache[RT])
>DBuilder.retainType(cast(MD));
>
> -  if (CGM.getCodeGenOpts().EnableDebugEntryValues)
> -// This will be used to emit debug entry values.
> -analyzeParametersModification(CGM.getContext(), SPDefCache,
> ParamCache);
> -
>DBuilder.finalize();
>  }
>
>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.h
> b/clang/lib/CodeGen/CGDebugInfo.h
> index 9a097615b4b4..5341bfa7f350 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.h
> +++ b/clang/lib/CodeGen/CGDebugInfo.h
> @@ -146,10 +146,6 @@ class CGDebugInfo {
>
>llvm::DenseMap DIFileCache;
>llvm::DenseMap SPCache;
> -  /// Cache function definitions relevant to use for parameters mutation
> -  /// analysis.
> -  llvm::DenseMap SPDefCache;
> -  llvm::DenseMap Para

Re: [clang] 3f4b70c - Revert "[clang][modules] Add support for merging lifetime-extended temporaries"

2019-12-26 Thread David Blaikie via cfe-commits
Please include details about the reason for the revert (links to and quotes
from buildbots are helpful, etc) in the commit message - so others can
follow along more easily (if they're seeing a local regression, they might
be able to check if this revert is likely to address it - if they want to
pick up the patch/do some similar change at a later date, this might help
explain what was wrong with this approach & would need to be addressed
before making another attempt)

On Sat, Nov 30, 2019 at 8:53 AM via cfe-commits 
wrote:

>
> Author: Tyker
> Date: 2019-11-30T17:52:26+01:00
> New Revision: 3f4b70c79e686117c2754d2c0a5a44c8b6829e79
>
> URL:
> https://github.com/llvm/llvm-project/commit/3f4b70c79e686117c2754d2c0a5a44c8b6829e79
> DIFF:
> https://github.com/llvm/llvm-project/commit/3f4b70c79e686117c2754d2c0a5a44c8b6829e79.diff
>
> LOG: Revert "[clang][modules] Add support for merging lifetime-extended
> temporaries"
>
> This reverts commit 3c7f6b439699a9cbbc0ac8d288cc70aff357446b.
>
> Added:
>
>
> Modified:
> clang/include/clang/AST/DeclCXX.h
> clang/include/clang/AST/TextNodeDumper.h
> clang/include/clang/Serialization/ASTReader.h
> clang/lib/AST/TextNodeDumper.cpp
> clang/lib/Serialization/ASTReaderDecl.cpp
>
> Removed:
> clang/test/Modules/Inputs/merge-lifetime-extended-temporary/a.h
> clang/test/Modules/Inputs/merge-lifetime-extended-temporary/b.h
> clang/test/Modules/Inputs/merge-lifetime-extended-temporary/c.h
>
> clang/test/Modules/Inputs/merge-lifetime-extended-temporary/module.modulemap
> clang/test/Modules/merge-lifetime-extended-temporary.cpp
>
>
>
> 
> diff  --git a/clang/include/clang/AST/DeclCXX.h
> b/clang/include/clang/AST/DeclCXX.h
> index 0f2018fb9e8c..63d67bd3f55b 100644
> --- a/clang/include/clang/AST/DeclCXX.h
> +++ b/clang/include/clang/AST/DeclCXX.h
> @@ -3041,9 +3041,7 @@ class NamespaceAliasDecl : public NamedDecl,
>
>  /// Implicit declaration of a temporary that was materialized by
>  /// a MaterializeTemporaryExpr and lifetime-extended by a declaration
> -class LifetimeExtendedTemporaryDecl final
> -: public Decl,
> -  public Mergeable {
> +class LifetimeExtendedTemporaryDecl final : public Decl {
>friend class MaterializeTemporaryExpr;
>friend class ASTDeclReader;
>
>
> diff  --git a/clang/include/clang/AST/TextNodeDumper.h
> b/clang/include/clang/AST/TextNodeDumper.h
> index d293ea190aa4..0ff5a614a864 100644
> --- a/clang/include/clang/AST/TextNodeDumper.h
> +++ b/clang/include/clang/AST/TextNodeDumper.h
> @@ -346,8 +346,6 @@ class TextNodeDumper
>void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
>void VisitBlockDecl(const BlockDecl *D);
>void VisitConceptDecl(const ConceptDecl *D);
> -  void
> -  VisitLifetimeExtendedTemporaryDecl(const LifetimeExtendedTemporaryDecl
> *D);
>  };
>
>  } // namespace clang
>
> diff  --git a/clang/include/clang/Serialization/ASTReader.h
> b/clang/include/clang/Serialization/ASTReader.h
> index b6dae68b3413..f0b5e9933823 100644
> --- a/clang/include/clang/Serialization/ASTReader.h
> +++ b/clang/include/clang/Serialization/ASTReader.h
> @@ -551,14 +551,6 @@ class ASTReader
>llvm::DenseMap>
>  AnonymousDeclarationsForMerging;
>
> -  /// Key used to identify LifetimeExtendedTemporaryDecl for merging,
> -  /// containing the lifetime-extending declaration and the mangling
> number.
> -  using LETemporaryKey = std::pair;
> -
> -  /// Map of already deserialiazed temporaries.
> -  llvm::DenseMap
> -  LETemporaryForMerging;
> -
>struct FileDeclsInfo {
>  ModuleFile *Mod = nullptr;
>  ArrayRef Decls;
>
> diff  --git a/clang/lib/AST/TextNodeDumper.cpp
> b/clang/lib/AST/TextNodeDumper.cpp
> index 561c76a45cbc..0ff95213118f 100644
> --- a/clang/lib/AST/TextNodeDumper.cpp
> +++ b/clang/lib/AST/TextNodeDumper.cpp
> @@ -1338,17 +1338,6 @@ void TextNodeDumper::VisitFunctionDecl(const
> FunctionDecl *D) {
>  OS << " <>>";
>  }
>
> -void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
> -const LifetimeExtendedTemporaryDecl *D) {
> -  OS << " extended by ";
> -  dumpBareDeclRef(D->getExtendingDecl());
> -  OS << " mangling ";
> -  {
> -ColorScope Color(OS, ShowColors, ValueColor);
> -OS << D->getManglingNumber();
> -  }
> -}
> -
>  void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
>dumpName(D);
>dumpType(D->getType());
>
> diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp
> b/clang/lib/Serialization/ASTReaderDecl.cpp
> index d6c57757cf8c..8991a39a7067 100644
> --- a/clang/lib/Serialization/ASTReaderDecl.cpp
> +++ b/clang/lib/Serialization/ASTReaderDecl.cpp
> @@ -424,9 +424,6 @@ namespace clang {
>  template
>  void mergeMergeable(Mergeable *D);
>
> -template <>
> -void mergeMergeable(Mergeable *D);
> -
>  void mergeTemplatePattern(RedeclarableTemplateDecl *D,
>RedeclarableTempl

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

2019-12-26 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:198
cppcoreguidelines-avoid-magic-numbers (redirects to 
readability-magic-numbers) 
+   cppcoreguidelines-avoid-non-const-global-variables
cppcoreguidelines-c-copy-assignment-signature (redirects to 
misc-unconventional-assign-operator) 


list.rst changed, you should update this!
Thanks



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] 2369560 - Fix -Wunused-lambda-capture warnings.

2019-12-26 Thread Eric Christopher via cfe-commits

Author: Eric Christopher
Date: 2019-12-26T15:27:21-08:00
New Revision: 2369560f4a7720b19edfbf9de14ef061307ff773

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

LOG: Fix -Wunused-lambda-capture warnings.

Added: 


Modified: 
clang-tools-extra/clang-query/QueryParser.cpp
clang/lib/ASTMatchers/Dynamic/Parser.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/QueryParser.cpp 
b/clang-tools-extra/clang-query/QueryParser.cpp
index db4b9a4b0530..a980722de9e6 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -26,7 +26,7 @@ namespace query {
 // is found before End, return StringRef().  Begin is adjusted to exclude the
 // lexed region.
 StringRef QueryParser::lexWord() {
-  Line = Line.drop_while([this](char c) {
+  Line = Line.drop_while([](char c) {
 // Don't trim newlines.
 return StringRef(" \t\v\f\r").contains(c);
   });

diff  --git a/clang/lib/ASTMatchers/Dynamic/Parser.cpp 
b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
index 1781f2a6439f..77c9629f6f85 100644
--- a/clang/lib/ASTMatchers/Dynamic/Parser.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -297,7 +297,7 @@ class Parser::CodeTokenizer {
 
   /// Consume all leading whitespace from \c Code.
   void consumeWhitespace() {
-Code = Code.drop_while([this](char c) {
+Code = Code.drop_while([](char c) {
   // Don't trim newlines.
   return StringRef(" \t\v\f\r").contains(c);
 });



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


[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2019-12-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Misc/loop-opt-setup.c:13
+int B(void) {
+#pragma clang loop unroll(full)
+  for (int i = 0; i < 16; ++i)

The test seems to pass without the code change 
(llvm/lib/Passes/PassBuilder.cpp) below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687



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


[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2019-12-26 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: llvm/lib/Passes/PassBuilder.cpp:484
+LPM2.addPass(LoopFullUnrollPass(Level,
+/*OnlyWhenForced=*/!PTO.LoopUnrolling,
 PTO.ForgetAllSCEVInLoopUnroll));

I would document that the normal unroll pass does not honor the forced unroll, 
it is surprising to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687



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


[PATCH] D62731: Add support for options -frounding-math, -ftrapping-math, -ffp-model=, and -ffp-exception-behavior=, : Specify floating point behavior

2019-12-26 Thread Anton Yudintsev via Phabricator via cfe-commits
AntonYudintsev added a comment.

I have found bug in clang-cl (win32 clang), related to recent inroduction of 
ffp-exception-behavior.
Unfortunately, I don't have a working patch yet, and since LLVM bugtracker 
registration is closed, I can not even submit a bug.

So, if it is not a trouble for you, I will email the bug description here.

Please let me know if it isn't appropriate. Bug description:


Windows: clang-cl is generating call to non-existing lib function for win32 
with /fp:except option.
With recent ffp-exception-behavior=maytrap/strict, fp:except in clang-cl became 
generate FPE aware code.

But in case of floorf and ceilf it generates call to non-existing library 
function.

clang-cl.exe -m32 /Ox /fp:except testFloor.cpp /FA
testFloor.cpp:

  #include 
  float ret(float v) {  return floorf(v); }

resulting assember:

  pusheax
  movssxmm0, dword ptr [esp + 8]
  movssdword ptr [esp], xmm0
  call_floorf #no such function!!!
  popeax
  ret

Expected behaviour:

there is no floorf lib function. Like with cosf and other math functions, 
floorf in MSVC is implemented as inline function.

So, it should be call to _floor (with apropriate conversion first).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62731



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


Re: [PATCH] D62731: Add support for options -frounding-math, -ftrapping-math, -ffp-model=, and -ffp-exception-behavior=, : Specify floating point behavior

2019-12-26 Thread Eric Christopher via cfe-commits
You can sign up for an account by emailing the admin account.

On Thu, Dec 26, 2019, 5:04 PM Anton Yudintsev via Phabricator <
revi...@reviews.llvm.org> wrote:

> AntonYudintsev added a comment.
>
> I have found bug in clang-cl (win32 clang), related to recent inroduction
> of ffp-exception-behavior.
> Unfortunately, I don't have a working patch yet, and since LLVM bugtracker
> registration is closed, I can not even submit a bug.
>
> So, if it is not a trouble for you, I will email the bug description here.
>
> Please let me know if it isn't appropriate. Bug description:
> 
>
> Windows: clang-cl is generating call to non-existing lib function for
> win32 with /fp:except option.
> With recent ffp-exception-behavior=maytrap/strict, fp:except in clang-cl
> became generate FPE aware code.
>
> But in case of floorf and ceilf it generates call to non-existing library
> function.
>
> clang-cl.exe -m32 /Ox /fp:except testFloor.cpp /FA
> testFloor.cpp:
>
>   #include 
>   float ret(float v) {  return floorf(v); }
>
> resulting assember:
>
>   pusheax
>   movssxmm0, dword ptr [esp + 8]
>   movssdword ptr [esp], xmm0
>   call_floorf #no such function!!!
>   popeax
>   ret
>
> Expected behaviour:
>
> there is no floorf lib function. Like with cosf and other math functions,
> floorf in MSVC is implemented as inline function.
>
> So, it should be call to _floor (with apropriate conversion first).
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D62731/new/
>
> https://reviews.llvm.org/D62731
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71846: [ASTMatchers] Fix for https://bugs.llvm.org/show_bug.cgi?id=44364

2019-12-26 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 235384.
njames93 edited the summary of this revision.
njames93 added a comment.

Think all the test cases are working, but they look like they could do with a 
clean up from someone who may know the clang-tidy-checks system better than 
myself


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

https://reviews.llvm.org/D71846

Files:
  clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1071,6 +1071,35 @@
  LanguageMode::Cxx17OrLater));
 }
 
+TEST(hasInitStatement, MatchesSelectionInitializers) {
+  EXPECT_TRUE(matches("void baz() { if (int i = 1; i > 0) {} }",
+  ifStmt(hasInitStatement(anything())),
+  LanguageMode::Cxx17OrLater));
+  EXPECT_TRUE(notMatches("void baz() { if (int i = 1) {} }",
+ ifStmt(hasInitStatement(anything();
+  EXPECT_TRUE(notMatches("void baz() { if (1 > 0) {} }",
+ ifStmt(hasInitStatement(anything();
+  EXPECT_TRUE(matches(
+  "void baz(int i) { switch (int j = i; j) { default: break; } }",
+  switchStmt(hasInitStatement(anything())), LanguageMode::Cxx17OrLater));
+  EXPECT_TRUE(notMatches("void baz(int i) { switch (i) { default: break; } }",
+ switchStmt(hasInitStatement(anything();
+}
+
+TEST(hasInitStatement, MatchesRangeForInitializers) {
+  EXPECT_TRUE(matches("void baz() {"
+  "int items[] = {};"
+  "for (auto &arr = items; auto &item : arr) {}"
+  "}",
+  cxxForRangeStmt(hasInitStatement(anything())),
+  LanguageMode::Cxx2aOrLater));
+  EXPECT_TRUE(notMatches("void baz() {"
+ "int items[] = {};"
+ "for (auto &item : items) {}"
+ "}",
+ cxxForRangeStmt(hasInitStatement(anything();
+}
+
 TEST(TemplateArgumentCountIs, Matches) {
   EXPECT_TRUE(
 matches("template struct C {}; C c;",
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -279,6 +279,7 @@
   REGISTER_MATCHER(hasIndex);
   REGISTER_MATCHER(hasInit);
   REGISTER_MATCHER(hasInitializer);
+  REGISTER_MATCHER(hasInitStatement);
   REGISTER_MATCHER(hasKeywordSelector);
   REGISTER_MATCHER(hasLHS);
   REGISTER_MATCHER(hasLocalQualifiers);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4297,6 +4297,35 @@
   return Node.isConstexpr();
 }
 
+/// Matches selection statements with initializer.
+///
+/// Given:
+/// \code
+///  void foo() {
+///if (int i = foobar(); i > 0) {}
+///switch (int i = foobar(); i) {}
+///for (auto& a = get_range(); auto& x : a) {}
+///  }
+///  void bar() {
+///if (foobar() > 0) {}
+///switch (foobar()) {}
+///for (auto& x : get_range()) {}
+///  }
+/// \endcode
+/// ifStmt(hasInitStatement(anything()))
+///   matches the if statement in foo but not in bar.
+/// switchStmt(hasInitStatement(anything()))
+///   matches the switch statement in foo but not in bar.
+/// cxxForRangeStmt(hasInitStatement(anything()))
+///   matches the range for statement in foo but not in bar.
+AST_POLYMORPHIC_MATCHER_P(hasInitStatement,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(IfStmt, SwitchStmt,
+  CXXForRangeStmt),
+  internal::Matcher, InnerMatcher) {
+  const Stmt *Init = Node.getInit();
+  return Init != nullptr && InnerMatcher.matches(*Init, Finder, Builder);
+}
+
 /// Matches the condition expression of an if statement, for loop,
 /// switch statement or conditional operator.
 ///
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -3009,6 +3009,23 @@
 
 
 
+MatcherExpr>nullPointerConstant
+Matches expressions that resolve to a null pointer constant, such as
+GNU's __null, C++11's nullptr, or C's NULL macro.
+

[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2019-12-26 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

Can we add an LLVM test w/ the metadata so that we have an entirely LLVM test 
flow that ensures the pass builder DTRT?

(I still would include the Clang side test which is also very useful to test 
integrating Clang w/ different flows through the pass manager.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71687



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


[clang-tools-extra] 5ca97d0 - Revert "Allow newlines in AST Matchers in clang-query files" + 1

2019-12-26 Thread Evgenii Stepanov via cfe-commits

Author: Evgenii Stepanov
Date: 2019-12-26T18:07:20-08:00
New Revision: 5ca97d0defeed38feec2352692f6bb80297d6712

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

LOG: Revert "Allow newlines in AST Matchers in clang-query files" + 1

Revert "Fix -Wunused-lambda-capture warnings."
This reverts commit 2369560f4a7720b19edfbf9de14ef061307ff773.
This reverts commit 522ee29a4fb3814db604b585c8637247477ec057.

clang/lib/ASTMatchers/Dynamic/Parser.cpp:610:13: warning: implicit conversion 
turns string literal into bool: 'const char [35]' to 'bool' 
[-Wstring-conversion]
assert(!"Newline should never be found here");

Added: 


Modified: 
clang-tools-extra/clang-query/Query.cpp
clang-tools-extra/clang-query/Query.h
clang-tools-extra/clang-query/QueryParser.cpp
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
clang/include/clang/ASTMatchers/Dynamic/Parser.h
clang/lib/ASTMatchers/Dynamic/Parser.cpp
clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/Query.cpp 
b/clang-tools-extra/clang-query/Query.cpp
index 8eafc5eed750..675fd968f46e 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -101,24 +101,9 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession 
&QS) const {
 Finder.matchAST(AST->getASTContext());
 
 if (QS.PrintMatcher) {
-  SmallVector Lines;
-  Source.split(Lines, "\n");
-  auto FirstLine = Lines[0];
-  Lines.erase(Lines.begin(), Lines.begin() + 1);
-  while (!Lines.empty() && Lines.back().empty()) {
-Lines.resize(Lines.size() - 1);
-  }
-  unsigned MaxLength = FirstLine.size();
-  std::string PrefixText = "Matcher: ";
-  OS << "\n  " << PrefixText << FirstLine;
-
-  for (auto Line : Lines) {
-OS << "\n" << std::string(PrefixText.size() + 2, ' ') << Line;
-MaxLength = std::max(MaxLength, Line.rtrim().size());
-  }
-
-  OS << "\n"
- << "  " << std::string(PrefixText.size() + MaxLength, '=') << "\n\n";
+  std::string prefixText = "Matcher: ";
+  OS << "\n  " << prefixText << Source << "\n";
+  OS << "  " << std::string(prefixText.size() + Source.size(), '=') << 
'\n';
 }
 
 for (auto MI = Matches.begin(), ME = Matches.end(); MI != ME; ++MI) {

diff  --git a/clang-tools-extra/clang-query/Query.h 
b/clang-tools-extra/clang-query/Query.h
index 78bcbc79cdf8..56af486984ee 100644
--- a/clang-tools-extra/clang-query/Query.h
+++ b/clang-tools-extra/clang-query/Query.h
@@ -44,7 +44,6 @@ struct Query : llvm::RefCountedBase {
   /// \return false if an error occurs, otherwise return true.
   virtual bool run(llvm::raw_ostream &OS, QuerySession &QS) const = 0;
 
-  StringRef RemainingContent;
   const QueryKind Kind;
 };
 

diff  --git a/clang-tools-extra/clang-query/QueryParser.cpp 
b/clang-tools-extra/clang-query/QueryParser.cpp
index a980722de9e6..4da2f5da79d4 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -26,10 +26,7 @@ namespace query {
 // is found before End, return StringRef().  Begin is adjusted to exclude the
 // lexed region.
 StringRef QueryParser::lexWord() {
-  Line = Line.drop_while([](char c) {
-// Don't trim newlines.
-return StringRef(" \t\v\f\r").contains(c);
-  });
+  Line = Line.ltrim();
 
   if (Line.empty())
 // Even though the Line is empty, it contains a pointer and
@@ -37,12 +34,12 @@ StringRef QueryParser::lexWord() {
 // code completion.
 return Line;
 
-  StringRef Word;
-  if (Line.front() == '#')
-Word = Line.substr(0, 1);
-  else
-Word = Line.take_until(isWhitespace);
+  if (Line.front() == '#') {
+Line = {};
+return StringRef();
+  }
 
+  StringRef Word = Line.take_until(isWhitespace);
   Line = Line.drop_front(Word.size());
   return Word;
 }
@@ -128,25 +125,9 @@ template  QueryRef 
QueryParser::parseSetOutputKind() {
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
-  StringRef Extra = Line;
-  StringRef ExtraTrimmed = Extra.drop_while(
-  [](char c) { return StringRef(" \t\v\f\r").contains(c); });
-
-  if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') ||
-  (ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' &&
-   ExtraTrimmed[1] == '\n'))
-Q->RemainingContent = Extra;
-  else {
-StringRef TrailingWord = lexWord();
-if (!TrailingWord.empty() && TrailingWord.front() == '#') {
-  Line = Line.drop_until([](char c) { return c == '\n'; });
-  Line = Line.drop_while([](char c) { return c == '\n'; });
-  return endQuery(Q);
-}
-if (!TrailingWord.empty()) {
-  return new InvalidQuery("unexpected ext

[PATCH] D71846: [ASTMatchers] Fix for https://bugs.llvm.org/show_bug.cgi?id=44364

2019-12-26 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Should also point out that clang-format now has a better time reformatting as i 
expanded the replacements range to include the entire else block rather than 
the start and end braces


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

https://reviews.llvm.org/D71846



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


Re: [clang] 522ee29 - Allow newlines in AST Matchers in clang-query files

2019-12-26 Thread Evgenii Stepanov via cfe-commits
Reverted in
https://github.com/llvm/llvm-project/commit/5ca97d0defeed38feec2352692f6bb80297d6712

On Thu, Dec 26, 2019 at 12:41 PM Stephen Kelly via cfe-commits
 wrote:
>
>
> Author: Stephen Kelly
> Date: 2019-12-26T20:40:33Z
> New Revision: 522ee29a4fb3814db604b585c8637247477ec057
>
> URL: 
> https://github.com/llvm/llvm-project/commit/522ee29a4fb3814db604b585c8637247477ec057
> DIFF: 
> https://github.com/llvm/llvm-project/commit/522ee29a4fb3814db604b585c8637247477ec057.diff
>
> LOG: Allow newlines in AST Matchers in clang-query files
>
> Reviewers: aaron.ballman
>
> Subscribers: cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D71842
>
> Added:
>
>
> Modified:
> clang-tools-extra/clang-query/Query.cpp
> clang-tools-extra/clang-query/Query.h
> clang-tools-extra/clang-query/QueryParser.cpp
> clang-tools-extra/clang-query/tool/ClangQuery.cpp
> clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
> clang/include/clang/ASTMatchers/Dynamic/Parser.h
> clang/lib/ASTMatchers/Dynamic/Parser.cpp
> clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang-tools-extra/clang-query/Query.cpp 
> b/clang-tools-extra/clang-query/Query.cpp
> index 675fd968f46e..8eafc5eed750 100644
> --- a/clang-tools-extra/clang-query/Query.cpp
> +++ b/clang-tools-extra/clang-query/Query.cpp
> @@ -101,9 +101,24 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession 
> &QS) const {
>  Finder.matchAST(AST->getASTContext());
>
>  if (QS.PrintMatcher) {
> -  std::string prefixText = "Matcher: ";
> -  OS << "\n  " << prefixText << Source << "\n";
> -  OS << "  " << std::string(prefixText.size() + Source.size(), '=') << 
> '\n';
> +  SmallVector Lines;
> +  Source.split(Lines, "\n");
> +  auto FirstLine = Lines[0];
> +  Lines.erase(Lines.begin(), Lines.begin() + 1);
> +  while (!Lines.empty() && Lines.back().empty()) {
> +Lines.resize(Lines.size() - 1);
> +  }
> +  unsigned MaxLength = FirstLine.size();
> +  std::string PrefixText = "Matcher: ";
> +  OS << "\n  " << PrefixText << FirstLine;
> +
> +  for (auto Line : Lines) {
> +OS << "\n" << std::string(PrefixText.size() + 2, ' ') << Line;
> +MaxLength = std::max(MaxLength, Line.rtrim().size());
> +  }
> +
> +  OS << "\n"
> + << "  " << std::string(PrefixText.size() + MaxLength, '=') << 
> "\n\n";
>  }
>
>  for (auto MI = Matches.begin(), ME = Matches.end(); MI != ME; ++MI) {
>
> diff  --git a/clang-tools-extra/clang-query/Query.h 
> b/clang-tools-extra/clang-query/Query.h
> index 56af486984ee..78bcbc79cdf8 100644
> --- a/clang-tools-extra/clang-query/Query.h
> +++ b/clang-tools-extra/clang-query/Query.h
> @@ -44,6 +44,7 @@ struct Query : llvm::RefCountedBase {
>/// \return false if an error occurs, otherwise return true.
>virtual bool run(llvm::raw_ostream &OS, QuerySession &QS) const = 0;
>
> +  StringRef RemainingContent;
>const QueryKind Kind;
>  };
>
>
> diff  --git a/clang-tools-extra/clang-query/QueryParser.cpp 
> b/clang-tools-extra/clang-query/QueryParser.cpp
> index 4da2f5da79d4..db4b9a4b0530 100644
> --- a/clang-tools-extra/clang-query/QueryParser.cpp
> +++ b/clang-tools-extra/clang-query/QueryParser.cpp
> @@ -26,7 +26,10 @@ namespace query {
>  // is found before End, return StringRef().  Begin is adjusted to exclude the
>  // lexed region.
>  StringRef QueryParser::lexWord() {
> -  Line = Line.ltrim();
> +  Line = Line.drop_while([this](char c) {
> +// Don't trim newlines.
> +return StringRef(" \t\v\f\r").contains(c);
> +  });
>
>if (Line.empty())
>  // Even though the Line is empty, it contains a pointer and
> @@ -34,12 +37,12 @@ StringRef QueryParser::lexWord() {
>  // code completion.
>  return Line;
>
> -  if (Line.front() == '#') {
> -Line = {};
> -return StringRef();
> -  }
> +  StringRef Word;
> +  if (Line.front() == '#')
> +Word = Line.substr(0, 1);
> +  else
> +Word = Line.take_until(isWhitespace);
>
> -  StringRef Word = Line.take_until(isWhitespace);
>Line = Line.drop_front(Word.size());
>return Word;
>  }
> @@ -125,9 +128,25 @@ template  QueryRef 
> QueryParser::parseSetOutputKind() {
>  }
>
>  QueryRef QueryParser::endQuery(QueryRef Q) {
> -  const StringRef Extra = Line;
> -  if (!lexWord().empty())
> -return new InvalidQuery("unexpected extra input: '" + Extra + "'");
> +  StringRef Extra = Line;
> +  StringRef ExtraTrimmed = Extra.drop_while(
> +  [](char c) { return StringRef(" \t\v\f\r").contains(c); });
> +
> +  if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') ||
> +  (ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' &&
> +   ExtraTrimmed[1] == '\n'))
> +Q->RemainingContent = Extra;
> +  else {
> +StringRef TrailingWord = lexWord();
> +if (!TrailingWord.empty() && Trailing

[PATCH] D62731: Add support for options -frounding-math, -ftrapping-math, -ffp-model=, and -ffp-exception-behavior=, : Specify floating point behavior

2019-12-26 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D62731#1796962 , @AntonYudintsev 
wrote:

> I have found bug in clang-cl (win32 clang), related to recent inroduction of 
> ffp-exception-behavior.
>  Unfortunately, I don't have a working patch yet, and since LLVM bugtracker 
> registration is closed, I can not even submit a bug.
>
> So, if it is not a trouble for you, I will email the bug description here.
>
> Please let me know if it isn't appropriate. Bug description:
>  
>
> Windows: clang-cl is generating call to non-existing lib function for win32 
> with /fp:except option.
>  With recent ffp-exception-behavior=maytrap/strict, fp:except in clang-cl 
> became generate FPE aware code.
>
> But in case of floorf and ceilf it generates call to non-existing library 
> function.
>
> clang-cl.exe -m32 /Ox /fp:except testFloor.cpp /FA
>  testFloor.cpp:
>
>   #include 
>   float ret(float v) {  return floorf(v); }
>
>
> resulting assember:
>
>   pusheax
>   movssxmm0, dword ptr [esp + 8]
>   movssdword ptr [esp], xmm0
>   call_floorf #no such function!!!
>   popeax
>   ret
>   
>
> Expected behaviour:
>
> there is no floorf lib function. Like with cosf and other math functions, 
> floorf in MSVC is implemented as inline function.
>
> So, it should be call to _floor (with apropriate conversion first).


Hopefully fixed by 53ee806d93e8d2371726ec5ce59b0e68b309c258 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62731



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


[PATCH] D71903: [Coroutines][6/6] Clang schedules new passes

2019-12-26 Thread JunMa via Phabricator via cfe-commits
junparser added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1227
+  
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CoroSplitPass()));
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroElidePass()));
+  
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CoroSplitPass()));

Since coro elision depends on other optimization pass(inline and so on)  
implicitly,  how can we adjust the pipeline to achieve this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71903



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


[PATCH] D70290: [OpenMP] Use the OpenMPIRBuilder for "omp parallel"

2019-12-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 235390.
jdoerfert added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Rebase + add a test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70290

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -260,6 +260,10 @@
   Function *OutlinedFn = PrivAI->getFunction();
   EXPECT_NE(F, OutlinedFn);
   EXPECT_FALSE(verifyModule(*M));
+  EXPECT_TRUE(OutlinedFn->hasFnAttribute(Attribute::NoUnwind));
+  EXPECT_TRUE(OutlinedFn->hasFnAttribute(Attribute::NoRecurse));
+  EXPECT_TRUE(OutlinedFn->hasParamAttribute(0, Attribute::NoAlias));
+  EXPECT_TRUE(OutlinedFn->hasParamAttribute(1, Attribute::NoAlias));
 
   EXPECT_TRUE(OutlinedFn->hasInternalLinkage());
   EXPECT_EQ(OutlinedFn->arg_size(), 3U);
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
@@ -452,10 +453,21 @@
   dbgs() << " PBR: " << BB->getName() << "\n";
   });
 
+  // Add some known attributes to the outlined function.
   Function *OutlinedFn = Extractor.extractCodeRegion(CEAC);
+  OutlinedFn->addParamAttr(0, Attribute::NoAlias);
+  OutlinedFn->addParamAttr(1, Attribute::NoAlias);
+  OutlinedFn->addFnAttr(Attribute::NoUnwind);
+  OutlinedFn->addFnAttr(Attribute::NoRecurse);
+
   LLVM_DEBUG(dbgs() << "After  outlining: " << *UI->getFunction() << "\n");
   LLVM_DEBUG(dbgs() << "   Outlined function: " << *OutlinedFn << "\n");
 
+  // For compability with the clang CG we move the outlined function after the
+  // one with the parallel region.
+  OutlinedFn->removeFromParent();
+  M.getFunctionList().insertAfter(OuterFn->getIterator(), OutlinedFn);
+
   // Remove the artificial entry introduced by the extractor right away, we
   // made our own entry block after all.
   {
@@ -486,6 +498,23 @@
   RealArgs.append(CI->arg_begin() + /* tid & bound tid */ 2, CI->arg_end());
 
   FunctionCallee RTLFn = getOrCreateRuntimeFunction(OMPRTL___kmpc_fork_call);
+  if (auto *F = dyn_cast(RTLFn.getCallee())) {
+if (!F->hasMetadata(llvm::LLVMContext::MD_callback)) {
+  llvm::LLVMContext &Ctx = F->getContext();
+  MDBuilder MDB(Ctx);
+  // Annotate the callback behavior of the __kmpc_fork_call:
+  //  - The callback callee is argument number 2 (microtask).
+  //  - The first two arguments of the callback callee are unknown (-1).
+  //  - All variadic arguments to the __kmpc_fork_call are passed to the
+  //callback callee.
+  F->addMetadata(
+  llvm::LLVMContext::MD_callback,
+  *llvm::MDNode::get(Ctx, {MDB.createCallbackEncoding(
+  2, {-1, -1},
+  /* VarArgsArePassed */ true)}));
+}
+  }
+
   Builder.CreateCall(RTLFn, RealArgs);
 
   LLVM_DEBUG(dbgs() << "With fork_call placed: "
Index: llvm/lib/Frontend/OpenMP/OMPConstants.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPConstants.cpp
+++ llvm/lib/Frontend/OpenMP/OMPConstants.cpp
@@ -65,7 +65,7 @@
 #define OMP_TYPE(VarName, InitValue) VarName = InitValue;
 #define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...)  \
   VarName = FunctionType::get(ReturnType, {__VA_ARGS__}, IsVarArg);\
-  VarName##Ptr = PointerType::getUnqual(T);
+  VarName##Ptr = PointerType::getUnqual(VarName);
 #define OMP_STRUCT_TYPE(VarName, StructName, ...)  \
   T = M.getTypeByName(StructName); \
   if (!T)  \
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -203,6 +203,9 @@
 #define __OMP_RTL_ATTRS(Name, FnAttrSet, RetAttrSet, ArgAttrSets)  \
   OMP_RTL_ATTRS(OMPRTL_##Name, FnAttrSet, RetAttrSet, ArgAttrSets)
 
+__OMP_RTL_ATTRS(__kmpc_fork_call, AttributeSet(EnumAttr(NoUnwind)),
+   

[PATCH] D70290: [OpenMP] Use the OpenMPIRBuilder for "omp parallel"

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

{icon times-circle color=red} Unit tests: fail. 61124 tests passed, 1 failed 
and 728 were skipped.

  failed: Clang.OpenMP/cancel_codegen.cpp

{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/D70290/new/

https://reviews.llvm.org/D70290



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


[PATCH] D64573: [Syntax] Allow to mutate syntax trees

2019-12-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for the fixes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64573



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


[PATCH] D69272: Enable '#pragma STDC FENV_ACCESS' in frontend

2019-12-26 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 235392.
sepavloff added a comment.

Updated patch

Removed the previous limitation on use of the pragma, which restricted the
pragma to the topmost block only. It should favor users who do not bother
about performance but want the usage be as defined by the Standard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69272

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CodeGen/pragma-fenv_access.c
  clang/test/Parser/pragma-fenv_access.c
  clang/test/Preprocessor/pragma_unknown.c

Index: clang/test/Preprocessor/pragma_unknown.c
===
--- clang/test/Preprocessor/pragma_unknown.c
+++ clang/test/Preprocessor/pragma_unknown.c
@@ -16,15 +16,6 @@
 // CHECK: {{^}}#pragma STDC FP_CONTRACT DEFAULT{{$}}
 // CHECK: {{^}}#pragma STDC FP_CONTRACT IN_BETWEEN{{$}}
 
-#pragma STDC FENV_ACCESS ON  // expected-warning {{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
-#pragma STDC FENV_ACCESS OFF
-#pragma STDC FENV_ACCESS DEFAULT
-#pragma STDC FENV_ACCESS IN_BETWEEN   // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS ON{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS OFF{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS DEFAULT{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS IN_BETWEEN{{$}}
-
 #pragma STDC CX_LIMITED_RANGE ON
 #pragma STDC CX_LIMITED_RANGE OFF
 #pragma STDC CX_LIMITED_RANGE DEFAULT 
Index: clang/test/Parser/pragma-fenv_access.c
===
--- /dev/null
+++ clang/test/Parser/pragma-fenv_access.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#pragma STDC FENV_ACCESS IN_BETWEEN   // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
+
+#pragma STDC FENV_ACCESS OFF
+
+float func_04(int x, float y) {
+  if (x)
+return y + 2;
+  #pragma STDC FENV_ACCESS ON // expected-error{{'#pragma STDC FENV_ACCESS' can only appear at file scope or at the start of a compound statement}}
+  return x + y;
+}
Index: clang/test/CodeGen/pragma-fenv_access.c
===
--- /dev/null
+++ clang/test/CodeGen/pragma-fenv_access.c
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+
+#pragma STDC FENV_ACCESS ON
+
+float func_01(float x, float y) {
+  return x + y;
+}
+// CHECK-LABEL: @func_01
+// CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+
+
+float func_02(float x, float y) {
+  #pragma STDC FENV_ACCESS OFF
+  return x + y;
+}
+// CHECK-LABEL: @func_02
+// CHECK: fadd float {{.*}}
+
+
+float func_03(float x, float y) {
+  return x + y;
+}
+// CHECK-LABEL: @func_03
+// CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+
+
+#pragma STDC FENV_ACCESS OFF
+
+float func_04(float x, float y) {
+  return x + y;
+}
+// CHECK-LABEL: @func_04
+// CHECK: fadd float {{.*}}
+
+
+float func_05(float x, float y) {
+  #pragma STDC FENV_ACCESS ON
+  return x + y;
+}
+// CHECK-LABEL: @func_05
+// CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+
+
+float func_06(float x, float y) {
+  return x + y;
+}
+// CHECK-LABEL: @func_06
+// CHECK: fadd float {{.*}}
+
+
+float func_07(float x, float y) {
+  x -= y;
+  if (x) {
+#pragma STDC FENV_ACCESS ON
+y *= 2;
+  }
+  return y + 4;
+}
+// CHECK-LABEL: @func_07
+// CHECK: call float @llvm.experimental.constrained.fsub.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+// CHECK: call float @llvm.experimental.constrained.fmul.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+// CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -9837,7 +9837,7 @@
   RHS.get() == E->getRHS())
 return E;
 
-  Sema::FPContractStateRAII FPContractState(getSema());
+  Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
   getSema().FPFeatures = E->getFPFeatures();
 
   return getDerived().RebuildBinaryOperator(E->ge

Re: [clang] ce1f95a - Reland "[clang] Remove the DIFlagArgumentNotModified debug info flag"

2019-12-26 Thread Djordje Todorovic via cfe-commits
Hi David,

It's a good question.

Current approach of the debug entry values will consider an entry value as a 
valid value until the variable gets modified.

Please consider this.

void fn(int a) {
  ...
  a++;
}

If there is an instruction that does not affect the code generated, e.g. an ADD 
instruction that gets optimized out from the case above, it won't force us to 
invalidate all the entry values before, since the instruction is not there in 
the final code generated. The GCC does the same thing in that situation. But if 
the instruction were at the beginning of the function (or somewhere else), we 
believe that there is an DBG_VALUE representing that variable's change (e.g. 
generated from the Salvage Debug Info), so the entry value would not be used 
any more.

If we come up with a case where a dead store causing an invalid use of the 
entry values, that will be good point for improvements.

Best regards,
Djordje

On 26.12.19. 22:33, David Blaikie wrote:
> 
> 
> On Wed, Nov 20, 2019 at 1:08 AM Djordje Todorovic via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> 
> 
> Author: Djordje Todorovic
> Date: 2019-11-20T10:08:07+01:00
> New Revision: ce1f95a6e077693f93d8869245f911aff3eb7e4c
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/ce1f95a6e077693f93d8869245f911aff3eb7e4c
> DIFF: 
> https://github.com/llvm/llvm-project/commit/ce1f95a6e077693f93d8869245f911aff3eb7e4c.diff
> 
> LOG: Reland "[clang] Remove the DIFlagArgumentNotModified debug info flag"
> 
> It turns out that the ExprMutationAnalyzer can be very slow when AST
> gets huge in some cases. The idea is to move this analysis to the LLVM
> back-end level (more precisely, in the LiveDebugValues pass). The new
> approach will remove the performance regression, simplify the
> implementation and give us front-end independent implementation.
> 
> 
> What if the LLVM backend optimized out a dead store? (then we might concnlude 
> that the argument is not modified, when it actually is modified?)
>  
> 
> 
> Differential Revision: https://reviews.llvm.org/D68206
> 
> Added:
> 
> 
> Modified:
>     clang/lib/CodeGen/CGDebugInfo.cpp
>     clang/lib/CodeGen/CGDebugInfo.h
>     
> lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
> 
> Removed:
>     clang/test/CodeGen/debug-info-param-modification.c
> 
> 
> 
> 
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index 116517a9cb99..a9b3831aa0b5 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -18,7 +18,6 @@
>  #include "CodeGenFunction.h"
>  #include "CodeGenModule.h"
>  #include "ConstantEmitter.h"
> -#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
>  #include "clang/AST/ASTContext.h"
>  #include "clang/AST/DeclFriend.h"
>  #include "clang/AST/DeclObjC.h"
> @@ -3686,15 +3685,6 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, 
> SourceLocation Loc,
>    if (HasDecl && isa(D))
>      DeclCache[D->getCanonicalDecl()].reset(SP);
> 
> -  // We use the SPDefCache only in the case when the debug entry values 
> option
> -  // is set, in order to speed up parameters modification analysis.
> -  //
> -  // FIXME: Use AbstractCallee here to support ObjCMethodDecl.
> -  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl)
> -    if (auto *FD = dyn_cast(D))
> -      if (FD->hasBody() && !FD->param_empty())
> -        SPDefCache[FD].reset(SP);
> -
>    // Push the function onto the lexical block stack.
>    LexicalBlockStack.emplace_back(SP);
> 
> @@ -4097,11 +4087,6 @@ llvm::DILocalVariable 
> *CGDebugInfo::EmitDeclare(const VarDecl *VD,
>                           llvm::DebugLoc::get(Line, Column, Scope, 
> CurInlinedAt),
>                           Builder.GetInsertBlock());
> 
> -  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
> -    if (auto *PD = dyn_cast(VD))
> -      ParamCache[PD].reset(D);
> -  }
> -
>    return D;
>  }
> 
> @@ -4717,29 +4702,6 @@ void CGDebugInfo::setDwoId(uint64_t Signature) {
>    TheCU->setDWOId(Signature);
>  }
> 
> -/// Analyzes each function parameter to determine whether it is constant
> -/// throughout the function body.
> -static void analyzeParametersModification(
> -    ASTContext &Ctx,
> -    llvm::DenseMap 
> &SPDefCache,
> -    llvm::DenseMap 
> &ParamCache) {
> -  for (auto &SP : SPDefCache) {
> -    auto *FD = SP.first;
> -    assert(FD->hasBody() && "Functions must have body here");
> -    const Stmt *FuncBody = (*FD).getBody();
> -    for (auto Parm : FD->parameters()) {
> -      ExprMutationAnalyzer F