[clang] 0f88cae - [Analyzer] Checker for Debugging Iterator Checkers

2019-11-07 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2019-11-08T08:59:50+01:00
New Revision: 0f88caeef8f2d4708f442d03db7723396712a143

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

LOG: [Analyzer] Checker for Debugging Iterator Checkers

For white-box testing correct container and iterator modelling it is essential
to access the internal data structures stored for container and iterators. This
patch introduces a simple debug checkers called debug.IteratorDebugging to
achieve this.

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

Added: 
clang/test/Analysis/debug-iterator-modeling.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 4d52655045b3..be455ae14f57 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1343,6 +1343,11 @@ def ReportStmts : Checker<"ReportStmts">,
   HelpText<"Emits a warning for every statement.">,
   Documentation;
 
+def DebugIteratorModeling : Checker<"DebugIteratorModeling">,
+  HelpText<"Check the analyzer's understanding of C++ iterators">,
+  Dependencies<[IteratorModeling]>,
+  Documentation;
+
 } // end "debug"
 
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
index 97ace68569ef..a84327f07a52 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -173,11 +173,12 @@ struct ContainerData {
 class IteratorChecker
 : public Checker, check::Bind,
- check::LiveSymbols, check::DeadSymbols> {
+ check::LiveSymbols, check::DeadSymbols, eval::Call> {
 
   std::unique_ptr OutOfRangeBugType;
   std::unique_ptr MismatchedBugType;
   std::unique_ptr InvalidatedBugType;
+  std::unique_ptr DebugMsgBugType;
 
   void handleComparison(CheckerContext , const Expr *CE, const SVal ,
 const SVal , const SVal ,
@@ -236,7 +237,35 @@ class IteratorChecker
ExplodedNode *ErrNode) const;
   void reportInvalidatedBug(const StringRef , const SVal ,
 CheckerContext , ExplodedNode *ErrNode) const;
-
+  template 
+  void analyzerContainerDataField(const CallExpr *CE, CheckerContext ,
+  Getter get) const;
+  void analyzerContainerBegin(const CallExpr *CE, CheckerContext ) const;
+  void analyzerContainerEnd(const CallExpr *CE, CheckerContext ) const;
+  template 
+  void analyzerIteratorDataField(const CallExpr *CE, CheckerContext ,
+ Getter get, SVal Default) const;
+  void analyzerIteratorPosition(const CallExpr *CE, CheckerContext ) const;
+  void analyzerIteratorContainer(const CallExpr *CE, CheckerContext ) const;
+  void analyzerIteratorValidity(const CallExpr *CE, CheckerContext ) const;
+  ExplodedNode *reportDebugMsg(llvm::StringRef Msg, CheckerContext ) const;
+
+  typedef void (IteratorChecker::*FnCheck)(const CallExpr *,
+   CheckerContext &) const;
+
+  CallDescriptionMap Callbacks = {
+{{0, "clang_analyzer_container_begin", 1},
+ ::analyzerContainerBegin},
+{{0, "clang_analyzer_container_end", 1},
+ ::analyzerContainerEnd},
+{{0, "clang_analyzer_iterator_position", 1},
+ ::analyzerIteratorPosition},
+{{0, "clang_analyzer_iterator_container", 1},
+ ::analyzerIteratorContainer},
+{{0, "clang_analyzer_iterator_validity", 1},
+ ::analyzerIteratorValidity},
+  };
+  
 public:
   IteratorChecker();
 
@@ -244,6 +273,7 @@ class IteratorChecker
 CK_IteratorRangeChecker,
 CK_MismatchedIteratorChecker,
 CK_InvalidatedIteratorChecker,
+CK_DebugIteratorModeling,
 CK_NumCheckKinds
   };
 
@@ -259,6 +289,7 @@ class IteratorChecker
  CheckerContext ) const;
   void checkLiveSymbols(ProgramStateRef State, SymbolReaper ) const;
   void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
+  bool evalCall(const CallEvent , CheckerContext ) const;
 };
 } // namespace
 
@@ -362,6 +393,9 @@ IteratorChecker::IteratorChecker() {
   /*SuppressOnSink=*/true));
   InvalidatedBugType.reset(
   new BugType(this, "Iterator invalidated", "Misuse of STL APIs"));
+  DebugMsgBugType.reset(
+  new BugType(this, "Checking analyzer assumptions", "debug",
+  /*SuppressOnSink=*/true));
 }
 
 void IteratorChecker::checkPreCall(const CallEvent ,
@@ -1627,6 +1661,124 @@ void IteratorChecker::reportInvalidatedBug(const 

[PATCH] D69991: Implement __attribute__((objc_direct)), __attribute__((objc_direct_members))

2019-11-07 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder marked 2 inline comments as done.
MadCoder added inline comments.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:1588
 // interface, we cannot perform this check.
+   //
+   // Note that for direct methods, because objc_msgSend is skipped,

doh I'll fix the tabs



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:4075
+
+  if (OMD->isClassMethod()) {
+const ObjCInterfaceDecl *OID = dyn_cast(CD);

I suspect this function requires synthesizing some debug metadata but I have 
absolutely no idea how and what ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69991



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


[PATCH] D69991: Implement __attribute__((objc_direct)), __attribute__((objc_direct_members))

2019-11-07 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder created this revision.
MadCoder added reviewers: rjmccall, jfb, doug.gregor, dexonsmith.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

__attribute__((objc_direct)) is an attribute on methods declaration and
implementation, categories, or extensions (for the latter two it applies
the attribute to all methods declared in the category/implementation),

A `direct` property specifier is added (@property(direct) type name)

These attributes / specifiers cause the method to have no associated
Objective-C metadata (for the property or the method itself), and the
calling convention to be a direct C function call.

The symbol for the method has enforced hidden visibility and such direct
calls are hence unreachable cross image. An explicit C function must be
made if so desired to wrap them.

The implicit `self` and `_cmd` arguments are preserved, however to
maintain compatibility with the usual `objc_msgSend` semantics,
3 fundamental precautions are taken:

1. for instance methods, `self` is nil-checked. On arm64 backends this 
typically adds a single instruction (cbz x0, ) to the codegen, for 
the vast majority of the cases when the return type is a scalar.

2. for class methods, because the class may not be realized/initialized yet, a 
call to `[self self]` is emitted. When the proper deployment target is used, 
this is optimized to `objc_opt_self(self)`.

  However, long term we might want to emit something better that the optimizer 
can reason about. When inlining kicks in, these calls aren't optimized away as 
the optimizer has no idea that a single call is really necessary.

3. the calling convention for the `_cmd` argument is changed: the caller leaves 
the second argument to the call undefined, and the selector is loaded inside 
the body when it's referenced only.

As far as error reporting goes, the compiler refuses:

- making any overloads direct,
- making an overload of a direct method,
- implementations marked as direct when the declaration in the interface isn't 
(the other way around is allowed, as the direct attribute is inherited from the 
declaration),
- marking methods required for protocol conformance as direct,
- messaging an unqualified `id` with a direct method,
- forming any @selector() expression with only direct selectors.

As warnings:

- any inconsistency of direct-related calling convention when @selector() or 
messaging is used,
- forming any @selector() expression with a possibly direct selector.

Lastly an `objc_direct_members` attribute is added that can decorate
`@implementation` blocks and causes methods only declared there (and in
no `@interface`) to be automatically direct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69991

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGObjCRuntime.h
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/test/CodeGenObjC/direct-method.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/method-direct.m

Index: clang/test/SemaObjC/method-direct.m
===
--- /dev/null
+++ clang/test/SemaObjC/method-direct.m
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wselector-type-mismatch %s
+
+@protocol Proto
+- (void)protoMethod; // expected-note {{previous declaration is here}}
++ (void)classProtoMethod; // expected-note {{previous declaration is here}}
+@end
+
+@protocol ProtoDirectFail
+- (void)protoMethod __attribute__((objc_direct)); // expected-error {{objc_direct attribute cannot be applied to methods declared in an Objective-C protocol}}
++ (void)classProtoMethod __attribute__((objc_direct)); // expected-error {{objc_direct attribute cannot be applied to methods declared in an Objective-C protocol}}
+@end
+
+__attribute__((objc_root_class))
+@interface Root
+- (void)rootRegular; // expected-note {{previous declaration is here}}
++ (void)classRootRegular; // expected-note {{previous declaration is here}}
+- (void)rootDirect __attribute__((objc_direct)); // expected-note {{previous declaration is here}};
++ (void)classRootDirect __attribute__((objc_direct)); // expected-note {{previous declaration is here}};
+- (void)notDirectInIface; // expected-note {{previous declaration is here}}
++ (void)classNotDirectInIface; // expected-note {{previous declaration is here}}
+@end
+
+__attribute__((objc_direct))

[PATCH] D69990: Populate CUDA flags on FreeBSD too, as many other toolchains do.

2019-11-07 Thread Gleb Popov via Phabricator via cfe-commits
6yearold created this revision.
Herald added subscribers: cfe-commits, emaste.
Herald added a project: clang.

This allows `clang` to be used to compile CUDA programs. Compiled
simple helloworld.cu with this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69990

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/FreeBSD.h


Index: clang/lib/Driver/ToolChains/FreeBSD.h
===
--- clang/lib/Driver/ToolChains/FreeBSD.h
+++ clang/lib/Driver/ToolChains/FreeBSD.h
@@ -64,6 +64,8 @@
   llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
+  void AddCudaIncludeArgs(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
 
   llvm::ExceptionHandling GetExceptionModel(
   const llvm::opt::ArgList ) const override;
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -397,6 +397,11 @@
   }
 }
 
+void FreeBSD::AddCudaIncludeArgs(const ArgList ,
+ ArgStringList ) const {
+  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
+}
+
 Tool *FreeBSD::buildAssembler() const {
   return new tools::freebsd::Assembler(*this);
 }


Index: clang/lib/Driver/ToolChains/FreeBSD.h
===
--- clang/lib/Driver/ToolChains/FreeBSD.h
+++ clang/lib/Driver/ToolChains/FreeBSD.h
@@ -64,6 +64,8 @@
   llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
+  void AddCudaIncludeArgs(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
 
   llvm::ExceptionHandling GetExceptionModel(
   const llvm::opt::ArgList ) const override;
Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -397,6 +397,11 @@
   }
 }
 
+void FreeBSD::AddCudaIncludeArgs(const ArgList ,
+ ArgStringList ) const {
+  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
+}
+
 Tool *FreeBSD::buildAssembler() const {
   return new tools::freebsd::Assembler(*this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69935: [DeclCXX] Remove unknown external linkage specifications

2019-11-07 Thread Ehud Katz via Phabricator via cfe-commits
ekatz added a comment.

Yes, these changes regard to the same thing - the removal of the "Linkage-Spec 
LanguageIDs". As you described it nicely, it is for linkage only, meaning C vs 
C++.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69935



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


[PATCH] D69292: Proposal to add -Wtautological-compare to -Wall

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Thanks. Looks good.


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

https://reviews.llvm.org/D69292



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-11-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 228364.
jdoerfert added a comment.

Do not eagerly create function declarations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785

Files:
  llvm/include/llvm/IR/OpenMPConstants.h
  llvm/include/llvm/IR/OpenMPIRBuilder.h
  llvm/include/llvm/IR/OpenMPKinds.def
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/OpenMPConstants.cpp
  llvm/lib/IR/OpenMPIRBuilder.cpp
  llvm/unittests/IR/CMakeLists.txt
  llvm/unittests/IR/IRBuilderTest.cpp
  llvm/unittests/IR/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/IR/OpenMPIRBuilderTest.cpp
===
--- /dev/null
+++ llvm/unittests/IR/OpenMPIRBuilderTest.cpp
@@ -0,0 +1,129 @@
+//===- llvm/unittest/IR/OpenMPIRBuilderTest.cpp - OpenMPIRBuilder tests ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/IR/OpenMPIRBuilder.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/DIBuilder.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/OpenMPConstants.h"
+#include "llvm/IR/Verifier.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace omp;
+using namespace types;
+
+namespace {
+
+class OpenMPIRBuilderTest : public testing::Test {
+protected:
+  void SetUp() override {
+M.reset(new Module("MyModule", Ctx));
+FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx),
+  /*isVarArg=*/false);
+F = Function::Create(FTy, Function::ExternalLinkage, "", M.get());
+BB = BasicBlock::Create(Ctx, "", F);
+  }
+
+  void TearDown() override {
+BB = nullptr;
+M.reset();
+uninitializeTypes();
+  }
+
+  LLVMContext Ctx;
+  std::unique_ptr M;
+  Function *F;
+  BasicBlock *BB;
+};
+
+TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  IRBuilder<> Builder(BB);
+
+  OMPBuilder.CreateBarrier({IRBuilder<>::InsertPoint()}, OMPD_for);
+  EXPECT_TRUE(M->global_empty());
+  EXPECT_EQ(M->size(), 6U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 0U);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 6U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 2U);
+
+  CallInst *GTID = dyn_cast(>front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), "__kmpc_global_thread_num");
+
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_NE(Barrier, nullptr);
+  EXPECT_EQ(Barrier->getNumArgOperands(), 2U);
+  EXPECT_EQ(Barrier->getCalledFunction()->getName(), "__kmpc_barrier");
+
+  EXPECT_EQ(cast(Barrier)->getArgOperand(1), GTID);
+
+  Builder.CreateUnreachable();
+  EXPECT_FALSE(verifyModule(*M));
+}
+
+TEST_F(OpenMPIRBuilderTest, DbgLoc) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+
+  IRBuilder<> Builder(BB);
+
+  DIBuilder DIB(*M);
+  auto File = DIB.createFile("test.dbg", "/");
+  auto CU =
+  DIB.createCompileUnit(dwarf::DW_LANG_C, File, "llvm-C", true, "", 0);
+  auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
+  auto SP = DIB.createFunction(
+  CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
+  DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
+  F->setSubprogram(SP);
+  auto Scope = DIB.createLexicalBlockFile(SP, File, 0);
+  DIB.finalize();
+
+  DebugLoc DL = DebugLoc::get(3, 7, Scope);
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  CallInst *GTID = dyn_cast(>front());
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_EQ(GTID->getDebugLoc(), DL);
+  EXPECT_EQ(Barrier->getDebugLoc(), DL);
+  EXPECT_TRUE(isa(Barrier->getOperand(0)));
+  if (!isa(Barrier->getOperand(0)))
+return;
+  GlobalVariable *Ident = cast(Barrier->getOperand(0));
+  EXPECT_TRUE(Ident->hasInitializer());
+  if (!Ident->hasInitializer())
+return;
+  Constant *Initializer = Ident->getInitializer();
+  EXPECT_TRUE(
+  isa(Initializer->getOperand(4)->stripPointerCasts()));
+  GlobalVariable *SrcStrGlob =
+  cast(Initializer->getOperand(4)->stripPointerCasts());
+  if (!SrcStrGlob)
+return;
+  EXPECT_TRUE(isa(SrcStrGlob->getInitializer()));
+  ConstantDataArray *SrcSrc =
+  dyn_cast(SrcStrGlob->getInitializer());
+  if (!SrcSrc)
+return;
+  EXPECT_EQ(SrcSrc->getAsCString(), ";test.dbg;foo;3;7;;");
+}
+} // namespace
Index: llvm/unittests/IR/IRBuilderTest.cpp

[PATCH] D69292: Proposal to add -Wtautological-compare to -Wall

2019-11-07 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu updated this revision to Diff 228361.
rtrieu added a comment.

Add -Wall tests to check that certain warning groups are active with it and a 
test to check all warning groups that are turned on by -Wall.


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

https://reviews.llvm.org/D69292

Files:
  include/clang/Basic/DiagnosticGroups.td
  test/Misc/warning-wall.c
  test/Sema/warn-bitwise-compare.c
  test/Sema/warn-overlap.c
  test/SemaCXX/warn-bitwise-compare.cpp

Index: test/SemaCXX/warn-bitwise-compare.cpp
===
--- test/SemaCXX/warn-bitwise-compare.cpp
+++ test/SemaCXX/warn-bitwise-compare.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-bitwise-compare %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -Wno-unused %s
 
 void test(int x) {
   bool b1 = (8 & x) == 3;
Index: test/Sema/warn-overlap.c
===
--- test/Sema/warn-overlap.c
+++ test/Sema/warn-overlap.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-overlap-compare %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -Wno-unused -Wno-loop-analysis %s
 
 #define mydefine 2
 
Index: test/Sema/warn-bitwise-compare.c
===
--- test/Sema/warn-bitwise-compare.c
+++ test/Sema/warn-bitwise-compare.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-bitwise-compare %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -Wno-unused %s
 
 #define mydefine 2
 
Index: test/Misc/warning-wall.c
===
--- test/Misc/warning-wall.c
+++ test/Misc/warning-wall.c
@@ -0,0 +1,95 @@
+RUN: diagtool tree -Wall > %t 2>&1
+RUN: FileCheck --input-file=%t %s
+
+ CHECK:-Wall
+CHECK-NEXT:  -Wmost
+CHECK-NEXT:-Wchar-subscripts
+CHECK-NEXT:-Wcomment
+CHECK-NEXT:-Wdelete-non-virtual-dtor
+CHECK-NEXT:  -Wdelete-non-abstract-non-virtual-dtor
+CHECK-NEXT:  -Wdelete-abstract-non-virtual-dtor
+CHECK-NEXT:-Wfor-loop-analysis
+CHECK-NEXT:-Wformat
+CHECK-NEXT:  -Wformat-extra-args
+CHECK-NEXT:  -Wformat-zero-length
+CHECK-NEXT:  -Wnonnull
+CHECK-NEXT:  -Wformat-security
+CHECK-NEXT:  -Wformat-y2k
+CHECK-NEXT:  -Wformat-invalid-specifier
+CHECK-NEXT:-Wimplicit
+CHECK-NEXT:  -Wimplicit-function-declaration
+CHECK-NEXT:  -Wimplicit-int
+CHECK-NEXT:-Winfinite-recursion
+CHECK-NEXT:-Wint-in-bool-context
+CHECK-NEXT:-Wmismatched-tags
+CHECK-NEXT:-Wmissing-braces
+CHECK-NEXT:-Wmove
+CHECK-NEXT:  -Wpessimizing-move
+CHECK-NEXT:  -Wredundant-move
+CHECK-NEXT:  -Wreturn-std-move
+CHECK-NEXT:  -Wself-move
+CHECK-NEXT:-Wmultichar
+CHECK-NEXT:-Wreorder
+CHECK-NEXT:  -Wreorder-ctor
+CHECK-NEXT:  -Wreorder-init-list
+CHECK-NEXT:-Wreturn-type
+CHECK-NEXT:  -Wreturn-type-c-linkage
+CHECK-NEXT:-Wself-assign
+CHECK-NEXT:  -Wself-assign-overloaded
+CHECK-NEXT:  -Wself-assign-field
+CHECK-NEXT:-Wself-move
+CHECK-NEXT:-Wsizeof-array-argument
+CHECK-NEXT:-Wsizeof-array-decay
+CHECK-NEXT:-Wstring-plus-int
+CHECK-NEXT:-Wtautological-compare
+CHECK-NEXT:  -Wtautological-constant-compare
+CHECK-NEXT:-Wtautological-constant-out-of-range-compare
+CHECK-NEXT:  -Wtautological-pointer-compare
+CHECK-NEXT:  -Wtautological-overlap-compare
+CHECK-NEXT:  -Wtautological-bitwise-compare
+CHECK-NEXT:  -Wtautological-undefined-compare
+CHECK-NEXT:  -Wtautological-objc-bool-compare
+CHECK-NEXT:-Wtrigraphs
+CHECK-NEXT:-Wuninitialized
+CHECK-NEXT:  -Wsometimes-uninitialized
+CHECK-NEXT:  -Wstatic-self-init
+CHECK-NEXT:-Wunknown-pragmas
+CHECK-NEXT:-Wunused
+CHECK-NEXT:  -Wunused-argument
+CHECK-NEXT:  -Wunused-function
+CHECK-NEXT:-Wunneeded-internal-declaration
+CHECK-NEXT:  -Wunused-label
+CHECK-NEXT:  -Wunused-private-field
+CHECK-NEXT:  -Wunused-lambda-capture
+CHECK-NEXT:  -Wunused-local-typedef
+CHECK-NEXT:  -Wunused-value
+CHECK-NEXT:-Wunused-comparison
+CHECK-NEXT:-Wunused-result
+CHECK-NEXT:-Wunevaluated-expression
+CHECK-NEXT:  -Wpotentially-evaluated-expression
+CHECK-NEXT:  -Wunused-variable
+CHECK-NEXT:-Wunused-const-variable
+CHECK-NEXT:  -Wunused-property-ivar
+CHECK-NEXT:-Wvolatile-register-var
+CHECK-NEXT:-Wobjc-missing-super-calls
+CHECK-NEXT:-Wobjc-designated-initializers
+CHECK-NEXT:-Wobjc-flexible-array
+CHECK-NEXT:-Woverloaded-virtual
+CHECK-NEXT:-Wprivate-extern
+CHECK-NEXT:-Wcast-of-sel-type
+CHECK-NEXT:-Wextern-c-compat
+CHECK-NEXT:-Wuser-defined-warnings
+CHECK-NEXT:  -Wparentheses
+CHECK-NEXT:-Wlogical-op-parentheses
+CHECK-NEXT:-Wlogical-not-parentheses
+CHECK-NEXT:-Wbitwise-conditional-parentheses
+CHECK-NEXT:

[PATCH] D69984: [OpenMP][Opt] Annotate known runtime functions and deduplicate more

2019-11-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, 
gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim.
Herald added a project: LLVM.
jdoerfert removed a subscriber: cfe-commits.
jdoerfert added a parent revision: D69930: [OpenMP] Introduce the OpenMPOpt 
transformation pass.

This adds ~27 more runtime calls to the OpenMPKinds.def file, all with
attributes. We deduplicate 16 of those automatically in function =
thread scope. And we annotate all of them automatically during the
OpenMPOpt discovery step. A test with all omp_ runtime calls to
track annotation coverage is included.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69984

Files:
  llvm/include/llvm/IR/OpenMPKinds.def
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/add_attributes.ll

Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- /dev/null
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -0,0 +1,696 @@
+; RUN: opt < %s -S -openmpopt| FileCheck %s
+; RUN: opt < %s -S -passes=openmpopt | FileCheck %s
+;
+; TODO: Not all omp_ methods are known to the OpenMPIRBuilder/OpenMPOpt.
+;
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+%struct.omp_lock_t = type { i8* }
+%struct.omp_nest_lock_t = type { i8* }
+
+define void @call_all(i32 %schedule, %struct.omp_lock_t* %lock, i32 %lock_hint, %struct.omp_nest_lock_t* %nest_lock, i32 %i, i8* %s, i64 %st, i8* %vp, double %d, i32 %proc_bind, i64 %allocator_handle, i8* %cp, i64 %event_handle, i32 %pause_resource) {
+entry:
+  %schedule.addr = alloca i32, align 4
+  %lock.addr = alloca %struct.omp_lock_t*, align 8
+  %lock_hint.addr = alloca i32, align 4
+  %nest_lock.addr = alloca %struct.omp_nest_lock_t*, align 8
+  %i.addr = alloca i32, align 4
+  %s.addr = alloca i8*, align 8
+  %st.addr = alloca i64, align 8
+  %vp.addr = alloca i8*, align 8
+  %d.addr = alloca double, align 8
+  %proc_bind.addr = alloca i32, align 4
+  %allocator_handle.addr = alloca i64, align 8
+  %cp.addr = alloca i8*, align 8
+  %event_handle.addr = alloca i64, align 8
+  %pause_resource.addr = alloca i32, align 4
+  store i32 %schedule, i32* %schedule.addr, align 4
+  store %struct.omp_lock_t* %lock, %struct.omp_lock_t** %lock.addr, align 8
+  store i32 %lock_hint, i32* %lock_hint.addr, align 4
+  store %struct.omp_nest_lock_t* %nest_lock, %struct.omp_nest_lock_t** %nest_lock.addr, align 8
+  store i32 %i, i32* %i.addr, align 4
+  store i8* %s, i8** %s.addr, align 8
+  store i64 %st, i64* %st.addr, align 8
+  store i8* %vp, i8** %vp.addr, align 8
+  store double %d, double* %d.addr, align 8
+  store i32 %proc_bind, i32* %proc_bind.addr, align 4
+  store i64 %allocator_handle, i64* %allocator_handle.addr, align 8
+  store i8* %cp, i8** %cp.addr, align 8
+  store i64 %event_handle, i64* %event_handle.addr, align 8
+  store i32 %pause_resource, i32* %pause_resource.addr, align 4
+  call void @omp_set_num_threads(i32 0)
+  call void @omp_set_dynamic(i32 0)
+  call void @omp_set_nested(i32 0)
+  call void @omp_set_max_active_levels(i32 0)
+  %0 = load i32, i32* %schedule.addr, align 4
+  call void @omp_set_schedule(i32 %0, i32 0)
+  %call = call i32 @omp_get_num_threads()
+  store i32 %call, i32* %i.addr, align 4
+  %1 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %1)
+  %call1 = call i32 @omp_get_dynamic()
+  store i32 %call1, i32* %i.addr, align 4
+  %2 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %2)
+  %call2 = call i32 @omp_get_nested()
+  store i32 %call2, i32* %i.addr, align 4
+  %3 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %3)
+  %call3 = call i32 @omp_get_max_threads()
+  store i32 %call3, i32* %i.addr, align 4
+  %4 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %4)
+  %call4 = call i32 @omp_get_thread_num()
+  store i32 %call4, i32* %i.addr, align 4
+  %5 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %5)
+  %call5 = call i32 @omp_get_num_procs()
+  store i32 %call5, i32* %i.addr, align 4
+  %6 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %6)
+  %call6 = call i32 @omp_in_parallel()
+  store i32 %call6, i32* %i.addr, align 4
+  %7 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %7)
+  %call7 = call i32 @omp_in_final()
+  store i32 %call7, i32* %i.addr, align 4
+  %8 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %8)
+  %call8 = call i32 @omp_get_active_level()
+  store i32 %call8, i32* %i.addr, align 4
+  %9 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %9)
+  %call9 = call i32 @omp_get_level()
+  store i32 %call9, i32* %i.addr, align 4
+  %10 = load i32, i32* %i.addr, align 4
+  call void @use_int(i32 %10)
+  %call10 = call i32 @omp_get_ancestor_thread_num(i32 0)
+  store i32 %call10, i32* %i.addr, align 4
+  %11 = load i32, i32* %i.addr, align 4
+  call 

[PATCH] D63636: [PowerPC][Altivec] Fix offsets for vec_xl and vec_xst

2019-11-07 Thread Nemanja Ivanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe0407f549653: [PowerPC][Altivec] Fix offsets for vec_xl and 
vec_xst (authored by nemanjai).
Herald added subscribers: shchenz, wuzish.

Changed prior to commit:
  https://reviews.llvm.org/D63636?vs=206123=228355#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63636

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-xl-xst.c

Index: clang/test/CodeGen/builtins-ppc-xl-xst.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xl-xst.c
@@ -0,0 +1,490 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -target-feature +power8-vector -triple powerpc64le-unknown-unknown \
+// RUN:   -emit-llvm %s -o - | FileCheck %s -check-prefixes=CHECK,CHECK-P8
+#include 
+
+// CHECK-LABEL: @test1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[__VEC_ADDR_I:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[__OFFSET_ADDR_I1:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[__PTR_ADDR_I2:%.*]] = alloca i16*, align 8
+// CHECK-NEXT:[[__ADDR_I3:%.*]] = alloca i8*, align 8
+// CHECK-NEXT:[[__OFFSET_ADDR_I:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[__PTR_ADDR_I:%.*]] = alloca i16*, align 8
+// CHECK-NEXT:[[__ADDR_I:%.*]] = alloca i8*, align 8
+// CHECK-NEXT:[[C_ADDR:%.*]] = alloca <8 x i16>*, align 8
+// CHECK-NEXT:[[PTR_ADDR:%.*]] = alloca i16*, align 8
+// CHECK-NEXT:store <8 x i16>* [[C:%.*]], <8 x i16>** [[C_ADDR]], align 8
+// CHECK-NEXT:store i16* [[PTR:%.*]], i16** [[PTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load i16*, i16** [[PTR_ADDR]], align 8
+// CHECK-NEXT:store i64 3, i64* [[__OFFSET_ADDR_I]], align 8
+// CHECK-NEXT:store i16* [[TMP0]], i16** [[__PTR_ADDR_I]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load i16*, i16** [[__PTR_ADDR_I]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = bitcast i16* [[TMP1]] to i8*
+// CHECK-NEXT:[[TMP3:%.*]] = load i64, i64* [[__OFFSET_ADDR_I]], align 8
+// CHECK-NEXT:[[ADD_PTR_I:%.*]] = getelementptr inbounds i8, i8* [[TMP2]], i64 [[TMP3]]
+// CHECK-NEXT:store i8* [[ADD_PTR_I]], i8** [[__ADDR_I]], align 8
+// CHECK-NEXT:[[TMP4:%.*]] = load i8*, i8** [[__ADDR_I]], align 8
+// CHECK-NEXT:[[TMP5:%.*]] = bitcast i8* [[TMP4]] to <8 x i16>*
+// CHECK-NEXT:[[TMP6:%.*]] = load <8 x i16>, <8 x i16>* [[TMP5]], align 1
+// CHECK-NEXT:[[TMP7:%.*]] = load <8 x i16>*, <8 x i16>** [[C_ADDR]], align 8
+// CHECK-NEXT:store <8 x i16> [[TMP6]], <8 x i16>* [[TMP7]], align 16
+// CHECK-NEXT:[[TMP8:%.*]] = load <8 x i16>*, <8 x i16>** [[C_ADDR]], align 8
+// CHECK-NEXT:[[TMP9:%.*]] = load <8 x i16>, <8 x i16>* [[TMP8]], align 16
+// CHECK-NEXT:[[TMP10:%.*]] = load i16*, i16** [[PTR_ADDR]], align 8
+// CHECK-NEXT:store <8 x i16> [[TMP9]], <8 x i16>* [[__VEC_ADDR_I]], align 16
+// CHECK-NEXT:store i64 7, i64* [[__OFFSET_ADDR_I1]], align 8
+// CHECK-NEXT:store i16* [[TMP10]], i16** [[__PTR_ADDR_I2]], align 8
+// CHECK-NEXT:[[TMP11:%.*]] = load i16*, i16** [[__PTR_ADDR_I2]], align 8
+// CHECK-NEXT:[[TMP12:%.*]] = bitcast i16* [[TMP11]] to i8*
+// CHECK-NEXT:[[TMP13:%.*]] = load i64, i64* [[__OFFSET_ADDR_I1]], align 8
+// CHECK-NEXT:[[ADD_PTR_I4:%.*]] = getelementptr inbounds i8, i8* [[TMP12]], i64 [[TMP13]]
+// CHECK-NEXT:store i8* [[ADD_PTR_I4]], i8** [[__ADDR_I3]], align 8
+// CHECK-NEXT:[[TMP14:%.*]] = load <8 x i16>, <8 x i16>* [[__VEC_ADDR_I]], align 16
+// CHECK-NEXT:[[TMP15:%.*]] = load i8*, i8** [[__ADDR_I3]], align 8
+// CHECK-NEXT:[[TMP16:%.*]] = bitcast i8* [[TMP15]] to <8 x i16>*
+// CHECK-NEXT:store <8 x i16> [[TMP14]], <8 x i16>* [[TMP16]], align 1
+// CHECK-NEXT:ret void
+//
+void test1(vector signed short *c, signed short *ptr) {
+*c = vec_xl(3ll, ptr);
+vec_xst(*c, 7ll, ptr);
+}
+
+// CHECK-LABEL: @test2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[__VEC_ADDR_I:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[__OFFSET_ADDR_I1:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[__PTR_ADDR_I2:%.*]] = alloca i16*, align 8
+// CHECK-NEXT:[[__ADDR_I3:%.*]] = alloca i8*, align 8
+// CHECK-NEXT:[[__OFFSET_ADDR_I:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[__PTR_ADDR_I:%.*]] = alloca i16*, align 8
+// CHECK-NEXT:[[__ADDR_I:%.*]] = alloca i8*, align 8
+// CHECK-NEXT:[[C_ADDR:%.*]] = alloca <8 x i16>*, align 8
+// CHECK-NEXT:[[PTR_ADDR:%.*]] = alloca i16*, align 8
+// CHECK-NEXT:store <8 x i16>* [[C:%.*]], <8 x i16>** [[C_ADDR]], align 8
+// CHECK-NEXT:store i16* 

[clang] e0407f5 - [PowerPC][Altivec] Fix offsets for vec_xl and vec_xst

2019-11-07 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2019-11-07T20:58:11-06:00
New Revision: e0407f54965318247c8fece2dfa5c9023acf0973

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

LOG: [PowerPC][Altivec] Fix offsets for vec_xl and vec_xst

As we currently have it implemented in altivec.h, the offsets for these two
intrinsics are element offsets. The documentation in the ABI (as well as the
implementation in both XL and GCC) states that these should be byte offsets.

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

Added: 
clang/test/CodeGen/builtins-ppc-xl-xst.c

Modified: 
clang/lib/Headers/altivec.h

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 77a0e494df36..7e231a2a428e 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16364,27 +16364,32 @@ vec_xl(signed long long __offset, unsigned char 
*__ptr) {
 
 static inline __ATTRS_o_ai vector signed short vec_xl(signed long long 
__offset,
   signed short *__ptr) {
-  return *(unaligned_vec_sshort *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_sshort *)__addr;
 }
 
 static inline __ATTRS_o_ai vector unsigned short
 vec_xl(signed long long __offset, unsigned short *__ptr) {
-  return *(unaligned_vec_ushort *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_ushort *)__addr;
 }
 
 static inline __ATTRS_o_ai vector signed int vec_xl(signed long long __offset,
 signed int *__ptr) {
-  return *(unaligned_vec_sint *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_sint *)__addr;
 }
 
 static inline __ATTRS_o_ai vector unsigned int vec_xl(signed long long 
__offset,
   unsigned int *__ptr) {
-  return *(unaligned_vec_uint *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_uint *)__addr;
 }
 
 static inline __ATTRS_o_ai vector float vec_xl(signed long long __offset,
float *__ptr) {
-  return *(unaligned_vec_float *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_float *)__addr;
 }
 
 #ifdef __VSX__
@@ -16394,17 +16399,20 @@ typedef vector double unaligned_vec_double 
__attribute__((aligned(1)));
 
 static inline __ATTRS_o_ai vector signed long long
 vec_xl(signed long long __offset, signed long long *__ptr) {
-  return *(unaligned_vec_sll *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_sll *)__addr;
 }
 
 static inline __ATTRS_o_ai vector unsigned long long
 vec_xl(signed long long __offset, unsigned long long *__ptr) {
-  return *(unaligned_vec_ull *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_ull *)__addr;
 }
 
 static inline __ATTRS_o_ai vector double vec_xl(signed long long __offset,
 double *__ptr) {
-  return *(unaligned_vec_double *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_double *)__addr;
 }
 #endif
 
@@ -16414,12 +16422,14 @@ typedef vector unsigned __int128 unaligned_vec_ui128
 __attribute__((aligned(1)));
 static inline __ATTRS_o_ai vector signed __int128
 vec_xl(signed long long __offset, signed __int128 *__ptr) {
-  return *(unaligned_vec_si128 *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_si128 *)__addr;
 }
 
 static inline __ATTRS_o_ai vector unsigned __int128
 vec_xl(signed long long __offset, unsigned __int128 *__ptr) {
-  return *(unaligned_vec_ui128 *)(__ptr + __offset);
+  signed char *__addr = (signed char *)__ptr + __offset;
+  return *(unaligned_vec_ui128 *)__addr;
 }
 #endif
 
@@ -16516,50 +16526,58 @@ static inline __ATTRS_o_ai void vec_xst(vector 
unsigned char __vec,
 static inline __ATTRS_o_ai void vec_xst(vector signed short __vec,
 signed long long __offset,
 signed short *__ptr) {
-  *(unaligned_vec_sshort *)(__ptr + __offset) = __vec;
+  signed char *__addr = (signed char *)__ptr + __offset;
+  *(unaligned_vec_sshort *)__addr = __vec;
 }
 
 static inline __ATTRS_o_ai void vec_xst(vector unsigned short __vec,
 signed long long __offset,
 unsigned short *__ptr) {
-  *(unaligned_vec_ushort *)(__ptr + __offset) = __vec;
+  signed 

[PATCH] D64024: [PowerPC][Altivec] Emit correct builtin for single precision vec_all_ne

2019-11-07 Thread Nemanja Ivanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG070e4027b024: [PowerPC][Altivec] Emit correct builtin for 
single precision vec_all_ne (authored by nemanjai).

Changed prior to commit:
  https://reviews.llvm.org/D64024?vs=207374=228354#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64024

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p8vector.c

Index: clang/test/CodeGen/builtins-ppc-p8vector.c
===
--- clang/test/CodeGen/builtins-ppc-p8vector.c
+++ clang/test/CodeGen/builtins-ppc-p8vector.c
@@ -469,6 +469,10 @@
 // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpeqdp.p
 
+  res_i = vec_all_eq(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
   /* vec_all_ne */
   res_i = vec_all_ne(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpequd.p
@@ -515,6 +519,13 @@
   dummy();
 // CHECK: @dummy
 
+  res_i = vec_all_ne(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
+  dummy();
+// CHECK: @dummy
+
   res_i = vec_all_nge(vda, vda);
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
@@ -563,6 +574,10 @@
 // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpeqdp.p
 
+  res_i = vec_any_eq(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
   /* vec_any_ne */
   res_i = vec_any_ne(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpequd.p
@@ -603,6 +618,10 @@
 // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpeqdp.p
 
+  res_i = vec_any_ne(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
   /* vec_all_ge */
   res_i = vec_all_ge(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -643,6 +662,10 @@
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
 
+  res_i = vec_all_ge(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgesp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgesp.p
+
   /* vec_all_gt */
   res_i = vec_all_gt(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -683,6 +706,10 @@
 // CHECK: @llvm.ppc.vsx.xvcmpgtdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgtdp.p
 
+  res_i = vec_all_gt(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgtsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgtsp.p
+
   /* vec_all_le */
   res_i = vec_all_le(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -723,6 +750,10 @@
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
 
+  res_i = vec_all_le(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgesp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgesp.p
+
   /* vec_all_lt */
   res_i = vec_all_lt(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -763,10 +794,18 @@
 // CHECK: @llvm.ppc.vsx.xvcmpgtdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgtdp.p
 
+  res_i = vec_all_lt(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgtsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgtsp.p
+
   res_i = vec_all_nan(vda);
 // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpeqdp.p
 
+  res_i = vec_all_nan(vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
   /* vec_any_ge */
   res_i = vec_any_ge(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -807,6 +846,10 @@
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
 
+  res_i = vec_any_ge(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgesp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgesp.p
+
   /* vec_any_gt */
   res_i = vec_any_gt(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -887,6 +930,10 @@
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
 
+  res_i = vec_any_le(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgesp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgesp.p
+
   /* vec_any_lt */
   res_i = vec_any_lt(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -927,6 +974,10 @@
 // CHECK: @llvm.ppc.vsx.xvcmpgtdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgtdp.p
 
+  res_i = vec_any_lt(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgtsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgtsp.p
+
   /* vec_max */
   res_vsll = vec_max(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vmaxsd
@@ -1309,6 +1360,12 @@
 // CHECK-LE: [[T1:%.+]] = and <2 x i64>
 // CHECK-LE: xor <2 x i64> [[T1]], 
 
+  res_vf = vec_nand(vfa, vfa);
+// CHECK: [[T1:%.+]] = and <4 x i32>
+// CHECK: xor <4 x i32> [[T1]], 
+// CHECK-LE: [[T1:%.+]] = and <4 x i32>
+// CHECK-LE: xor <4 x i32> [[T1]], 
+
   /* vec_orc */
   res_vsc = vec_orc(vsc, vsc);
 // CHECK: [[T1:%.+]] = xor <16 x i8> {{%.+}}, 
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -14784,7 +14784,7 @@
 static __inline__ int __ATTRS_o_ai vec_all_ne(vector float __a,
   

[clang] 070e402 - [PowerPC][Altivec] Emit correct builtin for single precision vec_all_ne

2019-11-07 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2019-11-07T20:40:32-06:00
New Revision: 070e4027b02453f0962e5b61335a517581c5528f

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

LOG: [PowerPC][Altivec] Emit correct builtin for single precision vec_all_ne

We currently emit a double precision comparison instruction for this, whereas we
need to emit the single precision version.

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

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p8vector.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 8352f8f740c2..77a0e494df36 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -14784,7 +14784,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ne(vector 
bool long long __a,
 static __inline__ int __ATTRS_o_ai vec_all_ne(vector float __a,
   vector float __b) {
 #ifdef __VSX__
-  return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, (vector double)__a, (vector 
double)__b);
+  return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ, __a, __b);
 #else
   return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __b);
 #endif

diff  --git a/clang/test/CodeGen/builtins-ppc-p8vector.c 
b/clang/test/CodeGen/builtins-ppc-p8vector.c
index a686b0a0796b..d494e463105e 100644
--- a/clang/test/CodeGen/builtins-ppc-p8vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p8vector.c
@@ -469,6 +469,10 @@ void test1() {
 // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpeqdp.p
 
+  res_i = vec_all_eq(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
   /* vec_all_ne */
   res_i = vec_all_ne(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpequd.p
@@ -515,6 +519,13 @@ void test1() {
   dummy();
 // CHECK: @dummy
 
+  res_i = vec_all_ne(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
+  dummy();
+// CHECK: @dummy
+
   res_i = vec_all_nge(vda, vda);
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
@@ -563,6 +574,10 @@ void test1() {
 // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpeqdp.p
 
+  res_i = vec_any_eq(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
   /* vec_any_ne */
   res_i = vec_any_ne(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpequd.p
@@ -603,6 +618,10 @@ void test1() {
 // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpeqdp.p
 
+  res_i = vec_any_ne(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
   /* vec_all_ge */
   res_i = vec_all_ge(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -643,6 +662,10 @@ void test1() {
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
 
+  res_i = vec_all_ge(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgesp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgesp.p
+
   /* vec_all_gt */
   res_i = vec_all_gt(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -683,6 +706,10 @@ void test1() {
 // CHECK: @llvm.ppc.vsx.xvcmpgtdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgtdp.p
 
+  res_i = vec_all_gt(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgtsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgtsp.p
+
   /* vec_all_le */
   res_i = vec_all_le(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -723,6 +750,10 @@ void test1() {
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
 
+  res_i = vec_all_le(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgesp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgesp.p
+
   /* vec_all_lt */
   res_i = vec_all_lt(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -763,10 +794,18 @@ void test1() {
 // CHECK: @llvm.ppc.vsx.xvcmpgtdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgtdp.p
 
+  res_i = vec_all_lt(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgtsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgtsp.p
+
   res_i = vec_all_nan(vda);
 // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpeqdp.p
 
+  res_i = vec_all_nan(vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpeqsp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpeqsp.p
+
   /* vec_any_ge */
   res_i = vec_any_ge(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -807,6 +846,10 @@ void test1() {
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
 
+  res_i = vec_any_ge(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgesp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgesp.p
+
   /* vec_any_gt */
   res_i = vec_any_gt(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpgtsd.p
@@ -887,6 +930,10 @@ void test1() {
 // CHECK: @llvm.ppc.vsx.xvcmpgedp.p
 // CHECK-LE: @llvm.ppc.vsx.xvcmpgedp.p
 
+  res_i = vec_any_le(vfa, vfa);
+// CHECK: @llvm.ppc.vsx.xvcmpgesp.p
+// CHECK-LE: @llvm.ppc.vsx.xvcmpgesp.p
+
   

[PATCH] D69979: clang: Guess at some platform FTZ/DAZ default settings

2019-11-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I checked Redhat 7.4 that's on the server I'm using for work. And I had a 
coworker check his Ubuntu 18.04 system with this program. And both systems 
printed 1f80 as the value of MXCSR which shows FTZ and DAZ are both 0. Are you 
seeing something different?

  #include 
  #include 
  
  int main() {
int csr = _mm_getcsr();
printf("%x\n", csr);
return 0;
  }


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

https://reviews.llvm.org/D69979



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


[PATCH] D69981: [www] More HTTPS and outdated link fixes.

2019-11-07 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

This LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69981



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


[PATCH] D64024: [PowerPC][Altivec] Emit correct builtin for single precision vec_all_ne

2019-11-07 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.
Herald added subscribers: shchenz, wuzish.

In D64024#1565190 , @jsji wrote:

> LGTM. 
>  BTW, looks like we are missing test cases all `vector float` `vec_all*` and 
> `vec_any*` and also non-vsx path?


The non-VSX path is tested in test/CodeGen/builtins-ppc-altivec.c
I will add the VSX tests in this commit.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64024



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


[PATCH] D69981: [www] More HTTPS and outdated link fixes.

2019-11-07 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: ldionne, zoecarver.
Herald added a reviewer: bollu.
Herald added subscribers: llvm-commits, arphaman, dexonsmith.
Herald added projects: clang, LLVM.

[www] More HTTPS and outdated link fixes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69981

Files:
  clang/www/UniversalDriver.html
  clang/www/analyzer/available_checks.html
  llvm/docs/_templates/layout.html
  polly/www/contributors.html
  polly/www/index.html
  polly/www/performance.html
  polly/www/publications.html

Index: polly/www/publications.html
===
--- polly/www/publications.html
+++ polly/www/publications.html
@@ -32,7 +32,7 @@
   representation 
 Tobias Grosser, Armin Groesslinger, Christian Lengauer
 Parallel Processing Letters 2012 22:04
-  http://www.grosser.es#pub-Polly;>Paper
+  https://www.grosser.es#pub-Polly;>Paper
 
 
Publications involving Polly 
@@ -53,7 +53,7 @@
   Felix-Antoine Quellet
   Master Thesis, Universite de Sherbrooke
   http://savoirs.usherbrooke.ca/bitstream/handle/11143/8171/Ouellet_Felix_Antoine_MSc_2016.pdf?sequence=4;>Thesis
+  href="https://savoirs.usherbrooke.ca/bitstream/handle/11143/8171/Ouellet_Felix_Antoine_MSc_2016.pdf?sequence=4;>Thesis
   
   
2015 
@@ -62,7 +62,7 @@
   Tobias Grosser, Sven Verdoolaege, Albert Cohen
ACM Transations on Programming Languages and Systems (TOPLAS), 37(4), July
2015
-  http://www.grosser.es#pub-polyhedral-AST-generation;>Paper
+  https://www.grosser.es#pub-polyhedral-AST-generation;>Paper
   
   On recovering multi-dimensional arrays in Polly
   Tobias Grosser, Sebastian Pop, J. Ramanujam, P. Sadayappan 
@@ -81,7 +81,7 @@
   Lattice QCD Optimization and Polytopic Representations of Distributed Memory 
   Michael Kruse
   Doctoral Thesis,  Ecole doctorale Informatique de Paris-Sud
-  http://www.theses.fr/2014PA112198;>Thesis
+  https://www.theses.fr/2014PA112198;>Thesis
   
   
2012 
Index: polly/www/performance.html
===
--- polly/www/performance.html
+++ polly/www/performance.html
@@ -17,7 +17,7 @@
 https://web.cse.ohio-state.edu/~pouchet.2/software/polybench/;>Polybench
 2.0 benchmark suite.  Each benchmark was run with double precision floating
 point values on an Intel Core Xeon X5670 CPU @ 2.93GHz (12 cores, 24 thread)
-system. We used http://pocc.sf.net;>PoCC and the included https://sourceforge.net/projects/pocc/files/;>PoCC and the included http://pluto-compiler.sf.net;>Pluto transformations to optimize the
 code. The source code of Polly and LLVM/clang was checked out on
 25/03/2011.
Index: polly/www/index.html
===
--- polly/www/index.html
+++ polly/www/index.html
@@ -115,7 +115,7 @@
   program optimization.
 
 
-   http://www.grosser.es#pub-polyhedral-AST-generation;>
+   https://www.grosser.es#pub-polyhedral-AST-generation;>
Polyhedral AST generation is more than scanning polyhedra
 Tobias Grosser, Sven Verdoolaege, Albert Cohen
 ACM Transations on Programming Languages and Systems (TOPLAS), 37(4),
@@ -335,9 +335,9 @@
   
   June
   
-  http://www.grosser.es;>Tobias is founded for
+  https://www.grosser.es;>Tobias is founded for
   three years by a http://research.google.com/university/relations/fellowship_recipients.html;>
+  href="https://ai.google/research/outreach/phd-fellowship/recipients/?category=2011;>
   Google Europe Fellowship in Efficient Computing.
   
   
@@ -345,7 +345,7 @@
 
   
   May 
-  http://www.grosser.es;>Tobias' diploma thesis and
+  https://www.grosser.es;>Tobias' diploma thesis and
   Raghesh's master thesis. See our list of publications.
   
Index: polly/www/contributors.html
===
--- polly/www/contributors.html
+++ polly/www/contributors.html
@@ -37,7 +37,7 @@
 http://research.google.com/university/relations/fellowship_recipients.html;>
 Google Europe Fellowship in Efficient Computing).
 
-Website: http://www.grosser.es;>www.grosser.es
+Website: https://www.grosser.es;>www.grosser.es
 
 
 Andreas Simbrger
@@ -45,8 +45,8 @@
 Andreas works on the profiling infrastructure during his PhD at University of
 Passau.
 
-Website: http://www.infosun.fim.uni-passau.de/cl/staff/simbuerger/;>
-http://www.infosun.fim.uni-passau.de/cl/staff/simbuerger/
+Website: https://www.infosun.fim.uni-passau.de/cl/staff/simbuerger/;>
+https://www.infosun.fim.uni-passau.de/cl/staff/simbuerger/
 Hongbin Zheng
 Hongbin Zheng is one of the two Co-founders of Polly. He was funded as a
 Google Summer of Code Student 2010 and implemented parts of the Polly frontends
Index: llvm/docs/_templates/layout.html
===
--- llvm/docs/_templates/layout.html
+++ llvm/docs/_templates/layout.html
@@ -8,6 +8,6 @@
 {% endblock %}
 
 {% block rootrellink 

[PATCH] D69878: Consoldiate internal denormal flushing controls

2019-11-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 228348.
arsenm added a comment.

Fix name in documentation


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

https://reviews.llvm.org/D69878

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCUDA/flush-denormals.cu
  clang/test/CodeGenCUDA/propagate-metadata.cu
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/CodeGenOpenCL/denorms-are-zero.cl
  clang/test/CodeGenOpenCL/gfx9-fp32-denorms.cl
  clang/test/Driver/cl-denorms-are-zero.cl
  clang/test/Driver/cuda-flush-denormals-to-zero.cu
  clang/test/Driver/denormal-fp-math.c
  clang/test/Driver/opencl.cl
  llvm/docs/LangRef.rst
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/CodeGen/NVPTX/fast-math.ll
  llvm/test/CodeGen/NVPTX/math-intrins.ll
  llvm/test/CodeGen/NVPTX/sqrt-approx.ll
  llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll

Index: llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll
===
--- llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll
+++ llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll
@@ -5,11 +5,11 @@
 ; hackery:
 
 ; RUN: cat %s > %t.ftz
-; RUN: echo 'attributes #0 = { "nvptx-f32ftz" = "true" }' >> %t.ftz
+; RUN: echo 'attributes #0 = { "denormal-fp-math-f32" = "preserve-sign" }' >> %t.ftz
 ; RUN: opt < %t.ftz -instcombine -S | FileCheck %s --check-prefix=CHECK --check-prefix=FTZ
 
 ; RUN: cat %s > %t.noftz
-; RUN: echo 'attributes #0 = { "nvptx-f32ftz" = "false" }' >> %t.noftz
+; RUN: echo 'attributes #0 = { "denormal-fp-math-f32" = "ieee" }' >> %t.noftz
 ; RUN: opt < %t.noftz -instcombine -S | FileCheck %s --check-prefix=CHECK --check-prefix=NOFTZ
 
 ; We handle nvvm intrinsics with ftz variants as follows:
Index: llvm/test/CodeGen/NVPTX/sqrt-approx.ll
===
--- llvm/test/CodeGen/NVPTX/sqrt-approx.ll
+++ llvm/test/CodeGen/NVPTX/sqrt-approx.ll
@@ -146,5 +146,5 @@
 }
 
 attributes #0 = { "unsafe-fp-math" = "true" }
-attributes #1 = { "nvptx-f32ftz" = "true" }
+attributes #1 = { "denormal-fp-math-f32" = "preserve-sign" }
 attributes #2 = { "reciprocal-estimates" = "rsqrtf:1,rsqrtd:1,sqrtf:1,sqrtd:1" }
Index: llvm/test/CodeGen/NVPTX/math-intrins.ll
===
--- llvm/test/CodeGen/NVPTX/math-intrins.ll
+++ llvm/test/CodeGen/NVPTX/math-intrins.ll
@@ -289,4 +289,4 @@
 }
 
 attributes #0 = { nounwind readnone }
-attributes #1 = { "nvptx-f32ftz" = "true" }
+attributes #1 = { "denormal-fp-math-f32" = "preserve-sign" }
Index: llvm/test/CodeGen/NVPTX/fast-math.ll
===
--- llvm/test/CodeGen/NVPTX/fast-math.ll
+++ llvm/test/CodeGen/NVPTX/fast-math.ll
@@ -162,4 +162,4 @@
 }
 
 attributes #0 = { "unsafe-fp-math" = "true" }
-attributes #1 = { "nvptx-f32ftz" = "true" }
+attributes #1 = { "denormal-fp-math-f32" = "preserve-sign" }
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -1703,9 +1704,10 @@
   // intrinsic, we don't have to look up any module metadata, as
   // FtzRequirementTy will be FTZ_Any.)
   if (Action.FtzRequirement != FTZ_Any) {
-bool FtzEnabled =
-II->getFunction()->getFnAttribute("nvptx-f32ftz").getValueAsString() ==
-"true";
+StringRef Attr = II->getFunction()
+ ->getFnAttribute("denormal-fp-math-f32")
+ .getValueAsString();
+bool FtzEnabled = parseDenormalFPAttribute(Attr) != DenormalMode::IEEE;
 
 if (FtzEnabled != (Action.FtzRequirement == FTZ_MustBeOn))
   return nullptr;
Index: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -120,14 +120,10 @@
   if 

[PATCH] D69979: clang: Guess at some platform FTZ/DAZ default settings

2019-11-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: spatel, craig.topper, RKSimon, hfinkel, probinson.
Herald added a subscriber: wdng.
arsenm added a parent revision: D69978: Separately track input and output 
denormal mode.

This is to avoid performance regressions when the default attribute
behavior is fixed to assume ieee.

  

I tested the default on x86_64 ubuntu, which seems to default to
FTZ/DAZ, but am guessing for x86 and PS4.


https://reviews.llvm.org/D69979

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/PS4CPU.h
  clang/test/Driver/default-denormal-fp-math.c


Index: clang/test/Driver/default-denormal-fp-math.c
===
--- /dev/null
+++ clang/test/Driver/default-denormal-fp-math.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck 
-check-prefix=CHECK-IEEE %s
+// RUN: %clang -### -target i386-unknown-linux-gnu -c %s -v 2>&1 | FileCheck 
-check-prefix=CHECK-ZEROSIGN %s
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -c %s -v 2>&1 | FileCheck 
-check-prefix=CHECK-ZEROSIGN %s
+// RUN: %clang -### -target x86_64-scei-ps4 -c %s -v 2>&1 | FileCheck 
-check-prefix=CHECK-ZEROSIGN %s
+
+// CHECK-IEEE: -fdenormal-fp-math=ieee,ieee
+// CHECK-ZEROSIGN: -fdenormal-fp-math=preserve-sign,preserve-sign
Index: clang/lib/Driver/ToolChains/PS4CPU.h
===
--- clang/lib/Driver/ToolChains/PS4CPU.h
+++ clang/lib/Driver/ToolChains/PS4CPU.h
@@ -88,6 +88,14 @@
   // capable of unit splitting.
   bool canSplitThinLTOUnit() const override { return false; }
 
+  llvm::DenormalMode getDefaultDenormalModeForType(
+const llvm::opt::ArgList ,
+Action::OffloadKind DeviceOffloadKind,
+const llvm::fltSemantics *FPType) const override {
+// DAZ and FTZ are on by default.
+return llvm::DenormalMode::getPreserveSign();
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -49,6 +49,11 @@
 
   std::vector ExtraOpts;
 
+  llvm::DenormalMode getDefaultDenormalModeForType(
+const llvm::opt::ArgList ,
+Action::OffloadKind DeviceOffloadKind,
+const llvm::fltSemantics *FPType = nullptr) const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -1044,3 +1044,17 @@
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);
 }
+
+llvm::DenormalMode Linux::getDefaultDenormalModeForType(
+  const llvm::opt::ArgList ,
+  Action::OffloadKind DeviceOffloadKind,
+  const llvm::fltSemantics *FPType) const {
+  switch (getTriple().getArch()) {
+  case llvm::Triple::x86:
+  case llvm::Triple::x86_64:
+// DAZ and FTZ are on by default.
+return llvm::DenormalMode::getPreserveSign();
+  default:
+return llvm::DenormalMode::getIEEE();
+  }
+}


Index: clang/test/Driver/default-denormal-fp-math.c
===
--- /dev/null
+++ clang/test/Driver/default-denormal-fp-math.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+// RUN: %clang -### -target i386-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-ZEROSIGN %s
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-ZEROSIGN %s
+// RUN: %clang -### -target x86_64-scei-ps4 -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-ZEROSIGN %s
+
+// CHECK-IEEE: -fdenormal-fp-math=ieee,ieee
+// CHECK-ZEROSIGN: -fdenormal-fp-math=preserve-sign,preserve-sign
Index: clang/lib/Driver/ToolChains/PS4CPU.h
===
--- clang/lib/Driver/ToolChains/PS4CPU.h
+++ clang/lib/Driver/ToolChains/PS4CPU.h
@@ -88,6 +88,14 @@
   // capable of unit splitting.
   bool canSplitThinLTOUnit() const override { return false; }
 
+  llvm::DenormalMode getDefaultDenormalModeForType(
+const llvm::opt::ArgList ,
+Action::OffloadKind DeviceOffloadKind,
+const llvm::fltSemantics *FPType) const override {
+// DAZ and FTZ are on by default.
+return llvm::DenormalMode::getPreserveSign();
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ 

[PATCH] D69308: [analyzer] Test cases for the unsupported features for Clang Static Analyzer

2019-11-07 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e0fb6484207: [analyzer] Add test cases for the unsupported 
C++ constructor modeling. (authored by dergachev.a).

Changed prior to commit:
  https://reviews.llvm.org/D69308?vs=227714=228344#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69308

Files:
  clang/test/Analysis/handle_constructors_for_default_arguments.cpp
  clang/test/Analysis/handle_constructors_with_new_array.cpp
  clang/www/analyzer/open_projects.html

Index: clang/www/analyzer/open_projects.html
===
--- clang/www/analyzer/open_projects.html
+++ clang/www/analyzer/open_projects.html
@@ -68,7 +68,7 @@
 
   Improve C++ support
   
-Handle aggregate construction.
+Handle construction as part of aggregate initialization.
   https://en.cppreference.com/w/cpp/language/aggregate_initialization;>Aggregates
   are objects that can be brace-initialized without calling a
   constructor (that is, https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html;>
@@ -89,12 +89,31 @@
   (Difficulty: Medium) 
 
 
-Handle constructors within new[]
-  When an array of objects is allocated using the operator new[],
+Handle array constructors.
+  When an array of objects is allocated (say, using the
+ operator new[] or defining a stack array),
  constructors for all elements of the array are called.
  We should model (potentially some of) such evaluations,
  and the same applies for destructors called from
  operator delete[].
+ See tests cases in https://github.com/llvm/llvm-project/tree/master/clang/test/Analysis/handle_constructors_with_new_array.cpp;>handle_constructors_with_new_array.cpp.
+  
+  
+  Constructing an array requires invoking multiple (potentially unknown)
+  amount of constructors with the same construct-expression.
+  Apart from the technical difficulties of juggling program points around
+  correctly to avoid accidentally merging paths together, we'll have to
+  be a judge on when to exit the loop and how to widen it.
+  Given that the constructor is going to be a default constructor,
+  a nice 95% solution might be to execute exactly one constructor and
+  then default-bind the resulting LazyCompoundVal to the whole array;
+  it'll work whenever the default constructor doesn't touch global state
+  but only initializes the object to various default values.
+  But if, say, we're making an array of strings,
+  depending on the implementation you might have to allocate a new buffer
+  for each string, and in this case default-binding won't cut it.
+  We might want to come up with an auxiliary analysis in order to perform
+  widening of these simple loops more precisely.
   
 
 
@@ -116,6 +135,24 @@
 Handle constructors for default arguments
   Default arguments in C++ are recomputed at every call,
  and are therefore local, and not static, variables.
+ See tests cases in https://github.com/llvm/llvm-project/tree/master/clang/test/Analysis/handle_constructors_for_default_arguments.cpp;>handle_constructors_for_default_arguments.cpp.
+  
+  
+  Default arguments are annoying because the initializer expression is
+  evaluated at the call site but doesn't syntactically belong to the
+  caller's AST; instead it belongs to the ParmVarDecl for the default
+  parameter. This can lead to situations when the same expression has to
+  carry different values simultaneously -
+  when multiple instances of the same function are evaluated as part of the
+  same full-expression without specifying the default arguments.
+  Even simply calling the function twice (not necessarily within the
+  same full-expression) may lead to program points agglutinating because
+  it's the same expression. There are some nasty test cases already
+  in temporaries.cpp (struct DefaultParam and so on). I recommend adding a
+  new LocationContext kind specifically to deal with this problem. It'll
+  also help you figure out the construction context when you evaluate the
+  construct-expression (though you might still need to do some additional
+  CFG work to get construction contexts right).
   
 
 
Index: clang/test/Analysis/handle_constructors_with_new_array.cpp
===
--- /dev/null
+++ clang/test/Analysis/handle_constructors_with_new_array.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fsyntax-only -analyze \
+// RUN:   -analyzer-checker=core,debug.ExprInspection %s -verify
+
+// These test cases demonstrate lack of Static Analyzer features.
+// The FIXME: tags indicate where we expect different output.
+
+// 

[PATCH] D66049: [analyzer] PR41729: Fix some false positives and improve strlcat and strlcpy modeling

2019-11-07 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGacac540422e8: [analyzer] PR41729: CStringChecker: Improve 
strlcat and strlcpy modeling. (authored by dergachev.a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66049

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bsd-string.c

Index: clang/test/Analysis/bsd-string.c
===
--- clang/test/Analysis/bsd-string.c
+++ clang/test/Analysis/bsd-string.c
@@ -9,6 +9,7 @@
 typedef __typeof(sizeof(int)) size_t;
 size_t strlcpy(char *dst, const char *src, size_t n);
 size_t strlcat(char *dst, const char *src, size_t n);
+size_t strlen(const char *s);
 void clang_analyzer_eval(int);
 
 void f1() {
@@ -18,9 +19,11 @@
 
 void f2() {
   char buf[5];
-  strlcpy(buf, "abcd", sizeof(buf)); // expected-no-warning
-  // FIXME: This should not warn. The string is safely truncated.
-  strlcat(buf, "efgh", sizeof(buf)); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+  size_t len;
+  len = strlcpy(buf, "abcd", sizeof(buf)); // expected-no-warning
+  clang_analyzer_eval(len == 4); // expected-warning{{TRUE}}
+  len = strlcat(buf, "efgh", sizeof(buf)); // expected-no-warning
+  clang_analyzer_eval(len == 8); // expected-warning{{TRUE}}
 }
 
 void f3() {
@@ -48,3 +51,83 @@
   char buf[8];
   return strlcpy(buf, "1234567", 0); // no-crash
 }
+
+void f8(){
+  char buf[5];
+  size_t len;
+
+  // basic strlcpy
+  len = strlcpy(buf,"123", sizeof(buf));
+  clang_analyzer_eval(len==3);// expected-warning{{TRUE}}
+  len = strlen(buf);
+  clang_analyzer_eval(len==3);// expected-warning{{TRUE}}
+
+  // testing bounded strlcat
+  len = strlcat(buf,"456", sizeof(buf));
+  clang_analyzer_eval(len==6);// expected-warning{{TRUE}}
+  len = strlen(buf);
+  clang_analyzer_eval(len==4);// expected-warning{{TRUE}}
+
+  // testing strlcat with size==0
+  len = strlcat(buf,"789", 0);
+  clang_analyzer_eval(len==7);// expected-warning{{TRUE}}
+  len = strlen(buf);
+  clang_analyzer_eval(len==4);// expected-warning{{TRUE}}
+
+  // testing strlcpy with size==0
+  len = strlcpy(buf,"123",0);
+  clang_analyzer_eval(len==3);// expected-warning{{TRUE}}
+  len = strlen(buf);
+  clang_analyzer_eval(len==4);// expected-warning{{TRUE}}
+
+}
+
+void f9(int unknown_size, char* unknown_src, char* unknown_dst){
+  char buf[8];
+  size_t len;
+
+  len = strlcpy(buf,"abba",sizeof(buf));
+
+  clang_analyzer_eval(len==4);// expected-warning{{TRUE}}
+  clang_analyzer_eval(strlen(buf)==4);// expected-warning{{TRUE}}
+
+  //size is unknown
+  len = strlcat(buf,"cd", unknown_size);
+  clang_analyzer_eval(len==6);// expected-warning{{TRUE}}
+  clang_analyzer_eval(strlen(buf)>=4);// expected-warning{{TRUE}}
+
+  //dst is unknown
+  len = strlcpy(unknown_dst,"abbc",unknown_size);
+  clang_analyzer_eval(len==4);// expected-warning{{TRUE}}
+  clang_analyzer_eval(strlen(unknown_dst));// expected-warning{{UNKNOWN}}
+
+  //src is unknown
+  len = strlcpy(buf,unknown_src, sizeof(buf));
+  clang_analyzer_eval(len);// expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(strlen(buf));// expected-warning{{UNKNOWN}}
+
+  //src, dst is unknown
+  len = strlcpy(unknown_dst, unknown_src, unknown_size);
+  clang_analyzer_eval(len);// expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(strlen(unknown_dst));// expected-warning{{UNKNOWN}}
+
+  //size is unknown
+  len = strlcat(buf+2,unknown_src+1, sizeof(buf));// expected-warning{{Size argument is greater than the length of the destination buffer}};
+}
+
+void f10(){
+  char buf[8];
+  size_t len;
+
+  len = strlcpy(buf,"abba",sizeof(buf));
+  clang_analyzer_eval(len==4);// expected-warning{{TRUE}}
+  strlcat(buf, "efghi",9);// expected-warning{{Size argument is greater than the length of the destination buffer}}
+}
+
+void f11() {
+  //test for Bug 41729
+  char a[256], b[256];
+  strlcpy(a, "world", sizeof(a));
+  strlcpy(b, "hello ", sizeof(b));
+  strlcat(b, a, sizeof(b)); // no-warning
+}
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -28,6 +28,7 @@
 using namespace ento;
 
 namespace {
+enum class ConcatFnKind { none = 0, strcat = 1, strlcat = 2 };
 class CStringChecker : public Checker< eval::Call,
  check::PreStmt,
  check::LiveSymbols,
@@ -129,11 +130,8 @@
   void evalStrncpy(CheckerContext , const CallExpr *CE) const;
   void evalStpcpy(CheckerContext , const CallExpr *CE) const;
   void evalStrlcpy(CheckerContext , const CallExpr *CE) const;
-  void evalStrcpyCommon(CheckerContext ,
-const CallExpr *CE,
-  

[clang] 5e0fb64 - [analyzer] Add test cases for the unsupported C++ constructor modeling.

2019-11-07 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2019-11-07T17:15:53-08:00
New Revision: 5e0fb648420702e47c94de53757928360a106e8c

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

LOG: [analyzer] Add test cases for the unsupported C++ constructor modeling.

Namely, for the following items:
- Handle constructors within new[];
- Handle constructors for default arguments.

Update the open projects page with a link to the newly added tests
and more hints for potential contributors.

Patch by Daniel Krupp!

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

Added: 
clang/test/Analysis/handle_constructors_for_default_arguments.cpp
clang/test/Analysis/handle_constructors_with_new_array.cpp

Modified: 
clang/www/analyzer/open_projects.html

Removed: 




diff  --git a/clang/test/Analysis/handle_constructors_for_default_arguments.cpp 
b/clang/test/Analysis/handle_constructors_for_default_arguments.cpp
new file mode 100644
index ..c54d86526ec7
--- /dev/null
+++ b/clang/test/Analysis/handle_constructors_for_default_arguments.cpp
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -fsyntax-only -analyze \
+// RUN:   -analyzer-checker=core,debug.ExprInspection %s -verify
+
+// These test cases demonstrate lack of Static Analyzer features.
+// The FIXME: tags indicate where we expect 
diff erent output.
+
+// Handle constructors for default arguments.
+// Default arguments in C++ are recomputed at every call,
+// and are therefore local, and not static, variables.
+void clang_analyzer_eval(bool);
+void clang_analyzer_warnIfReached();
+
+struct init_with_list {
+  int a;
+  init_with_list() : a(1) {}
+};
+
+struct init_in_body {
+  int a;
+  init_in_body() { a = 1; }
+};
+
+struct init_default_member {
+  int a = 1;
+};
+
+struct basic_struct {
+  int a;
+};
+
+// Top-level analyzed functions.
+void top_f(init_with_list l = init_with_list()) {
+  // We expect that the analyzer doesn't assume anything about the parameter.
+  clang_analyzer_eval(l.a == 1); // expected-warning {{TRUE}} expected-warning 
{{FALSE}}
+}
+
+void top_g(init_in_body l = init_in_body()) {
+  // We expect that the analyzer doesn't assume anything about the parameter.
+  clang_analyzer_eval(l.a == 1); // expected-warning {{TRUE}} expected-warning 
{{FALSE}}
+}
+
+void top_h(init_default_member l = init_default_member()) {
+  // We expect that the analyzer doesn't assume anything about the parameter.
+  clang_analyzer_eval(l.a == 1); // expected-warning {{TRUE}} expected-warning 
{{FALSE}}
+}
+
+// Not-top-level analyzed functions.
+int called_f(init_with_list l = init_with_list()) {
+  // We expect that the analyzer assumes the default value
+  // when called from test2().
+  return l.a;
+}
+
+int called_g(init_in_body l = init_in_body()) {
+  // We expect that the analyzer assumes the default value
+  // when called from test3().
+  return l.a;
+}
+
+int called_h(init_default_member l = init_default_member()) {
+  // We expect that the analyzer assumes the default value
+  // when called from test4().
+  return l.a;
+}
+
+int called_i(const init_with_list  = init_with_list()){
+  // We expect that the analyzer assumes the default value
+  // when called from test5().
+  return l.a;
+}
+
+int called_j(init_with_list & = init_with_list()){
+  // We expect that the analyzer assumes the default value
+  // when called from test6().
+  return l.a;
+}
+
+int plain_parameter_passing(basic_struct l) {
+  return l.a;
+}
+
+void test1() {
+  basic_struct b;
+  b.a = 1;
+  clang_analyzer_eval(plain_parameter_passing(b) == 1); //expected-warning 
{{TRUE}}
+}
+
+void test2() {
+  // We expect that the analyzer assumes the default value.
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(called_f() == 1); //expected-warning {{TRUE}} 
expected-warning {{FALSE}}
+}
+
+void test3() {
+  // We expect that the analyzer assumes the default value.
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(called_g() == 1); //expected-warning {{TRUE}} 
expected-warning {{FALSE}}
+}
+
+void test4() {
+  // We expect that the analyzer assumes the default value.
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(called_h() == 1); //expected-warning {{TRUE}} 
expected-warning {{FALSE}}
+}
+
+void test5() {
+  //We expect that the analyzer assumes the default value.
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(called_i() == 1); //expected-warning {{TRUE}} 
expected-warning {{FALSE}}
+}
+
+void test6() {
+  // We expect that the analyzer assumes the default value.
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(called_j() == 1); //expected-warning {{TRUE}} 
expected-warning {{FALSE}}
+}

diff  --git a/clang/test/Analysis/handle_constructors_with_new_array.cpp 
b/clang/test/Analysis/handle_constructors_with_new_array.cpp
new file mode 100644
index 

[clang] acac540 - [analyzer] PR41729: CStringChecker: Improve strlcat and strlcpy modeling.

2019-11-07 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2019-11-07T17:15:53-08:00
New Revision: acac540422e8cee4a77d10f087b2a2b67504b27b

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

LOG: [analyzer] PR41729: CStringChecker: Improve strlcat and strlcpy modeling.

- Fix false positive reports of strlcat.
- The return value of strlcat and strlcpy is now correctly calculated.
- The resulting string length of strlcat and strlcpy is now correctly
  calculated.

Patch by Daniel Krupp!

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
clang/test/Analysis/bsd-string.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 503c451670b8..f2c994b2a667 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -28,6 +28,7 @@ using namespace clang;
 using namespace ento;
 
 namespace {
+enum class ConcatFnKind { none = 0, strcat = 1, strlcat = 2 };
 class CStringChecker : public Checker< eval::Call,
  check::PreStmt,
  check::LiveSymbols,
@@ -129,11 +130,8 @@ class CStringChecker : public Checker< eval::Call,
   void evalStrncpy(CheckerContext , const CallExpr *CE) const;
   void evalStpcpy(CheckerContext , const CallExpr *CE) const;
   void evalStrlcpy(CheckerContext , const CallExpr *CE) const;
-  void evalStrcpyCommon(CheckerContext ,
-const CallExpr *CE,
-bool returnEnd,
-bool isBounded,
-bool isAppending,
+  void evalStrcpyCommon(CheckerContext , const CallExpr *CE, bool ReturnEnd,
+bool IsBounded, ConcatFnKind appendK,
 bool returnPtr = true) const;
 
   void evalStrcat(CheckerContext , const CallExpr *CE) const;
@@ -146,8 +144,8 @@ class CStringChecker : public Checker< eval::Call,
   void evalStrncasecmp(CheckerContext , const CallExpr *CE) const;
   void evalStrcmpCommon(CheckerContext ,
 const CallExpr *CE,
-bool isBounded = false,
-bool ignoreCase = false) const;
+bool IsBounded = false,
+bool IgnoreCase = false) const;
 
   void evalStrsep(CheckerContext , const CallExpr *CE) const;
 
@@ -1477,68 +1475,67 @@ void CStringChecker::evalstrLengthCommon(CheckerContext 
, const CallExpr *CE,
 void CStringChecker::evalStrcpy(CheckerContext , const CallExpr *CE) const {
   // char *strcpy(char *restrict dst, const char *restrict src);
   evalStrcpyCommon(C, CE,
-   /* returnEnd = */ false,
-   /* isBounded = */ false,
-   /* isAppending = */ false);
+   /* ReturnEnd = */ false,
+   /* IsBounded = */ false,
+   /* appendK = */ ConcatFnKind::none);
 }
 
 void CStringChecker::evalStrncpy(CheckerContext , const CallExpr *CE) const {
   // char *strncpy(char *restrict dst, const char *restrict src, size_t n);
   evalStrcpyCommon(C, CE,
-   /* returnEnd = */ false,
-   /* isBounded = */ true,
-   /* isAppending = */ false);
+   /* ReturnEnd = */ false,
+   /* IsBounded = */ true,
+   /* appendK = */ ConcatFnKind::none);
 }
 
 void CStringChecker::evalStpcpy(CheckerContext , const CallExpr *CE) const {
   // char *stpcpy(char *restrict dst, const char *restrict src);
   evalStrcpyCommon(C, CE,
-   /* returnEnd = */ true,
-   /* isBounded = */ false,
-   /* isAppending = */ false);
+   /* ReturnEnd = */ true,
+   /* IsBounded = */ false,
+   /* appendK = */ ConcatFnKind::none);
 }
 
 void CStringChecker::evalStrlcpy(CheckerContext , const CallExpr *CE) const {
-  // char *strlcpy(char *dst, const char *src, size_t n);
+  // size_t strlcpy(char *dest, const char *src, size_t size);
   evalStrcpyCommon(C, CE,
-   /* returnEnd = */ true,
-   /* isBounded = */ true,
-   /* isAppending = */ false,
+   /* ReturnEnd = */ true,
+   /* IsBounded = */ true,
+   /* appendK = */ ConcatFnKind::none,
/* returnPtr = */ false);
 }
 
 void CStringChecker::evalStrcat(CheckerContext , const CallExpr *CE) const {
-  //char *strcat(char *restrict s1, const char *restrict s2);
+  // char *strcat(char *restrict s1, const char *restrict s2);
   evalStrcpyCommon(C, CE,

[clang] 7215b7e - [creduce] Fixed a typo in the error message we're looking for.

2019-11-07 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2019-11-07T17:16:51-08:00
New Revision: 7215b7ef530bff896a1da70c6b062e9259f5fde7

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

LOG: [creduce] Fixed a typo in the error message we're looking for.

Added: 


Modified: 
clang/utils/creduce-clang-crash.py

Removed: 




diff  --git a/clang/utils/creduce-clang-crash.py 
b/clang/utils/creduce-clang-crash.py
index be16211c4da6..e886bf72e5a7 100755
--- a/clang/utils/creduce-clang-crash.py
+++ b/clang/utils/creduce-clang-crash.py
@@ -130,7 +130,7 @@ def read_expected_output(self):
r"fatal error: error in backend: (.+)",
r"LLVM ERROR: (.+)",
r"UNREACHABLE executed (at .+)?!",
-   r"LLVM IR generation of ceclaration '(.+)'",
+   r"LLVM IR generation of declaration '(.+)'",
r"Generating code for declaration '(.+)'",
r"\*\*\* Bad machine code: (.+) \*\*\*"]
 for msg_re in regexes:



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


[PATCH] D69978: Separately track input and output denormal mode

2019-11-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: scanon, cameron.mcinally, spatel, andrew.w.kaylor, 
mibintc, SjoerdMeijer.
Herald added subscribers: dexonsmith, hiraditya, tpr, nhaehnle, wdng, jvesely, 
jholewinski.
Herald added a project: LLVM.
arsenm added parent revisions: D69878: Consoldiate internal denormal flushing 
controls, D69598: Work on cleaning up denormal mode handling.

AMDGPU and x86 at least both have separate controls for whether
denormal results are flushed on output, and for whether denormals are
implicitly treated as 0 as an input. The current DAGCombiner use only
really cares about the input treatment of denormals.


https://reviews.llvm.org/D69978

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/denormalfpmode.c
  clang/test/CodeGenCUDA/flush-denormals.cu
  clang/test/CodeGenCUDA/propagate-metadata.cu
  clang/test/Driver/cl-denorms-are-zero.cl
  clang/test/Driver/cuda-flush-denormals-to-zero.cu
  clang/test/Driver/denormal-fp-math.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/ADT/FloatingPointMode.h
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/unittests/ADT/FloatingPointMode.cpp

Index: llvm/unittests/ADT/FloatingPointMode.cpp
===
--- llvm/unittests/ADT/FloatingPointMode.cpp
+++ llvm/unittests/ADT/FloatingPointMode.cpp
@@ -13,21 +13,122 @@
 
 namespace {
 
-TEST(FloatingPointModeTest, ParseDenormalFPAttribute) {
-  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttribute("ieee"));
-  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttribute(""));
+TEST(FloatingPointModeTest, ParseDenormalFPAttributeComponent) {
+  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttributeComponent("ieee"));
+  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttributeComponent(""));
   EXPECT_EQ(DenormalMode::PreserveSign,
-parseDenormalFPAttribute("preserve-sign"));
+parseDenormalFPAttributeComponent("preserve-sign"));
   EXPECT_EQ(DenormalMode::PositiveZero,
-parseDenormalFPAttribute("positive-zero"));
-  EXPECT_EQ(DenormalMode::Invalid, parseDenormalFPAttribute("foo"));
+parseDenormalFPAttributeComponent("positive-zero"));
+  EXPECT_EQ(DenormalMode::Invalid, parseDenormalFPAttributeComponent("foo"));
 }
 
 TEST(FloatingPointModeTest, DenormalAttributeName) {
-  EXPECT_EQ("ieee", denormalModeName(DenormalMode::IEEE));
-  EXPECT_EQ("preserve-sign", denormalModeName(DenormalMode::PreserveSign));
-  EXPECT_EQ("positive-zero", denormalModeName(DenormalMode::PositiveZero));
-  EXPECT_EQ("", denormalModeName(DenormalMode::Invalid));
+  EXPECT_EQ("ieee", denormalModeKindName(DenormalMode::IEEE));
+  EXPECT_EQ("preserve-sign", denormalModeKindName(DenormalMode::PreserveSign));
+  EXPECT_EQ("positive-zero", denormalModeKindName(DenormalMode::PositiveZero));
+  EXPECT_EQ("", denormalModeKindName(DenormalMode::Invalid));
+}
+
+TEST(FloatingPointModeTest, ParseDenormalFPAttribute) {
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute("ieee"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute("ieee,ieee"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute("ieee,"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute(""));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute(","));
+
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("preserve-sign"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("preserve-sign,"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("preserve-sign,preserve-sign"));
+
+  EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::PositiveZero),
+parseDenormalFPAttribute("positive-zero"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::PositiveZero),
+parseDenormalFPAttribute("positive-zero,positive-zero"));
+
+
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::PositiveZero),
+parseDenormalFPAttribute("ieee,positive-zero"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::IEEE),
+

[PATCH] D68108: Redeclare Objective-C property accessors inside the ObjCImplDecl in which they are synthesized.

2019-11-07 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Thanks for patiently working through this with me.


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

https://reviews.llvm.org/D68108



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


[PATCH] D68162: [analyzer][MallocChecker][NFC] Communicate the allocation family to auxiliary functions with parameters

2019-11-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks again!~

In D68162#1705928 , @Szelethus wrote:

> I guess you two are right. Maybe the best solution would be collapse `const 
> CallExpr *` and `AllocationFamily` parameters into `CallEvent`, and just 
> query the relevant information. Sure, its a query every time we need it, but 
> nothing impacts performance as much as months of hair pulling trying to 
> understand what this file does :^)


Just make sure not to store call events in the program state, 'cause they're 
short-lived :)


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

https://reviews.llvm.org/D68162



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


[PATCH] D68165: [analyzer][MallocChecker][NFC] Split checkPostCall up, deploy CallDescriptionMap

2019-11-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I think my `strdup` comments weren't addressed >.<




Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:378-379
+
+  using CheckFn = void (MallocChecker::*)(CheckerContext , const CallExpr 
*CE,
+  ProgramStateRef State) const;
+

baloghadamsoftware wrote:
> Szelethus wrote:
> > Szelethus wrote:
> > > NoQ wrote:
> > > > Whenever i see a (`CE`, `State`) pair, it screams `CallEvent` to me. 
> > > > That said, i'm worried that `State` in these callbacks isn't 
> > > > necessarily equal to `C.getState()` (the latter, by the way, is always 
> > > > equal to the `CallEvent`'s `.getState()` - that's a relief, right?), so 
> > > > if you'll ever be in the mood to check that, that'd be great :)
> > > It should be always equal to it. I'll change it.
> > Hmmm, I tried making this take a (`CallEvent`, `CheckerContext`), but it 
> > bloated the code for little gain, since every handler function would start 
> > with the retrieval of the state and the call expression. That said, I could 
> > cascade these down to `FreeMemAux`, `MallocMemAux`, etc, to also take this 
> > pair instead, but I'll be honest, I don't see point until something 
> > actually breaks.
> This is the standard way in the checkers: almost every handler function 
> starts with the retrieval of the state from the `CheckerContext`. The only 
> reason for an extra `State` parameter is that sometimes we create more states 
> in the lower level functions but only add the final one to the 
> `CheckerContext` as a new transition. Does something like this happen here?
I agree with @baloghadamsoftware here. If you pass `State` explicitly, it looks 
like an indication for the reader that this `State` may be different from 
`C.getState()`. If in practice they're the same, i'd rather do `C.getState()` 
in every method than confuse the reader.

Also do you remember what makes us query `CallExpr` so often? Given that 
`CallEvent` includes `CallExpr`, we should be able to expose everything we need 
as `CallEvent` methods. Say, we should be able to replace `MallocMemAux(C, CE, 
CE->getArg(0), ...)` with `MallocMemAux(C, Call, Call.getArgExpr(0), ...)` and 
only do `Call.getOriginExpr()` once when we report a bug.


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

https://reviews.llvm.org/D68165



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


[PATCH] D59516: [analyzer] Add custom filter functions for GenericTaintChecker

2019-11-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

@NoQ: "Why not simply remove taint?"
@boga95: //*removes taint*//
@NoQ: "Hmm, now that i think about it, adding a 'no taint' marker might 
actually work correctly more often."

Like, if you have taint on `$x` and try to remove taint from `derived<$x, 
x.a>`, your current implementation will do nothing. But the approach with 
adding a 'no taint' marker will actually add a new marker and make subsequent 
lookups to `derived<$x, x.a>` will return the newly added marker, which is the 
correct behavior; additionally, `derived<$x, x.b>` would remain tainted (where 
`b != a`), which is also the correct behavior. It would have still failed when 
you describe the sub-region slightly differently, but that'd be a fairly minor 
glitch.

The right way to proceed further with the `removeTaint()` approach on 
`SymbolDerived` is to introduce `removePartialTaint()` that would complement 
`addPartialTaint()`. But that will require changing the data structure in the 
program state from a simple set of tainted sub-regions to a sophisticated tree 
of sub-regions that are marked up as tainted or not tainted. Which might have 
as well been a marker.

I still tend to believe that `removeTaint()` is the right approach, but it's a 
bit harder to get right and a bit worse if not enough effort is invested into 
it.

There definitely is, however, a good use for the `removeTaint()` function in 
both approaches: namely, our taint checker still lacks `checkDeadSymbols` :D




Comment at: clang/lib/StaticAnalyzer/Checkers/Taint.cpp:111-112
+ProgramStateRef taint::removeTaint(ProgramStateRef State, SymbolRef Sym) {
+  // If this is a symbol cast, remove the cast before adding the taint. Taint
+  // is cast agnostic.
+  while (const SymbolCast *SC = dyn_cast(Sym))

That's not entirely true. Like, if you check `(char)x`, you still have 24 bytes 
of `x` controlled by the attacker. But that's a good false-positive-proof 
approach.



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:474-476
+  const FunctionDecl *FDecl = C.getCalleeDecl(CE);
+  if (!FDecl || FDecl->getKind() != Decl::Function)
+return;

boga95 wrote:
> Szelethus wrote:
> > When do these happen? For implicit functions in C? 
> For example, a lambda doesn't have an FunctionDecl.
Lambda most certainly has a `FunctionDecl`, which is the declaration of its 
`operator()()`, and that's exactly what's going to be in `FDecl` if a lambda is 
invoked. However, the `getKind()` of this `FunctionDecl` will not be 
`Decl::Function` but `Decl::CXXMethod`, like of any other member function.

So this second check is checking that the function is a simple global function.

I recommend replacing with `!isa(FDecl)`, purely for 
readability, or at least adding a comment.


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

https://reviews.llvm.org/D59516



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


[PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-11-07 Thread Eric Christopher via Phabricator via cfe-commits
echristo updated this revision to Diff 228339.
echristo added a comment.

Update to remove comments around SROA addition.


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

https://reviews.llvm.org/D65410

Files:
  clang/test/CodeGen/2008-07-30-implicit-initialization.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments2.cpp
  clang/test/CodeGen/atomic-ops-libcall.c
  clang/test/CodeGenCXX/atomicinit.cpp
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/discard-name-values.cpp
  clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
  clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
  clang/test/CodeGenCXX/nrvo.cpp
  clang/test/CodeGenCXX/stack-reuse.cpp
  clang/test/CodeGenCXX/wasm-args-returns.cpp
  clang/test/CodeGenObjCXX/arc-blocks.mm
  clang/test/CodeGenObjCXX/nrvo.mm
  clang/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
  clang/test/PCH/no-escaping-block-tail-calls.cpp
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
  llvm/test/Feature/optnone-opt.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Transforms/MemCpyOpt/lifetime.ll
  llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
  llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll

Index: llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
===
--- llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
+++ llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
@@ -74,7 +74,7 @@
 define i32 @two_shifts_by_sext_with_extra_use(i32 %val, i8 signext %len) {
 ; CHECK-LABEL: @two_shifts_by_sext_with_extra_use(
 ; CHECK-NEXT:[[CONV:%.*]] = sext i8 [[LEN:%.*]] to i32
-; CHECK-NEXT:tail call void @use_int32(i32 [[CONV]])
+; CHECK-NEXT:call void @use_int32(i32 [[CONV]])
 ; CHECK-NEXT:[[SHL:%.*]] = shl i32 [[VAL:%.*]], [[CONV]]
 ; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SHL]], [[CONV]]
 ; CHECK-NEXT:ret i32 [[SHR]]
@@ -101,7 +101,7 @@
 define i32 @two_shifts_by_same_sext_with_extra_use(i32 %val, i8 signext %len) {
 ; CHECK-LABEL: @two_shifts_by_same_sext_with_extra_use(
 ; CHECK-NEXT:[[CONV:%.*]] = sext i8 [[LEN:%.*]] to i32
-; CHECK-NEXT:tail call void @use_int32(i32 [[CONV]])
+; CHECK-NEXT:call void @use_int32(i32 [[CONV]])
 ; CHECK-NEXT:[[SHL:%.*]] = shl i32 [[VAL:%.*]], [[CONV]]
 ; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SHL]], [[CONV]]
 ; CHECK-NEXT:ret i32 [[SHR]]
Index: llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
===
--- llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
+++ llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
@@ -7,7 +7,7 @@
 
 define i1 @PR33605(i32 %a, i32 %b, i32* %c) {
 ; ALL-LABEL: @PR33605(
-; ALL-NEXT:  for.body:
+; ALL-NEXT:  entry:
 ; ALL-NEXT:[[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
 ; ALL-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
 ; ALL-NEXT:[[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
@@ -15,16 +15,16 @@
 ; ALL-NEXT:br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
 ; ALL:   if.then:
 ; ALL-NEXT:store i32 [[OR]], i32* [[ARRAYIDX]], align 4
-; ALL-NEXT:tail call void @foo()
+; ALL-NEXT:call void @foo()
 ; ALL-NEXT:br label [[IF_END]]
 ; ALL:   if.end:
-; ALL-NEXT:[[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ]
+; ALL-NEXT:[[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[ENTRY:%.*]] ]
 ; ALL-NEXT:[[TMP1:%.*]] = load i32, i32* [[C]], align 4
 ; ALL-NEXT:[[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]]
 ; ALL-NEXT:br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]]
 ; ALL:   if.then.1:
 ; ALL-NEXT:store i32 [[OR]], i32* [[C]], align 4
-; ALL-NEXT:tail call void @foo()
+; ALL-NEXT:call void @foo()
 ; ALL-NEXT:br label [[IF_END_1]]
 ; ALL:   if.end.1:
 ; ALL-NEXT:[[CHANGED_1_OFF0_1:%.*]] = phi i1 [ true, [[IF_THEN_1]] ], [ [[CHANGED_1_OFF0]], [[IF_END]] ]
Index: llvm/test/Transforms/MemCpyOpt/lifetime.ll
===
--- llvm/test/Transforms/MemCpyOpt/lifetime.ll
+++ llvm/test/Transforms/MemCpyOpt/lifetime.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -O1 -S | FileCheck %s
+; RUN: opt < %s -O2 -S | FileCheck %s
 
 ; performCallSlotOptzn in MemCpy should not exchange the calls to
 ; @llvm.lifetime.start and @llvm.memcpy.
Index: llvm/test/Other/new-pm-thinlto-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-defaults.ll
@@ -112,17 +112,32 @@
 ; CHECK-O-NEXT: Running pass: SROA
 ; CHECK-O-NEXT: Running pass: EarlyCSEPass
 ; 

RE: [clang] 03b84e4 - [clang] Report sanitizer blacklist as a dependency in cc1

2019-11-07 Thread Voss, Matthew via cfe-commits
Hi Jan,

It looks like this commit is causing DFSAN failures on the sanitizer bots and 
our internal CI. Could you take a look?

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24312/steps/64-bit%20check-dfsan/logs/stdio

Thanks,
Matthew

> -Original Message-
> From: cfe-commits  On Behalf Of Jan
> Korous via cfe-commits
> Sent: Thursday, November 7, 2019 2:07 PM
> To: cfe-commits@lists.llvm.org
> Subject: [clang] 03b84e4 - [clang] Report sanitizer blacklist as a
> dependency in cc1
> 
> 
> Author: Jan Korous
> Date: 2019-11-07T14:06:43-08:00
> New Revision: 03b84e4f6d0e1c04f22d69cc445f36e1f713beb4
> 
> URL: https://github.com/llvm/llvm-
> project/commit/03b84e4f6d0e1c04f22d69cc445f36e1f713beb4
> DIFF: https://github.com/llvm/llvm-
> project/commit/03b84e4f6d0e1c04f22d69cc445f36e1f713beb4.diff
> 
> LOG: [clang] Report sanitizer blacklist as a dependency in cc1
> 
> Previously these were reported from the driver which blocked clang-scan-
> deps from getting the full set of dependencies from cc1 commands.
> 
> Also the default sanitizer blacklist that is added in driver was never
> reported as a dependency. I introduced -fsanitize-system-blacklist cc1
> option to keep track of which blacklists were user-specified and which
> were added by driver and clang -MD now also reports system blacklists as
> dependencies.
> 
> Differential Revision: https://reviews.llvm.org/D69290
> 
> Added:
> 
> 
> Modified:
> clang/include/clang/Driver/Options.td
> clang/include/clang/Driver/SanitizerArgs.h
> clang/lib/Driver/SanitizerArgs.cpp
> clang/lib/Frontend/CompilerInvocation.cpp
> clang/test/Driver/fsanitize-blacklist.c
> clang/test/Frontend/dependency-gen.c
> 
> Removed:
> 
> 
> 
> ##
> ##
> diff  --git a/clang/include/clang/Driver/Options.td
> b/clang/include/clang/Driver/Options.td
> index dcd2976a97f2..c2e30a16b8da 100644
> --- a/clang/include/clang/Driver/Options.td
> +++ b/clang/include/clang/Driver/Options.td
> @@ -979,6 +979,9 @@ def fno_sanitize_EQ : CommaJoined<["-"], "fno-
> sanitize=">, Group,  def fsanitize_blacklist : Joined<["-
> "], "fsanitize-blacklist=">,
>Group,
>HelpText<"Path to blacklist file for
> sanitizers">;
> +def fsanitize_system_blacklist : Joined<["-"],
> +"fsanitize-system-blacklist=">,
> +  HelpText<"Path to system blacklist file for sanitizers">,
> +  Flags<[CC1Option]>;
>  def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
>   Group,
>   HelpText<"Don't use blacklist file for
> sanitizers">;
> 
> diff  --git a/clang/include/clang/Driver/SanitizerArgs.h
> b/clang/include/clang/Driver/SanitizerArgs.h
> index c37499e0f201..0aebf8cb225d 100644
> --- a/clang/include/clang/Driver/SanitizerArgs.h
> +++ b/clang/include/clang/Driver/SanitizerArgs.h
> @@ -25,8 +25,8 @@ class SanitizerArgs {
>SanitizerSet RecoverableSanitizers;
>SanitizerSet TrapSanitizers;
> 
> -  std::vector BlacklistFiles;
> -  std::vector ExtraDeps;
> +  std::vector UserBlacklistFiles;
> + std::vector SystemBlacklistFiles;
>int CoverageFeatures = 0;
>int MsanTrackOrigins = 0;
>bool MsanUseAfterDtor = true;
> 
> diff  --git a/clang/lib/Driver/SanitizerArgs.cpp
> b/clang/lib/Driver/SanitizerArgs.cpp
> index cc6c5e6ef438..8937197c253c 100644
> --- a/clang/lib/Driver/SanitizerArgs.cpp
> +++ b/clang/lib/Driver/SanitizerArgs.cpp
> @@ -557,29 +557,35 @@ SanitizerArgs::SanitizerArgs(const ToolChain ,
> 
>// Setup blacklist files.
>// Add default blacklist from resource directory.
> -  addDefaultBlacklists(D, Kinds, BlacklistFiles);
> +  addDefaultBlacklists(D, Kinds, SystemBlacklistFiles);
>// Parse -f(no-)sanitize-blacklist options.
>for (const auto *Arg : Args) {
>  if (Arg->getOption().matches(options::OPT_fsanitize_blacklist)) {
>Arg->claim();
>std::string BLPath = Arg->getValue();
>if (llvm::sys::fs::exists(BLPath)) {
> -BlacklistFiles.push_back(BLPath);
> -ExtraDeps.push_back(BLPath);
> +UserBlacklistFiles.push_back(BLPath);
>} else {
>  D.Diag(clang::diag::err_drv_no_such_file) << BLPath;
>}
>  } else if (Arg-
> >getOption().matches(options::OPT_fno_sanitize_blacklist)) {
>Arg->claim();
> -  BlacklistFiles.clear();
> -  ExtraDeps.clear();
> +  UserBlacklistFiles.clear();
> +  SystemBlacklistFiles.clear();
>  }
>}
>// Validate blacklists format.
>{
>  std::string BLError;
>  std::unique_ptr SCL(
> -llvm::SpecialCaseList::create(BlacklistFiles, BLError));
> +llvm::SpecialCaseList::create(UserBlacklistFiles, BLError));
> +if (!SCL.get())
> +  D.Diag(clang::diag::err_drv_malformed_sanitizer_blacklist) <<
> + BLError;  }  {
> +std::string BLError;
> +std::unique_ptr SCL(
> +

[PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-11-07 Thread Eric Christopher via Phabricator via cfe-commits
echristo updated this revision to Diff 228338.
echristo marked an inline comment as done.
echristo added a comment.
Herald added subscribers: aheejin, sbc100, nhaehnle, jvesely.

I've gone ahead and enabled SROA here. In the testing I've done so far it's 
helped execute time quite a bit and compile time/object size as well. It'll be 
really good for use with the trivial auto var initialization option also. SROA 
is a bit of a worry right now for debugging, but it's an area that's been 
improved upon significantly and I'm not worried about it getting a lot better.

Future plans here are likely going to be moving it to a more separate pass 
pipeline so I can pull out things like superfluous instcombines etc while 
continuing to do incremental performance improvements. In addition, I'm going 
to do experiments with enabling fast-isel at O1 
 so we can look at the compile time 
and performance impact of individual changes there - and hopefully some 
debugging analysis in the near term.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65410

Files:
  clang/test/CodeGen/2008-07-30-implicit-initialization.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments2.cpp
  clang/test/CodeGen/atomic-ops-libcall.c
  clang/test/CodeGenCXX/atomicinit.cpp
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/discard-name-values.cpp
  clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
  clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
  clang/test/CodeGenCXX/nrvo.cpp
  clang/test/CodeGenCXX/stack-reuse.cpp
  clang/test/CodeGenCXX/wasm-args-returns.cpp
  clang/test/CodeGenObjCXX/arc-blocks.mm
  clang/test/CodeGenObjCXX/nrvo.mm
  clang/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
  clang/test/PCH/no-escaping-block-tail-calls.cpp
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll
  llvm/test/Feature/optnone-opt.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Transforms/MemCpyOpt/lifetime.ll
  llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
  llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll

Index: llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
===
--- llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
+++ llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll
@@ -74,7 +74,7 @@
 define i32 @two_shifts_by_sext_with_extra_use(i32 %val, i8 signext %len) {
 ; CHECK-LABEL: @two_shifts_by_sext_with_extra_use(
 ; CHECK-NEXT:[[CONV:%.*]] = sext i8 [[LEN:%.*]] to i32
-; CHECK-NEXT:tail call void @use_int32(i32 [[CONV]])
+; CHECK-NEXT:call void @use_int32(i32 [[CONV]])
 ; CHECK-NEXT:[[SHL:%.*]] = shl i32 [[VAL:%.*]], [[CONV]]
 ; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SHL]], [[CONV]]
 ; CHECK-NEXT:ret i32 [[SHR]]
@@ -101,7 +101,7 @@
 define i32 @two_shifts_by_same_sext_with_extra_use(i32 %val, i8 signext %len) {
 ; CHECK-LABEL: @two_shifts_by_same_sext_with_extra_use(
 ; CHECK-NEXT:[[CONV:%.*]] = sext i8 [[LEN:%.*]] to i32
-; CHECK-NEXT:tail call void @use_int32(i32 [[CONV]])
+; CHECK-NEXT:call void @use_int32(i32 [[CONV]])
 ; CHECK-NEXT:[[SHL:%.*]] = shl i32 [[VAL:%.*]], [[CONV]]
 ; CHECK-NEXT:[[SHR:%.*]] = ashr i32 [[SHL]], [[CONV]]
 ; CHECK-NEXT:ret i32 [[SHR]]
Index: llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
===
--- llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
+++ llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll
@@ -7,7 +7,7 @@
 
 define i1 @PR33605(i32 %a, i32 %b, i32* %c) {
 ; ALL-LABEL: @PR33605(
-; ALL-NEXT:  for.body:
+; ALL-NEXT:  entry:
 ; ALL-NEXT:[[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
 ; ALL-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
 ; ALL-NEXT:[[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
@@ -15,16 +15,16 @@
 ; ALL-NEXT:br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
 ; ALL:   if.then:
 ; ALL-NEXT:store i32 [[OR]], i32* [[ARRAYIDX]], align 4
-; ALL-NEXT:tail call void @foo()
+; ALL-NEXT:call void @foo()
 ; ALL-NEXT:br label [[IF_END]]
 ; ALL:   if.end:
-; ALL-NEXT:[[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ]
+; ALL-NEXT:[[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[ENTRY:%.*]] ]
 ; ALL-NEXT:[[TMP1:%.*]] = load i32, i32* [[C]], align 4
 ; ALL-NEXT:[[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]]
 ; ALL-NEXT:br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]]
 ; ALL:   if.then.1:
 ; ALL-NEXT:store i32 [[OR]], i32* [[C]], align 4
-; ALL-NEXT:

[PATCH] D69950: Reapply "Fix crash on switch conditions of non-integer types in templates"

2019-11-07 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.

LGTM for ClangTidy, assuming you ran `ninja check-all`.


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

https://reviews.llvm.org/D69950



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


[PATCH] D69922: [OpenMP] Use the OpenMP-IR-Builder

2019-11-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 228331.
jdoerfert marked 2 inline comments as done.
jdoerfert added a comment.
Herald added a project: LLVM.

Adjust tests as requested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69922

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fopenmp.c
  clang/test/OpenMP/barrier_codegen.cpp
  llvm/include/llvm/IR/OpenMPIRBuilder.h

Index: llvm/include/llvm/IR/OpenMPIRBuilder.h
===
--- llvm/include/llvm/IR/OpenMPIRBuilder.h
+++ llvm/include/llvm/IR/OpenMPIRBuilder.h
@@ -37,6 +37,9 @@
   /// Description of a LLVM-IR insertion point (IP) and a debug/source location
   /// (filename, line, column, ...).
   struct LocationDescription {
+template 
+LocationDescription(const IRBuilder )
+: IP(IRB.saveIP()), DL(IRB.getCurrentDebugLocation()) {}
 LocationDescription(const IRBuilder<>::InsertPoint ) : IP(IP) {}
 LocationDescription(const IRBuilder<>::InsertPoint , const DebugLoc )
 : IP(IP), DL(DL) {}
Index: clang/test/OpenMP/barrier_codegen.cpp
===
--- clang/test/OpenMP/barrier_codegen.cpp
+++ clang/test/OpenMP/barrier_codegen.cpp
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CLANGCG
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CLANGCG
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
@@ -14,6 +18,10 @@
 // CHECK-DAG: [[EXPLICIT_BARRIER_LOC:@.+]] = {{.+}} [[IDENT_T]] { i32 0, i32 34, i32 0, i32 0, i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @{{.+}}, i32 0, i32 0) }
 // CHECK-DAG: [[LOC:@.+]] = {{.+}} [[IDENT_T]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @{{.+}}, i32 0, i32 0) }
 
+// CLANGCG-NOT: readonly
+// IRBUILDER:  ; Function Attrs: nofree nosync nounwind readonly
+// IRBUILDER-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
+
 void foo() {}
 
 template 
Index: clang/test/Driver/fopenmp.c
===
--- clang/test/Driver/fopenmp.c
+++ clang/test/Driver/fopenmp.c
@@ -124,6 +124,12 @@
 // CHECK-LD-STATIC-IOMP5-NO-BDYNAMIC: "-{{B?}}static" {{.*}} "-liomp5"
 // CHECK-LD-STATIC-IOMP5-NO-BDYNAMIC-NOT: "-Bdynamic"
 //
+// RUN: %clang -target x86_64-linux-gnu -fopenmp -fopenmp-enable-irbuilder -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CC1-OPENMPIRBUILDER
+//
+// CHECK-CC1-OPENMPIRBUILDER: "-cc1"
+// CHECK-CC1-OPENMPIRBUILDER-SAME: "-fopenmp"
+// CHECK-CC1-OPENMPIRBUILDER-SAME: "-fopenmp-enable-irbuilder"
+//
 // We'd like to check that the default is sane, but until we have the ability
 // to *always* semantically analyze OpenMP without always generating runtime
 // calls (in the event of an unsupported runtime), we don't have a good way to
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2996,6 +2996,8 @@
   Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
   Opts.OpenMPIsDevice =
   Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
+  Opts.OpenMPIRBuilder =
+  Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_enable_irbuilder);
   bool IsTargetSpecified =
   Opts.OpenMPIsDevice || 

[PATCH] D69971: clang-format: [JS] support null operators.

2019-11-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69971



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


[PATCH] D69972: clang-format: [JS] test declared fields.

2019-11-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Thanks for this  patch, this LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69972



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-11-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 228327.
jdoerfert added a comment.

Adjust RTL attributes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785

Files:
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/include/llvm/IR/OpenMPConstants.h
  llvm/include/llvm/IR/OpenMPIRBuilder.h
  llvm/include/llvm/IR/OpenMPKinds.def
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/OpenMPConstants.cpp
  llvm/lib/IR/OpenMPIRBuilder.cpp
  llvm/unittests/IR/CMakeLists.txt
  llvm/unittests/IR/IRBuilderTest.cpp
  llvm/unittests/IR/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/IR/OpenMPIRBuilderTest.cpp
===
--- /dev/null
+++ llvm/unittests/IR/OpenMPIRBuilderTest.cpp
@@ -0,0 +1,129 @@
+//===- llvm/unittest/IR/OpenMPIRBuilderTest.cpp - OpenMPIRBuilder tests ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/IR/OpenMPIRBuilder.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/DIBuilder.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/OpenMPConstants.h"
+#include "llvm/IR/Verifier.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace omp;
+using namespace types;
+
+namespace {
+
+class OpenMPIRBuilderTest : public testing::Test {
+protected:
+  void SetUp() override {
+M.reset(new Module("MyModule", Ctx));
+FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx),
+  /*isVarArg=*/false);
+F = Function::Create(FTy, Function::ExternalLinkage, "", M.get());
+BB = BasicBlock::Create(Ctx, "", F);
+  }
+
+  void TearDown() override {
+BB = nullptr;
+M.reset();
+uninitializeTypes();
+  }
+
+  LLVMContext Ctx;
+  std::unique_ptr M;
+  Function *F;
+  BasicBlock *BB;
+};
+
+TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  IRBuilder<> Builder(BB);
+
+  OMPBuilder.CreateBarrier({IRBuilder<>::InsertPoint()}, OMPD_for);
+  EXPECT_TRUE(M->global_empty());
+  EXPECT_EQ(M->size(), 6U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 0U);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 6U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 2U);
+
+  CallInst *GTID = dyn_cast(>front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), "__kmpc_global_thread_num");
+
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_NE(Barrier, nullptr);
+  EXPECT_EQ(Barrier->getNumArgOperands(), 2U);
+  EXPECT_EQ(Barrier->getCalledFunction()->getName(), "__kmpc_barrier");
+
+  EXPECT_EQ(cast(Barrier)->getArgOperand(1), GTID);
+
+  Builder.CreateUnreachable();
+  EXPECT_FALSE(verifyModule(*M));
+}
+
+TEST_F(OpenMPIRBuilderTest, DbgLoc) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+
+  IRBuilder<> Builder(BB);
+
+  DIBuilder DIB(*M);
+  auto File = DIB.createFile("test.dbg", "/");
+  auto CU =
+  DIB.createCompileUnit(dwarf::DW_LANG_C, File, "llvm-C", true, "", 0);
+  auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
+  auto SP = DIB.createFunction(
+  CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
+  DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
+  F->setSubprogram(SP);
+  auto Scope = DIB.createLexicalBlockFile(SP, File, 0);
+  DIB.finalize();
+
+  DebugLoc DL = DebugLoc::get(3, 7, Scope);
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  CallInst *GTID = dyn_cast(>front());
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_EQ(GTID->getDebugLoc(), DL);
+  EXPECT_EQ(Barrier->getDebugLoc(), DL);
+  EXPECT_TRUE(isa(Barrier->getOperand(0)));
+  if (!isa(Barrier->getOperand(0)))
+return;
+  GlobalVariable *Ident = cast(Barrier->getOperand(0));
+  EXPECT_TRUE(Ident->hasInitializer());
+  if (!Ident->hasInitializer())
+return;
+  Constant *Initializer = Ident->getInitializer();
+  EXPECT_TRUE(
+  isa(Initializer->getOperand(4)->stripPointerCasts()));
+  GlobalVariable *SrcStrGlob =
+  cast(Initializer->getOperand(4)->stripPointerCasts());
+  if (!SrcStrGlob)
+return;
+  EXPECT_TRUE(isa(SrcStrGlob->getInitializer()));
+  ConstantDataArray *SrcSrc =
+  dyn_cast(SrcStrGlob->getInitializer());
+  if (!SrcSrc)
+return;
+  EXPECT_EQ(SrcSrc->getAsCString(), ";test.dbg;foo;3;7;;");
+}
+} // namespace
Index: 

[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-11-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 228328.
jdoerfert added a comment.

Remove accidental newline change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785

Files:
  llvm/include/llvm/IR/OpenMPConstants.h
  llvm/include/llvm/IR/OpenMPIRBuilder.h
  llvm/include/llvm/IR/OpenMPKinds.def
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/OpenMPConstants.cpp
  llvm/lib/IR/OpenMPIRBuilder.cpp
  llvm/unittests/IR/CMakeLists.txt
  llvm/unittests/IR/IRBuilderTest.cpp
  llvm/unittests/IR/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/IR/OpenMPIRBuilderTest.cpp
===
--- /dev/null
+++ llvm/unittests/IR/OpenMPIRBuilderTest.cpp
@@ -0,0 +1,129 @@
+//===- llvm/unittest/IR/OpenMPIRBuilderTest.cpp - OpenMPIRBuilder tests ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/IR/OpenMPIRBuilder.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/DIBuilder.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/OpenMPConstants.h"
+#include "llvm/IR/Verifier.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace omp;
+using namespace types;
+
+namespace {
+
+class OpenMPIRBuilderTest : public testing::Test {
+protected:
+  void SetUp() override {
+M.reset(new Module("MyModule", Ctx));
+FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx),
+  /*isVarArg=*/false);
+F = Function::Create(FTy, Function::ExternalLinkage, "", M.get());
+BB = BasicBlock::Create(Ctx, "", F);
+  }
+
+  void TearDown() override {
+BB = nullptr;
+M.reset();
+uninitializeTypes();
+  }
+
+  LLVMContext Ctx;
+  std::unique_ptr M;
+  Function *F;
+  BasicBlock *BB;
+};
+
+TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  IRBuilder<> Builder(BB);
+
+  OMPBuilder.CreateBarrier({IRBuilder<>::InsertPoint()}, OMPD_for);
+  EXPECT_TRUE(M->global_empty());
+  EXPECT_EQ(M->size(), 6U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 0U);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 6U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 2U);
+
+  CallInst *GTID = dyn_cast(>front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), "__kmpc_global_thread_num");
+
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_NE(Barrier, nullptr);
+  EXPECT_EQ(Barrier->getNumArgOperands(), 2U);
+  EXPECT_EQ(Barrier->getCalledFunction()->getName(), "__kmpc_barrier");
+
+  EXPECT_EQ(cast(Barrier)->getArgOperand(1), GTID);
+
+  Builder.CreateUnreachable();
+  EXPECT_FALSE(verifyModule(*M));
+}
+
+TEST_F(OpenMPIRBuilderTest, DbgLoc) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+
+  IRBuilder<> Builder(BB);
+
+  DIBuilder DIB(*M);
+  auto File = DIB.createFile("test.dbg", "/");
+  auto CU =
+  DIB.createCompileUnit(dwarf::DW_LANG_C, File, "llvm-C", true, "", 0);
+  auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
+  auto SP = DIB.createFunction(
+  CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
+  DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
+  F->setSubprogram(SP);
+  auto Scope = DIB.createLexicalBlockFile(SP, File, 0);
+  DIB.finalize();
+
+  DebugLoc DL = DebugLoc::get(3, 7, Scope);
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  CallInst *GTID = dyn_cast(>front());
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_EQ(GTID->getDebugLoc(), DL);
+  EXPECT_EQ(Barrier->getDebugLoc(), DL);
+  EXPECT_TRUE(isa(Barrier->getOperand(0)));
+  if (!isa(Barrier->getOperand(0)))
+return;
+  GlobalVariable *Ident = cast(Barrier->getOperand(0));
+  EXPECT_TRUE(Ident->hasInitializer());
+  if (!Ident->hasInitializer())
+return;
+  Constant *Initializer = Ident->getInitializer();
+  EXPECT_TRUE(
+  isa(Initializer->getOperand(4)->stripPointerCasts()));
+  GlobalVariable *SrcStrGlob =
+  cast(Initializer->getOperand(4)->stripPointerCasts());
+  if (!SrcStrGlob)
+return;
+  EXPECT_TRUE(isa(SrcStrGlob->getInitializer()));
+  ConstantDataArray *SrcSrc =
+  dyn_cast(SrcStrGlob->getInitializer());
+  if (!SrcSrc)
+return;
+  EXPECT_EQ(SrcSrc->getAsCString(), ";test.dbg;foo;3;7;;");
+}
+} // namespace
Index: llvm/unittests/IR/IRBuilderTest.cpp

[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-07 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:4435-4437
+if (DMIB == DMIB_alloc) Kind = OMPC_MAP_alloc;
+else if (DMIB == DMIB_to) Kind = OMPC_MAP_to;
+else if (DMIB == DMIB_from) Kind = OMPC_MAP_from;

ABataev wrote:
> Use `switch`
In this switch statement, I checked if the implicit map contains any "declare 
target link" to prove that for the normal case (no declare target link/to), 
DMIB_default and DMIB_default is unreachable for scalar and pointer.
However, this change is not quite right since I haven't added any extra 
ImplicitMap to deal with the case that ImplicitMap contains "declare target 
link" variable. (instead, I only create an extra field in ImplicitMap only so 
that I can demonstrate) And the reason why I'm hesitant to do so is that adding 
another two ImplicitMap only for "declare target link" might be a little be 
overkill?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D69972: clang-format: [JS] test declared fields.

2019-11-07 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: krasimir.
Herald added a project: clang.

TypeScript now supports declaring fields:

  class Foo {
declare field: string;
  }

clang-format happens to already format this fine, so this change just
adds a regression test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69972

Files:
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2359,5 +2359,12 @@
"  static #staticPrivateMethod() {}\n");
 }
 
+TEST_F(FormatTestJS, DeclaredFields) {
+  verifyFormat("class Example {\n"
+   "  declare pub: string;\n"
+   "  declare private priv: string;\n"
+   "}\n");
+}
+
 } // namespace format
 } // end namespace clang


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2359,5 +2359,12 @@
"  static #staticPrivateMethod() {}\n");
 }
 
+TEST_F(FormatTestJS, DeclaredFields) {
+  verifyFormat("class Example {\n"
+   "  declare pub: string;\n"
+   "  declare private priv: string;\n"
+   "}\n");
+}
+
 } // namespace format
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69969: [SEH] Defer checking filter expression types until instantiaton

2019-11-07 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7177ce978e8f: [SEH] Defer checking filter expression types 
until instantiaton (authored by rnk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69969

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Sema/__try.c
  clang/test/SemaCXX/exceptions-seh.cpp


Index: clang/test/SemaCXX/exceptions-seh.cpp
===
--- clang/test/SemaCXX/exceptions-seh.cpp
+++ clang/test/SemaCXX/exceptions-seh.cpp
@@ -113,3 +113,17 @@
   } catch(int) {
   }
 };
+
+template  void dependent_filter() {
+  __try {
+might_crash();
+  } __except (T()) { // expected-error {{filter expression has non-integral 
type 'NotInteger'}}
+  }
+}
+
+struct NotInteger { int x; };
+
+void instantiate_dependent_filter() {
+  dependent_filter();
+  dependent_filter(); // expected-note {{requested here}}
+}
Index: clang/test/Sema/__try.c
===
--- clang/test/Sema/__try.c
+++ clang/test/Sema/__try.c
@@ -111,7 +111,7 @@
   __try {
 
   }
-  __except ( NotFilterExpression() ) { // expected-error{{filter expression 
type should be an integral value not 'const char *'}}
+  __except ( NotFilterExpression() ) { // expected-error{{filter expression 
has non-integral type 'const char *'}}
 
   }
 }
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -4184,19 +4184,16 @@
   return SEHTryStmt::Create(Context, IsCXXTry, TryLoc, TryBlock, Handler);
 }
 
-StmtResult
-Sema::ActOnSEHExceptBlock(SourceLocation Loc,
-  Expr *FilterExpr,
-  Stmt *Block) {
+StmtResult Sema::ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr,
+ Stmt *Block) {
   assert(FilterExpr && Block);
-
-  if(!FilterExpr->getType()->isIntegerType()) {
-return StmtError(Diag(FilterExpr->getExprLoc(),
- diag::err_filter_expression_integral)
- << FilterExpr->getType());
+  QualType FTy = FilterExpr->getType();
+  if (!FTy->isIntegerType() && !FTy->isDependentType()) {
+return StmtError(
+Diag(FilterExpr->getExprLoc(), diag::err_filter_expression_integral)
+<< FTy);
   }
-
-  return SEHExceptStmt::Create(Context,Loc,FilterExpr,Block);
+  return SEHExceptStmt::Create(Context, Loc, FilterExpr, Block);
 }
 
 void Sema::ActOnStartSEHFinallyBlock() {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8935,7 +8935,7 @@
   "function %0 with unknown type must be given a function type">;
 
 def err_filter_expression_integral : Error<
-  "filter expression type should be an integral value not %0">;
+  "filter expression has non-integral type %0">;
 
 def err_non_asm_stmt_in_naked_function : Error<
   "non-ASM statement in naked function is not supported">;


Index: clang/test/SemaCXX/exceptions-seh.cpp
===
--- clang/test/SemaCXX/exceptions-seh.cpp
+++ clang/test/SemaCXX/exceptions-seh.cpp
@@ -113,3 +113,17 @@
   } catch(int) {
   }
 };
+
+template  void dependent_filter() {
+  __try {
+might_crash();
+  } __except (T()) { // expected-error {{filter expression has non-integral type 'NotInteger'}}
+  }
+}
+
+struct NotInteger { int x; };
+
+void instantiate_dependent_filter() {
+  dependent_filter();
+  dependent_filter(); // expected-note {{requested here}}
+}
Index: clang/test/Sema/__try.c
===
--- clang/test/Sema/__try.c
+++ clang/test/Sema/__try.c
@@ -111,7 +111,7 @@
   __try {
 
   }
-  __except ( NotFilterExpression() ) { // expected-error{{filter expression type should be an integral value not 'const char *'}}
+  __except ( NotFilterExpression() ) { // expected-error{{filter expression has non-integral type 'const char *'}}
 
   }
 }
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -4184,19 +4184,16 @@
   return SEHTryStmt::Create(Context, IsCXXTry, TryLoc, TryBlock, Handler);
 }
 
-StmtResult
-Sema::ActOnSEHExceptBlock(SourceLocation Loc,
-  Expr *FilterExpr,
-  Stmt *Block) {
+StmtResult Sema::ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr,
+ Stmt *Block) {
   assert(FilterExpr && Block);
-
-  if(!FilterExpr->getType()->isIntegerType()) {
-return 

[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-11-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 228320.
jdoerfert added a comment.

Use source location information to build the ident string and debug info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785

Files:
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/include/llvm/IR/OpenMPConstants.h
  llvm/include/llvm/IR/OpenMPIRBuilder.h
  llvm/include/llvm/IR/OpenMPKinds.def
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/OpenMPConstants.cpp
  llvm/lib/IR/OpenMPIRBuilder.cpp
  llvm/unittests/IR/CMakeLists.txt
  llvm/unittests/IR/IRBuilderTest.cpp
  llvm/unittests/IR/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/IR/OpenMPIRBuilderTest.cpp
===
--- /dev/null
+++ llvm/unittests/IR/OpenMPIRBuilderTest.cpp
@@ -0,0 +1,129 @@
+//===- llvm/unittest/IR/OpenMPIRBuilderTest.cpp - OpenMPIRBuilder tests ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/IR/OpenMPIRBuilder.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/DIBuilder.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/OpenMPConstants.h"
+#include "llvm/IR/Verifier.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace omp;
+using namespace types;
+
+namespace {
+
+class OpenMPIRBuilderTest : public testing::Test {
+protected:
+  void SetUp() override {
+M.reset(new Module("MyModule", Ctx));
+FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx),
+  /*isVarArg=*/false);
+F = Function::Create(FTy, Function::ExternalLinkage, "", M.get());
+BB = BasicBlock::Create(Ctx, "", F);
+  }
+
+  void TearDown() override {
+BB = nullptr;
+M.reset();
+uninitializeTypes();
+  }
+
+  LLVMContext Ctx;
+  std::unique_ptr M;
+  Function *F;
+  BasicBlock *BB;
+};
+
+TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  IRBuilder<> Builder(BB);
+
+  OMPBuilder.CreateBarrier({IRBuilder<>::InsertPoint()}, OMPD_for);
+  EXPECT_TRUE(M->global_empty());
+  EXPECT_EQ(M->size(), 6U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 0U);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 6U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 2U);
+
+  CallInst *GTID = dyn_cast(>front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), "__kmpc_global_thread_num");
+
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_NE(Barrier, nullptr);
+  EXPECT_EQ(Barrier->getNumArgOperands(), 2U);
+  EXPECT_EQ(Barrier->getCalledFunction()->getName(), "__kmpc_barrier");
+
+  EXPECT_EQ(cast(Barrier)->getArgOperand(1), GTID);
+
+  Builder.CreateUnreachable();
+  EXPECT_FALSE(verifyModule(*M));
+}
+
+TEST_F(OpenMPIRBuilderTest, DbgLoc) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+
+  IRBuilder<> Builder(BB);
+
+  DIBuilder DIB(*M);
+  auto File = DIB.createFile("test.dbg", "/");
+  auto CU =
+  DIB.createCompileUnit(dwarf::DW_LANG_C, File, "llvm-C", true, "", 0);
+  auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
+  auto SP = DIB.createFunction(
+  CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
+  DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
+  F->setSubprogram(SP);
+  auto Scope = DIB.createLexicalBlockFile(SP, File, 0);
+  DIB.finalize();
+
+  DebugLoc DL = DebugLoc::get(3, 7, Scope);
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  CallInst *GTID = dyn_cast(>front());
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_EQ(GTID->getDebugLoc(), DL);
+  EXPECT_EQ(Barrier->getDebugLoc(), DL);
+  EXPECT_TRUE(isa(Barrier->getOperand(0)));
+  if (!isa(Barrier->getOperand(0)))
+return;
+  GlobalVariable *Ident = cast(Barrier->getOperand(0));
+  EXPECT_TRUE(Ident->hasInitializer());
+  if (!Ident->hasInitializer())
+return;
+  Constant *Initializer = Ident->getInitializer();
+  EXPECT_TRUE(
+  isa(Initializer->getOperand(4)->stripPointerCasts()));
+  GlobalVariable *SrcStrGlob =
+  cast(Initializer->getOperand(4)->stripPointerCasts());
+  if (!SrcStrGlob)
+return;
+  EXPECT_TRUE(isa(SrcStrGlob->getInitializer()));
+  ConstantDataArray *SrcSrc =
+  dyn_cast(SrcStrGlob->getInitializer());
+  if (!SrcSrc)
+return;
+  EXPECT_EQ(SrcSrc->getAsCString(), 

[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-11-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D69785#1737581 , @lebedev.ri wrote:

> As far as i can tell the builder does not add any debug info.
>  Should it?


It does now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[PATCH] D69970: [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood (reland with fixes)

2019-11-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In D69970#1737814 , @dblaikie wrote:

> The failure I am investigating from the original commit of this at Google 
> probably isn't related to the assertion failure that caused the revert of 
> this patch/being addressed by this recommit. So if you could hold off a bit 
> while I try to help provide a reproduction or enough detail for you to 
> investigate this other internal failure?
>
> At the moment the details I have is that the resulting assembly has an unused 
> label/basic block boundary that's resulting in a location 0 (an un-located 
> instruction placed at the beginning of a basic block uses location zero so it 
> doesn't flow from the previous BB). Hmm, maybe that's unrelated, though. I 
> haven't quite nailed it down yet.


Thanks for the heads-up. I'm happy to hold off for now. I've also kicked off a 
stage2 -O3 -gline-tables-only build to be on the safe side.


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

https://reviews.llvm.org/D69970



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


[PATCH] D69970: [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood (reland with fixes)

2019-11-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

The failure I am investigating from the original commit of this at Google 
probably isn't related to the assertion failure that caused the revert of this 
patch/being addressed by this recommit. So if you could hold off a bit while I 
try to help provide a reproduction or enough detail for you to investigate this 
other internal failure?

At the moment the details I have is that the resulting assembly has an unused 
label/basic block boundary that's resulting in a location 0 (an un-located 
instruction placed at the beginning of a basic block uses location zero so it 
doesn't flow from the previous BB). Hmm, maybe that's unrelated, though. I 
haven't quite nailed it down yet.


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

https://reviews.llvm.org/D69970



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


[PATCH] D69971: clang-format: [JS] support null operators.

2019-11-07 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: krasimir.
Herald added a project: clang.

JavaScript / TypeScript is adding two new operators: the null
propagating operator `?.` and the nullish coalescing operator `??`.

  const x = foo ?? 'default';
  const z = foo?.bar?.baz;

This change adds support to lex and format both.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69971

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -,6 +,14 @@
   verifyFormat("return !!x;\n");
 }
 
+TEST_F(FormatTestJS, NullPropagatingOperator) {
+  verifyFormat("let x = foo?.bar?.baz();\n");
+}
+
+TEST_F(FormatTestJS, NullishCoalescingOperator) {
+  verifyFormat("const val = something ?? 'some other default';\n");
+}
+
 TEST_F(FormatTestJS, Conditional) {
   verifyFormat("y = x ? 1 : 2;");
   verifyFormat("x ? 1 : 2;");
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -100,6 +100,10 @@
 static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
 static const tok::TokenKind JSExponentiationEqual[] = {tok::star,
tok::starequal};
+static const tok::TokenKind JSNullPropagatingOperator[] = {tok::question,
+   tok::period};
+static const tok::TokenKind JSNullishOperator[] = {tok::question,
+   tok::question};
 
 // FIXME: Investigate what token type gives the correct operator priority.
 if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
@@ -116,6 +120,14 @@
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+  return;
+if (tryMergeTokens(JSNullPropagatingOperator,
+   TT_JsNullPropagatingOperator)) {
+  // Treat like a regular "." access.
+  Tokens.back()->Tok.setKind(tok::period);
+  return;
+}
 if (tryMergeJSPrivateIdentifier())
   return;
   }
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -60,6 +60,8 @@
   TYPE(JsExponentiationEqual)  
\
   TYPE(JsFatArrow) 
\
   TYPE(JsNonNullAssertion) 
\
+  TYPE(JsNullishCoalescingOperator)
\
+  TYPE(JsNullPropagatingOperator)  
\
   TYPE(JsPrivateIdentifier)
\
   TYPE(JsTypeColon)
\
   TYPE(JsTypeOperator) 
\


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -,6 +,14 @@
   verifyFormat("return !!x;\n");
 }
 
+TEST_F(FormatTestJS, NullPropagatingOperator) {
+  verifyFormat("let x = foo?.bar?.baz();\n");
+}
+
+TEST_F(FormatTestJS, NullishCoalescingOperator) {
+  verifyFormat("const val = something ?? 'some other default';\n");
+}
+
 TEST_F(FormatTestJS, Conditional) {
   verifyFormat("y = x ? 1 : 2;");
   verifyFormat("x ? 1 : 2;");
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -100,6 +100,10 @@
 static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
 static const tok::TokenKind JSExponentiationEqual[] = {tok::star,
tok::starequal};
+static const tok::TokenKind JSNullPropagatingOperator[] = {tok::question,
+   tok::period};
+static const tok::TokenKind JSNullishOperator[] = {tok::question,
+   tok::question};
 
 // FIXME: Investigate what token type gives the correct operator priority.
 if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
@@ -116,6 +120,14 @@
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+  return;

[clang] 7177ce9 - [SEH] Defer checking filter expression types until instantiaton

2019-11-07 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2019-11-07T14:52:04-08:00
New Revision: 7177ce978e8f8e5409cec90bad07df92441656e3

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

LOG: [SEH] Defer checking filter expression types until instantiaton

While here, wordsmith the error a bit. Now clang says:
  error: filter expression has non-integral type 'Foo'

Fixes PR43779

Reviewers: amccarth

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaStmt.cpp
clang/test/Sema/__try.c
clang/test/SemaCXX/exceptions-seh.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1aff4688de5d..88d73dc89b55 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8935,7 +8935,7 @@ def err_unknown_any_function : Error<
   "function %0 with unknown type must be given a function type">;
 
 def err_filter_expression_integral : Error<
-  "filter expression type should be an integral value not %0">;
+  "filter expression has non-integral type %0">;
 
 def err_non_asm_stmt_in_naked_function : Error<
   "non-ASM statement in naked function is not supported">;

diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 6c680f29da4f..9680720f549e 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -4184,19 +4184,16 @@ StmtResult Sema::ActOnSEHTryBlock(bool IsCXXTry, 
SourceLocation TryLoc,
   return SEHTryStmt::Create(Context, IsCXXTry, TryLoc, TryBlock, Handler);
 }
 
-StmtResult
-Sema::ActOnSEHExceptBlock(SourceLocation Loc,
-  Expr *FilterExpr,
-  Stmt *Block) {
+StmtResult Sema::ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr,
+ Stmt *Block) {
   assert(FilterExpr && Block);
-
-  if(!FilterExpr->getType()->isIntegerType()) {
-return StmtError(Diag(FilterExpr->getExprLoc(),
- diag::err_filter_expression_integral)
- << FilterExpr->getType());
+  QualType FTy = FilterExpr->getType();
+  if (!FTy->isIntegerType() && !FTy->isDependentType()) {
+return StmtError(
+Diag(FilterExpr->getExprLoc(), diag::err_filter_expression_integral)
+<< FTy);
   }
-
-  return SEHExceptStmt::Create(Context,Loc,FilterExpr,Block);
+  return SEHExceptStmt::Create(Context, Loc, FilterExpr, Block);
 }
 
 void Sema::ActOnStartSEHFinallyBlock() {

diff  --git a/clang/test/Sema/__try.c b/clang/test/Sema/__try.c
index cfb47e61d4ca..f7c5c97da104 100644
--- a/clang/test/Sema/__try.c
+++ b/clang/test/Sema/__try.c
@@ -111,7 +111,7 @@ void TEST() {
   __try {
 
   }
-  __except ( NotFilterExpression() ) { // expected-error{{filter expression 
type should be an integral value not 'const char *'}}
+  __except ( NotFilterExpression() ) { // expected-error{{filter expression 
has non-integral type 'const char *'}}
 
   }
 }

diff  --git a/clang/test/SemaCXX/exceptions-seh.cpp 
b/clang/test/SemaCXX/exceptions-seh.cpp
index 7375ec9bf816..1d8cc4917e98 100644
--- a/clang/test/SemaCXX/exceptions-seh.cpp
+++ b/clang/test/SemaCXX/exceptions-seh.cpp
@@ -113,3 +113,17 @@ void (^use_cxx_in_global_block)() = ^{
   } catch(int) {
   }
 };
+
+template  void dependent_filter() {
+  __try {
+might_crash();
+  } __except (T()) { // expected-error {{filter expression has non-integral 
type 'NotInteger'}}
+  }
+}
+
+struct NotInteger { int x; };
+
+void instantiate_dependent_filter() {
+  dependent_filter();
+  dependent_filter(); // expected-note {{requested here}}
+}



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


[libunwind] d3c7443 - Correctly update isSignalFrame when unwinding the stack via dwarf.

2019-11-07 Thread Sterling Augustine via cfe-commits

Author: Sterling Augustine
Date: 2019-11-07T14:48:35-08:00
New Revision: d3c744313c3cca0c076f031ec71e66ca74b12f2a

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

LOG: Correctly update isSignalFrame when unwinding the stack via dwarf.

A "signal frame" is a function or block of code where execution arrives via a 
signal or interrupt, rather than via a normal call instruction. In fact, a 
particular instruction is interrupted by the signal and needs to be restarted. 
Therefore, when the signal handler is complete, execution needs to return to 
the interrupted instruction, rather than the instruction immediately following 
the call instruction, as in a normal call.

Stack unwinders need to know this to correctly unwind signal frames. Dwarf 
handily provides an "S" in the CIE augmentation string to describe this case, 
and the libunwind API provides various functions to for unwinders to determine 
it,.

The llvm libunwind implementation correctly sets it's internal variable 
"isSignalFrame" when initializing an unwind context. However, upon stepping up 
the stack, the current implementation correctly reads the augmentation string 
and sets it in the CIE info (which it then discards), libunwind doesn't update 
it's internal unwind context data structure.

This change fixes that, and provides compatibility with both the canonical 
libunwind and the libgcc implementation.

Reviewers: jfb

Subscribers: christof, libcxx-commits

Tags: #libc

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

Added: 
libunwind/test/signal_frame.pass.cpp

Modified: 
libunwind/src/DwarfInstructions.hpp
libunwind/src/UnwindCursor.hpp
libunwind/src/UnwindLevel1-gcc-ext.c

Removed: 




diff  --git a/libunwind/src/DwarfInstructions.hpp 
b/libunwind/src/DwarfInstructions.hpp
index 29a070fa3e04..48ef1866d6e1 100644
--- a/libunwind/src/DwarfInstructions.hpp
+++ b/libunwind/src/DwarfInstructions.hpp
@@ -34,7 +34,7 @@ class DwarfInstructions {
   typedef typename A::sint_t sint_t;
 
   static int stepWithDwarf(A , pint_t pc, pint_t fdeStart,
-   R );
+   R , bool );
 
 private:
 
@@ -150,7 +150,8 @@ v128 DwarfInstructions::getSavedVectorRegister(
 
 template 
 int DwarfInstructions::stepWithDwarf(A , pint_t pc,
-   pint_t fdeStart, R ) {
+   pint_t fdeStart, R ,
+   bool ) {
   FDE_Info fdeInfo;
   CIE_Info cieInfo;
   if (CFI_Parser::decodeFDE(addressSpace, fdeStart, ,
@@ -196,6 +197,8 @@ int DwarfInstructions::stepWithDwarf(A , 
pint_t pc,
   // restoring SP means setting it to CFA.
   newRegisters.setSP(cfa);
 
+  isSignalFrame = cieInfo.isSignalFrame;
+
 #if defined(_LIBUNWIND_TARGET_AARCH64)
   // If the target is aarch64 then the return address may have been signed
   // using the v8.3 pointer authentication extensions. The original

diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index b4d44e111a65..4c18614b33d2 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -929,7 +929,7 @@ class UnwindCursor : public AbstractUnwindCursor{
 return DwarfInstructions::stepWithDwarf(_addressSpace,
   (pint_t)this->getReg(UNW_REG_IP),
   (pint_t)_info.unwind_info,
-  _registers);
+  _registers, _isSignalFrame);
   }
 #endif
 

diff  --git a/libunwind/src/UnwindLevel1-gcc-ext.c 
b/libunwind/src/UnwindLevel1-gcc-ext.c
index 63e4083a4579..008df815665e 100644
--- a/libunwind/src/UnwindLevel1-gcc-ext.c
+++ b/libunwind/src/UnwindLevel1-gcc-ext.c
@@ -221,7 +221,14 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct 
_Unwind_Context *context) {
 _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
   int *ipBefore) {
   _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p)", (void *)context);
-  *ipBefore = 0;
+  int isSignalFrame = __unw_is_signal_frame((unw_cursor_t *)context);
+  // Negative means some kind of error (probably UNW_ENOINFO), but we have no
+  // good way to report that, and this maintains backward compatibility with 
the
+  // implementation that hard-coded zero in every case, even signal frames.
+  if (isSignalFrame <= 0)
+*ipBefore = 0;
+  else
+*ipBefore = 1;
   return _Unwind_GetIP(context);
 }
 

diff  --git a/libunwind/test/signal_frame.pass.cpp 
b/libunwind/test/signal_frame.pass.cpp
new file mode 100644
index ..b14e95a51528
--- /dev/null
+++ b/libunwind/test/signal_frame.pass.cpp

[PATCH] D69925: remove redundant LLVM version from version string when setting CLANG_VENDOR

2019-11-07 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Thanks for the review, leaving open for final comments, will merge tomorrow.

FWIW, I think we can now purge "svn" from `BACKEND_PACKAGE_STRING` and other 
places in the tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69925



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


[PATCH] D69969: [SEH] Defer checking filter expression types until instantiaton

2019-11-07 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69969



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


[PATCH] D69925: remove redundant LLVM version from version string when setting CLANG_VENDOR

2019-11-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

If we expect that CLANG_VERSION_STRING and BACKEND_PACKAGE_STRING are going to 
be the same, then the extra note isn't really buying us anything.  LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69925



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


[PATCH] D69970: [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood (reland with fixes)

2019-11-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
vsk added reviewers: aprantl, djtodoro, dblaikie.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently, clang emits subprograms for declared functions when the
target debugger or DWARF standard is known to support entry values
(DW_OP_entry_value & the GNU equivalent).

Treat DW_AT_tail_call the same way to allow debuggers to follow cross-TU
tail calls.

Pre-patch debug session with a cross-TU tail call:

  * frame #0: 0x00010fa4 main`target at b.c:4:3 [opt]
frame #1: 0x00010f99 main`main at a.c:8:10 [opt]

Post-patch (note that the tail-calling frame, "helper", is visible):

  * frame #0: 0x00010fa4 main`target at b.c:4:3 [opt]
frame #1: 0x00010f80 main`helper [opt] [artificial]
frame #2: 0x00010f99 main`main at a.c:8:10 [opt]

This was reverted in 5b9a072c 
 because 
it attached declaration
subprograms to inlinable builtin calls, which interacted badly with the
MergeICmps pass. The fix is to not attach declarations to builtins.

rdar://46577651

Previous review: https://reviews.llvm.org/D69743


https://reviews.llvm.org/D69970

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
  llvm/test/DebugInfo/X86/dwarf-callsite-related-attrs.ll

Index: llvm/test/DebugInfo/X86/dwarf-callsite-related-attrs.ll
===
--- llvm/test/DebugInfo/X86/dwarf-callsite-related-attrs.ll
+++ llvm/test/DebugInfo/X86/dwarf-callsite-related-attrs.ll
@@ -25,6 +25,14 @@
 
 @sink = global i32 0, align 4, !dbg !0
 
+define void @__has_no_subprogram() {
+entry:
+  %0 = load volatile i32, i32* @sink, align 4
+  %inc = add nsw i32 %0, 1
+  store volatile i32 %inc, i32* @sink, align 4
+  ret void
+}
+
 ; ASM: DW_TAG_subprogram
 ; ASM:   DW_AT_call_all_calls
 ; OBJ: [[bat_sp:.*]]: DW_TAG_subprogram
@@ -70,6 +78,7 @@
 ; OBJ: DW_AT_call_tail_call
 define void @_Z3foov() !dbg !25 {
 entry:
+  tail call void @__has_no_subprogram()
   tail call void @_Z3barv(), !dbg !26
   tail call void @_Z3batv(), !dbg !27
   tail call void @_Z3barv(), !dbg !26
Index: clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -56,6 +56,7 @@
 
 // NO-ATTR-NOT: FlagAllCallsDescribed
 
+// HAS-ATTR-DAG: DISubprogram(name: "declaration1", {{.*}}, flags: DIFlagPrototyped
 // HAS-ATTR-DAG: DISubprogram(name: "declaration2", {{.*}}, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition
 // HAS-ATTR-DAG: DISubprogram(name: "struct1", {{.*}}, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
 // HAS-ATTR-DAG: DISubprogram(name: "struct1", {{.*}}, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition
Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -1,15 +1,32 @@
-// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-EXT
-// CHECK-EXT: !DISubprogram(name: "fn1"
+// When entry values are emitted, expect a subprogram for extern decls so that
+// the dwarf generator can describe call site parameters at extern call sites.
+//
+// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \
+// RUN:   | FileCheck %s -check-prefix=ENTRY-VAL -implicit-check-not='DISubprogram(name: "memcmp"'
+// ENTRY-VAL: !DISubprogram(name: "fn1"
 
-// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
-// CHECK-NOT: !DISubprogram(name: "fn1"
+// Similarly, when the debugger tuning is gdb, expect a subprogram for extern
+// decls so that the dwarf generator can describe information needed for tail
+// call frame reconstrution.
+//
+// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -ggdb -S -emit-llvm %s -o - \
+// RUN:   | FileCheck %s -check-prefix=GDB -implicit-check-not='DISubprogram(name: "memcmp"'
+// GDB: !DISubprogram(name: "fn1"
+//
+// Do not emit a subprogram for extern decls when entry values are disabled and
+// the tuning is not set to gdb.
+//
+// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o - \
+// RUN:   | FileCheck %s -check-prefix=SCE -implicit-check-not='DISubprogram(name: "memcmp"'
+// SCE-NOT: !DISubprogram(name: "fn1"
 
 extern int fn1(int a, int b);
+extern int memcmp(const void *s1, const void *s2, unsigned long n);
 
-int fn2 () {
+int fn2 (int *src, int *dst) {
   int x = 4, y = 5;
   int res = fn1(x, y);
-
-  return res;
+  int res2 = 

[PATCH] D69935: [DeclCXX] Remove unknown external linkage specifications

2019-11-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D69935#1737615 , @ekatz wrote:

> With this change (current trunk) you can write code as follows:
>
>   extern "C++11" int x;
>
>
> And it will pass compilation. No other compiler support it, nor it should, as 
> there is no such thing as `extern "C++11"` nor `extern "C++14"`.


Ah, thanks - fair enough. This should probably include a test case to 
demonstrate that? (though I suppose it's sort of hard to imagine why such a 
test case would be useful but for this particular bug & adding a test case 
would only cover one possible spelling here)

Are all the changes proposed here necessary to fix that bug?

But yeah, in general, it looks like these constants really aren't suitable for 
C++11/14 data at all. They're about C V C++ linkage/mangling/etc & just 
happened to use the DWARF constants for some reason (mentioned in the comment 
above, though I don't find it super compelling).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69935



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


[PATCH] D69969: [SEH] Defer checking filter expression types until instantiaton

2019-11-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: amccarth.
Herald added a project: clang.

While here, wordsmith the error a bit. Now clang says:

  error: filter expression has non-integral type 'Foo'

Fixes PR43779


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69969

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Sema/__try.c
  clang/test/SemaCXX/exceptions-seh.cpp


Index: clang/test/SemaCXX/exceptions-seh.cpp
===
--- clang/test/SemaCXX/exceptions-seh.cpp
+++ clang/test/SemaCXX/exceptions-seh.cpp
@@ -113,3 +113,17 @@
   } catch(int) {
   }
 };
+
+template  void dependent_filter() {
+  __try {
+might_crash();
+  } __except (T()) { // expected-error {{filter expression has non-integral 
type 'NotInteger'}}
+  }
+}
+
+struct NotInteger { int x; };
+
+void instantiate_dependent_filter() {
+  dependent_filter();
+  dependent_filter(); // expected-note {{requested here}}
+}
Index: clang/test/Sema/__try.c
===
--- clang/test/Sema/__try.c
+++ clang/test/Sema/__try.c
@@ -111,7 +111,7 @@
   __try {
 
   }
-  __except ( NotFilterExpression() ) { // expected-error{{filter expression 
type should be an integral value not 'const char *'}}
+  __except ( NotFilterExpression() ) { // expected-error{{filter expression 
has non-integral type 'const char *'}}
 
   }
 }
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -4184,19 +4184,16 @@
   return SEHTryStmt::Create(Context, IsCXXTry, TryLoc, TryBlock, Handler);
 }
 
-StmtResult
-Sema::ActOnSEHExceptBlock(SourceLocation Loc,
-  Expr *FilterExpr,
-  Stmt *Block) {
+StmtResult Sema::ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr,
+ Stmt *Block) {
   assert(FilterExpr && Block);
-
-  if(!FilterExpr->getType()->isIntegerType()) {
-return StmtError(Diag(FilterExpr->getExprLoc(),
- diag::err_filter_expression_integral)
- << FilterExpr->getType());
+  QualType FTy = FilterExpr->getType();
+  if (!FTy->isIntegerType() && !FTy->isDependentType()) {
+return StmtError(
+Diag(FilterExpr->getExprLoc(), diag::err_filter_expression_integral)
+<< FTy);
   }
-
-  return SEHExceptStmt::Create(Context,Loc,FilterExpr,Block);
+  return SEHExceptStmt::Create(Context, Loc, FilterExpr, Block);
 }
 
 void Sema::ActOnStartSEHFinallyBlock() {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8935,7 +8935,7 @@
   "function %0 with unknown type must be given a function type">;
 
 def err_filter_expression_integral : Error<
-  "filter expression type should be an integral value not %0">;
+  "filter expression has non-integral type %0">;
 
 def err_non_asm_stmt_in_naked_function : Error<
   "non-ASM statement in naked function is not supported">;


Index: clang/test/SemaCXX/exceptions-seh.cpp
===
--- clang/test/SemaCXX/exceptions-seh.cpp
+++ clang/test/SemaCXX/exceptions-seh.cpp
@@ -113,3 +113,17 @@
   } catch(int) {
   }
 };
+
+template  void dependent_filter() {
+  __try {
+might_crash();
+  } __except (T()) { // expected-error {{filter expression has non-integral type 'NotInteger'}}
+  }
+}
+
+struct NotInteger { int x; };
+
+void instantiate_dependent_filter() {
+  dependent_filter();
+  dependent_filter(); // expected-note {{requested here}}
+}
Index: clang/test/Sema/__try.c
===
--- clang/test/Sema/__try.c
+++ clang/test/Sema/__try.c
@@ -111,7 +111,7 @@
   __try {
 
   }
-  __except ( NotFilterExpression() ) { // expected-error{{filter expression type should be an integral value not 'const char *'}}
+  __except ( NotFilterExpression() ) { // expected-error{{filter expression has non-integral type 'const char *'}}
 
   }
 }
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -4184,19 +4184,16 @@
   return SEHTryStmt::Create(Context, IsCXXTry, TryLoc, TryBlock, Handler);
 }
 
-StmtResult
-Sema::ActOnSEHExceptBlock(SourceLocation Loc,
-  Expr *FilterExpr,
-  Stmt *Block) {
+StmtResult Sema::ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr,
+ Stmt *Block) {
   assert(FilterExpr && Block);
-
-  if(!FilterExpr->getType()->isIntegerType()) {
-return StmtError(Diag(FilterExpr->getExprLoc(),
-   

[PATCH] D69952: [OPENMP50]Generalize handling of context matching/scoring.

2019-11-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked 3 inline comments as done.
ABataev added inline comments.



Comment at: clang/include/clang/Basic/OpenMPKinds.h:43
+/// Struct to store the context selectors info.
+template >
+struct OpenMPCtxSelectorData {

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > jdoerfert wrote:
> > > > > I feel uneasy about using an ArrayRef for storage as it can easily 
> > > > > lead to UB when the underlying values go out of scope.
> > > > This structure is used in 2 ways: 1. Store the data befoere creating 
> > > > the attribute (which will store all the data). 2. Generalize data later 
> > > > atthe codegen phase without allocating new memory (the data is alredy 
> > > > stored in the attribute and don't need to allocate it several times).
> > > That might all be true but it does not address my comments. I argue that 
> > > this is easy to be misused not that it will not work right now. For me 
> > > this is a potentially misused performance improvement, a combination we 
> > > should not introduce.
> > > 
> > > You could, for example, remove the ArrayRef default parameter and make it 
> > > explicit at the instantiation sites. Though, I'd actually prefer owning 
> > > the data here, e.g., in a SmallVector.
> > I can remove the default parameter, sure. But hen the attribute created 
> > already, we don't need to create a new container, we can use ArrayRefs 
> > which may point to the memory allocated for the attribute without danger of 
> > undefied behavior.
> My point is that there is always "danger of UB" if you point to memory 
> allocated somewhere else. At the end of the day, this is just a container but 
> one that may or may not own the underlying memory. If it does, people can use 
> it as they use any other container. If it does not, people may still sue it 
> as they use any other container but changes to the lifetime of the underlying 
> memory will potentially cause UB down the line.
> 
> There is little incentive to open up potential error sources only to optimize 
> for performance of something that is very likely not even visible in a 
> profile. I mean, we will not see the impact of am additional memcpy of 
> `sizeof(unsigned) * #ContextSelectors` bytes, or anything similar.
It is not about the performance rather than to reduce mem usage. We may have a 
lot of context selectors, very complex, associated woth the same function. And 
I don't think it is a bad idea to reuse the previously allocated memory rather 
than allocate a new one and increase the memory pressure for the compiler



Comment at: clang/include/clang/Basic/OpenMPKinds.h:56
+ OpenMPContextSelectorKind Ctx, const U )
+  : CtxSet(CtxSet), Ctx(Ctx), Names(Names.begin(), Names.end()) {}
+};

jdoerfert wrote:
> ABataev wrote:
> > ABataev wrote:
> > > jdoerfert wrote:
> > > > ABataev wrote:
> > > > > jdoerfert wrote:
> > > > > > Why do you need a second template version here?
> > > > > To construct the object when the container Names cannot be created 
> > > > > dieectly using the first constructor (SmallVector and UniqueVector 
> > > > > are not quite compatible in this sence, for example)
> > > > That can be addressed by changing the first constructor. Why is it an 
> > > > xvalue there and why is the container not const?
> > > In short, to avoid some extra memory allocation/deallocation. I can make 
> > > the container const, ok.
> > Tried to make it `const`, it breaks a lot of code and almost impossible to 
> > fix
> ```
>   explicit OpenMPCtxSelectorData(OpenMPContextSelectorSetKind CtxSet,
>  OpenMPContextSelectorKind Ctx,
>  const VectorType )
>   : CtxSet(CtxSet), Ctx(Ctx), Names(Names) {}
> ```
> 
> Is what I meant. It should also remove the need for the second constructor.
We may have a different comtainer type there, like `UniqurVector`, or 
itertor_range, for example, or something else, not completely compatible with 
the `VectorType` itself.



Comment at: clang/include/clang/Basic/OpenMPKinds.h:57
+  : CtxSet(CtxSet), Ctx(Ctx), Names(Names.begin(), Names.end()) {}
+};
+

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > jdoerfert wrote:
> > > > > It seems we always associate a scope with this class (even if the 
> > > > > type of the scope varies), right? If so we can add it into this class 
> > > > > to simplify the interfaces and tie them together in a nicer way.
> > > > What scope are you ralking about?
> > > "scope" was me thinking about the above issues while I was writing this 
> > > comment about the "score":
> > > 
> > > It seems we always associate a score with this class (even if the type of 
> > > the score varies), right? If so we can add it into this class to simplify 
> > > the interfaces and tie them together in a nicer way.
> > Ah, 

[PATCH] D69290: [clang] Report sanitizer blacklist as a dependency in cc1 instead of driver

2019-11-07 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG03b84e4f6d0e: [clang] Report sanitizer blacklist as a 
dependency in cc1 (authored by jkorous).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69290

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fsanitize-blacklist.c
  clang/test/Frontend/dependency-gen.c

Index: clang/test/Frontend/dependency-gen.c
===
--- clang/test/Frontend/dependency-gen.c
+++ clang/test/Frontend/dependency-gen.c
@@ -27,3 +27,20 @@
 #ifndef INCLUDE_FLAG_TEST
 #include 
 #endif
+
+// RUN: echo "fun:foo" > %t.blacklist1
+// RUN: echo "fun:foo" > %t.blacklist2
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist1 -fsanitize-blacklist=%t.blacklist2 -I ./ | FileCheck -check-prefix=TWO-BLACK-LISTS %s
+// TWO-BLACK-LISTS: dependency-gen.o:
+// TWO-BLACK-LISTS-DAG: blacklist1
+// TWO-BLACK-LISTS-DAG: blacklist2
+// TWO-BLACK-LISTS-DAG: x.h
+// TWO-BLACK-LISTS-DAG: dependency-gen.c
+
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -I ./ | FileCheck -check-prefix=USER-AND-SYS-DEPS %s
+// USER-AND-SYS-DEPS: dependency-gen.o:
+// USER-AND-SYS-DEPS-DAG: cfi_blacklist.txt
+
+// RUN: %clang -MMD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -I ./ | FileCheck -check-prefix=ONLY-USER-DEPS %s
+// ONLY-USER-DEPS: dependency-gen.o:
+// NOT-ONLY-USER-DEPS: cfi_blacklist.txt
\ No newline at end of file
Index: clang/test/Driver/fsanitize-blacklist.c
===
--- clang/test/Driver/fsanitize-blacklist.c
+++ clang/test/Driver/fsanitize-blacklist.c
@@ -16,22 +16,18 @@
 // RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress -fsanitize-blacklist=%t.good -fsanitize-blacklist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST
 // CHECK-BLACKLIST: -fsanitize-blacklist={{.*}}.good" "-fsanitize-blacklist={{.*}}.second
 
-// Now, check for -fdepfile-entry flags.
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-blacklist=%t.good -fsanitize-blacklist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST2
-// CHECK-BLACKLIST2: -fdepfile-entry={{.*}}.good" "-fdepfile-entry={{.*}}.second
-
 // Check that the default blacklist is not added as an extra dependency.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST-ASAN --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
-// CHECK-DEFAULT-BLACKLIST-ASAN: -fsanitize-blacklist={{.*[^w]}}asan_blacklist.txt
+// CHECK-DEFAULT-BLACKLIST-ASAN: -fsanitize-system-blacklist={{.*[^w]}}asan_blacklist.txt
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST-HWASAN --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
-// CHECK-DEFAULT-BLACKLIST-HWASAN: -fsanitize-blacklist={{.*}}hwasan_blacklist.txt
+// CHECK-DEFAULT-BLACKLIST-HWASAN: -fsanitize-system-blacklist={{.*}}hwasan_blacklist.txt
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=nullability -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=alignment -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist=
 // RUN: %clang -target %itanium_abi_triple -fsanitize=float-divide-by-zero -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry 

[PATCH] D68720: Support -fstack-clash-protection for x86

2019-11-07 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

In D68720#1733839 , @serge-sans-paille 
wrote:

> @sylvestre.ledru did the testing and benchmarking on firefox (see 
> https://bugzilla.mozilla.org/show_bug.cgi?id=1588710#c12), everything seems 
> ok, let's move forward?


Actually, not sure about the benchmark anymore. I am checking with experts. 
Sorry


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D69950: Reapply "Fix crash on switch conditions of non-integer types in templates"

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

I don't have experience with clang-tidy tests, but I think these two small, 
test-only changes are small enough that you can go ahead and commit them 
without review from a clang-tidy owner. lgtm


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

https://reviews.llvm.org/D69950



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


[clang] 03b84e4 - [clang] Report sanitizer blacklist as a dependency in cc1

2019-11-07 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2019-11-07T14:06:43-08:00
New Revision: 03b84e4f6d0e1c04f22d69cc445f36e1f713beb4

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

LOG: [clang] Report sanitizer blacklist as a dependency in cc1

Previously these were reported from the driver which blocked clang-scan-deps 
from getting the full set of dependencies from cc1 commands.

Also the default sanitizer blacklist that is added in driver was never reported 
as a dependency. I introduced -fsanitize-system-blacklist cc1 option to keep 
track of which blacklists were user-specified and which were added by driver 
and clang -MD now also reports system blacklists as dependencies.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/fsanitize-blacklist.c
clang/test/Frontend/dependency-gen.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index dcd2976a97f2..c2e30a16b8da 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -979,6 +979,9 @@ def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, 
Group,
 def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
   Group,
   HelpText<"Path to blacklist file for sanitizers">;
+def fsanitize_system_blacklist : Joined<["-"], "fsanitize-system-blacklist=">,
+  HelpText<"Path to system blacklist file for sanitizers">,
+  Flags<[CC1Option]>;
 def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
  Group,
  HelpText<"Don't use blacklist file for 
sanitizers">;

diff  --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index c37499e0f201..0aebf8cb225d 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -25,8 +25,8 @@ class SanitizerArgs {
   SanitizerSet RecoverableSanitizers;
   SanitizerSet TrapSanitizers;
 
-  std::vector BlacklistFiles;
-  std::vector ExtraDeps;
+  std::vector UserBlacklistFiles;
+  std::vector SystemBlacklistFiles;
   int CoverageFeatures = 0;
   int MsanTrackOrigins = 0;
   bool MsanUseAfterDtor = true;

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index cc6c5e6ef438..8937197c253c 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -557,29 +557,35 @@ SanitizerArgs::SanitizerArgs(const ToolChain ,
 
   // Setup blacklist files.
   // Add default blacklist from resource directory.
-  addDefaultBlacklists(D, Kinds, BlacklistFiles);
+  addDefaultBlacklists(D, Kinds, SystemBlacklistFiles);
   // Parse -f(no-)sanitize-blacklist options.
   for (const auto *Arg : Args) {
 if (Arg->getOption().matches(options::OPT_fsanitize_blacklist)) {
   Arg->claim();
   std::string BLPath = Arg->getValue();
   if (llvm::sys::fs::exists(BLPath)) {
-BlacklistFiles.push_back(BLPath);
-ExtraDeps.push_back(BLPath);
+UserBlacklistFiles.push_back(BLPath);
   } else {
 D.Diag(clang::diag::err_drv_no_such_file) << BLPath;
   }
 } else if (Arg->getOption().matches(options::OPT_fno_sanitize_blacklist)) {
   Arg->claim();
-  BlacklistFiles.clear();
-  ExtraDeps.clear();
+  UserBlacklistFiles.clear();
+  SystemBlacklistFiles.clear();
 }
   }
   // Validate blacklists format.
   {
 std::string BLError;
 std::unique_ptr SCL(
-llvm::SpecialCaseList::create(BlacklistFiles, BLError));
+llvm::SpecialCaseList::create(UserBlacklistFiles, BLError));
+if (!SCL.get())
+  D.Diag(clang::diag::err_drv_malformed_sanitizer_blacklist) << BLError;
+  }
+  {
+std::string BLError;
+std::unique_ptr SCL(
+llvm::SpecialCaseList::create(SystemBlacklistFiles, BLError));
 if (!SCL.get())
   D.Diag(clang::diag::err_drv_malformed_sanitizer_blacklist) << BLError;
   }
@@ -952,15 +958,15 @@ void SanitizerArgs::addArgs(const ToolChain , const 
llvm::opt::ArgList ,
 CmdArgs.push_back(
 Args.MakeArgString("-fsanitize-trap=" + toString(TrapSanitizers)));
 
-  for (const auto  : BlacklistFiles) {
+  for (const auto  : UserBlacklistFiles) {
 SmallString<64> BlacklistOpt("-fsanitize-blacklist=");
 BlacklistOpt += BLPath;
 CmdArgs.push_back(Args.MakeArgString(BlacklistOpt));
   }
-  for (const auto  : ExtraDeps) {
-SmallString<64> ExtraDepOpt("-fdepfile-entry=");
-ExtraDepOpt += Dep;
-

[PATCH] D69952: [OPENMP50]Generalize handling of context matching/scoring.

2019-11-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Basic/OpenMPKinds.h:43
+/// Struct to store the context selectors info.
+template >
+struct OpenMPCtxSelectorData {

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > jdoerfert wrote:
> > > > I feel uneasy about using an ArrayRef for storage as it can easily lead 
> > > > to UB when the underlying values go out of scope.
> > > This structure is used in 2 ways: 1. Store the data befoere creating the 
> > > attribute (which will store all the data). 2. Generalize data later atthe 
> > > codegen phase without allocating new memory (the data is alredy stored in 
> > > the attribute and don't need to allocate it several times).
> > That might all be true but it does not address my comments. I argue that 
> > this is easy to be misused not that it will not work right now. For me this 
> > is a potentially misused performance improvement, a combination we should 
> > not introduce.
> > 
> > You could, for example, remove the ArrayRef default parameter and make it 
> > explicit at the instantiation sites. Though, I'd actually prefer owning the 
> > data here, e.g., in a SmallVector.
> I can remove the default parameter, sure. But hen the attribute created 
> already, we don't need to create a new container, we can use ArrayRefs which 
> may point to the memory allocated for the attribute without danger of 
> undefied behavior.
My point is that there is always "danger of UB" if you point to memory 
allocated somewhere else. At the end of the day, this is just a container but 
one that may or may not own the underlying memory. If it does, people can use 
it as they use any other container. If it does not, people may still sue it as 
they use any other container but changes to the lifetime of the underlying 
memory will potentially cause UB down the line.

There is little incentive to open up potential error sources only to optimize 
for performance of something that is very likely not even visible in a profile. 
I mean, we will not see the impact of am additional memcpy of `sizeof(unsigned) 
* #ContextSelectors` bytes, or anything similar.



Comment at: clang/include/clang/Basic/OpenMPKinds.h:56
+ OpenMPContextSelectorKind Ctx, const U )
+  : CtxSet(CtxSet), Ctx(Ctx), Names(Names.begin(), Names.end()) {}
+};

ABataev wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > jdoerfert wrote:
> > > > > Why do you need a second template version here?
> > > > To construct the object when the container Names cannot be created 
> > > > dieectly using the first constructor (SmallVector and UniqueVector are 
> > > > not quite compatible in this sence, for example)
> > > That can be addressed by changing the first constructor. Why is it an 
> > > xvalue there and why is the container not const?
> > In short, to avoid some extra memory allocation/deallocation. I can make 
> > the container const, ok.
> Tried to make it `const`, it breaks a lot of code and almost impossible to fix
```
  explicit OpenMPCtxSelectorData(OpenMPContextSelectorSetKind CtxSet,
 OpenMPContextSelectorKind Ctx,
 const VectorType )
  : CtxSet(CtxSet), Ctx(Ctx), Names(Names) {}
```

Is what I meant. It should also remove the need for the second constructor.



Comment at: clang/include/clang/Basic/OpenMPKinds.h:57
+  : CtxSet(CtxSet), Ctx(Ctx), Names(Names.begin(), Names.end()) {}
+};
+

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > jdoerfert wrote:
> > > > It seems we always associate a scope with this class (even if the type 
> > > > of the scope varies), right? If so we can add it into this class to 
> > > > simplify the interfaces and tie them together in a nicer way.
> > > What scope are you ralking about?
> > "scope" was me thinking about the above issues while I was writing this 
> > comment about the "score":
> > 
> > It seems we always associate a score with this class (even if the type of 
> > the score varies), right? If so we can add it into this class to simplify 
> > the interfaces and tie them together in a nicer way.
> Ah, I see. We store scores in the different representations in different 
> places. In parsing/sema the score is represented as ExprResult, while in 
> codegen it is represented as llvm::APSInt. It means that we need to introduce 
> another one template parameter for the score. Are you ok with the third 
> template param for the type of the score?
Yes, please. That ties the score directly to the name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69952



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


[PATCH] D69664: [Diagnostics] Teach -Wnull-dereference about address_space attribute

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01b10bc7b149: [Diagnostics] Teach -Wnull-dereference about 
address_space attribute (authored by xbolva00).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69664

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/exprs.c


Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,17 +179,27 @@
   test18_e(); // expected-error {{too few arguments to function call, expected 
at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
-  *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null 
pointer}} \
+  *(int *)0 = 0; // expected-warning 
{{indirection of non-volatile null pointer}} \
   // expected-note {{consider using __builtin_trap}}
-  *(volatile int*)0 = 0;  // Ok.
+  *(volatile int *)0 = 0;// Ok.
+  *(int __attribute__((address_space(256))) *)0 = 0; // Ok.
+  *(int __attribute__((address_space(0))) *)0 = 0;   // expected-warning 
{{indirection of non-volatile null pointer}} \
+ // expected-note {{consider using __builtin_trap}}
+  *(int_AS256 *)0 = 0;   // Ok.
 
   // rdar://9269271
-  int x = *(int*)0;  // expected-warning {{indirection of non-volatile null 
pointer}} \
+  int x = *(int *)0;   
   // expected-warning {{indirection of non-volatile null pointer}} 
\
+ // expected-note {{consider using __builtin_trap}}
+  int x2 = *(volatile int *)0; 
   // Ok.
+  int x3 = *(int __attribute__((address_space(0))) *)0;
   // expected-warning {{indirection of non-volatile null pointer}} 
\
  // expected-note {{consider using __builtin_trap}}
-  int x2 = *(volatile int*)0; // Ok.
-  int *p = &(*(int*)0); // Ok;
+  int x4 = *(int_AS256 *)0;
   // Ok.
+  int *p = &(*(int *)0);   
   // Ok.
+  int_AS256 *p1 = &(*(int __attribute__((address_space(256))) *)0);
   // Ok.
+  int __attribute__((address_space(0))) *p2 = &(*(int 
__attribute__((address_space(0))) *)0); // Ok.
 }
 
 int test20(int x) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -481,16 +481,21 @@
   // optimizer will delete, so warn about it.  People sometimes try to use this
   // to get a deterministic trap and are surprised by clang's behavior.  This
   // only handles the pattern "*null", which is a very syntactic check.
-  if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))
-if (UO->getOpcode() == UO_Deref &&
-UO->getSubExpr()->IgnoreParenCasts()->
-  isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull) 
&&
+  const auto *UO = dyn_cast(E->IgnoreParenCasts());
+  if (UO && UO->getOpcode() == UO_Deref) {
+const LangAS AS =
+UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
+if ((!isTargetAddressSpace(AS) ||
+ (isTargetAddressSpace(AS) && toTargetAddressSpace(AS) == 0)) &&
+UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
+S.Context, Expr::NPC_ValueDependentIsNotNull) &&
 !UO->getType().isVolatileQualified()) {
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-  S.PDiag(diag::warn_indirection_through_null)
-<< UO->getSubExpr()->getSourceRange());
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-S.PDiag(diag::note_indirection_through_null));
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::warn_indirection_through_null)
+<< UO->getSubExpr()->getSourceRange());
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::note_indirection_through_null));
+}
   }
 }
 


Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,17 +179,27 @@
   test18_e(); // expected-error {{too few arguments to function call, expected at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
-  *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null pointer}} \
+  *(int *)0 = 0; // 

[PATCH] D69664: [Diagnostics] Teach -Wnull-dereference about address_space attribute

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 228301.
xbolva00 added a comment.

Removed unused variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69664

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/exprs.c


Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,17 +179,27 @@
   test18_e(); // expected-error {{too few arguments to function call, expected 
at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
-  *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null 
pointer}} \
+  *(int *)0 = 0; // expected-warning 
{{indirection of non-volatile null pointer}} \
   // expected-note {{consider using __builtin_trap}}
-  *(volatile int*)0 = 0;  // Ok.
+  *(volatile int *)0 = 0;// Ok.
+  *(int __attribute__((address_space(256))) *)0 = 0; // Ok.
+  *(int __attribute__((address_space(0))) *)0 = 0;   // expected-warning 
{{indirection of non-volatile null pointer}} \
+ // expected-note {{consider using __builtin_trap}}
+  *(int_AS256 *)0 = 0;   // Ok.
 
   // rdar://9269271
-  int x = *(int*)0;  // expected-warning {{indirection of non-volatile null 
pointer}} \
+  int x = *(int *)0;   
   // expected-warning {{indirection of non-volatile null pointer}} 
\
+ // expected-note {{consider using __builtin_trap}}
+  int x2 = *(volatile int *)0; 
   // Ok.
+  int x3 = *(int __attribute__((address_space(0))) *)0;
   // expected-warning {{indirection of non-volatile null pointer}} 
\
  // expected-note {{consider using __builtin_trap}}
-  int x2 = *(volatile int*)0; // Ok.
-  int *p = &(*(int*)0); // Ok;
+  int x4 = *(int_AS256 *)0;
   // Ok;
+  int *p = &(*(int *)0);   
   // Ok;
+  int_AS256 *p1 = &(*(int __attribute__((address_space(256))) *)0);
   // Ok;
+  int __attribute__((address_space(0))) *p2 = &(*(int 
__attribute__((address_space(0))) *)0); // Ok;
 }
 
 int test20(int x) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -481,16 +481,21 @@
   // optimizer will delete, so warn about it.  People sometimes try to use this
   // to get a deterministic trap and are surprised by clang's behavior.  This
   // only handles the pattern "*null", which is a very syntactic check.
-  if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))
-if (UO->getOpcode() == UO_Deref &&
-UO->getSubExpr()->IgnoreParenCasts()->
-  isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull) 
&&
+  const auto *UO = dyn_cast(E->IgnoreParenCasts());
+  if (UO && UO->getOpcode() == UO_Deref) {
+const LangAS AS =
+UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
+if ((!isTargetAddressSpace(AS) ||
+ (isTargetAddressSpace(AS) && toTargetAddressSpace(AS) == 0)) &&
+UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
+S.Context, Expr::NPC_ValueDependentIsNotNull) &&
 !UO->getType().isVolatileQualified()) {
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-  S.PDiag(diag::warn_indirection_through_null)
-<< UO->getSubExpr()->getSourceRange());
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-S.PDiag(diag::note_indirection_through_null));
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::warn_indirection_through_null)
+<< UO->getSubExpr()->getSourceRange());
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::note_indirection_through_null));
+}
   }
 }
 


Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,17 +179,27 @@
   test18_e(); // expected-error {{too few arguments to function call, expected at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
-  *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null pointer}} \
+  *(int *)0 = 0; // expected-warning {{indirection of non-volatile null pointer}} \
   // expected-note 

[PATCH] D69664: [Diagnostics] Teach -Wnull-dereference about address_space attribute

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 228303.
xbolva00 added a comment.

Fixed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69664

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/exprs.c


Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,17 +179,27 @@
   test18_e(); // expected-error {{too few arguments to function call, expected 
at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
-  *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null 
pointer}} \
+  *(int *)0 = 0; // expected-warning 
{{indirection of non-volatile null pointer}} \
   // expected-note {{consider using __builtin_trap}}
-  *(volatile int*)0 = 0;  // Ok.
+  *(volatile int *)0 = 0;// Ok.
+  *(int __attribute__((address_space(256))) *)0 = 0; // Ok.
+  *(int __attribute__((address_space(0))) *)0 = 0;   // expected-warning 
{{indirection of non-volatile null pointer}} \
+ // expected-note {{consider using __builtin_trap}}
+  *(int_AS256 *)0 = 0;   // Ok.
 
   // rdar://9269271
-  int x = *(int*)0;  // expected-warning {{indirection of non-volatile null 
pointer}} \
+  int x = *(int *)0;   
   // expected-warning {{indirection of non-volatile null pointer}} 
\
+ // expected-note {{consider using __builtin_trap}}
+  int x2 = *(volatile int *)0; 
   // Ok.
+  int x3 = *(int __attribute__((address_space(0))) *)0;
   // expected-warning {{indirection of non-volatile null pointer}} 
\
  // expected-note {{consider using __builtin_trap}}
-  int x2 = *(volatile int*)0; // Ok.
-  int *p = &(*(int*)0); // Ok;
+  int x4 = *(int_AS256 *)0;
   // Ok.
+  int *p = &(*(int *)0);   
   // Ok.
+  int_AS256 *p1 = &(*(int __attribute__((address_space(256))) *)0);
   // Ok.
+  int __attribute__((address_space(0))) *p2 = &(*(int 
__attribute__((address_space(0))) *)0); // Ok.
 }
 
 int test20(int x) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -481,16 +481,21 @@
   // optimizer will delete, so warn about it.  People sometimes try to use this
   // to get a deterministic trap and are surprised by clang's behavior.  This
   // only handles the pattern "*null", which is a very syntactic check.
-  if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))
-if (UO->getOpcode() == UO_Deref &&
-UO->getSubExpr()->IgnoreParenCasts()->
-  isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull) 
&&
+  const auto *UO = dyn_cast(E->IgnoreParenCasts());
+  if (UO && UO->getOpcode() == UO_Deref) {
+const LangAS AS =
+UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
+if ((!isTargetAddressSpace(AS) ||
+ (isTargetAddressSpace(AS) && toTargetAddressSpace(AS) == 0)) &&
+UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
+S.Context, Expr::NPC_ValueDependentIsNotNull) &&
 !UO->getType().isVolatileQualified()) {
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-  S.PDiag(diag::warn_indirection_through_null)
-<< UO->getSubExpr()->getSourceRange());
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-S.PDiag(diag::note_indirection_through_null));
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::warn_indirection_through_null)
+<< UO->getSubExpr()->getSourceRange());
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::note_indirection_through_null));
+}
   }
 }
 


Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,17 +179,27 @@
   test18_e(); // expected-error {{too few arguments to function call, expected at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
-  *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null pointer}} \
+  *(int *)0 = 0; // expected-warning {{indirection of non-volatile null pointer}} \
   // expected-note {{consider using 

[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

I am not sure if "may" is ideal, it could suggest that compiler is not very 
sure and emits just some conservative message.

"not all paths in this non-void {function,block} return a value" gives some 
extra confidence that compiler knows there is a buggy control path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[PATCH] D69958: Improve VFS compatibility on Windows

2019-11-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This looks good to me. I had one suggestion, and I would also like to hear from 
another reviewer who has more ownership over VFS.




Comment at: llvm/include/llvm/Support/VirtualFileSystem.h:657
+  // slashes to match backslashes (and vice versa).
+  bool pathComponentMatches(llvm::StringRef lhs, llvm::StringRef rhs) const {
+if ((CaseSensitive ? lhs.equals(rhs) : lhs.equals_lower(rhs)))

IIUC, this method receives path components, which must not contain path 
separators, or the root path component, `\` or `/`. Is there some way to 
express that invariant? Maybe just comment like "A path component must not 
contain path separators, unless it is the root component, which is represented 
as a single path separator," or an assert with the same effect.



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1666
   // paths become globally default.
   if (Start->equals("."))
 ++Start;

Unrelated, but I wonder if this needs to be `while` instead of `if` to handle 
repeated `foo/./././bar`.


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

https://reviews.llvm.org/D69958



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


[PATCH] D69664: [Diagnostics] Teach -Wnull-dereference about address_space attribute

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 228298.
xbolva00 added a comment.

More tests.
Handle __attribute__((address_space(0))).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69664

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/exprs.c


Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,17 +179,27 @@
   test18_e(); // expected-error {{too few arguments to function call, expected 
at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
-  *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null 
pointer}} \
+  *(int *)0 = 0; // expected-warning 
{{indirection of non-volatile null pointer}} \
   // expected-note {{consider using __builtin_trap}}
-  *(volatile int*)0 = 0;  // Ok.
+  *(volatile int *)0 = 0;// Ok.
+  *(int __attribute__((address_space(256))) *)0 = 0; // Ok.
+  *(int __attribute__((address_space(0))) *)0 = 0;   // expected-warning 
{{indirection of non-volatile null pointer}} \
+ // expected-note {{consider using __builtin_trap}}
+  *(int_AS256 *)0 = 0;   // Ok.
 
   // rdar://9269271
-  int x = *(int*)0;  // expected-warning {{indirection of non-volatile null 
pointer}} \
+  int x = *(int *)0;   
   // expected-warning {{indirection of non-volatile null pointer}} 
\
+ // expected-note {{consider using __builtin_trap}}
+  int x2 = *(volatile int *)0; 
   // Ok.
+  int x3 = *(int __attribute__((address_space(0))) *)0;
   // expected-warning {{indirection of non-volatile null pointer}} 
\
  // expected-note {{consider using __builtin_trap}}
-  int x2 = *(volatile int*)0; // Ok.
-  int *p = &(*(int*)0); // Ok;
+  int x4 = *(int_AS256 *)0;
   // Ok;
+  int *p = &(*(int *)0);   
   // Ok;
+  int_AS256 *p1 = &(*(int __attribute__((address_space(256))) *)0);
   // Ok;
+  int __attribute__((address_space(0))) *p2 = &(*(int 
__attribute__((address_space(0))) *)0); // Ok;
 }
 
 int test20(int x) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -481,16 +481,21 @@
   // optimizer will delete, so warn about it.  People sometimes try to use this
   // to get a deterministic trap and are surprised by clang's behavior.  This
   // only handles the pattern "*null", which is a very syntactic check.
-  if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))
-if (UO->getOpcode() == UO_Deref &&
-UO->getSubExpr()->IgnoreParenCasts()->
-  isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull) 
&&
+  const auto *UO = dyn_cast(E->IgnoreParenCasts());
+  if (UO && UO->getOpcode() == UO_Deref) {
+const LangAS AS =
+UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
+bool isTargetAS = isTargetAddressSpace(AS);
+if ((!isTargetAS || (isTargetAS && toTargetAddressSpace(AS) == 0)) &&
+UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
+S.Context, Expr::NPC_ValueDependentIsNotNull) &&
 !UO->getType().isVolatileQualified()) {
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-  S.PDiag(diag::warn_indirection_through_null)
-<< UO->getSubExpr()->getSourceRange());
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-S.PDiag(diag::note_indirection_through_null));
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::warn_indirection_through_null)
+<< UO->getSubExpr()->getSourceRange());
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::note_indirection_through_null));
+}
   }
 }
 


Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,17 +179,27 @@
   test18_e(); // expected-error {{too few arguments to function call, expected at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
-  *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null pointer}} \
+  *(int *)0 = 0; // expected-warning {{indirection of non-volatile null pointer}} \

[PATCH] D69089: [Parser] #pragma clang transform

2019-11-07 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 228297.
Meinersbur added a comment.

- Switch to monorepo
- Move Transform.h/cpp to clangBasic
- Separate Transform and TransformClause


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69089

Files:
  clang/include/clang/AST/StmtTransform.h
  clang/include/clang/AST/TransformClauseKinds.def
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/Transform.h
  clang/include/clang/Basic/TransformKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/StmtTransform.cpp
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Transform.cpp
  clang/lib/Parse/CMakeLists.txt
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/ParseTransform.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/SemaTransform.cpp
  clang/test/Parser/pragma-transform.cpp

Index: clang/test/Parser/pragma-transform.cpp
===
--- /dev/null
+++ clang/test/Parser/pragma-transform.cpp
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -std=c++11 -fexperimental-transform-pragma -verify %s
+
+void pragma_transform(int *List, int Length) {
+// FIXME: This does not emit an error
+#pragma clang
+
+/* expected-error@+1 {{expected a transformation name}} */
+#pragma clang transform
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{unknown transformation}} */
+#pragma clang transform unknown_transformation
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+2 {{expected loop after transformation pragma}} */
+#pragma clang transform unroll
+  pragma_transform(List, Length);
+
+/* expected-error@+1 {{unknown clause name}} */
+#pragma clang transform unroll unknown_clause
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{expected '(' after 'partial'}} */
+#pragma clang transform unroll partial
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{expected expression}} */
+#pragma clang transform unroll partial(
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{expected '(' after 'partial'}} */
+#pragma clang transform unroll partial)
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+2 {{expected ')'}} */
+/* expected-note@+1 {{to match this '('}} */
+#pragma clang transform unroll partial(4
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{expected expression}} */
+#pragma clang transform unroll partial()
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+/* expected-error@+1 {{use of undeclared identifier 'badvalue'}} */
+#pragma clang transform unroll partial(badvalue)
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+
+  {
+/* expected-error@+2 {{expected statement}} */
+#pragma clang transform unroll
+  }
+}
+
+/* expected-error@+1 {{expected unqualified-id}} */
+#pragma clang transform unroll
+int I;
+
+/* expected-error@+1 {{expected unqualified-id}} */
+#pragma clang transform unroll
+void func();
+
+class C1 {
+/* expected-error@+3 {{this pragma cannot appear in class declaration}} */
+/* expected-error@+2 {{expected member name or ';' after declaration specifiers}} */
+/* expected-error@+1 {{unknown type name 'unroll'}} */
+#pragma clang transform unroll
+};
+
+template
+void pragma_transform_template_func(int *List, int Length) {
+#pragma clang transform unroll partial(F)
+  for (int i = 0; i < Length; i+=1)
+  List[i] = i;
+}
+
+template
+class C2 {
+  void pragma_transform_template_class(int *List, int Length) {
+#pragma clang transform unroll partial(F)
+for (int i = 0; i < Length; i+=1)
+List[i] = i;
+  }
+};
Index: clang/lib/Sema/SemaTransform.cpp
===
--- /dev/null
+++ clang/lib/Sema/SemaTransform.cpp
@@ -0,0 +1,49 @@
+//=== SemaTransform.h - -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Semantic analysis for code transformations.
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/StmtTransform.h"
+#include "clang/Basic/Transform.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
+
+using namespace clang;
+
+StmtResult
+Sema::ActOnLoopTransformDirective(Transform::Kind Kind,
+  llvm::ArrayRef 

[PATCH] D69263: [clangd] Implement cross-file rename.

2019-11-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 228294.
hokein marked 13 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69263

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -38,8 +38,8 @@
 llvm::Expected>
 runFindDocumentHighlights(ClangdServer , PathRef File, Position Pos);
 
-llvm::Expected>
-runRename(ClangdServer , PathRef File, Position Pos, StringRef NewName);
+llvm::Expected runRename(ClangdServer , PathRef File,
+Position Pos, StringRef NewName);
 
 std::string runDumpAST(ClangdServer , PathRef File);
 
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -96,10 +96,9 @@
   return std::move(*Result);
 }
 
-llvm::Expected> runRename(ClangdServer ,
-PathRef File, Position Pos,
-llvm::StringRef NewName) {
-  llvm::Optional>> Result;
+llvm::Expected runRename(ClangdServer , PathRef File,
+Position Pos, llvm::StringRef NewName) {
+  llvm::Optional> Result;
   Server.rename(File, Pos, NewName, /*WantFormat=*/true, capture(Result));
   return std::move(*Result);
 }
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -9,8 +9,10 @@
 #include "Annotations.h"
 #include "TestFS.h"
 #include "TestTU.h"
+#include "index/Ref.h"
 #include "refactor/Rename.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -18,8 +20,45 @@
 namespace clangd {
 namespace {
 
-MATCHER_P2(RenameRange, Code, Range, "") {
-  return replacementToEdit(Code, arg).range == Range;
+using testing::Eq;
+using testing::Pair;
+using testing::UnorderedElementsAre;
+
+// Build a RefSlab from all marked ranges in the annotation. The ranges are
+// assumed to associate with the given SymbolName.
+std::unique_ptr buildRefSlab(const Annotations ,
+  llvm::StringRef SymbolName,
+  llvm::StringRef Path) {
+  RefSlab::Builder Builder;
+  TestTU TU;
+  TU.HeaderCode = Code.code();
+  auto Symbols = TU.headerSymbols();
+  const auto  = findSymbol(Symbols, SymbolName).ID;
+  for (const auto  : Code.ranges()) {
+Ref R;
+R.Kind = RefKind::Reference;
+R.Location.Start.setLine(Range.start.line);
+R.Location.Start.setColumn(Range.start.character);
+R.Location.End.setLine(Range.end.line);
+R.Location.End.setColumn(Range.end.character);
+auto U = URI::create(Path).toString();
+R.Location.FileURI = U.c_str();
+Builder.insert(SymbolID, R);
+  }
+
+  return std::make_unique(std::move(Builder).build());
+}
+
+std::vector<
+std::pair>
+applyEdits(FileEdits FE) {
+  std::vector> Results;
+  for (auto  : FE)
+Results.emplace_back(
+It.first().str(),
+llvm::cantFail(tooling::applyAllReplacements(
+It.getValue().InitialCode, It.getValue().Replacements)));
+  return Results;
 }
 
 // Generates an expected rename result by replacing all ranges in the given
@@ -73,11 +112,11 @@
 auto AST = TU.build();
 llvm::StringRef NewName = "abcde";
 auto RenameResult =
-renameWithinFile(AST, testPath(TU.Filename), Code.point(), NewName);
+rename({Code.point(), NewName, AST, testPath(TU.Filename)});
 ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
-auto ApplyResult = llvm::cantFail(
-tooling::applyAllReplacements(Code.code(), *RenameResult));
-EXPECT_EQ(expectedResult(Code, NewName), ApplyResult);
+ASSERT_EQ(1u, RenameResult->size());
+EXPECT_EQ(applyEdits(std::move(*RenameResult)).front().second,
+  expectedResult(Code, NewName));
   }
 }
 
@@ -168,27 +207,97 

[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D69762#1737612 , @easyaspi314 wrote:

> How about "this non-void {function|block} {may|does} not return a value"


FWIW, I am happy with this clear and concise suggestion. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[PATCH] D69263: [clangd] Implement cross-file rename.

2019-11-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:345
+  SourceLocation SourceLocationBeg =
+  SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
+  RInputs.Pos, SM, AST.getASTContext().getLangOpts()));

ilya-biryukov wrote:
> Why is this different from `prepareRename`, which does not call 
> `getMacroArgExpandedLocation`?
> 
I didn't change it in this patch, but you raise a good point, `prepareRename` 
should call `getMacroArgExpandedLocation`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69263



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


[PATCH] D69935: [DeclCXX] Remove unknown external linkage specifications

2019-11-07 Thread Ehud Katz via Phabricator via cfe-commits
ekatz added a comment.

With this change (current trunk) you can write code as follows:

  extern "C++11" int x;

And it will pass compilation. No other compiler support it, nor it should, as 
there is no such thing as `extern "C++11"` nor `extern "C++14"`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69935



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


[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-07 Thread easyaspi314 (Devin) via Phabricator via cfe-commits
easyaspi314 added a comment.

How about "this non-void {function|block} {may|does} not return a value"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[PATCH] D69878: Consoldiate internal denormal flushing controls

2019-11-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm marked an inline comment as done.
arsenm added a comment.

In D69878#1736865 , @Anastasia wrote:

> > Stop emitting the denorms-are-zero attribute for the OpenCL flag. It
> >  has no in-tree users. The meaning would also be target dependent, such
> >  as the AMDGPU choice to treat this as only meaning allow flushing of
> >  f32 and not f16 or f64. The naming is also potentially confusing,
> >  since DAZ in other contexts refers to instructions implicitly treating
> >  input denormals as zero, not necessarily flushing output denormals to
> >  zero.
>
> Would the targets supporting OpenCL need to define their own behavior in 
> `getDefaultDenormalModeForType`?


Yes. The future ieee default should be conservatively correct though




Comment at: clang/include/clang/Driver/ToolChain.h:619
+  const llvm::fltSemantics *FPType = nullptr) const {
+// FIXME: This should be IEEE when default handling is fixed.
+return llvm::DenormalMode::Invalid;

Anastasia wrote:
> Can you elaborate what has to be done in order to fix this?
The main problem is the current user assumes non-ieee by default. The main 
blocker is knowing what platforms should default to something different to 
avoid performance regressions. I have the patch almost ready to switch the 
default, it’s just missing toolchain overrides


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

https://reviews.llvm.org/D69878



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


[PATCH] D69962: [CFG] Fix a flaky crash in CFGBlock::getLastCondition().

2019-11-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/test/Analysis/a_flaky_crash.cpp:19
+
+// 256 copies of the same run-line to make it crash more often when it breaks.
+

This is a trade-off between reliability and not increasing test time too much. 
This test starts with an "a", so it fires up immediately, and on my machine 
it's not the last test to finish during `check-clang-analysis`, so i guess it 
shouldn't cause too much trouble.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69962



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


[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:579
 def warn_maybe_falloff_nonvoid_function : Warning<
-  "control may reach end of non-void function">,
+  "not all control paths in this function return a value; non-void function 
must return a value">,
   InGroup;

Quuxplusone wrote:
> As long as we're messing with this wording: Does it actually help any human 
> reader to distinguish "control paths" versus simply "paths"? And could we DRY 
> it up by saying
> 
> > not all paths in this non-void {function,block} return a value
> 
> > this non-void {function,block} does not return a value
> 
> > not all paths in this coroutine return a value, and the promise type %0 
> > does not declare 'return_void()'
> 
> > this coroutine does not return a value, and the promise type %0 does not 
> > declare 'return_void()'
> 
> I don't think the Coroutines warning needs to specifically call out 
> "undefined behavior," unless it is trying to say that the code is IFNDR. //Of 
> course// falling off the end of a function is UB if it ever actually happens 
> at runtime; that's no different whether it's a coroutine or a regular 
> function/block. The only reason for a wording difference in the Coroutines 
> case is that the colloquial notion of a "(non-)void coroutine" (whose return 
> type would be something like `task`) is slightly less familiar than the 
> colloquial notion of a "(non-)void function" (whose return type is literally 
> `void`).
I am also wondering if we could use some better term than "control paths", but 
I haven't found any :)  Paths sound to general for me but I am not strongly 
opposed.

if @aaron.ballman  is happy with your wording, so do I.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[PATCH] D69962: [CFG] Fix a flaky crash in CFGBlock::getLastCondition().

2019-11-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, Szelethus, 
baloghadamsoftware, Charusso.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Using an end iterator of an empty CFG block boiled down to dereferencing a 
garbage pointer.

This was fun to debug because the actual segfault occurs once in ~20 runs on 
the original code (on my system; on top of that, each run took several 
minutes). On the newly added test it crashes even more rarely, roughly once in 
500 runs.

CFG uses `llvm::BumpVector` for storing the list of elements. Its iterators are 
typedefs for raw pointers, so there's no way to check the correctness of the 
iterator by injecting assertions into it.

> [12:26:29] <@NoQ> I'm about to commit a fix for a flaky crash that's 
> reproducible once in ~1000 compilations. Can we make for-loops in lit?
>  [12:27:12] <@jdoerfert> @NoQ: jdenny: has an extension to do that (I think)
>  [12:36:40] <@NoQ> @jdoerfert: Thanks!
>  [12:36:59] <@jdoerfert> @NoQ: so, I doubt we have on in-tree
>  [12:37:21] <@NoQ> Mm, ok. I guess i could copy-paste the run-line :)
>  [12:37:36] <@Lebedev.RI> i remember seeing previous fixes with such idea, 
> but i don't recall how they achieved that
>  [12:37:37] <@jdoerfert> that is one way, yes ;)
>  [12:38:16] <@jdoerfert> #include <>; #include<>; #include<>; ... exponential 
> growth!


Repository:
  rC Clang

https://reviews.llvm.org/D69962

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/Analysis/a_flaky_crash.cpp

Index: clang/test/Analysis/a_flaky_crash.cpp
===
--- /dev/null
+++ clang/test/Analysis/a_flaky_crash.cpp
@@ -0,0 +1,277 @@
+// This code used to crash but unpredictably and rarely.
+// Even with the current set of run-lines, if a buildbot tells you that
+// you broke this test there's a chance that someone else broke it
+// a few commits ago.
+
+struct S {
+  S();
+  ~S();
+};
+
+bool bar(S);
+
+void foo() {
+  int x;
+  if (true && bar(S()))
+++x; // expected-warning{{The expression is an uninitialized value. The computed value will also be garbage}}
+}
+
+// 256 copies of the same run-line to make it crash more often when it breaks.
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: 

[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-11-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

As far as i can tell the builder does not add any debug info.
Should it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[PATCH] D58896: Suppress -Wchar-subscripts if the index is a literal char

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

int('i') is nice fixit we could emit in this case! Thanks for this idea!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58896



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


[PATCH] D69925: remove redundant LLVM version from version string when setting CLANG_VENDOR

2019-11-07 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Just grabbed a version string off a MBP:

  $ clang --version
  Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  Target: x86_64-apple-darwin18.7.0
  Thread model: posix
  InstalledDir: /Library/Developer/CommandLineTools/usr/bin

So it looks like the Apple distribution has a quite different implementation of 
this method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69925



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


[clang] b95bb08 - [CodeGenModule] Group blocks runtime globals together, NFC

2019-11-07 Thread Vedant Kumar via cfe-commits

Author: Vedant Kumar
Date: 2019-11-07T12:46:26-08:00
New Revision: b95bb0847a1ea366dda69901c24415e0d00a9527

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

LOG: [CodeGenModule] Group blocks runtime globals together, NFC

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.h

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index f5014c05b067..33d419a02903 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -523,18 +523,18 @@ class CodeGenModule : public CodeGenTypeCache {
 int GlobalUniqueCount;
   } Block;
 
+  GlobalDecl initializedGlobalDecl;
+
+  /// @}
+
   /// void @llvm.lifetime.start(i64 %size, i8* nocapture )
   llvm::Function *LifetimeStartFn = nullptr;
 
   /// void @llvm.lifetime.end(i64 %size, i8* nocapture )
   llvm::Function *LifetimeEndFn = nullptr;
 
-  GlobalDecl initializedGlobalDecl;
-
   std::unique_ptr SanitizerMD;
 
-  /// @}
-
   llvm::MapVector DeferredEmptyCoverageMappingDecls;
 
   std::unique_ptr CoverageMapping;



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


[PATCH] D68912: Adds -Wrange-loop-analysis to -Wall

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 accepted this revision.
xbolva00 added a comment.
This revision is now accepted and ready to land.

Formally unblocking this


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

https://reviews.llvm.org/D68912



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


[PATCH] D69922: [OpenMP] Use the OpenMP-IR-Builder

2019-11-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 4 inline comments as done.
jdoerfert added inline comments.



Comment at: clang/test/Driver/fopenmp.c:130-131
+// CHECK-CC1-OPENMPIRBUILDER: "-cc1"
+// CHECK-CC1-OPENMPIRBUILDER: "-fopenmp"
+// CHECK-CC1-OPENMPIRBUILDER: "-fopenmp-enable-irbuilder"
+//

ABataev wrote:
> `CHECK...-SAME`?
Sure, will do.



Comment at: clang/test/OpenMP/barrier_codegen.cpp:42
+// CLANGCG-NOT: inaccessiblemem
+// IRBUILDER:  ; Function Attrs: inaccessiblemem_or_argmemonly nofree 
nosync nounwind readonly
+// IRBUILDER-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)

ABataev wrote:
> Not sure about correctness of `inaccessiblemem_or_argmemonly` attribute 
> applied to this function. Are you sure about this? This is maybe true for the 
> NVPTX/AMDGCN runtimes but not the generic version of libomp.
Fair point. I'll remove it for now but we should come up with a scheme. Maybe 
communicating the target library and other information to the IRBuilder so we 
can select based on those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69922



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


[PATCH] D58896: Suppress -Wchar-subscripts if the index is a literal char

2019-11-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D58896#1737242 , @edward-jones 
wrote:

> In D58896#1737200 , @xbolva00 wrote:
>
> > Well, i am not sure if one twitter report is good motivation to criple 
> > warning.
>
>
> The motivation for suppressing the warning was that it is not uncommon to use 
> a character literal in lookup tables. In addition in brings the warning 
> inline with the behaviour of `-Wchar-subscripts` in GCC.


Peanut gallery says: If it's "not uncommon," then {when,if} you resubmit this 
for review, it should be easy and therefore mandatory to provide at least one 
example of someone actually using a character literal as a lookup table index. 
I've never seen such a construct in my life, so real-world examples (e.g. 
GitHub links) would be useful.

Especially useful would be links to GitHub examples of `'i'[arr]` or `arr['i']` 
where the //most appropriate fix// is legitimately "upgrade your Clang thus 
suppressing the diagnostic" as opposed to "rewrite the expression as 
`arr[int('i')]` or `arr[105]` depending on what you actually mean it to do."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58896



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


[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:579
 def warn_maybe_falloff_nonvoid_function : Warning<
-  "control may reach end of non-void function">,
+  "not all control paths in this function return a value; non-void function 
must return a value">,
   InGroup;

As long as we're messing with this wording: Does it actually help any human 
reader to distinguish "control paths" versus simply "paths"? And could we DRY 
it up by saying

> not all paths in this non-void {function,block} return a value

> this non-void {function,block} does not return a value

> not all paths in this coroutine return a value, and the promise type %0 does 
> not declare 'return_void()'

> this coroutine does not return a value, and the promise type %0 does not 
> declare 'return_void()'

I don't think the Coroutines warning needs to specifically call out "undefined 
behavior," unless it is trying to say that the code is IFNDR. //Of course// 
falling off the end of a function is UB if it ever actually happens at runtime; 
that's no different whether it's a coroutine or a regular function/block. The 
only reason for a wording difference in the Coroutines case is that the 
colloquial notion of a "(non-)void coroutine" (whose return type would be 
something like `task`) is slightly less familiar than the colloquial 
notion of a "(non-)void function" (whose return type is literally `void`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[PATCH] D69925: remove redundant LLVM version from version string when setting CLANG_VENDOR

2019-11-07 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D69925#1737361 , @arphaman wrote:

> +1, Apple's clang has an `#ifdef 0` around this code.


Is that +1 in favor of the patch as is, or +1 to @eli.friedman 's comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69925



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


[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:584-587
 def err_maybe_falloff_nonvoid_block : Error<
   "control may reach end of non-void block">;
 def err_falloff_nonvoid_block : Error<
   "control reaches end of non-void block">;

xbolva00 wrote:
> aaron.ballman wrote:
> > Should we change this wording as well? Along with any other instances of 
> > similar wording (I don't recall if we have something similar for lambdas or 
> > if we defer to the function diagnostics in that case)?
> +1, I agree.
> 
> It would be better if somebody more familiar with  Obj-C / coroutines and 
> related terminology would improve these text.
I think you've already got the gist of it. `block does not return a value; 
non-void blocks must return a value`, and similar for coroutines.

In fact, I wonder why we don't just combine these diagnostics for all three 
situations and use a `%select` for them? That seems like a reasonable thing to 
do (having not put a ton of thought into it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[PATCH] D69952: [OPENMP50]Generalize handling of context matching/scoring.

2019-11-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 228290.
ABataev added a comment.

Rebase + address some comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69952

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -388,25 +388,41 @@
   if (Expr *E = Attr.getVariantFuncRef())
 VariantFuncRef = Subst(E);
 
-  ExprResult Score;
-  if (Expr *E = Attr.getScore())
-Score = Subst(E);
-
   // Check function/variant ref.
   Optional> DeclVarData =
   S.checkOpenMPDeclareVariantFunction(
   S.ConvertDeclToDeclGroup(New), VariantFuncRef.get(), Attr.getRange());
   if (!DeclVarData)
 return;
-  // Instantiate the attribute.
-  Sema::OpenMPDeclareVariantCtsSelectorData Data(
-  Attr.getCtxSelectorSet(), Attr.getCtxSelector(),
-  llvm::makeMutableArrayRef(Attr.implVendors_begin(),
-Attr.implVendors_size()),
-  Score);
+  SmallVector Scores;
+  SmallVector Data;
+  for (unsigned I = 0, E = Attr.scores_size(); I < E; ++I) {
+ExprResult Score;
+if (Expr *E = *std::next(Attr.scores_begin(), I))
+  Score = Subst(E);
+Scores.push_back(Score);
+// Instantiate the attribute.
+auto CtxSet = static_cast(
+*std::next(Attr.ctxSelectorSets_begin(), I));
+auto Ctx = static_cast(
+*std::next(Attr.ctxSelectors_begin(), I));
+switch (CtxSet) {
+case OMPCtxSet_implementation:
+  switch (Ctx) {
+  case OMPCtx_vendor:
+Data.emplace_back(CtxSet, Ctx, Attr.implVendors());
+break;
+  case OMPCtxUnknown:
+llvm_unreachable("Unexpected context selector kind.");
+  }
+  break;
+case OMPCtxSetUnknown:
+  llvm_unreachable("Unexpected context selector set kind.");
+}
+  }
   S.ActOnOpenMPDeclareVariantDirective(DeclVarData.getValue().first,
DeclVarData.getValue().second,
-   Attr.getRange(), Data);
+   Attr.getRange(), Data, Scores);
 }
 
 static void instantiateDependentAMDGPUFlatWorkGroupSizeAttr(
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -5190,30 +5190,62 @@
   return std::make_pair(FD, cast(DRE));
 }
 
-void Sema::ActOnOpenMPDeclareVariantDirective(
-FunctionDecl *FD, Expr *VariantRef, SourceRange SR,
-const Sema::OpenMPDeclareVariantCtsSelectorData ) {
-  if (Data.CtxSet == OMPDeclareVariantAttr::CtxSetUnknown ||
-  Data.Ctx == OMPDeclareVariantAttr::CtxUnknown)
+void Sema::ActOnOpenMPDeclareVariantDirective(FunctionDecl *FD,
+  Expr *VariantRef, SourceRange SR,
+  ArrayRef Data,
+  ArrayRef Scores) {
+  if (Scores.empty())
 return;
-  Expr *Score = nullptr;
-  if (Data.CtxScore.isUsable()) {
-Score = Data.CtxScore.get();
-if (!Score->isTypeDependent() && !Score->isValueDependent() &&
-!Score->isInstantiationDependent() &&
-!Score->containsUnexpandedParameterPack()) {
-  llvm::APSInt Result;
-  ExprResult ICE = VerifyIntegerConstantExpression(Score, );
-  if (ICE.isInvalid())
-return;
+  SmallVector CtxScores;
+  SmallVector CtxSets;
+  SmallVector Ctxs;
+  SmallVector ImplVendors;
+  bool IsError = false;
+  for (unsigned I = 0, E = Scores.size(); I < E; ++I) {
+OpenMPContextSelectorSetKind CtxSet = Data[I].CtxSet;
+OpenMPContextSelectorKind Ctx = Data[I].Ctx;
+if (CtxSet == OMPCtxSetUnknown || Ctx == OMPCtxUnknown)
+  return;
+Expr *Score = nullptr;
+if (Scores[I].isUsable()) {
+  Score = Scores[I].get();
+  if (!Score->isTypeDependent() && !Score->isValueDependent() &&
+  !Score->isInstantiationDependent() &&
+  !Score->containsUnexpandedParameterPack()) {
+Score =
+PerformOpenMPImplicitIntegerConversion(Score->getExprLoc(), Score)
+.get();
+if (Score)
+  Score = VerifyIntegerConstantExpression(Score).get();
+  }
+} else {
+  Score = ActOnIntegerConstant(SourceLocation(), 0).get();
 }
-  } else {
-Score = ActOnIntegerConstant(SourceLocation(), 0).get();
+switch (CtxSet) {
+case 

[PATCH] D69961: [clangd] Fix a regression of not showing documentation from forward declarations.

2019-11-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

There is a regression from https://reviews.llvm.org/D68467. Unlike class
forward declarations, function ducomentation is written in the declaration in
headers, the function definition doesn't contain any documentation, cases like:

  foo.h
  // this is foo.
  void foo();
  foo.cc
  
  void foo() {}

we should still show documentation from the foo declaration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69961

Files:
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp


Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -411,6 +411,7 @@
   Symbol L, R;
   L.ID = R.ID = SymbolID("x");
   L.Definition.FileURI = "file:/x.h";
+  L.SymInfo.Kind = index::SymbolKind::Class;
   R.Documentation = "Forward declarations because x.h is too big to include";
 
   Symbol M = mergeSymbol(L, R);
Index: clang-tools-extra/clangd/index/Merge.cpp
===
--- clang-tools-extra/clangd/index/Merge.cpp
+++ clang-tools-extra/clangd/index/Merge.cpp
@@ -186,11 +186,16 @@
 S.Signature = O.Signature;
   if (S.CompletionSnippetSuffix == "")
 S.CompletionSnippetSuffix = O.CompletionSnippetSuffix;
-  // Don't accept documentation from bare forward declarations, if there is a
-  // definition and it didn't provide one. S is often an undocumented class,
-  // and O is a non-canonical forward decl preceded by an irrelevant comment.
-  if (S.Documentation == "" && !S.Definition)
-S.Documentation = O.Documentation;
+  if (S.Documentation == "") {
+// Don't accept documentation from bare forward class declarations, if 
there
+// is a definition and it didn't provide one. S is often an undocumented
+// class, and O is a non-canonical forward decl preceded by an irrelevant
+// comment.
+bool IsClass = S.SymInfo.Kind == index::SymbolKind::Class ||
+   S.SymInfo.Kind == index::SymbolKind::Struct;
+if (!IsClass || !S.Definition)
+  S.Documentation = O.Documentation;
+  }
   if (S.ReturnType == "")
 S.ReturnType = O.ReturnType;
   if (S.Type == "")


Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -411,6 +411,7 @@
   Symbol L, R;
   L.ID = R.ID = SymbolID("x");
   L.Definition.FileURI = "file:/x.h";
+  L.SymInfo.Kind = index::SymbolKind::Class;
   R.Documentation = "Forward declarations because x.h is too big to include";
 
   Symbol M = mergeSymbol(L, R);
Index: clang-tools-extra/clangd/index/Merge.cpp
===
--- clang-tools-extra/clangd/index/Merge.cpp
+++ clang-tools-extra/clangd/index/Merge.cpp
@@ -186,11 +186,16 @@
 S.Signature = O.Signature;
   if (S.CompletionSnippetSuffix == "")
 S.CompletionSnippetSuffix = O.CompletionSnippetSuffix;
-  // Don't accept documentation from bare forward declarations, if there is a
-  // definition and it didn't provide one. S is often an undocumented class,
-  // and O is a non-canonical forward decl preceded by an irrelevant comment.
-  if (S.Documentation == "" && !S.Definition)
-S.Documentation = O.Documentation;
+  if (S.Documentation == "") {
+// Don't accept documentation from bare forward class declarations, if there
+// is a definition and it didn't provide one. S is often an undocumented
+// class, and O is a non-canonical forward decl preceded by an irrelevant
+// comment.
+bool IsClass = S.SymInfo.Kind == index::SymbolKind::Class ||
+   S.SymInfo.Kind == index::SymbolKind::Struct;
+if (!IsClass || !S.Definition)
+  S.Documentation = O.Documentation;
+  }
   if (S.ReturnType == "")
 S.ReturnType = O.ReturnType;
   if (S.Type == "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68912: Adds -Wrange-loop-analysis to -Wall

2019-11-07 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Thanks for the review. I also looked at some of the new warnings and I'm  
preparing patches to fix them.


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

https://reviews.llvm.org/D68912



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


[clang] 2b943c4 - [Sema] Fixes a crash with a templated destructor

2019-11-07 Thread Mark de Wever via cfe-commits

Author: Mark de Wever
Date: 2019-11-07T21:22:27+01:00
New Revision: 2b943c46873a6411c5a79dcd708d8c72ce5b3675

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

LOG: [Sema] Fixes a crash with a templated destructor

The issue was introduced by D33189 which fixed PR33189.

Fixes PR38671: "destructor cannot be declared as a template" leads to segfault 
in Sema::LookupSpecialMember

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

Added: 


Modified: 
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaTemplate/destructor-template.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 44c9d276c3e7..df817e6bcef1 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -3112,11 +3112,10 @@ Sema::SpecialMemberOverloadResult 
Sema::LookupSpecialMember(CXXRecordDecl *RD,
   });
 }
 CXXDestructorDecl *DD = RD->getDestructor();
-assert(DD && "record without a destructor");
 Result->setMethod(DD);
-Result->setKind(DD->isDeleted() ?
-SpecialMemberOverloadResult::NoMemberOrDeleted :
-SpecialMemberOverloadResult::Success);
+Result->setKind(DD && !DD->isDeleted()
+? SpecialMemberOverloadResult::Success
+: SpecialMemberOverloadResult::NoMemberOrDeleted);
 return *Result;
   }
 

diff  --git a/clang/test/SemaTemplate/destructor-template.cpp 
b/clang/test/SemaTemplate/destructor-template.cpp
index 6570b6456406..0d28ec816c6e 100644
--- a/clang/test/SemaTemplate/destructor-template.cpp
+++ b/clang/test/SemaTemplate/destructor-template.cpp
@@ -92,3 +92,13 @@ class PR33189
   template 
   ~PR33189() { } // expected-error{{destructor cannot be declared as a 
template}}
 };
+
+namespace PR38671 {
+struct S {
+  template 
+  ~S(); // expected-error{{destructor cannot be declared as a template}}
+};
+struct T : S {// expected-note{{destructor of 'T' is implicitly deleted 
because base class 'PR38671::S' has no destructor}}
+  ~T() = default; // expected-warning{{explicitly defaulted destructor is 
implicitly deleted}}
+};
+} // namespace PR38671



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


[PATCH] D69225: Sema: Fixes a crash with a templated destructor

2019-11-07 Thread Mark de Wever via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b943c46873a: [Sema] Fixes a crash with a templated 
destructor (authored by Mordante).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69225

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaTemplate/destructor-template.cpp


Index: clang/test/SemaTemplate/destructor-template.cpp
===
--- clang/test/SemaTemplate/destructor-template.cpp
+++ clang/test/SemaTemplate/destructor-template.cpp
@@ -92,3 +92,13 @@
   template 
   ~PR33189() { } // expected-error{{destructor cannot be declared as a 
template}}
 };
+
+namespace PR38671 {
+struct S {
+  template 
+  ~S(); // expected-error{{destructor cannot be declared as a template}}
+};
+struct T : S {// expected-note{{destructor of 'T' is implicitly deleted 
because base class 'PR38671::S' has no destructor}}
+  ~T() = default; // expected-warning{{explicitly defaulted destructor is 
implicitly deleted}}
+};
+} // namespace PR38671
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3112,11 +3112,10 @@
   });
 }
 CXXDestructorDecl *DD = RD->getDestructor();
-assert(DD && "record without a destructor");
 Result->setMethod(DD);
-Result->setKind(DD->isDeleted() ?
-SpecialMemberOverloadResult::NoMemberOrDeleted :
-SpecialMemberOverloadResult::Success);
+Result->setKind(DD && !DD->isDeleted()
+? SpecialMemberOverloadResult::Success
+: SpecialMemberOverloadResult::NoMemberOrDeleted);
 return *Result;
   }
 


Index: clang/test/SemaTemplate/destructor-template.cpp
===
--- clang/test/SemaTemplate/destructor-template.cpp
+++ clang/test/SemaTemplate/destructor-template.cpp
@@ -92,3 +92,13 @@
   template 
   ~PR33189() { } // expected-error{{destructor cannot be declared as a template}}
 };
+
+namespace PR38671 {
+struct S {
+  template 
+  ~S(); // expected-error{{destructor cannot be declared as a template}}
+};
+struct T : S {// expected-note{{destructor of 'T' is implicitly deleted because base class 'PR38671::S' has no destructor}}
+  ~T() = default; // expected-warning{{explicitly defaulted destructor is implicitly deleted}}
+};
+} // namespace PR38671
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3112,11 +3112,10 @@
   });
 }
 CXXDestructorDecl *DD = RD->getDestructor();
-assert(DD && "record without a destructor");
 Result->setMethod(DD);
-Result->setKind(DD->isDeleted() ?
-SpecialMemberOverloadResult::NoMemberOrDeleted :
-SpecialMemberOverloadResult::Success);
+Result->setKind(DD && !DD->isDeleted()
+? SpecialMemberOverloadResult::Success
+: SpecialMemberOverloadResult::NoMemberOrDeleted);
 return *Result;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68578: [HIP] Fix device stub name

2019-11-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

There are a number of places in IRGen that pass around `GlobalDecl`s with the 
expectation that that's sufficient to uniquely identify a symbol.  The fact 
that IRGen breaks down the GD at the last second before passing it to the 
mangler, rather than passing it to the mangler and letting the mangler decide 
what to do with it, doesn't really change anything and is arguably poor code 
design anyway.  Inventing a second declaration, or trying to propagate a flag 
outside of GD, is just fighting the architecture for no good reason.


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

https://reviews.llvm.org/D68578



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


[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-11-07 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.

I'm a bit worried that this manual parsing technique will need fixing again in 
the future, but I think this is at least a reasonable incremental improvement.

LGTM with a minor nit.




Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:54
+  }
+  NestingLevel++;
+  break;

Might as well use `++NestingLevel` given that you don't care about the result 
anyway. Similar below.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp:197
+
+typedef S<(0 > 0), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'

I was going to suggest another test involving attributes (which can have 
arbitrary expressions as arguments to the attribute), but then I discovered 
attributes in Clang are broken in the place where it would be an issue for this 
check anyway. :-D (I filed https://bugs.llvm.org/show_bug.cgi?id=43939 to 
address the attribute issue.)




Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D67460



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


[PATCH] D69853: [OpenMP][NFCI] Introduce llvm/IR/OpenMPConstants.h

2019-11-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with a nit




Comment at: llvm/include/llvm/IR/OpenMPConstants.h:1
+//===- IR/OpenMPConstants.h - OpenMP related constants & helper - C++ -*-===//
+//

Just `OpenMPConstants.h`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69853



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


[PATCH] D69952: [OPENMP50]Generalize handling of context matching/scoring.

2019-11-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/include/clang/Basic/OpenMPKinds.h:56
+ OpenMPContextSelectorKind Ctx, const U )
+  : CtxSet(CtxSet), Ctx(Ctx), Names(Names.begin(), Names.end()) {}
+};

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > jdoerfert wrote:
> > > > Why do you need a second template version here?
> > > To construct the object when the container Names cannot be created 
> > > dieectly using the first constructor (SmallVector and UniqueVector are 
> > > not quite compatible in this sence, for example)
> > That can be addressed by changing the first constructor. Why is it an 
> > xvalue there and why is the container not const?
> In short, to avoid some extra memory allocation/deallocation. I can make the 
> container const, ok.
Tried to make it `const`, it breaks a lot of code and almost impossible to fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69952



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


[PATCH] D69822: [clang] Add new -fdebug-default-version flag.

2019-11-07 Thread David Blaikie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d8f9c244074: [clang] Add -fdebug-default-version for 
specifying the default DWARF version (authored by dblaikie).

Changed prior to commit:
  https://reviews.llvm.org/D69822?vs=228250=228287#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69822

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/test/Driver/debug-default-version.c

Index: clang/test/Driver/debug-default-version.c
===
--- /dev/null
+++ clang/test/Driver/debug-default-version.c
@@ -0,0 +1,44 @@
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefixes=NODEBUGINFO,NODWARF4
+
+// Check which debug info formats we use on Windows. By default, in an MSVC
+// environment, we should use codeview. You can enable dwarf, which implicitly
+// disables codeview, or you can explicitly ask for both if you don't know how
+// the app will be debugged.
+// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -o - %s 2>&1 \
+// RUN: | FileCheck %s --check-prefixes=DWARF2,NOCODEVIEW
+// Explicitly request both.
+// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -o - %s 2>&1 \
+// RUN: | FileCheck %s --check-prefixes=DWARF4,CODEVIEW
+
+// Do Assembler testing most of the same test cases as those above.
+
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5
+
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -x assembler -c -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5
+// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5
+
+int main(void) {
+  return 0;
+}
+
+// NOCODEVIEW-NOT: -gcodeview
+// CODEVIEW: "-gcodeview"
+
+// NODEBUGINFO-NOT: -debug-info-kind=
+
+// DWARF2: "-dwarf-version=2"
+// DWARF3: "-dwarf-version=3"
+// DWARF4: "-dwarf-version=4"
+// DWARF5: "-dwarf-version=5"
+
+// NOCODEVIEW-NOT: -gcodeview
+// NODWARF4-NOT: -dwarf-version=4
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -68,6 +68,9 @@
 unsigned ParseFunctionAlignment(const ToolChain ,
 const llvm::opt::ArgList );
 
+unsigned ParseDebugDefaultVersion(const ToolChain ,
+  const llvm::opt::ArgList );
+
 void AddAssemblerKPIC(const ToolChain ,
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1138,6 +1138,21 @@
   return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value;
 }
 
+unsigned tools::ParseDebugDefaultVersion(const ToolChain ,
+ const ArgList ) {
+  const Arg *A = Args.getLastArg(options::OPT_fdebug_default_version);
+
+  if (!A)
+return 0;
+
+  unsigned Value = 0;
+  if 

[clang] 8d8f9c2 - [clang] Add -fdebug-default-version for specifying the default DWARF version

2019-11-07 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2019-11-07T12:05:58-08:00
New Revision: 8d8f9c24407461fadf1730e80ebcf7c767254715

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

LOG: [clang] Add -fdebug-default-version for specifying the default DWARF 
version

This flag decouples specifying the DWARF version from enabling/disabling
DWARF in general (or the gN level - gmlt/limited/standalone, etc) while
still allowing existing -gdwarf-N flags to override this default.

Patch by Caroline Tice!

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

Added: 
clang/test/Driver/debug-default-version.c

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8995f3d198e4..dcd2976a97f2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1958,6 +1958,8 @@ def fsplit_dwarf_inlining: Flag <["-"], 
"fsplit-dwarf-inlining">, Group
   Flags<[CC1Option]>, HelpText<"Provide minimal debug info in the 
object/executable to facilitate online symbolication/stack traces in the 
absence of .dwo/.dwp files when using Split DWARF">;
 def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, 
Group,
   Flags<[CC1Option]>;
+def fdebug_default_version: Joined<["-"], "fdebug-default-version=">, 
Group,
+  HelpText<"Default DWARF version to use, if a -g option caused DWARF debug 
info to be produced">;
 def fdebug_prefix_map_EQ
   : Joined<["-"], "fdebug-prefix-map=">, Group,
 Flags<[CC1Option,CC1AsOption]>,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 17cb4816e61f..008742aca57f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3335,7 +3335,6 @@ static void RenderDebugOptions(const ToolChain , const 
Driver ,
   // This avoids having to monkey around further in cc1 other than to disable
   // codeview if not running in a Windows environment. Perhaps even that
   // decision should be made in the driver as well though.
-  unsigned DWARFVersion = 0;
   llvm::DebuggerKind DebuggerTuning = TC.getDefaultDebuggerTuning();
 
   bool SplitDWARFInlining =
@@ -3418,11 +3417,18 @@ static void RenderDebugOptions(const ToolChain , 
const Driver ,
 }
   }
 
+  unsigned DWARFVersion = 0;
+  unsigned DefaultDWARFVersion = ParseDebugDefaultVersion(TC, Args);
   if (EmitDwarf) {
 // Start with the platform default DWARF version
 DWARFVersion = TC.GetDefaultDwarfVersion();
 assert(DWARFVersion && "toolchain default DWARF version must be nonzero");
 
+// If the user specified a default DWARF version, that takes precedence
+// over the platform default.
+if (DefaultDWARFVersion)
+  DWARFVersion = DefaultDWARFVersion;
+
 // Override with a user-specified DWARF version
 if (GDwarfN)
   if (auto ExplicitVersion = DwarfVersionNum(GDwarfN->getSpelling()))
@@ -6354,6 +6360,11 @@ void ClangAs::ConstructJob(Compilation , const 
JobAction ,
 if (WantDebug)
   DwarfVersion = DwarfVersionNum(A->getSpelling());
   }
+
+  unsigned DefaultDwarfVersion = ParseDebugDefaultVersion(getToolChain(), 
Args);
+  if (DwarfVersion == 0)
+DwarfVersion = DefaultDwarfVersion;
+
   if (DwarfVersion == 0)
 DwarfVersion = getToolChain().GetDefaultDwarfVersion();
 

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 10743559e048..709ddaae4ab0 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1138,6 +1138,21 @@ unsigned tools::ParseFunctionAlignment(const ToolChain 
,
   return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value;
 }
 
+unsigned tools::ParseDebugDefaultVersion(const ToolChain ,
+ const ArgList ) {
+  const Arg *A = Args.getLastArg(options::OPT_fdebug_default_version);
+
+  if (!A)
+return 0;
+
+  unsigned Value = 0;
+  if (StringRef(A->getValue()).getAsInteger(10, Value) || Value > 5 ||
+  Value < 2)
+TC.getDriver().Diag(diag::err_drv_invalid_int_value)
+<< A->getAsString(Args) << A->getValue();
+  return Value;
+}
+
 void tools::AddAssemblerKPIC(const ToolChain , const ArgList ,
  ArgStringList ) {
   llvm::Reloc::Model RelocationModel;

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 79468e6b8926..cf1ce14249ea 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -68,6 +68,9 @@ 

[PATCH] D69855: [clang-tidy] Fix llvm-namespace-comment for macro expansions

2019-11-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

There's a design question about why it should accept the expanded macro name 
instead of requiring the user to write the macro. I am worried about allowing 
the expanded form because the presumable use of a macro is to control the name, 
so this invites name mismatches in other configuration modes.




Comment at: 
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp:30
+// Record all defined macros. We store the whole token to compare names
+// later
+

Missing full stop.



Comment at: 
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp:32
+
+const MacroInfo *const MI = MD->getMacroInfo();
+

You can drop the latter `const` (we don't do top-level `const` qualification 
with any consistency).



Comment at: 
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp:50-51
+
+Check->addMacro(MacroNameTok.getIdentifierInfo()->getName().str(),
+Value.str());
+  }

You only need to add the macro name in this case, not its value, which should 
simplify this code considerably.



Comment at: 
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp:83
+const SourceManager , Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  PP->addPPCallbacks(std::make_unique(PP, this));
+}

Rather than making an entire new object for PP callbacks, why not make 
`NamespaceCommentCheck` inherit from `PPCallbacks`? It seems like it would 
simplify the interface somewhat.



Comment at: 
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp:208-215
+  std::find_if(std::begin(Macros), std::end(Macros),
+   [](const auto ) {
+ return NamespaceNameInComment == Macro.first;
+   });
+
+  if (MacroIt != Macros.end()) {
+return;

Rather than this, I'd suggest using `llvm::any_of()`.



Comment at: clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.h:43
+  // Store macros to verify that warning is not thrown when namespace name is a
+  // preprocessed define
+  std::vector> Macros;

Missing a full stop at the end of the sentence.



Comment at: clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.h:44
+  // preprocessed define
+  std::vector> Macros;
 };

I think a better approach is to use a set of some sort because the value of the 
macro is never used in the check. Probably a `SmallPtrSet` over `StringRef`.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvm-namespace-comment.cpp:19
+}
+// CHECK-FIXES: } // namespace macro_expansion
+

This seems unintuitive to me -- it should suggest the macro name instead.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvm-namespace-comment.cpp:27
+  void h();
+} // namespace macro_expansion

This also seems unintuitive to me, I would have wanted this to diagnose and 
provide a fixit for suggesting the macro name, not its expansion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69855



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


[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:584-587
 def err_maybe_falloff_nonvoid_block : Error<
   "control may reach end of non-void block">;
 def err_falloff_nonvoid_block : Error<
   "control reaches end of non-void block">;

aaron.ballman wrote:
> Should we change this wording as well? Along with any other instances of 
> similar wording (I don't recall if we have something similar for lambdas or 
> if we defer to the function diagnostics in that case)?
+1, I agree.

It would be better if somebody more familiar with  Obj-C / coroutines and 
related terminology would improve these text.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-07 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1034
+  let Spellings = [Clang<"sycl_kernel">];
+  let Subjects = SubjectList<[Function]>;
+  let LangOpts = [SYCL];

aaron.ballman wrote:
> Shouldn't this be `FunctionTemplate` instead?
@aaron.ballman, I'm not sure.
I tried to use FunctionTemplate instead of Function, but I get following 
warning:
```
warning: 'sycl_kernel' attribute only applies to redeclarable templates
```
I investigated this a little and Sema passes Function declaration instead of 
FunctionTemplate to the function validating the attribute appertains to the 
right subject. I think it's because attributes are handled before 
FunctionTemplateDecl node is created.
Do we have an infrastructure to handle "FunctionTemplate" attributes?

I can't find any other attribute with FunctionTemplate subject to learn from...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


  1   2   3   >